3 exists, compare start_date field with department_id=3 */ $database->StartTrans(); if($action==1) { $error = common_schedules::validate_precedence($jobid,$mysql_start,$department); if(strlen($error)== 0 ) { $context = array( "job_id" => $jobid, "dept_id" => $department, "mysql_start" => $mysql_start, "mysql_end" => $mysql_end, "hours" => $hours, "users" => $users, "id" => $cal_id ); common_schedules::update_schedule($context); } } elseif($action==3) { $error = common_schedules::validate_precedence($jobid,$mysql_start,$department); if(strlen($error)== 0 ) { $context = array( "job_id" => $jobid, "mysql_start" => $mysql_start, "mysql_end" => $mysql_end, "id" => $cal_id, "move" => $moveall, "delta" => $dayDelta ); common_schedules::update_schedule_from_drag($context); } common_schedules::validate_succession($jobid,$mysql_start,$department); } else { common_schedules::remove_schedule($cal_id); } logs::submit_logs(array("table" => "job_schedules", "action_type" => 2,"foreign_id" => $last_user_id, "description" => "Modified")); $result = $database->CompleteTrans(); $status = false; if($result && strlen($error) == 0) $status = true; else $status = false; $results = array("status" => $status, "reasons" => $error ); $json = json_encode($results); echo $json; ?>