| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/onesupportdemo.onesolution.hk/task/ |
Upload File : |
<?php
require_once(__DIR__ . '/../checkuser.php');
//-----------------------------------------------------------------------------
// Save if POST method
//-----------------------------------------------------------------------------
if (isPost()) {
$keyValues = $_POST['job_detail'];
/*foreach ($keyValues as $id => $attributes) {
//$keyValues[$id]['job_id'] = $_POST['job_id'];
}*/
if (!$dbh->beginTransaction()) {
throw new Exception('mysql begin transaction failure.');
}
try {
$activate_pending_task = array();
//for pending task
if(!empty($_POST["pending_task"])){
//$pending_tasks = $_POST["pending_task"];
//var_dump($_POST["pending_task"]);
foreach($_POST["pending_task"] as $key => $task){
//var_dump($task);
if(isset($task["add_to_job"]) && $task["add_to_job"] == 1 ){
//add follow up task to new job
$activate_pending_task[] = $task;
//set old task status to 4 as cancel
/*$sql = "update sup_job_detail set status = ? where id = ? and status = ?";
$parameters = array(4, $task["job_detail_id"], 3);
if (!($sth = $dbh->prepare($sql))) {
throw new Exception("sql prepare statement failure: $sql");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute($parameters)) {
throw new Exception("sql execute statement failure: $sql");
}*/
//keep status as follow up and update follow up flag
$sql = "update sup_job_detail set follow_up_flag = ? where id = ? and follow_up_flag = ?";
$parameters = array(1, $task["job_detail_id"], 0);
if (!($sth = $dbh->prepare($sql))) {
throw new Exception("sql prepare statement failure: $sql");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute($parameters)) {
throw new Exception("sql execute statement failure: $sql");
}
//set sup_job_pending to delete
$sql = "update sup_job_pending set actived = ? where job_detail_id = ?";
$parameters = array(0, $task["job_detail_id"]);
if (!($sth = $dbh->prepare($sql))) {
throw new Exception("sql prepare statement failure: $sql");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute($parameters)) {
throw new Exception("sql execute statement failure: $sql");
}
//insert new task to that job
/*$sql = "insert into sup_job_detail set createby=?, createdate=?, lastupdate=?, lastupby=?, actived=?, deleted=?, job_id=?, title=?, remarks=?, status=?, task_category_id=?, from_job_pending_id=?";
$parameters = array($_SESSION['webadmin']['id'], date("Y-m-d H:i:s"), $_SESSION['webadmin']['id'], date("Y-m-d H:i:s"), 1, 0, $task["job_detail_id"], $task["title"], $task["remarks"], 1, $task["task_category_id"], "");
if (!($sth = $dbh->prepare($sql))) {
throw new Exception("sql prepare statement failure: $sql");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute($parameters)) {
throw new Exception("sql execute statement failure: $sql");
}*/
}
}
//var_dump($activate_pending_task);
Job::createDetails($activate_pending_task);
}
Job::createDetails($keyValues);
if (!$dbh->commit()) {
throw new Exception('mysql commit transaction failure.');
}
} catch (Exception $exception) {
if (!$dbh->rollBack()) {
throw new Exception('mysql roll back transaction failure.');
}
throw $exception;
}
unset($_SESSION["all_job_ids"]);
if (Util::isAdmin()) {
//redirectAndExit(Util::link(__DIR__ . '/../job/index.php') . '?message=Saved.');
//redirectAndExit(Util::link(__DIR__ . '/../job/modifyform.php') . '?id='.$_POST['job_id'].'&message=Job Created.');
//redirectAndExit(Util::link(__DIR__ . '/../job/index.php') . '?message=Job Created.');
$startdate = date("Y-m-d");
$enddate = Date('Y-m-d', strtotime($startdate ."+1 month"));
redirectAndExit(Util::link(__DIR__ . '/../job/index.php') . '?start_date='.$startdate.'&end_date='.$enddate.'&message=Job Created.');
} else if($_SESSION['webadmin']['role'] == 2){
redirectAndExit(Util::link(__DIR__ . '/../job/index.php') . '?today=1&message=Job Created.');
} else if($_SESSION['webadmin']['role'] == 3){
redirectAndExit(Util::link(__DIR__ . '/../job/index.php') . '?today=1&message=Job Created.');}
else{
$data = array(
'id' => $_POST['job_id'],
'message' => 'Job Saved',
);
//redirectAndExit(Util::link(__DIR__ . '/../job/modifyform.php') . '?' . http_build_query($data));
redirectAndExit(Util::link(__DIR__ . '/../job/modifyform.php') . '?' . http_build_query($data));
}
}