If you have any questions about this task :"
. ""
. "
"
. " ";
}
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);
// print_r($out);
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["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'];
$this->load->view('users/view_header_user', $data);
$this->load->view('jobs/view_viewmyjoboffer', $data);
$this->load->view('users/view_footer_user', $data);
} else {
redirect('dash'); // go back to dash if not valid
}
} else {
redirect('dash'); // go back to dash if not valid
}
}
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,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);
$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);
}
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);
}
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 create() {
$data = $this->getSessionArray();
$mybalance = 0;
$data['job_message'] = '';
// print_r($_SESSION);
$title = NULL;
$description = NULL;
$job_detail = NULL;
$timeline = NULL;
// $timeline_days = NULL;
$price = NULL;
$submit = NULL;
extract($_POST);
$redirected = false;
if ($_POST) {
$in = array();
$in['title'] = $title;
$in['description'] = $description;
$in['timeline_days'] = $timeline;
$in['job_detail'] =$this->input->post('job_detail'); // Somehow this doesnt show when large $job_detail;
$in['price'] = $price * 100;
$in['member_id'] = $_SESSION['member_id'];
$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';
}
}
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->load->view('users/view_header_user', $data);
$this->load->view('jobs/view_create', $data);
$this->load->view('users/view_footer_user', $data);
}
}
public function processjob() {
$jobID = $this->input->post('jobID');
if ($jobID > 0) {
$this->processingJob($jobID);
// $data = $this->getSessionArray();
} else {
redirect('/jobs/manage');
}
}
public function jobagree() {
$data = $this->getSessionArray();
//echo 'Ameye-- '. rand(100,999);
//print_r($this->input->post());
if ($_POST) {
$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) {
redirect('/jobs/create');
}
}
$data['page_key'] = 'WRB_POST_JOB_TERM';
$data['txt_detail'] = $this->readFixedText($data['page_key']);
$this->load->view('users/view_header_user', $data);
$this->load->view('jobs/view_jobagree', $data);
$this->load->view('users/view_footer_user', $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)', price*0.01||'Naira' AS price, created::date"
. " FROM members_jobs WHERE id =" . $jobID . " AND member_id = " . $_SESSION['member_id'];
$query = $this->db->query($mysql);
$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;
$data['jobID'] = $jobID;
$this->load->view('users/view_header_user', $data);
$this->load->view('jobs/view_joboffer', $data);
$this->load->view('users/view_footer_user', $data);
} else {
redirect('/jobs/manage');
}
// echo "process job " . $jobID;
}
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);
}
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();
$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;
}
}
// 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);
}
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.