Files
WrenchBoradWeb/www/application/controllers/Jobs.php
T
2022-07-09 19:22:51 -04:00

1474 lines
64 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Jobs extends Users_Controller {
var $actionMessage = '';
function __construct() {
parent::__construct();
if (!isset($_SESSION['username']) or $_SESSION['username'] == '') {
redirect(home);
}
}
public function index() {
$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 startcreate(){
$data = $this->getSessionArray();
$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'];
$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'=>'Weve been focused on making a the from also not been eye',
'delivery'=>'',
'img'=>'/site3/assets/media/jobs/share-stories.jpg',
'timeline_days'=>'7',
'price'=> 2000
],
[
'ID'=>'TESTMYAPP',
'name'=>'Test my App and give feedback',
'description'=>'Weve been focused on making a the from also not been eye',
'delivery'=>'',
'img'=>'/site3/assets/media/jobs/test-app.jpg',
'timeline_days'=>'7',
'price'=> 2000
],
[
'ID'=>'REVIEWFEEDBACK',
'name'=>'Review My Blog Story with feedback',
'description'=>'Weve been focused on making a the from also not been eye',
'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'=>'Weve been focused on making a the from also not been eye',
'delivery'=>'',
'img'=>'/site3/assets/media/jobs/propose-new.jpg',
'timeline_days'=>'7',
'price'=> 2000
],
[
'ID'=>'WEBSITEREVIEW',
'name'=>'Visit and review my Website provide feedback',
'description'=>'Weve been focused on making a the from also not been eye',
'delivery'=>'',
'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,"
. " '<div id=\"J'||mi.id||'\"><input type=submit id=\"submit_'||mi.id||'\" name=\"mview\" onclick=\"return post_nav_find_action($jaction,'||mi.id||');\" class=\"btn btn-info btn-xs\" value=\"View\"></div>' 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";
//jo.status=1 AND
$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'] = "<ul class='pagination'>";
$config['full_tag_close'] = "</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$page = is_numeric($page) ? $page : 0;
// <a href="#" onclick="showOfferModal('$offer_code; ');"
$mysql = "SELECT to_char(mi.added, 'YYYY-MM-DD')||'<br><a href=\"#\" onclick=\"showOfferModal('''||jo.offer_code||''');\" >'||jo.offer_code||'</a>' AS added_code,mjs.title,"
. "m.firstname AS Client,"
. " '<div id=\"J'||mi.id||'\"><input type=submit id=\"submit_'||mi.id||'\" name=\"mview\" onclick=\"return post_nav_find_action($jaction,'||mi.id||');\" class=\"btn btn-info btn-xs\" value=\"View\"></div>' 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 LIMIT " . $config["per_page"] . " OFFSET " . $page;
//jo.status=1 AND
$this->load->library('table');
$this->table->set_template($this->template);
$query = $this->db->query($mysql);
$this->table->set_heading(array('data' => 'Added/ID', 'style' => 'width:100px'), 'Title', 'Client', array('data' => 'Action', 'style' => 'width:70px'));
/* $this->table->set_heading(
array('data' => 'Added', 'style' => 'width:120px'),
array('data' => 'Action', 'style' => 'width:100px'));
*/
$data['job_interest_table'] = $this->table->generate($query);
$data["links"] = $this->pagination->create_links();
/* $this->load->view('users/view_header_user', $data);
$this->load->view('jobs/view_pendinginterest', $data);
$this->load->view('users/view_footer_user', $data); */
$this->renderSecurePage('jobs/view_pendinginterest', $data);
}
public function jobinterest() {
$data['message_list'] = '';
$interest_id = $this->input->post('interest_id');
$data = $this->getSessionArray();
$jaction = "''/jobs/jobinterest''";
$data['total_jobs_completed'] = $data['total_jobs_active'] = $data['total_jobs_uncompleted'] = $data['total_pending_offers'] = 0;
$data['dash_title'] = 'Manage Offer Interset';
$mysql = "SELECT to_char(mi.added, 'YYYY-MM-DD') AS added,jo.offer_code,mjs.title,"
. "m.firstname AS Client,mi.offer_id,m.id AS client_id, mi.id AS interest_id,md.description AS client_description,m.added::date AS client_added,"
. " '<div id=\"J'||mi.id||'\"><input type=submit id=\"submit_'||mi.id||'\" name=\"mview\" onclick=\"return InterestDetail('||mi.id||');\" class=\"btn btn-info btn-xs\" value=\"View\"></div>' 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 "
. "LEFT JOIN members_detail md ON md.member_id=m.id "
. "WHERE jo.member_id =" . $_SESSION['member_id'] . " "
. " AND mi.id=" . $interest_id . " "
. " AND mi.status = 1 ORDER BY mi.added ASC"; //AND jo.status=1 AND jo.expire> now()
$query = $this->db->query($mysql);
$num = $query->num_rows();
if ($num > 0) {
$row = $query->row_array();
$data['added'] = $row['added'];
$data['client'] = $row['client'];
$data['title'] = $row['title'];
$data['offer_code'] = $row['offer_code'];
$data['interest_id'] = $row['interest_id']; // The interested member id is here
$data['client_description'] = $row['client_description'];
$data['client_added'] = $row['client_added'];
$data['message_list'] = $this->getMarketInterestMessage($data['offer_code'], $row['client_id']);
// $data['skills_set'] = $this->getUserSavedSkillsSet($row['client_id']);
//onclick="showModal( $interest_id)"
//to_char(mi.added, 'YYYY-MM-DD HH24:MI') AS added
$out = $this->getClientJobStats($row['client_id']);
$data['total_jobs_completed'] = $out['total_jobs_completed'];
$data['total_jobs_active'] = $out['total_jobs_active'];
$data['total_jobs_uncompleted'] = $out['total_jobs_uncompleted'];
$data['total_pending_offers'] = $out['total_pending_offers'];
$mysql = "SELECT mi.added::date AS added, "
. "'<a href=\"#\" onclick=\"showModal('||mi.id||');\" >'||m.firstname||'</a>' AS Client,"
. "CASE WHEN mi.status =1 THEN 'Pending' WHEN mi.status=5 THEN 'Approved' ELSE 'Unknown' END AS status,"
. "(CASE WHEN mi.status = 1 THEN '<div id=\"J'||mi.id||'\"><input type=submit id=\"submit_'||mi.id||'\" name=\"mview\" onclick=\"return post_nav_other_interest($jaction,'||mi.id||');\" class=\"btn btn-info btn-xs\" value=\"View\"></div>' ELSE '' END) AS Sel "
. "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.offer_id=" . $row['offer_id'] . " "
. "AND mi.id <> $interest_id ORDER BY mi.added ASC"; //AND jo.status=1 AND jo.expire> now()
$query2 = $this->db->query($mysql);
} else {
}
$this->load->library('table');
$this->table->set_template($this->template);
$this->table->set_heading(array('data' => 'Added', 'style' => 'width:120px'), 'Interested Client', array('data' => 'Status', 'style' => 'width:90px'), array('data' => '', 'style' => 'width:90px'));
$data['job_others_interest_table'] = $this->table->generate($query2);
$this->renderSecurePage('jobs/view_manageinterest', $data);
}
private function getMarketInterestMessage($offer_code, $client_id) {
$data = $this->getSessionArray();
$member_id = $_SESSION['member_id'];
$mysql = "SELECT m.firstname, s.added::date as msg_added,s.msg FROM members_messages s LEFT JOIN members m ON m.id=s.senders_id "
. "WHERE s.msg_type='MRKTINT' AND s.memo='$offer_code' "
. "AND s.member_id=$client_id AND s.senders_id = $member_id "
. "OR s.member_id= $member_id AND s.senders_id=$client_id "
. "ORDER BY s.id DESC LIMIT 4";
$query = $this->db->query($mysql);
$tmsg = "";
foreach ($query->result() as $row) {
$tmsg .= "<b>" . $row->msg_added . "</b> - <b>From:</b>" . $row->firstname;
$tmsg .= "<br>";
$tmsg .= $row->msg;
$tmsg .= "<hr size='1'>";
}
return $tmsg;
}
public function jobinterest_modal() {
$interest_id = $this->input->get('interest_id');
$data = $this->getSessionArray();
$mysql = "SELECT to_char(mi.added, 'YYYY-MM-DD') AS added,jo.offer_code,mjs.title,"
. "m.firstname AS Client,mi.offer_id,m.id AS client_id, mi.id AS interest_id,md.description AS client_description,m.added::date AS client_added,"
. " '<div id=\"J'||mi.id||'\"><input type=submit id=\"submit_'||mi.id||'\" name=\"mview\" onclick=\"return InterestDetail('||mi.id||');\" class=\"btn btn-info btn-xs\" value=\"View\"></div>' 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 "
. "LEFT JOIN members_detail md ON md.member_id=m.id "
. "WHERE jo.member_id =" . $_SESSION['member_id'] . " "
. " AND mi.id=" . $interest_id . " "
. "AND jo.status=1 AND mi.status = 1 AND jo.expire> now() ORDER BY mi.added ASC";
$query = $this->db->query($mysql);
$num = $query->num_rows();
if ($num > 0) {
$row = $query->row_array();
//$data['added'] = $row['added'];
$data['client'] = $row['client'];
//$data['title'] = $row['title'];
//$data['offer_code'] = $row['offer_code'];
//$data['interest_id'] = $row['interest_id']; // The interested member id is here
$data['client_description'] = $row['client_description'];
$data['skills_set'] = $this->getUserSavedSkillsSet($row['client_id']);
} else {
$data["client"] = "Undefined";
$data["client_description"] = "Failed to load client";
$data["skills_set"] = "";
}
$this->load->view('jobs/view_manageinterest_modal', $data);
}
public function loaduserSkills() {
$member_id = $this->input->get('interest_id');
$data = $this->getSessionArray();
$mysql = "SELECT to_char(m.added, 'YYYY-MM-DD') AS added,m.firstname AS client,m.id AS client_id,"
. "md.description AS client_description "
. "FROM members m "
. "LEFT JOIN members_detail md ON md.member_id=m.id "
. "WHERE m.id=" . $_SESSION['member_id'];
$query = $this->db->query($mysql);
$num = $query->num_rows();
if ($num > 0) {
$row = $query->row_array();
$data['client'] = $row['client'];
$data['client_description'] = $row['client_description'];
} else {
$data["client"] = "Undefined";
$data["client_description"] = "No entry yet...";
$data["skills_set"] = "";
}
$data['skills_set'] = $this->getUserSavedSkillsSet($member_id);
$this->load->view('jobs/view_manageinterest_modal', $data);
}
public function offerdetail_modal() {
$contract_id = trim($this->input->get('contact_id'));
$data = $this->getSessionArray();
$mysql = " SELECT j.title,j.price,j.timeline_days,j.job_detail,j.description FROM members_jobs j LEFT JOIN members_jobs_offer jo ON jo.job_id = j.id WHERE jo.offer_code='$contract_id' ";
$query = $this->db->query($mysql);
$num = $query->num_rows();
if ($num > 0) {
$data = $query->row_array();
$data['contract_id'] = $contract_id;
$this->load->view('jobs/modals/view_offerdetail_modal', $data);
}
}
public function jobdetail_modal() {
$contract_id = trim($this->input->get('contact_id'));
$data = $this->getSessionArray();
$mysql = " SELECT title,price,delivery_date,job_detail,description,delivery_date FROM members_jobs_contract WHERE contract='$contract_id' ";
$query = $this->db->query($mysql);
$num = $query->num_rows();
if ($num > 0) {
$data = $query->row_array();
$data['contract_id'] = $contract_id;
$this->load->view('jobs/modals/view_jobdetail_modal', $data);
}
}
public function jobinterest_modal_BAK() {
$interest_id = $this->input->get('interest_id');
$data = $this->getSessionArray();
$mysql = "SELECT to_char(mi.added, 'YYYY-MM-DD') AS added,jo.offer_code,mjs.title,"
. "m.firstname AS Client,mi.offer_id,m.id AS client_id, mi.id AS interest_id,md.description AS client_description,m.added::date AS client_added,"
. " '<div id=\"J'||mi.id||'\"><input type=submit id=\"submit_'||mi.id||'\" name=\"mview\" onclick=\"return InterestDetail('||mi.id||');\" class=\"btn btn-info btn-xs\" value=\"View\"></div>' 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 "
. "LEFT JOIN members_detail md ON md.member_id=m.id "
. "WHERE jo.member_id =" . $_SESSION['member_id'] . " "
. " AND mi.id=" . $interest_id . " "
. "AND jo.status=1 AND mi.status = 1 AND jo.expire> now() ORDER BY mi.added ASC";
$query = $this->db->query($mysql);
$num = $query->num_rows();
if ($num > 0) {
$row = $query->row_array();
//$data['added'] = $row['added'];
$data['client'] = $row['client'];
//$data['title'] = $row['title'];
//$data['offer_code'] = $row['offer_code'];
//$data['interest_id'] = $row['interest_id']; // The interested member id is here
$data['client_description'] = $row['client_description'];
$data['skills_set'] = $this->getUserSavedSkillsSet($row['client_id']);
} else {
$data["client"] = "Undefined";
$data["client_description"] = "Failed to load client";
$data["skills_set"] = "";
}
$this->load->view('jobs/view_manageinterest_modal', $data);
}
private function getUserSavedSkillsSet($client_id) {
$skills = "<table>";
$mysql = " SELECT mk.*,sc.category,st.skill "
. "FROM members_skills mk "
. "LEFT JOIN skill_types st ON st.id = mk.skill_id "
. "LEFT JOIN skill_category sc ON sc.id = mk.category_id "
. "WHERE mk.member_id = $client_id AND mk.status=1";
$query = $this->db->query($mysql);
if ($query->num_rows() > 0) {
foreach ($query->result_array() as $row) {
$skills .= "<tr><td>" . $row["category"] . "-" . $row["skill"] . "</td></tr>";
}
}
$skills .= "</table>";
return $skills;
}
public function procinterest() {
// url: "/jobs/procinterest?proc=ACCEPT&interest_id=" + interest_id
// url: "/jobs/procinterest?proc=REJECT&interest_id=" + interest_id
// url: "/jobs/procinterest?proc=CANCEL&interest_id=" + interest_id
$data = $this->getSessionArray();
$inx= [];
$inx['interest_id'] = $this->input->get('interest_id');
$proc = $this->input->get('proc');
$inx['interest'] = 0;
$inx['member_id'] = $_SESSION['member_id'];
switch ($proc) {
case 'ACCEPT':
$inx['interest'] = JOB_INTEREST_ACCEPT;
break;
case 'REJECT':
$inx['interest'] = JOB_INTEREST_REJECT;
break;
case 'CANCEL':
$inx['interest'] = JOB_INTEREST_CANCEL;
break;
}
if ($inx['interest'] > 0) {
$inx['action'] = WRENCHBOARD_JOB_PROC_INTEREST;
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($inx, $out);
if ($res == PHP_CREATED_OK) {
echo 'Success - ' . $out['status'];
} else {
echo 'Error - ' . $out['status'];
}
}
// echo "AMEYE $interest_id $proc ";
}
private function vjobinterest() {
//
//echo 'ameye';
$data = $this->getSessionArray();
$data['dash_title'] = 'Yes Public Offer Interset';
$mysql = "SELECT to_char(mi.added, 'YYYY-MM-DD HH24:MI') AS added,jo.offer_code,mjs.title,"
. "m.firstname||' '||m.lastname AS Client,"
. " '<div id=\"J'||mi.id||'\"><input type=submit id=\"submit_'||mi.id||'\" name=\"mview\" onclick=\"return InterestDetail('||mi.id||');\" class=\"btn btn-info btn-xs\" value=\"View\"></div>' 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 jo.status=1 AND jo.expire> now() ORDER BY mi.added ASC";
$this->load->library('table');
$this->table->set_template($this->template);
$query = $this->db->query($mysql);
$this->table->set_heading(array('data' => 'Added', 'style' => 'width:140px'), 'Code', 'Title', 'Client', array('data' => 'Action', 'style' => 'width:90px'));
$data['job_interest_table'] = $this->table->generate($query);
$this->load->view('users/view_header_user', $data);
$this->load->view('jobs/vofferinterest', $data);
$this->load->view('users/view_footer_user', $data);
}
public function viewjob() {
$data = $this->getSessionArray();
$jobOfferID = $this->input->post('jobOfferID');
$data['jobOfferID'] = $jobOfferID;
if ($jobOfferID != '') {
$this->load->model('job_model');
$out = $this->job_model->loadJobOffer($_SESSION['member_id'], $jobOfferID);
// print_r($out);
if ($out['result'] == 1) {
$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"];
$this->load->view('users/view_header_user', $data);
$this->load->view('jobs/view_viewjoboffer', $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 market() {
$data = array();
$data = $this->getSessionArray();
$data['offer_dash'] = '';
$this->load->library('table');
$this->table->set_template($this->template);
$data["dash_title"] = "Available Jobs & Tasks";
$mysql = 'SELECT jo.offer_code,mj.title,mj.description,mj.timeline_days,mj.price,jo.job_description FROM members_jobs_offer jo '
. ' LEFT JOIN members_jobs mj ON mj.id=jo.job_id '
. ' WHERE mj.status=1 AND jo.status=1 '
. ' AND expire> now() AND public_view > 0';
$query = $this->db->query($mysql);
$num = $query->num_rows();
$data['market_table_result'] = $query->result(); // used in new impl.
if ($num > 0) {
$myTable = "<table class='table table-striped table-hover table-bordered table-condensed'>";
foreach ($query->result_array() as $row) {
$myTable .= $this->makeMarketTableRow($row);
}
$myTable .="</table>";
// $this->table->set_heading('Added/Expire', 'Title/Recipient', 'Status', '');
$data['market_table'] = $myTable; // $this->table->generate($query);
// $offer_found = true;
} else {
$data['market_table'] = '';
}
$_SESSION['secure_data'] = $data; // all data needed for secure page
$data['page_title'] = "Available Jobs & Tasks";
/* $this->load->view('users/view_header_user', $data);
$this->load->view('jobs/view_market', $data);
$this->load->view('users/view_footer_user', $data);
*/
// var_dump( $data['market_table_result']);
// exit;
$this->renderSecurePage('jobs/view_market', $data);
}
private function makeMarketTableRow($row) {
return "<tr><td style='width:100px;'><b>" . $row['offer_code'] . "</b></td><td>" . $row['title'] . "</td><td style='width:100px;'><input type=submit id='submit_" . $row['offer_code'] . "' name=\"mview\" onclick=\"return EDetail('" . $row['offer_code'] . "');\" class=\"btn btn-info btn-xs\" value=\"View\"></td></tr>"
. "<tr><td colspan = '3'><div id='" . $row['offer_code'] . "'></div></td></tr>";
}
public function showinterest() {
$data = $this->getSessionArray();
$in=[];
$in['offer_code'] = $this->input->get('job_contract');
$in['member_id'] = $_SESSION['member_id']; // just maing sure
$in['action'] = WRENCHBOARD_JOB_SEND_INTEREST;
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($in, $out);
if ($res == PHP_CREATED_OK) {
echo 'Success - ' . $out['status'];
} else {
echo 'Error - ' . $out['status'];
}
}
public function marketrmessage() {
$data = $this->getSessionArray();
// echo 'Ameye';
$in=[];
$in['offer_code'] = $this->input->get('offer_code');
$in['yourmessage'] = $this->input->get('yourmessage');
$in['member_id'] = $_SESSION['member_id']; // just maing sure
$in['msg_type'] = 'JOB';
$in['action'] = WRENCHBOARD_JOB_SEND_QUESTION;
// $this->load->model('backend_model');
$out = array();
$out['status'] = '';
$res = $this->wrenchboard_api($in, $out);
if ($res == PHP_CREATED_OK) {
echo 'Success - Message sent' . $out['status'];
} else {
echo 'Error - ' . $out['status'];
}
}
public function offermessage()
{
$data = $this->getSessionArray();
// echo 'Ameye';
$in =[];
$in['offer_code'] = $this->input->get('offer_code');
$in['yourmessage'] = $this->input->get('yourmessage');
$in['interest_id'] = $this->input->get('interest_id');
$in['member_id'] = $_SESSION['member_id']; // just maing sure
$in['msg_type'] = 'MRKTINT'; // MARKET INTEREST
$in['action'] = WRENCHBOARD_JOB_MRKTINT_QUEST;
// $this->load->model('backend_model');
$out = array();
$out['status'] = '';
$res = $this->wrenchboard_api($in, $out);
// print_r($out);
if ($res == PHP_CREATED_OK) {
//echo rand(100,999)." " .$out['client_id'];
echo $this->getMarketInterestMessage( $in['offer_code'], $out['client_id'] ); //'Success - Message sent' . $out['status'];
} else {
echo 'Error - ' . $out['status'];
}
}
public function marketdetail() {
$myTable = '';
$offer_code = $this->input->get('job_contract');
$mysql = "SELECT jo.id AS offer_id,jo.offer_code,mj.title,mj.description,mj.timeline_days,mj.price,jo.job_description,jo.expire::date FROM members_jobs_offer jo "
. "LEFT JOIN members_jobs mj ON mj.id=jo.job_id "
. " WHERE mj.status=1 AND jo.status=1 AND jo.offer_code ='" . $offer_code . "' ";
$query = $this->db->query($mysql);
$num = $query->num_rows();
if ($num > 0) {
$row = $query->row_array();
$myTable = " <div class='card card-xl-stretch mb-5 mb-xl-8'>";
$myTable .= $this->makeMarketDetailTableRow($row);
$myTable .="</div>";
}
echo $myTable;
}
private function makeMarketDetailTableRow($row) {
$data['interest'] = 0;
$mysql = "SELECT count(*) AS interest FROM members_offer_interest WHERE offer_id=".$row['offer_id'];
$query = $this->db->query($mysql);
if( $query->num_rows() > 0 ) {
$data = $query->row_array();
}
return "<div class='card-body'><table class='table table-sm table-hover table-bordered table-condensed' style='background-color: #ffffff;'><tr><td colspan='2' ><b>" . $row['offer_code'] . "</b> Timeline:" . $row['timeline_days'] . " day(s) - <b>Budget: </b> " . $row['price'] * 0.01 . " Naira</td></tr>"
. "<tr><td style='width:100px;'><b>Title</b></td><td>" . $row['title'] . "</td></tr>"
. "<tr><td><b>Description</b></td><td>" . $row['description'] . "</td></tr>"
. "<tr><td><b>Detail</b></td><td>" . $row['job_description'] . "</td></tr>"
. "<tr><td colspan='2' >Interests : <b>" . $data['interest'] . "</b> Expire:<b> " . $row['expire']."</b> </td></tr>"
. "<tr><td colspan='2' style='text-align:center; padding-bottom: 10px;'><b>If you are interested in this task, send message to the owner </b><input type=submit id='submit_interest_" . $row['offer_code'] . "' name=\"mview\" onclick=\"return SInterest('" . $row['offer_code'] . "');\" class=\"btn btn-success btn-xs\" value=\"Send Interest Request\"></td></tr>"
. "<tr><td colspan='2'><div id='" . $row['offer_code'] . "'></div><hr size='1'></td></tr>"
."<tr><td colspan='2'>If you have any questions about this task :"
. "<div id='msg_result_" . $row['offer_code'] . "'><form name=\"job_message\"><table class='table table-striped table-hover table-bordered table-condensed'>"
. "<tr><td><textarea name='yourmessage' cols=\"5\" rows=\"3\" class=\"textarea form-control\" class=\"btn btn-warning btn-xs\" placeholder=\"Enter message here ...\"></textarea></td></tr>"
. "<tr><td style='text-align:right;'><button id='submit_yourmessage_" . $row['offer_code'] . "' onclick=\"return OMessage('" . $row['offer_code'] . "');\" class=\"btn btn-warning btn-sm\">Send Message</button></td></tr></table></form></div>"
. "</td></tr>"
. " </table></div>";
}
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["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();
$data['offer_dash'] = '';
$this->load->library('table');
$this->table->set_template($this->template);
$data["offer_dash"] = "<div class=\"thumb\"><img src='assets/images/notask.png' alt=\"Active Projects\"></div>";
$data["dash_title"] = "<a href='/jobs/pendingoffer'>My Pending Offer(s)</a>";
$jbx = "''/jobs/viewmyjob''";
$mysql = "SELECT jo.added::date||'<br>'||jo.expire::date,j.title||'<br><b>To :</b>'||jo.email AS tRec,"
. 'CASE WHEN jo.status = 1 THEN \'Pending\' ELSE \'Other\' END AS status,'
. "'<input type=submit onclick=\"return post_nav_find_action($jbx,'''||jo.offer_code||''')\" name=\"manage\" class=\"btn btn-primary btn-xs\" value=\"View\">' 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||'<br>'||jo.expire::date AS job_dates,j.title||'<br><b>To :</b>'||(CASE WHEN jo.public_view > 0 THEN '-Public View' ELSE jo.email END) AS tRec,"
. "'<input type=submit onclick=\"return post_nav_find_action($jbx,'''||jo.offer_code||''')\" name=\"manage\" class=\"btn btn-primary btn-xs\" value=\"View\">' 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,"
. "'<input type=submit onclick=\"return post_nav_find_action($jbx,'''||jo.offer_code||''')\" name=\"manage\" class=\"btn btn-primary btn-xs\" value=\"View\">' 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'] = "Offer(s)";
$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"] = "<div class=\"thumb\"><img src='assets/images/notask.png' alt=\"Active Projects\"></div>";
$data["dash_title"] = "<a href='/jobs/pendingoffer'>My Pending Offer(s)</a>";
$jbx = "''/jobs/viewmyjob''";
$mysql = "SELECT jo.added::date||'<br>'||jo.expire::date,j.title||'<br><b>To :</b>'||jo.email AS tRec,"
. 'CASE WHEN jo.status = 1 THEN \'Pending\' ELSE \'Other\' END AS status,'
. "'<input type=submit onclick=\"return post_nav_find_action($jbx,'''||jo.offer_code||''')\" name=\"manage\" class=\"btn btn-primary btn-xs\" value=\"View\">' 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||'<br>'||jo.expire::date AS job_dates,j.title||'<br><b>To :</b>'||(CASE WHEN jo.public_view > 0 THEN '-Public View' ELSE jo.email END) AS tRec,"
. "'<input type=submit onclick=\"return post_nav_find_action($jbx,'''||jo.offer_code||''')\" name=\"manage\" class=\"btn btn-primary btn-xs\" value=\"View\">' 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,"
. "'<input type=submit onclick=\"return post_nav_find_action($jbx,'''||jo.offer_code||''')\" name=\"manage\" class=\"btn btn-primary btn-xs\" value=\"View\">' 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);
}
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);
}
private function getJobTemplateFill($template_page){
$templateList = $this->jobsTemplates();
foreach ($templateList as $row){
if ( $row['ID'] == trim($template_page)){
return $row;
}
}
return [];
}
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'];
$timeline = $preFill['timeline_days'];
$price = $preFill['price'];
}
else
{
$title = NULL;
$description = NULL;
$timeline = NULL;
$price = 0;
}
$mybalance = 0;
$data['job_message'] = '';
$job_detail = NULL;
$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;
$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;
}
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 <a href='/proj/active'>manage page</a> 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 "<div class=\"text-left\"><div class=\"alert alert-info no-border\">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.</div></div>";
} else {
echo "<div class=\"text-left\"><div class=\"alert alert-danger no-border\">Unable to send offer :" . $out["status"] . "</div></div>";
}
//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 "<div class=\"text-left\"><div class=\"alert alert-info no-border\">We have notified the user/email about this offer. This offer would expire in a day if the recipient did nothing.</div></div>";
} else {
echo "<div class=\"text-left\"><div class=\"alert alert-danger no-border\">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.</div></div>";
}
// 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 "<div class=\"text-left\"><div class=\"alert alert-info no-border\">We have notified each members by email about this offer. This offer would automatically expire in a day if the recipient(s) did nothing.</div></div>";
} else {
// echo "Unable to send offer";
echo "<div class=\"text-left\"><div class=\"alert alert-danger no-border\">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.</div></div>";
}
//echo 'Group Result';
}
public function deletejob() {
$data = $this->getSessionArray();
$jobID = $this->input->get('job_id');
if ($jobID != '' AND $jobID > 0) {
$in["job_id"] = $jobID;
$in['member_id'] = $_SESSION['member_id'];
$in['action'] = WRENCHBOARD_JOB_DELETEJOB;
$this->load->model('backend_model');
$out = array();
$this->backend_model->wrenchboard_api($in, $out);
echo $out['status'];
}
}
public function manage() {
$data = $this->getSessionArray();
$this->load->library('table');
$this->table->set_template($this->template);
$jbx = "''/jobs/processjob''";
$mysql = "SELECT '<b>Date: </b>'||created::date||'<br><b>Timeline: </b>'||timeline_days||' day(s)'||'<br><b>Price: </b>'||price*0.01||' ' AS Job,"
. " '<b>Title: </b>'||title||'<br><b>Description: </b>'||description AS detail, "
. " '<table><tr><td><input type=button onclick=\"return post_nav_find_action($jbx, '||id||')\" name=\"manage\" class=\"btn btn-info btn-xs\" value=\"View\"></td><td><div id=\"subdel'||id||'\" ><input type=button id=\"dacc'||id||'\" onclick=\"return deleteJob('||id||')\" name=\"manage\" class=\"btn btn-warning btn-xs\" value=\"Del\"></td></tr></table>' AS manage"
. " FROM members_jobs WHERE member_id = " . $_SESSION['member_id'] . " AND status=1 ORDER BY id DESC";
$this->load->library('pagination');
$config = array();
$query = $this->db->query($mysql);
$config["total_rows"] = $query->num_rows();
$config["base_url"] = base_url() . "/jobs/manage";
$config["per_page"] = 5;
$config["uri_segment"] = 3;
$config["num_links"] = 5;
$config['full_tag_open'] = "<ul class='pagination'>";
$config['full_tag_close'] = "</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$mysql = "SELECT '<b>Date: </b>'||created::date||'<br><b>Timeline: </b>'||timeline_days||' day(s)'||'<br><b>Price: </b>'||price*0.01||' ' AS Job,"
. " '<b>Title: </b>'||title||'<br><b>Description: </b>'||description AS detail, "
. " '<table><tr><td><input type=button onclick=\"return post_nav_find_action($jbx, '||id||')\" name=\"manage\" class=\"btn btn-info btn-xs\" value=\"View\"><div id=\"subdel'||id||'\" ></td><td><input type=button id=\"dacc'||id||'\" onclick=\"return deleteJob('||id||')\" name=\"manage\" class=\"btn btn-warning btn-xs\" value=\"Del\"></td></tr></table>' AS manage"
. " FROM members_jobs WHERE member_id = " . $_SESSION['member_id'] . " AND status=1 ORDER BY id DESC LIMIT " . $config["per_page"] . " OFFSET " . $page;
$query = $this->db->query($mysql);
$this->table->set_heading(array('data' => 'Job/Task', 'style' => 'width:150px'), 'Title/Description', array('data' => 'Manage', 'style' => 'width:120px'));
$data["links"] = $this->pagination->create_links();
// array('data' => 'Del.', 'style' => 'width:80px')
$data['page_title'] = "Manage Job(s)";
$data['job_table_rows'] = $query->result();
$data['job_table'] = $this->table->generate($query);
/* $this->load->view('users/view_header_user', $data);
$this->load->view('jobs/view_manage', $data);
$this->load->view('users/view_footer_user', $data); */
$this->renderSecurePage('jobs/view_manage', $data);
}
}