3 exists, compare start_date field with department_id=3 */ $error = common_schedules::validate_precedence($job_id,$mysql_start,$dept_id); if(strlen($error) == 0) { $context = array( "job_id" => $job_id, "department_id" => $dept_id, "start_date" => $mysql_start, "end_date" => $mysql_end, "hours" => $hours, "users" => $users ); $result=common_schedules::create_schedule($context); logs::submit_logs(array("table" => "job_schedules", "action_type" => 1,"foreign_id" => $result, "description" => "Created")); } $status = false; if($result) $status = true; else $status = false; $results = array("status" => $status, "reasons" => $error); $json = json_encode($results); echo $json; ?>