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; * */ $data = $this->getSessionArray(); // 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 ) // $data = $this->getSessionArray(); if (!isset($_SESSION['username']) or $_SESSION['username'] == '') { redirect(home); } else { $this->load->view('users/view_header_user', $data); $this->load->view('users/view_dash', $data); $this->load->view('users/view_footer_user', $data); } } public function pastdue() { $data = $this->getSessionArray(); if (!isset($_SESSION['username']) or $_SESSION['username'] == '') { redirect(home); } else { $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; $data['member_id'] = $_SESSION['member_id']; // = $ret->email; $this->load->library('table'); $this->table->set_template($this->template); $jbx = "''/proj/latejob''"; $mysql = "SELECT 'Project ID:'||mc.contract||'
Title:'||mc.title AS Project,m.firstname||' '||m.lastname AS Client," . " 'Timeline: '||mc.timeline_days||' day(s)
Price:'||mc.price*0.01 ,mc.description," . " '' AS manage," . " (CASE WHEN mc.status = 1 AND mc.delivery_date > now() THEN 'Active' WHEN mc.status = 1 AND mc.delivery_date load->library('pagination'); $config = array(); $query = $this->db->query($mysql); $config["total_rows"] = $query->num_rows(); $config["base_url"] = base_url() . "/proj/pastdue"; $config["per_page"] = 5; $config["uri_segment"] = 3; $config["num_links"] = 5; $config['full_tag_open'] = ""; $config['num_tag_open'] = '
  • '; $config['num_tag_close'] = '
  • '; $config['cur_tag_open'] = "
  • "; $config['cur_tag_close'] = "
  • "; $config['next_tag_open'] = "
  • "; $config['next_tagl_close'] = "
  • "; $config['prev_tag_open'] = "
  • "; $config['prev_tagl_close'] = "
  • "; $config['first_tag_open'] = "
  • "; $config['first_tagl_close'] = "
  • "; $config['last_tag_open'] = "
  • "; $config['last_tagl_close'] = "
  • "; $this->pagination->initialize($config); $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; $page = is_numeric($page) ? $page : 0; $mysql = "SELECT 'ID:'||mc.contract||'
    Timeline:'||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 AS Project," . " 'Title: '||mc.title||'
    Description: '||mc.description AS description," . " (CASE WHEN mc.status=4 THEN '' " . " WHEN mc.status = 1 AND mc.delivery_date > now() THEN '' " . " WHEN mc.status = 1 AND mc.delivery_date ' " . " ELSE '' END) AS manage " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id " . " WHERE mc.member_id = " . $_SESSION['member_id'] . " AND mc.status IN (1,2) " . " AND mc.delivery_date < now() " . " LIMIT " . $config["per_page"] . " OFFSET " . $page; $query = $this->db->query($mysql); $data['ref_site'] = "/proj/active/$page"; $this->table->set_heading(array('data' => 'Job', 'style' => 'width:180px'), 'Title/Description', array('data' => '', 'style' => 'width:100px; cellpadding:0px;')); $data['job_table'] = $this->table->generate($query); $data["links"] = $this->pagination->create_links(); $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_activejob', $data); $this->load->view('users/view_footer_user', $data);*/ //view_pastduejob.php $data['page_title'] ="Past Due"; $this->renderSecurePage('jobs/view_pastduejob', $data); } } public function active() { $data = $this->getSessionArray(); if (!isset($_SESSION['username']) or $_SESSION['username'] == '') { redirect(home); } else { $data = $this->getSessionArray(); $this->load->library('table'); $this->table->set_template($this->template); $jbx = "''/proj/thisjob''"; $mysql = "SELECT 'ID:'||mc.contract||'
    Timeline:'||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 AS Project," . " 'Title: '||mc.title||'
    Description: '||mc.description AS description,'\/proj\/thisjob' AS qpath, mc.id AS offer_id," . " (CASE WHEN mc.status=4 THEN '' " . " WHEN mc.status = 1 AND mc.delivery_date > now() THEN '' " . " WHEN mc.status = 1 AND mc.delivery_date PastDue' " . " ELSE '' END) AS manage " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id " . " WHERE mc.member_id = " . $_SESSION['member_id'] . " AND mc.status IN (1,2,4) AND mc.delivery_date > now() " . " OR mc.client_id =" . $_SESSION['member_id'] . " AND mc.status IN (1,2,4) AND mc.delivery_date > now()"; $mysqlDEL = "SELECT 'Project ID:'||mc.contract||'
    Title:'||mc.title AS Project,m.firstname||' '||m.lastname AS Client," . " 'Timeline: '||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 ,mc.description," . " '' AS manage," . " (CASE WHEN mc.status = 1 AND mc.delivery_date > now() THEN 'Active' WHEN mc.status = 1 AND mc.delivery_date PastDue' " . " WHEN mc.status = 4 THEN 'Review' ELSE 'Not Set' END) AS status " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id WHERE mc.member_id = " . $_SESSION['member_id'] . " " . " AND mc.status IN (1,2,4) OR mc.client_id =" . $_SESSION['member_id'] . " " . " AND mc.status IN (1,2,4) "; $this->load->library('pagination'); $query = $this->db->query($mysql); $config =$this->paginationConfig(3,5,$query->num_rows(),"/proj/active",5); $this->pagination->initialize($config); $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; $page = is_numeric($page) ? $page : 0; $mysqlDEL = "SELECT 'ID:'||mc.contract||'
    '||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 AS Project," . " 'Title: '||mc.title||'
    Description: '||mc.description AS description," . " (CASE WHEN mc.status=4 THEN '' " . " WHEN mc.status = 1 AND mc.delivery_date > now() THEN '' " . " WHEN mc.status = 1 AND mc.delivery_date PastDue' " . "ELSE '' END) AS manage " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id WHERE mc.member_id = " . $_SESSION['member_id'] . " AND mc.status IN (1,2,4) OR mc.client_id =" . $_SESSION['member_id'] . " AND mc.status IN (1,2,4) LIMIT " . $config["per_page"] . " OFFSET " . $page; $mysql = "SELECT 'ID:'||mc.contract||'
    Timeline:'||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 AS Project," . " 'Title: '||mc.title||'
    Description: '||mc.description AS description,'\/proj\/thisjob' AS qpath, mc.id AS offer_id,mc.delivery_date::date," . " (CASE WHEN mc.status=4 THEN '' " . " WHEN mc.status = 1 AND mc.delivery_date > now() THEN '' " . " WHEN mc.status = 1 AND mc.delivery_date PastDue' " . " ELSE '' END) AS manage " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id " . " WHERE mc.member_id = " . $_SESSION['member_id'] . " AND mc.status IN (1,2,4) AND mc.delivery_date > now() " . " OR mc.client_id =" . $_SESSION['member_id'] . " AND mc.status IN (1,2,4) AND mc.delivery_date > now() LIMIT ". $config["per_page"] . " OFFSET " . $page;; $query = $this->db->query($mysql); $data['job_table_result'] = $query->result();; $data['ref_site'] = "/proj/active/$page"; $data['job_table'] = $this->table->generate($query); $this->table->set_heading(array('data' => 'Job', 'style' => 'width:180px'), 'Title/Description', array('data' => '', 'style' => 'width:100px; cellpadding:0px;')); //$this->table->set_heading('Job', 'Description', ''); $data['job_table'] = $this->table->generate($query); $data["links"] = $this->pagination->create_links(); $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['page_title'] = "Active Task"; $data['recent_complete'] = $this->jobHistory(4); $this->RenderUserPage('jobs/view_activejob', $data); } } public function thisjobfiles() { if (!isset($_SESSION['username']) or $_SESSION['username'] == '') { echo "Denied..."; return; } $jobID = $this->input->get('jobID'); $data['jobID'] = $jobID; $mybalance = 10666; $data['mybalance'] = $mybalance; $this->load->model('backend_model'); $data = $this->load_files($data, $jobID); //echo $this->messageAccordion($data['message_result']); the loadfile will handle this call echo $data['message_result_show']; //echo $data['message_table']; } private function messageAccordion($message_result) { $msgA = "
    "; $ii = 0; foreach ($message_result as $row) { $ii++; $clin = ""; if ($ii == 1) { $clin = "in"; } // echo $row->title; // echo $row->name; // echo $row->body; $callapseName = "collapseP" . $ii; $msgA .=""; } $msgA .="
    "; return $msgA; } public function latejob() { // echo 'oooooooooooooooooooooooooo'; // $data['redirect_to'] = str_replace(base_url(),'',$_SERVER['HTTP_REFERER']); $uploaded = false; $data = $this->getSessionArray(); $data['redirect_to'] = '/proj/pastdue/'; if (!isset($_SESSION['username']) or $_SESSION['username'] == '') { redirect(home); } else { $message = ""; $ajax = $this->input->post('ajax'); $jobID = $this->input->post('jobID'); $data['jobID'] = $jobID; //$mybalance = 10666; //$data['mybalance'] = $mybalance; $this->load->model('backend_model'); if ($_POST && !isset($_POST['uploadForm'])) { $msgArray = array(); $msgArray['message'] = trim($this->input->post('jobmessage')); $msgArray['contract'] = $this->input->post('contractId'); $msgArray['msg_type'] = 'TEXT'; $msgArray['member_id'] = $_SESSION['member_id']; // = $ret->email; if ($msgArray['message'] != '') { // NOTE THAT IT msg_type is IMPORTTANT $msgArray['msg_type'] = 'TEXT'; $msgArray['action'] = WRENCHBOARD_CONTRACT_MESSAGE; $out = array(); $res = $this->backend_model->wrenchboard_api($msgArray, $out); // print_r( $out ); } } else if ($_POST && isset($_POST['uploadForm']) && isset($_FILES["fileToUpload"])) { list ($message, $uploaded) = $this->process_files($_FILES["fileToUpload"]); } $data = $this->load_files($data, $jobID); $data["sizeLimit"] = $this->backend_model->cfgReadChar("system.upload_size_limit"); $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['message'] = $message; $data['this_is_client'] = false; $data['this_is_project_owner'] = false; $data['disabled1'] = 'disabled'; $data['disabled2'] = 'disabled'; $data['disabled11'] = 'disabled'; $data['disabled22'] = 'disabled'; /* $data['job_status'] = $jbD1->status; $data['job_member_id'] = $jbD1->member_id; $data['job_client_id'] = $jbD1->client_id; */ if ($data['job_member_id'] == $_SESSION['member_id']) { $data['this_is_client'] = false; $data['this_is_project_owner'] = true; if ( $data["job_status"] == 1 or $data["job_status"] == 2 ) { $data['disabled11'] = ''; $data['disabled22'] = ''; } } if ($ajax == 1) { echo $res; } else { // $this->load->view('users/view_header_user', $data); // $this->load->view('jobs/view_latejob', $data); // $this->load->view('users/view_footer_user', $data); $this->RenderUserPage('jobs/view_latejob', $data); } } } public function thisjob() { $data = $this->getSessionArray(); $data['redirect_to'] = '/proj/active/'; $uploaded = false; if (!isset($_SESSION['username']) or $_SESSION['username'] == '') { redirect(home); return; } ob_start(); $message = ""; $res = -1; // echo rand(100,9999). " ameye 1"; if ($_POST) { $ajax = $this->input->post('ajax'); $jobID = $this->input->post('jobID'); } else { $ajax = $this->input->get('ajax'); $jobID = $this->input->get('jobID'); $message = $this->input->get('message'); } $data['jobID'] = $jobID; //$mybalance = 10666; //$data['mybalance'] = $mybalance; $this->load->model('backend_model'); // echo rand(100,9999). " ameye 2"; if ($_POST && !isset($_POST['uploadForm'])) { // echo rand(100,9999). " ameye 2222-2222"; // exit; $msgArray = array(); $msgArray['message'] = trim($this->input->post('jobmessage')); $msgArray['contract'] = $this->input->post('contractId'); $msgArray['msg_type'] = 'TEXT'; $msgArray['member_id'] = $_SESSION['member_id']; // = $ret->email; if (trim($msgArray['message']) != '') { // NOTE THAT IT msg_type is IMPORTTANT $msgArray['msg_type'] = 'TEXT'; $msgArray['action'] = WRENCHBOARD_CONTRACT_MESSAGE; $out = array(); $res = $this->backend_model->wrenchboard_api($msgArray, $out); } else { $res = "Message is empty!"; } } else if ($_POST && isset($_POST['uploadForm']) && isset($_FILES["fileToUpload"])) { list ($message, $uploaded) = $this->process_files($_FILES["fileToUpload"]); } $data = $this->load_files($data, $jobID); //$this->load_files($data, $jobID); $data["sizeLimit"] = $this->backend_model->cfgReadChar("system.upload_size_limit"); $data["force_job_wait"] = $this->backend_model->cfgReadChar("system.force_job_wait"); // configuration to supress wait time $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['message'] = $message; $data['this_is_client'] = false; $data['this_is_project_owner'] = false; $data['disabled1'] = 'disabled'; $data['disabled2'] = 'disabled'; $data['disabled11'] = 'disabled'; $data['disabled22'] = 'disabled'; if ( $data["force_job_wait"] == 0 ){ //just forget about delays $data['disabled1'] = $data['disabled2'] = $data['disabled11'] = $data['disabled22'] =''; } /* $data['job_status'] = $jbD1->status; $data['job_member_id'] = $jbD1->member_id; $data['job_client_id'] = $jbD1->client_id; */ if ($data['job_member_id'] == $_SESSION['member_id']) { $data['this_is_client'] = false; $data['this_is_project_owner'] = true; if ($data["job_status"] == CONTRACT_NOTIFY_COMPLETE) { $data['disabled11'] = ''; $data['disabled22'] = ''; } } else { $data['this_is_client'] = true; $data['this_is_project_owner'] = false; if ($data["job_status"] == 1 and $data['force_wait'] == false) { $data['disabled1'] = ''; $data['disabled2'] = ''; } } if ($ajax == 1) { ob_end_clean(); echo isset($res)? $res:''; // $this->RenderUserPage('jobs/view_thisjob', $data); } else { /* $this->load->view('users/view_header_user', $data); $this->load->view('jobs/view_thisjob', $data); $this->load->view('users/view_footer_user', $data); */ ob_end_flush(); if ($uploaded) { redirect('/proj/thisjob?jobID='.$jobID.'&message='.$message); } else { $this->RenderUserPage('jobs/view_thisjob', $data); } } } public function mycompltjob() { $uploaded = false; $data = $this->getSessionArray(); if (!isset($_SESSION['username']) or $_SESSION['username'] == '') { redirect(home); } else { $message = ""; $ajax = $this->input->post('ajax'); $jobID = $this->input->post('jobID'); $data['jobID'] = $jobID; $mybalance = 10666; $data['mybalance'] = $mybalance; $this->load->model('backend_model'); $data = $this->load_files($data, $jobID); $data["sizeLimit"] = $this->backend_model->cfgReadChar("system.upload_size_limit"); if ($_POST && !isset($_POST['uploadForm'])) { $msgArray = array(); $msgArray['message'] = trim($this->input->post('jobmessage')); $msgArray['contract'] = $this->input->post('contractId'); $msgArray['msg_type'] = 'TEXT'; $msgArray['member_id'] = $_SESSION['member_id']; // = $ret->email; if ($msgArray['message'] != '') { // NOTE THAT IT msg_type is IMPORTTANT $msgArray['msg_type'] = 'TEXT'; $msgArray['action'] = WRENCHBOARD_CONTRACT_MESSAGE; $out = array(); $res = $this->backend_model->wrenchboard_api($msgArray, $out); // print_r( $out ); } } else if ($_POST && isset($_POST['uploadForm']) && isset($_FILES["fileToUpload"])) { list ($message, $uploaded) = $this->process_files($_FILES["fileToUpload"]); } $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['message'] = $message; $data['this_is_client'] = false; $data['this_is_project_owner'] = false; $data['disabled1'] = 'disabled'; $data['disabled2'] = 'disabled'; $data['disabled11'] = 'disabled'; $data['disabled22'] = 'disabled'; /* $data['job_status'] = $jbD1->status; $data['job_member_id'] = $jbD1->member_id; $data['job_client_id'] = $jbD1->client_id; */ if ($data['job_member_id'] == $_SESSION['member_id']) { $data['this_is_client'] = false; $data['this_is_project_owner'] = true; if ($data["job_status"] == CONTRACT_NOTIFY_COMPLETE) { $data['disabled11'] = ''; $data['disabled22'] = ''; } } else { $data['this_is_client'] = true; $data['this_is_project_owner'] = false; if ($data["job_status"] == 1 and $data['force_wait'] == false) { $data['disabled1'] = ''; $data['disabled2'] = ''; } } if ($ajax == 1) { echo $res; } else { $this->load->view('users/view_header_user', $data); $this->load->view('jobs/view_view_mycomplj', $data); $this->load->view('users/view_footer_user', $data); } } } public function compltjob() { // echo 'oooooooooooooooooooooooooo'; $uploaded = false; $data = $this->getSessionArray(); if (!isset($_SESSION['username']) or $_SESSION['username'] == '') { redirect(home); } else { $message = ""; $ajax = $this->input->post('ajax'); $jobID = $this->input->post('jobID'); $data['jobID'] = $jobID; $mybalance = 10666; $data['mybalance'] = $mybalance; $this->load->model('backend_model'); $data = $this->load_files($data, $jobID); $data["sizeLimit"] = $this->backend_model->cfgReadChar("system.upload_size_limit"); if ($_POST && !isset($_POST['uploadForm'])) { $msgArray = array(); $msgArray['message'] = trim($this->input->post('jobmessage')); $msgArray['contract'] = $this->input->post('contractId'); $msgArray['msg_type'] = 'TEXT'; $msgArray['member_id'] = $_SESSION['member_id']; // = $ret->email; if ($msgArray['message'] != '') { // NOTE THAT IT msg_type is IMPORTTANT $msgArray['msg_type'] = 'TEXT'; $msgArray['action'] = WRENCHBOARD_CONTRACT_MESSAGE; $out = array(); $res = $this->backend_model->wrenchboard_api($msgArray, $out); // print_r( $out ); } } else if ($_POST && isset($_POST['uploadForm']) && isset($_FILES["fileToUpload"])) { list ($message, $upaloded) = $this->process_files($_FILES["fileToUpload"]); } $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['message'] = $message; $data['this_is_client'] = false; $data['this_is_project_owner'] = false; $data['disabled1'] = 'disabled'; $data['disabled2'] = 'disabled'; $data['disabled11'] = 'disabled'; $data['disabled22'] = 'disabled'; /* $data['job_status'] = $jbD1->status; $data['job_member_id'] = $jbD1->member_id; $data['job_client_id'] = $jbD1->client_id; */ if ($data['job_member_id'] == $_SESSION['member_id']) { $data['this_is_client'] = false; $data['this_is_project_owner'] = true; if ($data["job_status"] == CONTRACT_NOTIFY_COMPLETE) { $data['disabled11'] = ''; $data['disabled22'] = ''; } } else { $data['this_is_client'] = true; $data['this_is_project_owner'] = false; if ($data["job_status"] == 1 and $data['force_wait'] == false) { $data['disabled1'] = ''; $data['disabled2'] = ''; } } if ($ajax == 1) { echo $res; } else { //$this->load->view('users/view_header_user', $data); //$this->load->view('jobs/view_view_complj', $data); //$this->load->view('users/view_footer_user', $data); $data['redirect_to'] = '/proj/complete'; $this->renderSecurePage('jobs/view_view_complj', $data); } } } private function load_files($data, $jobID) { $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; $data['member_id'] = $_SESSION['member_id']; // = $ret->email; //$detail_button = " '' "; $detail_button =" 'Delivery Detail' "; //$detail_button = " 'Linked label' "; // ' "; $is_live = $this->backend_model->cfgReadChar("system.live"); $this->load->library('table'); $this->table->set_template($this->template_nohead); $jbx = "''thisjob''"; $mysql = "SELECT 'Project ID :'||mc.contract||' - Name: '||m.firstname||'
    Title:'||mc.title||'
    '||'Description: '||mc.description||'
    Timeline: '||mc.timeline_days||' day(s) Price: '||mc.price*0.01||'Naira'||' Expected Delivery: '||mc.delivery_date||' '||$detail_button AS this_job," . " mc.contract AS contract_id, mc.job_detail AS job_detail " . "FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id " . " WHERE (mc.member_id = '" . $_SESSION['member_id'] . "' OR mc.client_id='" . $_SESSION['member_id'] . "') AND mc.id=" . ((int)$jobID); $query = $this->db->query($mysql); $result = $query->result_array(); $jbD = array("this_job" => "", "contract_id" => "", "job_detail" => ""); if (is_array($result) && count($result)>0) { $jbD = $result[0]; } //---------------------- $mysql = "SELECT m.id,mc.contract, m.firstname,mc.title,mc.description, mc.timeline_days, mc.price*0.01,mc.delivery_date, mc.contract AS contract_id, mc.job_detail AS job_detail , $detail_button As delivery_details,mc.status AS current_job_status FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id WHERE (mc.member_id = '" . $_SESSION['member_id'] . "' OR mc.client_id='" . $_SESSION['member_id'] . "') AND mc.id=" . ((int)$jobID); $query = $this->db->query($mysql); $result = $query->result(); $r = new stdClass(); $r->id = ""; $r->contract = ""; $r->firstname = ""; $r->title = ""; $r->description = ""; $r->timeline_days = ""; $r->price = ""; $r->delivery_date = ""; $r->contract_id = ""; $r->job_detail = ""; $r->delivery_details = ""; $data["this_job_result"] = is_array($result) ? $result[0] : $r; //---------------------- // $this->table->set_heading('Job', 'Client', 'Terms', 'Price', 'Manage', 'Status'); $data['job_table'] = $this->table->generate($query); $data['this_job'] = $jbD["this_job"]; $data['contract_id'] = $jbD["contract_id"]; $data['job_detail'] = $jbD["job_detail"]; /* $sqlMsg = "SELECT (CASE WHEN jc.msg_type='FILE' THEN ''||jc.message||'' ELSE '['||m.firstname||']->'||jc.created||'
    '||jc.message END) AS msg " . "FROM jobs_contract_message jc " . "LEFT JOIN members m ON m.id=jc.member_id " . "WHERE jc.contract='" . $data['contract_id'] . "' ORDER by jcESC"; /* $file_icon = "\"Icon\""; $sqlMsg = "SELECT to_char(jc.created, 'YYYY-MM-DD HH24:MI') AS date1, ''||(CASE WHEN jc.msg_type='FILE' THEN 'FILE-' ELSE '' END) ||''||m.firstname AS title,jc.id as msg_id," . "(CASE WHEN jc.msg_type='FILE' THEN ''||jc.message||'' ELSE jc.message END) AS msg " . "FROM jobs_contract_message jc " . "LEFT JOIN members m ON m.id=jc.member_id " . "WHERE jc.contract='" . $data['contract_id'] . "' ORDER by jc.id DESC"; */ $sqlMsg = "SELECT to_char(jc.created, 'YYYY-MM-DD HH24:MI') AS date1, ''||(CASE WHEN jc.msg_type='FILE' THEN ' - ' ELSE '' END) ||''||m.firstname AS title,jc.id as msg_id," . "(CASE WHEN jc.msg_type='FILE' THEN ''||jc.message||'' ELSE jc.message END) AS msg, " . " jc.msg_type, jc.message " . "FROM jobs_contract_message jc " . "LEFT JOIN members m ON m.id=jc.member_id " . "WHERE jc.contract='" . $data['contract_id'] . "' ORDER by jc.id DESC"; $query_message = $this->db->query($sqlMsg); //ABOUT TO BE RETIRED $this->table->set_template($this->template_nohead); $this->table->set_heading(''); $data['message_table'] = $this->table->generate($query_message); //=================== $data['message_result'] = $query_message->result(); //---------------------------------------------------------------- /* Neeed to get just the files here - part of the display items */ $files_only= []; foreach ($data['message_result'] as $frow){ if ($frow->msg_type==='FILE'){ $files_only[]=$frow; } } $data['files_only'] =$files_only; //----- END OFFILYER FILES ONLY OUT ------------------------------ // $data['message_result_show'] = $this->messageAccordion($data['message_result']); $mysql3 = "SELECT *,(delivery_date::date- now()::date)::int AS remaining_days FROM members_jobs_contract WHERE id= " . ((int)$jobID); $query3 = $this->db->query($mysql3); $result3 = $query3->result_array(); $jbD1 = array("status"=>"","member_id"=>"","client_id"=>"","contract"=>"","timeline_days"=>"","remaining_days"=>""); if (is_array($result3) && count($result3)) { $jbD1 = $result3[0]; } $data['job_status'] = $jbD1["status"]; $data['job_member_id'] = $jbD1["member_id"]; $data['job_client_id'] = $jbD1["client_id"]; $data['job_contract'] = $jbD1["contract"]; $data['timeline_days'] = $jbD1["timeline_days"]; $data['remaining_days'] = $jbD1["remaining_days"]; $data['force_wait'] = false; if ($data['remaining_days'] > 0) { if ($data['timeline_days'] / 2 < $data['remaining_days']) { $data['force_wait'] = true; } //lef us use just one day if ($data['timeline_days'] - $data['remaining_days'] > 1) { $data['force_wait'] = false; } } return $data; } public function processjob_status() { $out = array(); $out["result"] = ''; $data['member_id'] = $_SESSION['member_id']; // = $ret->email; $data['proc'] = $this->input->get('proc'); $data['job_id'] = $this->input->get('jobID'); $data['job_contract'] = $this->input->get('job_contract'); $mysql = "SELECT * FROM members_jobs_contract WHERE contract ='" . $data['job_contract'] . "' AND id =" . $data['job_id']; $query = $this->db->query($mysql); $jbD = $query->row(); $data['job_action'] = 0; switch ($data['proc']) { case 'NCOMPLETE': $data['job_action'] = CONTRACT_NOTIFY_COMPLETE; break; case 'REQCANCEL': $data['job_action'] = CONTRACT_REQUEST_CANCEL; break; case 'ACCEPTCMP': $data['job_action'] = CONTRACT_ACCEPT_COMPLETE; break; case 'REJECTCMP': $data['job_action'] = CONTRACT_REJECT_COMPLETE; break; case 'EXTENDLATE': $data['extension'] = $this->input->get('extension'); $data['job_action'] = CONTRACT_EXTEND_TIMELINE; break; case 'REQCANCELLATE': $data['job_action'] = CONTRACT_CANCEL_CONTRACT; break; } $this->load->model('backend_model'); $data['action'] = WRENCHBOARD_CONTRACT_STATUS; $res = $this->backend_model->wrenchboard_api($data, $out); echo $out["result"]; /* * Array ( [proc] => ACCEPTCMP [job_id] => 13 [job_contract] => 7BW9B9R8BB ) ameye * * * * define('CONTRACT_CANCEL_CONTRACT', 7 ); * define('CONTRACT_EXTEND_TIMELINE', 9 ); * define('CONTRACT_NOTIFY_COMPLETE', 4 ); define('CONTRACT_REQUEST_CANCEL', 3 ); define('CONTRACT_ACCEPT_COMPLETE', 5 ); define('CONTRACT_REJECT_COMPLETE', 1 ); * proc=NCOMPLETE& proc=REQCANCEL& proc=ACCEPTCMP& proc=REJECTCMP& */ // print_r($data); } public function complete() { $data = $this->getSessionArray(); if (!isset($_SESSION['username']) or $_SESSION['username'] == '') { redirect(home); } else { $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; $data['member_id'] = $_SESSION['member_id']; // = $ret->email; $mybalance = 10666; $data['mybalance'] = $mybalance; $this->load->library('table'); $this->table->set_template($this->template); $jbx = "''/proj/compltjob''"; $mysql = "SELECT 'Project:'||mc.contract||'
    Timeline: '||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 AS Project," . " " . " 'Title:'||mc.title||'
    Description:'||mc.description," . " ( CASE WHEN mc.status=5 THEN 'Completed' Else '' END) AS status," . " '' AS manage " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id WHERE mc.status=5 AND mc.member_id = " . $_SESSION['member_id']; $mysql = "SELECT 'Date:'||mc.created::date||'
    Timeline: '||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 AS Project," . " " . " 'Project:'||mc.contract||'-'||m.firstname||'
    Title:'||mc.title||'
    Description:'||mc.description," . " '' AS manage " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id WHERE mc.status=5 AND mc.member_id = " . $_SESSION['member_id']; $query = $this->db->query($mysql); $this->load->library('pagination'); $config = array(); $query = $this->db->query($mysql); $config["total_rows"] = $query->num_rows(); $config["base_url"] = base_url() . "/proj/complete"; $config["per_page"] = 5; $config["uri_segment"] = 3; $config["num_links"] = 5; $config['full_tag_open'] = "
      "; $config['full_tag_close'] = "
    "; $config['num_tag_open'] = '
  • '; $config['num_tag_close'] = '
  • '; $config['cur_tag_open'] = "
  • "; $config['cur_tag_close'] = "
  • "; $config['next_tag_open'] = "
  • "; $config['next_tagl_close'] = "
  • "; $config['prev_tag_open'] = "
  • "; $config['prev_tagl_close'] = "
  • "; $config['first_tag_open'] = "
  • "; $config['first_tagl_close'] = "
  • "; $config['last_tag_open'] = "
  • "; $config['last_tagl_close'] = "
  • "; $this->pagination->initialize($config); $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; $page = is_numeric($page) ? $page : 0; $mysql = "SELECT 'Date:'||mc.created::date||'
    Timeline: '||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 AS Project," . " " . " 'Project:'||mc.contract||' by '||m.firstname||'
    Title:'||mc.title||'
    Description:'||mc.description," . " '' AS manage " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id WHERE mc.status=5 AND mc.member_id = " . $_SESSION['member_id'] . " ORDER BY mc.created DESC LIMIT " . $config["per_page"] . " OFFSET " . $page; // LIMIT " . $config["per_page"] . " OFFSET " . $page; $query = $this->db->query($mysql); //array('data' => 'Job', 'style' => 'width:120px') $this->table->set_heading(array('data' => 'Job', 'style' => 'width:180px'), 'Title/Description', array('data' => 'View', 'style' => 'width:40px; cellpadding:0px;')); $data['job_table'] = $this->table->generate($query); $data["links"] = $this->pagination->create_links(); $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_completejob', $data); } } public function mycomplete() { $data = $this->getSessionArray(); if (!isset($_SESSION['username']) or $_SESSION['username'] == '') { redirect(home); } else { $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; $data['member_id'] = $_SESSION['member_id']; // = $ret->email; $mybalance = 10666; $data['mybalance'] = $mybalance; $this->load->library('table'); $this->table->set_template($this->template); $jbx = "''/proj/mycompltjob''"; $mysql = "SELECT 'Project:'||mc.contract||'
    Timeline: '||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 AS Project," . " " . " 'Title:'||mc.title||'
    Description:'||mc.description," . " ( CASE WHEN mc.status=5 THEN 'Completed' Else '' END) AS status," . " '' AS manage " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id WHERE mc.status=5 AND mc.member_id = " . $_SESSION['member_id']; $mysql = "SELECT 'Date:'||mc.created::date||'
    Timeline: '||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 AS Project," . " " . " 'Project:'||mc.contract||'-'||m.firstname||'
    Title:'||mc.title||'
    Description:'||mc.description," . " '' AS manage " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id WHERE mc.status=5 AND mc.client_id = " . $_SESSION['member_id']; $query = $this->db->query($mysql); $this->load->library('pagination'); $config = array(); $query = $this->db->query($mysql); $config["total_rows"] = $query->num_rows(); $config["base_url"] = base_url() . "/proj/mycomplete"; $config["per_page"] = 5; $config["uri_segment"] = 3; $config["num_links"] = 5; $config['full_tag_open'] = "
      "; $config['full_tag_close'] = "
    "; $config['num_tag_open'] = '
  • '; $config['num_tag_close'] = '
  • '; $config['cur_tag_open'] = "
  • "; $config['cur_tag_close'] = "
  • "; $config['next_tag_open'] = "
  • "; $config['next_tagl_close'] = "
  • "; $config['prev_tag_open'] = "
  • "; $config['prev_tagl_close'] = "
  • "; $config['first_tag_open'] = "
  • "; $config['first_tagl_close'] = "
  • "; $config['last_tag_open'] = "
  • "; $config['last_tagl_close'] = "
  • "; $this->pagination->initialize($config); $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; $page = is_numeric($page) ? $page : 0; $mysql = "SELECT 'Date:'||mc.created::date||'
    Timeline: '||mc.timeline_days||' day(s)
    Price:'||mc.price*0.01 AS Project," . " " . " 'Project:'||mc.contract||' by '||m.firstname||'
    Title:'||mc.title||'
    Description:'||mc.description," . " '' AS manage " . " FROM members_jobs_contract mc LEFT JOIN members m ON m.id=mc.client_id WHERE mc.status=5 AND mc.client_id = " . $_SESSION['member_id'] . " ORDER BY mc.created DESC LIMIT " . $config["per_page"] . " OFFSET " . $page; // LIMIT " . $config["per_page"] . " OFFSET " . $page; $query = $this->db->query($mysql); //array('data' => 'Job', 'style' => 'width:120px') $this->table->set_heading(array('data' => 'Job', 'style' => 'width:180px'), 'Title/Description', array('data' => 'View', 'style' => 'width:40px; cellpadding:0px;')); $data['job_table'] = $this->table->generate($query); $data["links"] = $this->pagination->create_links(); $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_mycompletejob', $data); $this->load->view('users/view_footer_user', $data); */ $data['page_title'] ="Previous Tasks"; $this->renderSecurePage('jobs/view_mycompletejob', $data); } } /* * This is the file upload function */ private function process_files($files) { $uploaded = false; $result = ""; $d_txt = ""; $is_live = $this->backend_model->cfgReadChar("system.live"); $sizeLimit = $this->backend_model->cfgReadChar("system.upload_size_limit"); if ($this->input->post('contractId') == "" || (int) $_SESSION['member_id'] < 1) { $result = "Invalid contract or member ID"; } else if (is_array($files)) { $target_dir = "/opt/wrenchboard/" . ($is_live ? "LIVE" : "TEST") . "/contract/" . $this->input->post('contractId'); if (!file_exists($target_dir)) { @mkdir($target_dir, 0777, true); } $i = 0; foreach ($files["name"] as $key => $name) { if ($files["error"][$key] == 0) { $target_file = $target_dir . "/" . $name; if ($files["size"][$key] <= $sizeLimit && move_uploaded_file($files["tmp_name"][$key], $target_file)) { $msgArray['action'] = WRENCHBOARD_CONTRACT_MESSAGE; $msgArray['message'] = $name; $msgArray['contract'] = $this->input->post('contractId'); $msgArray['msg_type'] = 'FILE'; $msgArray['member_id'] = $_SESSION['member_id']; // = $ret->email; $out = array(); $res = $this->backend_model->wrenchboard_api($msgArray, $out); // print_r( $out ); $i++; } } } $result = $i > 0 ? "Uploaded file(s): ${i}" : "Failed to process uploaded files${d_txt}"; $uploaded = $i > 0; } else { $result = "Files were not uploaded${d_txt}"; } // echo $result; return array($result, $uploaded); } public function demo() { $data = $this->getSessionArray(); $this->renderSecurePage('jobs/view_demo', $data); } public function upload() { $data = $this->getSessionArray(); $jobID = $this->input->post('jobID'); $contractId = $this->input->post('contractId'); $this->load->model('backend_model'); $sizeLimit = $this->backend_model->cfgReadChar("system.upload_size_limit"); $files = array( "name" => array($_FILES["fileToUpload"]["name"]), "error" => array($_FILES["fileToUpload"]["error"]), "tmp_name" => array($_FILES["fileToUpload"]["tmp_name"]), "size" => array($_FILES["fileToUpload"]["size"]), "type" => array($_FILES["fileToUpload"]["type"]) ); $is_live = $this->backend_model->cfgReadChar("system.live"); list ($message, $uploaded) = $this->process_files($files); if ($uploaded) { header("Content-Type:application/json"); echo json_encode( array( "status"=>1, "message"=> ($message != '' ? $message : "File upload failed with an unexpected error.") )); } else { header("Content-Type:application/json"); echo json_encode( array( "status"=>0, "message"=> ($message != '' ? $message : "Sorry, there was an error uploading your file.") )); } } }