input->post('username');
$data['name'] = $_SESSION['name']; // = $this->input->post('username');
$data['firstname'] = $_SESSION['firstname']; // = $ret->firstname;
$data['lastname'] = $_SESSION['lastname']; // = $ret->lastname;
$data['email'] = $_SESSION['email']; // = $ret->email;
// print_r($_SESSION);
//Array ( [__ci_last_regenerate] => 1474689025 [username] => ses66181+1@gmail.com [name] => ses66181+1@gmail.com [firstname] => Olusesan [lastname] => Amey [email] => ses66181+1@gmail.com )
//
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
redirect(home);
} else {
$this->load->view('users/view_header_user', $data);
$this->load->view('users/view_active', $data);
$this->load->view('users/view_footer_user', $data);
}
}
public function startcreate(){
$data = $this->getSessionArray();
$this->load->model('dash_model');
$out = $this->dash_model->getDashData($data);
$this->load->model('job_model');
$data['jobs_list'] = $this->job_model->getComboJobListOrdered($_SESSION['member_id'],50);
$data['active_task'] = $out['active_task'];
$data['active_pass_due'] = $out['active_pass_due'];
$data['current_balance'] = $out['current_balance'];
$data['new_message'] = $out['new_message'];
$data['template_data'] = $this->jobsTemplates();
$this->renderSecurePage('jobs/view_startcreate', $data);
}
private function jobsTemplates(){
return [
[
'ID'=>'FACEBOOKSHARE',
'name'=>'Share my article on your FaceBook Page',
'description'=>'Pick from the articles on my blog and share on your FaceBook page',
'delivery'=>'You will need to have a minimum of 100 friends on your profile',
'img'=>'/site3/assets/media/jobs/share-stories.jpg',
'timeline_days'=>'7',
'price'=> 2000
],
[
'ID'=>'TESTMYAPP',
'name'=>'Test my App and give feedback',
'description'=>'Download install and go through my app, upload feedback as part of my testing',
'delivery'=>'You will have to capture and upload up to 12 screens',
'img'=>'/site3/assets/media/jobs/test-app.jpg',
'timeline_days'=>'7',
'price'=> 2000
],
[
'ID'=>'REVIEWFEEDBACK',
'name'=>'Review My Blog Story with feedback',
'description'=>'View my Blog or Site stories, review and provide feedbacks or comments',
'delivery'=>'',
'img'=>'/site3/assets/media/jobs/review-stories.jpg',
'timeline_days'=>'7',
'price'=> 2000
],
[
'ID'=>'PROPOSEBLOG',
'name'=>'Propose new articles tiltles for my blog',
'description'=>'Look at my site stories, propose 5 new articles for my contents line',
'delivery'=>'Proposed items myst be relvant to the site and not currenlty present in any form',
'img'=>'/site3/assets/media/jobs/propose-new.jpg',
'timeline_days'=>'7',
'price'=> 2000
],
[
'ID'=>'WEBSITEREVIEW',
'name'=>'Visit and review my Website provide feedback',
'description'=>'Visit my website,browse througn the pages and provide feedback',
'delivery'=>'Capture 10 screen shots and upload',
'img'=>'/site3/assets/media/jobs/review-site.jpg',
'timeline_days'=>'7',
'price'=> 2000
],
];
}
public function active() {
$data['username'] = $_SESSION['username']; // = $this->input->post('username');
$data['name'] = $_SESSION['name']; // = $this->input->post('username');
$data['firstname'] = $_SESSION['firstname']; // = $ret->firstname;
$data['lastname'] = $_SESSION['lastname']; // = $ret->lastname;
$data['email'] = $_SESSION['email']; // = $ret->email;
// print_r($_SESSION);
//Array ( [__ci_last_regenerate] => 1474689025 [username] => ses66181+1@gmail.com [name] => ses66181+1@gmail.com [firstname] => Olusesan [lastname] => Amey [email] => ses66181+1@gmail.com )
//
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
redirect(home);
} else {
$this->load->view('users/view_header_user', $data);
$this->load->view('users/view_active', $data);
$this->load->view('users/view_footer_user', $data);
}
}
public function offerinterest() {
$data = $this->getSessionArray();
$jaction = "''/jobs/jobinterest''";
$mysql = "SELECT to_char(mi.added, 'YYYY-MM-DD HH24:MI') AS added,jo.offer_code,mjs.title,"
. "m.firstname||' '||m.lastname AS Client,"
. " '
' AS view "
. "FROM members_offer_interest mi "
. "LEFT JOIN members m ON m.id = mi.member_id "
. "LEFT JOIN members_jobs_offer jo ON jo.id=mi.offer_id "
. "LEFT JOIN members_jobs mjs ON mjs.id=jo.job_id "
. "WHERE jo.member_id =" . $_SESSION['member_id'] . " "
. "AND mi.status=1 AND jo.expire> now() + '-3 days' ORDER BY mi.added ASC";
$this->load->library('pagination');
$config = array();
$query = $this->db->query($mysql);
$config["total_rows"] = $query->num_rows();
$data['dash_title'] = "Public Offer Interset [" . $config["total_rows"] . "]";
$config["base_url"] = base_url() . "/jobs/offerinterest";
$config["per_page"] = 5;
$config["uri_segment"] = 3;
$config["num_links"] = 5;
$config['full_tag_open'] = "
";
}
public function viewmyjob() {
$data = $this->getSessionArray();
$jobOfferID = $this->input->post('jobOfferID');
$data['jobOfferID'] = $jobOfferID;
if ($jobOfferID != '') {
$this->load->model('job_model');
$out = $this->job_model->readMyloadJobOffer($_SESSION['member_id'], $jobOfferID);
if ($out['result'] == 1) {
$data["job_sent_to"] = $out["job_sent_to"];
$data["added_date"] = $out["added_date"];
$data["title"] = $out["title"];
$data["description"] = $out["description"];
$data["timeline_days"] = $out["timeline_days"];
$data["price"] = $out["price"];
$data["offer_code"] = $out["offer_code"];
$data['is_public_view'] = $out['public_view'];
$a_from = array('\t','\n','\r','\0','\v');
$a_to = array("\t","\n","\r","","");
$data["job_description"] = trim(trim(str_replace($a_from,$a_to,$out["job_description"])),'"'); // str_replace('"','\"',$out["job_description"]); // $out["job_description"];
$date = date_create($out["expire"]);
$out["expire"] = date_format($date, 'Y-m-d H:i');
$data["expire"] = $out["expire"];
$data['job_link'] = 'https://'.$_SERVER['HTTP_HOST']."/plb/viewjob/".$out['offer_code'];
$data['page_title'] = 'View Job - '.$out["offer_code"];
$this->RenderUserPage('jobs/view_viewmyjoboffer', $data);
} else {
redirect('dash'); // go back to dash if not valid
}
} else {
redirect('dash'); // go back to dash if not valid
}
}
public function myoffer() {
// $data = array();
$data = $this->getSessionArray();
$this->load->model('offers_model');
$out = $this->offers_model->getUserPendingOffers($_SESSION['member_id'], 10000);
$data['my_offer_rows'] = $out["my_offer_rows"]; //same
$data['offer_dash_result'] = $out["my_offer_rows"]; //same
$data['offer_found']= count($out["my_offer_rows"])>0;
$data['dash_title'] = "Pending Offers";
$this->renderSecurePage('jobs/view_myoffer', $data);
}
public function pendingoffer() {
$data = array();
$data = $this->getSessionArray();
$data['offer_dash'] = '';
$this->load->library('table');
$this->table->set_template($this->template);
$data["offer_dash"] = "
";
$data["dash_title"] = "My Pending Offer(s)";
$jbx = "''/jobs/viewmyjob''";
$mysql = "SELECT jo.added::date||' '||jo.expire::date,j.title||' To :'||jo.email AS tRec,"
. 'CASE WHEN jo.status = 1 THEN \'Pending\' ELSE \'Other\' END AS status,'
. "'' AS View "
. "FROM members_jobs_offer jo LEFT JOIN members_jobs j ON j.id = jo.job_id "
. "WHERE jo.expire > now() AND jo.status = 1 "
. "AND jo.member_id = " . $_SESSION['member_id'] . "LIMIT 400";
$mysql = "SELECT jo.added::date||' '||jo.expire::date AS job_dates,j.title||' To :'||(CASE WHEN jo.public_view > 0 THEN '-Public View' ELSE jo.email END) AS tRec,"
. "'' AS View "
. "FROM members_jobs_offer jo LEFT JOIN members_jobs j ON j.id = jo.job_id "
. "WHERE jo.expire > now() AND jo.status = 1 "
. "AND jo.member_id = " . $_SESSION['member_id'] . " ORDER BY jo.id DESC LIMIT 400";
// . 'CASE WHEN jo.status = 1 AND jo.public_view =0 THEN \'Pending\' WHEN jo.status = 1 AND jo.public_view >0 THEN \'Active\' ELSE \'Other\' END AS status,'
$query = $this->db->query($mysql);
$mysql2 = "SELECT jo.added::date AS start_job_date, jo.expire::date AS end_job_date, j.title, (CASE WHEN jo.public_view > 0 THEN '-Public View' ELSE jo.email END) AS job_to,jo.offer_code AS offer_code,"
. "'' AS View "
. "FROM members_jobs_offer jo LEFT JOIN members_jobs j ON j.id = jo.job_id "
. "WHERE jo.expire > now() AND jo.status = 1 "
. "AND jo.member_id = " . $_SESSION['member_id'] . " ORDER BY jo.id DESC LIMIT 400";
$query2 = $this->db->query($mysql2);
$data['offer_dash_rows'] = $query2->result();
$num = $query->num_rows();
if ($num > 0) {
// array('data' => 'Added/Expire', 'style' => 'width:100px')
$this->table->set_heading(array('data' => 'Added/Expire', 'style' => 'width:100px'), 'Title/Recipient', array('data' => ' ', 'style' => 'width:80px'));
$data['offer_dash'] = $this->table->generate($query);
$offer_found = true;
}
$_SESSION['secure_data'] = $data; // all data needed for secure page
$data['page_title'] = "my Market Job(s)";
/* $this->load->view('users/view_header_user', $data);
$this->load->view('jobs/view_pendingoffer', $data);
$this->load->view('users/view_footer_user', $data);
*/
$data['page_title'] = "My Pending Offer(s)";
$this->renderSecurePage('jobs/view_pendingoffer', $data);
}
public function jobgrp() {
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
redirect(home);
return;
}
$data = $this->getSessionArray();
$data["job_message"] = "";
$data["group_id"] = 0;
if ($_POST && isset($_POST['del'])) {
$group_id = $this->input->post('del');
$data['job_message'] = $this->deleteMemberGroup($group_id);
} else if ($_POST && isset($_POST['delmember'])) {
$data["group_id"] = $this->input->post('group_id') + 0;
$member_id = $this->input->post('delmember') + 0;
$data['job_message'] = $this->deleteMemberGroupMember($data["group_id"], $member_id);
} else if ($_POST && isset($_POST['group_id'])) {
$data["group_id"] = $this->input->post('group_id') + 0;
$data['job_message'] = $this->addMemberGroupMember($data["group_id"]);
} else if ($_POST) {
$group_name = trim($this->input->post('group_name'));
// echo 'ameye....'.$group_name ;
$x = array();
$x['member_id'] = $_SESSION['member_id'];
$x['group_name'] = $group_name;
$x['action'] = WRENCHBOARD_JOB_CREATE_GROUP;
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($x, $out);
if ($res == PHP_CREATED_OK) {
// print_r($out);
} else {
$data['job_message'] = 'Unable to create job group...';
}
}
list($data['group_table'], $groups) = $this->getMembersJobGroup($data["group_id"]);
if (count($groups) > 0) {
if ($data["group_id"] > 0) {
$data["group_name"] = $groups[$data["group_id"]];
} else {
$data["group_name"] = reset($groups);
$data["group_id"] = key($groups);
}
$data['group_member_table'] = $this->addGroupMemberForm($data["group_id"]) . $this->getJobGroupMembers($data["group_id"]);
} else {
$data["group_id"] = 0;
$data["group_name"] = "";
$data["group_member_table"] = "Please add a group";
}
// $this->load->view('users/view_header_user', $data);
// $this->load->view('jobs/view_jobgroup', $data);
// $this->load->view('users/view_footer_user', $data);
$this->renderSecurePage('jobs/view_jobgroup', $data);
}
public function jobgrp_members() {
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
echo "Denied";
return;
}
$group_id = $this->input->get('group_id');
echo $this->addGroupMemberForm($group_id) . $this->getJobGroupMembers($group_id);
}
private function deleteMemberGroup($group_id) {
$this->load->model('job_model');
return $this->job_model->deleteMemberGroup($group_id);
}
private function deleteMemberGroupMember($group_id, $group_member_id) {
$this->load->model('job_model');
return $this->job_model->deleteMemberGroupMember($group_id, $group_member_id);
}
private function addMemberGroupMember($group_id) {
$firstname = $this->input->post('firstname');
$lastname = $this->input->post('lastname');
$email = $this->input->post('email');
if ($firstname == '')
return 'Invalid first name';
if ($lastname == '')
return 'Invalid last name';
if ($email == '' || !filter_var($email, FILTER_VALIDATE_EMAIL))
return 'Invalid_e-mail';
$this->load->model('job_model');
return $this->job_model->addMemberGroupMember($group_id, $firstname, $lastname, $email);
}
private function getJobGroupMembers($group_id) {
$this->load->model('job_model');
return $this->job_model->getJobGroupMembers($group_id);
}
private function getMembersJobGroup($sel) {
$this->load->model('job_model');
return $this->job_model->getMembersJobGroup($sel);
}
private function addGroupMemberForm($group_id) {
$this->load->model('job_model');
return $this->job_model->addGroupMemberForm($group_id);
}
public function clonejob(){
$jobUid = $this->input->post('jobUid');
if ( $jobUid !=''){
redirect('/jobs/create/'.$jobUid);
}
}
private function getJobTemplateFill($template_page){
$templateList = $this->jobsTemplates();
foreach ($templateList as $row){
if ( $row['ID'] == trim($template_page)){
return $row;
}
}
// You get here if you dont find any template - let see if this is an existimg job
// d9bf082d-b72f-45d9-80d7-490d58a3bd2d
if (strlen($template_page) < 40 && strlen($template_page) > 15){ // dont et attacked here , clean it up
$this->load->model('job_model');
$jobDataRows = $this->job_model->selectUserJobUid($_SESSION['member_id'],$template_page);
if (count($jobDataRows) > 0 ){
// var_dump( $jobData );
// exit();
$jobData = $jobDataRows[0];
return [
'ID'=> $jobData['uid'],
'name'=> $jobData['title'],
'description'=> $jobData['description'],
'delivery'=> trim(trim(str_replace('\n',"\n", $jobData['job_detail'])),'"'),
'img'=>'/site3/assets/media/jobs/share-stories.jpg',
'timeline_days'=> $jobData['timeline_days'],
'price'=> $jobData['price'],
'country' => $jobData['country']
];
}
}
// echo strlen($template_page);
return [];
}
/*
Table "public.members_jobs"
Column | Type | Collation | Nullable | Default
---------------+-----------------------------+-----------+----------+------------------------------------------
id | integer | | not null | nextval('members_jobs_id_seq'::regclass)
member_id | integer | | |
title | character varying(150) | | |
description | character varying(300) | | |
job_detail | text | | |
timeline_days | integer | | not null |
price | integer | | not null |
loc | inet | | |
created | timestamp without time zone | | | now()
updated | timestamp without time zone | | | now()
status | integer | | | 1
country | character varying(2) | | |
uid | uuid | | | uuid_generate_v4()
Indexes:
*/
public function create() {
$data = $this->getSessionArray();
$template_page = ($this->uri->segment(3)) ? $this->uri->segment(3) : '';
$preFill = $this->getJobTemplateFill($template_page);
if(!empty($preFill))
{
$title = $preFill['name'];
$description = $preFill['description'];
$job_detail = $preFill['delivery'];
$timeline = $preFill['timeline_days'];
$price = $preFill['price'];
}
else
{
$title = NULL;
$description = NULL;
$timeline = NULL;
$price = 0;
$job_detail = NULL;
}
$mybalance = 0;
$data['job_message'] = '';
$country = 'NG';
$submit = NULL;
$country_job ='NG';
$amountArray = [];
for ($i = 2000; $i <= 10000; $i = $i + 1000) {
$amountArray[] = [$i,$i,'Naira'];
}
$marketArray = [];
for ($i = 2; $i <= 6; $i = $i + 1) {
$marketArray[] = [$i,$i,'Days'];
}
for ($i = 7; $i <= 21; $i = $i + 7) {
$marketArray[] = [$i,$i,'Week(s)'];
}
for ($i = 30; $i <= 90; $i = $i + 30) {
$marketArray[] = [$i,$i,'Month(s)'];
}
$data['amount_array'] = $amountArray;
$data['timeline_array'] = $marketArray;
$mysqlJ = "SELECT id, title,created::date FROM members_jobs WHERE
member_id = " . $_SESSION['member_id'] . "
AND status = 1
ORDER BY id DESC LIMIT 5";
$query = $this->db->query($mysqlJ);
$data['recentjobs'] = $query->result();
$data['recentjobs_count'] = $query->num_rows();
extract($_POST);
$redirected = false;
if ($_POST) {
$in = array();
$in['title'] = $title;
$in['description'] = $description;
$in['timeline_days'] = $this->input->post('timeline') ; //$timeline;
$in['job_detail'] = trim( $this->input->post('job_detail') ); // Somehow this doesnt show when large $job_detail;
$price = $this->input->post('price');
$in['price'] = $price * 100; // (is_int($price)? $price:0) * 100;
$in['member_id'] = $_SESSION['member_id'];
$in['country'] = $country_job;
$this->load->model('job_model');
if ($this->job_model->verifyJobInputs($in) == true) {
$in['action'] = WRENCHBOARD_JOB_CREATEJOB;
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($in, $out);
if ($res == PHP_CREATED_OK) {
// print_r($out);
if ($out['job_id'] > 0) {
$this->processingJob($out['job_id']);
$redirected = true;
}
} else {
$data['job_message'] = 'Unable to create job...';
}
} else {
$data['job_message'] = 'Enter all required fields';
}
}
$this->load->model('combo_model');
$this->combo_model->defaultComboMessage = 'Select Job Country';
$data['country_job'] = $this->combo_model->getCountryJobCombo('country', $country);
$data['job_price'] = $this->combo_model->getJobPriceCombo('price','Naira', $price);
$data['timeline_combo'] = $this->combo_model->marketTimeline('timeline', $timeline);
$data['title'] = $title;
$data['description'] = $description;
$data['timeline_days'] = $timeline;
$data['job_detail'] = trim( $job_detail );
$data['price'] = $price;
$data['country'] = $country_job;
$data['page_title'] = "Create Job";
if ($redirected == false) {
$this->load->model('dash_model');
$out = $this->dash_model->getDashData($data);
$data['active_task'] = $out['active_task'];
$data['active_pass_due'] = $out['active_pass_due'];
$data['current_balance'] = $out['current_balance'];
$data['new_message'] = $out['new_message'];
$this->renderSecurePage('jobs/view_create', $data);
}
}
public function processjob() {
$jobID = $this->input->post('jobID');
if ($jobID > 0) {
$this->processingJob($jobID);
// $data = $this->getSessionArray();
} else {
redirect('/jobs/manage');
}
}
public function agreejobterms(){
$data = $this->getSessionArray();
$in = array();
$in['action'] = WRENCHBOARD_ACCOUNT_TERMS;
$in['action_item'] = ACCOUNT_AGREE_JOBS;
$in['member_id'] = $_SESSION['member_id'];
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($in, $out);
//echo $res;
//exit;
if ($res == PHP_API_OK || $out["terms_update"]=='completed') {
redirect('/jobs/create',$data);
}
}
public function jobagree() {
$data = $this->getSessionArray();
if ($_POST) {
echo "Ameye";
exit;
$in = array();
$in['action'] = WRENCHBOARD_ACCOUNT_TERMS;
$in['action_item'] = ACCOUNT_AGREE_JOBS;
$in['member_id'] = $_SESSION['member_id'];
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($in, $out);
if ($res == PHP_API_OK || $out["terms_update"]=='completed') {
redirect('/jobs/create');
}
}
$data['page_key'] = 'WRB_POST_JOB_TERM';
$data['txt_detail'] = $this->readFixedText($data['page_key']);
$this->renderSecurePage('jobs/view_jobagree', $data);
}
private function processingJob($jobID) {
// $jobID = $this->input->post('jobID');
if ($jobID > 0) {
$data = $this->getSessionArray();
$this->load->model('combo_model');
$data['my_job_group'] = $this->combo_model->getUserJobGroupCombo('job_group', $_SESSION['member_id'], '');
$data['my_post_duration'] = $this->combo_model->getJobPostDuration('job_duration', 0);
$this->load->library('table');
$this->table->set_template($this->template);
$mysql = "SELECT title,description,timeline_days||' day(s)' AS day_timeline, price*0.01||'Naira' AS price, created::date AS create_date, job_detail"
. " FROM members_jobs WHERE id =" . $jobID . " AND member_id = " . $_SESSION['member_id'];
$query = $this->db->query($mysql);
$data['job_table_row'] = $query->row();
$this->table->set_heading('Title', 'Description', 'Timeline', 'Price', 'Created');
$data['job_table'] = $this->table->generate($query);
$this->load->model('job_model'); // too bad I have to run again
$jobData = $this->job_model->getJob($jobID);
$data['job_description'] = $jobData->job_detail;
/*stripslashes(htmlspecialchars_decode(
trim(trim(str_replace($a_from,$a_to,$jobData->job_detail)),'"'))); */
$data['jobID'] = $jobID;
$activeJobData = $this->job_model->selectMarketJob($jobID);
$data['active_job_data'] = $activeJobData;
// var_dump( $activeJobData );
// $this->load->view('users/view_header_user', $data);
// $this->load->view('jobs/view_joboffer', $data);
// $this->load->view('users/view_footer_user', $data);
$data['page_title'] ="View Job";
$this->renderSecurePage('jobs/view_joboffer', $data);
} else {
redirect('/jobs/manage');
}
// echo "process job " . $jobID;
}
/*
./assets/js/pages/editor_wysihtml5.js
./assets/js/plugins/editors/wysihtml5/parsers.js
./assets/js/plugins/editors/wysihtml5/toolbar.js
./assets/js/plugins/editors/wysihtml5/wysihtml5.min.js
./assets/js/plugins/forms/editable/wysihtml5.js
./assets/css/bootstrap.min.css
./assets/css/bootstrap-wysihtml5.css
./assets/js/core/libraries/bootstrap.min.js
*/
public function viewjob_accept() {
// echo 'home....0';
$this->concludeOffer(OFFER_ACCEPT);
}
public function viewjob_reject() {
//echo 'home....1';
$this->concludeOffer(OFFER_REJECT);
}
public function viewjob_cancel() {
//echo 'home....1';
$this->concludeOffer(OFFER_CANCEL);
}
public function viewjob_sendtome()
{
$this->concludeOffer(OFFER_SENDTOME);
}
public function viewjob_resend()
{
$this->concludeOffer(OFFER_RESEND);
}
public function viewjob_extend()
{
$this->concludeOffer(OFFER_EXTEND);
}
private function concludeOffer($offer_result) {
//WRENCHBOARD_JOB_OFFER_CONCLUDE
$jobOfferID = $this->input->get('jobOfferID');
$in = array();
$in['offer_code'] = $jobOfferID;
$in['member_id'] = $_SESSION['member_id'];
$in['offer_result'] = $offer_result;
$in['action'] = WRENCHBOARD_JOB_OFFER_CONCLUDE;
$this->load->model('backend_model');
$out = array();
if ( $in['member_id']!= 0){
$res = $this->backend_model->wrenchboard_api($in, $out);
}
if ($out["result"] == "OK") {
switch ($offer_result) {
case OFFER_ACCEPT:
echo "You have accepted this offer and we have notified the client. Please go to manage page to continue ";
break;
case OFFER_REJECT:
echo "You have rejected this offer and we have notified the client.";
break;
case OFFER_CANCEL:
echo "You have cancelled this offer and we have notified the recipient.";
break;
case OFFER_EXTEND:
echo "New time";
break;
}
}
// print_r($out);
}
public function processjob_individ() {
$jobID = $this->input->get('jobID');
$email = $this->input->get('rec_email');
$descr = urldecode( $this->input->get('jobdescription') );
if ($jobID == '' || $jobID < 1) {
echo "Invalid job ID";
return;
}
if ($email == '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Invalid recipient e-mail";
return;
}
if ($descr == '') {
echo "Missing job description";
return;
}
// echo $descr;
$this->sendIndividualJobOffer($jobID, $email, $descr);
// echo 'Completed';
}
public function processjob_group() {
$jobID = $this->input->get('jobID');
$group = $this->input->get('job_group');
$descr = urldecode( $this->input->get('jobdescription') );
if ($jobID == '' || $jobID < 1) {
echo "Invalid job ID";
return;
}
if ($group == '' || $group < 1) {
echo "Invalid group";
return;
}
if ($descr == '') {
echo "Missing job description";
return;
}
$group_member_count = 0;
$mysql = "SELECT count(id) AS m_count FROM members_job_groupmember WHERE group_id = $group AND member_id= ". $_SESSION['member_id'];
$query = $this->db->query($mysql);
if ( $query->num_rows()> 0 )
{
$qr = $query->result_array();
// print_r($qr);
$group_member_count = $qr[0]['m_count'];
}
if( $group_member_count == 0 )
{
echo "cannot send job to empty group";
return;
}
// echo $jobID." ".$group;
$this->sendGroupJobOffer($jobID, $group, $descr);
}
public function processjob_public() {
$jobID = $this->input->get('jobID');
$job_duration = $this->input->get('job_duration');
$descr = urldecode( $this->input->get('jobdescription') );
if ($jobID == '' || $jobID < 1) {
echo "Invalid job ID";
return;
}
if ($job_duration == '' || $job_duration < 1) {
echo "Invalid Duration";
return;
}
if ($descr == '') {
echo "Missing job description";
return;
}
$this->sendPublicJobOffer($jobID, $job_duration, $descr);
// echo 'Ameye';
}
private function sendPublicJobOffer($jobID, $duration, $descr) {
// this function will handle the call to backend
// to manage the sending of offer to group of people
$in["job_id"] = $jobID;
$in["duration"] = $duration;
$in["job_description"] = $descr;
$in['member_id'] = $_SESSION['member_id'];
//var_dump($in);
$in['action'] = WRENCHBOARD_JOB_OFFER_PUBLIC;
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($in, $out);
//$out["status"] = '';
//$res = $this->wrenchboard_api($in, $out);
// print_r($out);
if ($res == PHP_CREATED_OK) {
// echo "Offer sent to public";
echo "
We have placed this offer in the public domain. This offer would expire in days you have specified. You will receive email alerts if anybody is interested.
";
} else {
echo "
Unable to send offer :" . $out["status"] . "
";
}
//echo 'Group Result';
}
private function sendIndividualJobOffer($jobID, $email, $descr) {
// this function will handle sending offer to invidual
$in["job_id"] = $jobID;
$in["email"] = $email;
$in["job_description"] = $descr;
$in['member_id'] = $_SESSION['member_id'];
// var_dump($in);
$in['action'] = WRENCHBOARD_JOB_OFFER_INDVI;
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($in, $out);
if ($res == PHP_CREATED_OK) {
// echo "Offer sent";
echo "
We have notified the user/email about this offer. This offer would expire in a day if the recipient did nothing.
";
} else {
echo "
We are unable to send the offer to the recipient. This is usually caused by an insufficient balance in your account to pay for the task.
";
}
// echo 'Individual Result';
}
private function sendGroupJobOffer($jobID, $group, $descr) {
// this function will handle the call to backend
// to manage the sending of offer to group of people
$in["job_id"] = $jobID;
$in["group_id"] = $group;
$in["job_description"] = $descr;
$in['member_id'] = $_SESSION['member_id'];
//var_dump($in);
$in['action'] = WRENCHBOARD_JOB_OFFER_GROUP;
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($in, $out);
if ($res == PHP_CREATED_OK) {
echo "
We have notified each members by email about this offer. This offer would automatically expire in a day if the recipient(s) did nothing.