1
|
|
|
<?php |
2
|
|
|
require_once('modules/Calls_Reschedule/Calls_Reschedule.php'); |
3
|
|
|
require_once('modules/Calls/Call.php'); |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
$call = new call(); |
7
|
|
|
$timedate =new TimeDate(); |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
$id = $_POST['call_id']; |
11
|
|
|
$date = $_POST['date']; |
12
|
|
|
$reason = $_POST['reason']; |
13
|
|
|
$hour = $_POST['date_start_hours']; |
14
|
|
|
$minutes = $_POST['date_start_minutes']; |
15
|
|
|
$ampm = $_POST['date_start_meridiem']; |
16
|
|
|
|
17
|
|
|
$time_format = $timedate->get_user_time_format(); //get the logged in users time settings |
|
|
|
|
18
|
|
|
|
19
|
|
|
//Combine date and time dependant on users settings |
20
|
|
|
$time_separator = ":"; |
21
|
|
|
if(preg_match('/\d+([^\d])\d+([^\d]*)/s', $time_format, $match)) { |
22
|
|
|
$time_separator = $match[1]; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
if(!empty($hour) && !empty($minutes)) { |
26
|
|
|
|
27
|
|
|
$time_start = $hour. $time_separator .$minutes; |
28
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
if(isset($ampm ) && !empty($ampm )) { |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
$time_start = $timedate->merge_time_meridiem($time_start, $timedate->get_time_format(), $ampm); |
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
if(isset($time_start) && strlen($date) == 10) { |
38
|
|
|
|
39
|
|
|
$date_start = $date.' ' .$time_start; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
$call->retrieve($id); |
44
|
|
|
$call->date_start = $date_start;//set new the start date |
45
|
|
|
$call->save();//save the new start date |
46
|
|
|
//get the duration of the call |
47
|
|
|
$hours = $call->duration_hours; |
48
|
|
|
$mins = $call->duration_minutes; |
49
|
|
|
|
50
|
|
|
//get the new start date directly from the database to avoid sugar changing the format to users setting |
51
|
|
|
$query = 'SELECT date_start FROM calls WHERE id="'.$id.'"'; |
52
|
|
|
$result = $call->db->getOne($query); |
53
|
|
|
//add on the duration of call and save the end date/time |
54
|
|
|
$Date = strtotime($result); |
55
|
|
|
$newDate = strtotime('+'.$hours.' hours', $Date); |
56
|
|
|
$newDate = strtotime('+'.$mins.' minutes', $newDate); |
57
|
|
|
$newDate = date("Y-m-d H:i:s", $newDate); |
58
|
|
|
$call->date_end = $newDate; |
59
|
|
|
//save call and call attempt history |
60
|
|
|
$reschedule = new Calls_Reschedule(); |
61
|
|
|
|
62
|
|
|
$reschedule->reason = $reason; |
63
|
|
|
$reschedule->call_id = $id; |
64
|
|
|
|
65
|
|
|
$call->save(); |
66
|
|
|
$reschedule->save();//save call attempt history line |
67
|
|
|
|
68
|
|
|
|
This method has been deprecated.