forked from 1btcxe/backstage2
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathajax.cal.php
51 lines (44 loc) · 1.62 KB
/
ajax.cal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
include('lib/common.php');
String::magicQuotesOff();
$rows = $_REQUEST['rows'];
if ($rows) {
$done_tables = array();
foreach ($rows as $row) {
$seconds = ($row['total_y']/50) * 1800;
$edate_field = $row['edate_field'];
$sdate_field = $row['sdate_field'];
$original = DB::getRecord($row['table'],$row['id'],0,1);
$sdate = date('Y-m-d H:i:s',strtotime($original[$sdate_field]) + $seconds);
$edate = date('Y-m-d H:i:s',strtotime($original[$edate_field]) + $seconds);
if ($row['f_table_id'] > 0) {
$f_id_parts = explode(',',$row['f_id_field']);
$f_parts = explode('.',$f_id_parts[(count($f_id_parts)-1)]);
if (!in_array($row['table'],$done_tables) && !array_key_exists($row['id'],$done_tables)) {
$a = DB::update($row['table'],array($row['edate_field']=>$edate,$row['sdate_field']=>$sdate),$row['id']);
if ($a)
$done_tables[($row['id'])] = $row['table'];
}
DB::update($f_parts[0],array($f_parts[1]=>$row['f_id']),$row['f_table_id']);
}
else {
if (!in_array($row['table'],$done_tables) && !array_key_exists($row['id'],$done_tables)) {
if ($row['f_id_field'])
$a = DB::update($row['table'],array($row['edate_field']=>$edate,$row['sdate_field']=>$sdate,$row['f_id_field']=>$row['f_id']),$row['id']);
else
$a = DB::update($row['table'],array($row['edate_field']=>$edate,$row['sdate_field']=>$sdate),$row['id']);
if ($a)
$done_tables[($row['id'])] = $row['table'];
}
}
}
}
if (!$errors) {
Messages::add('Save successfull.');
Messages::display();
}
else {
Errors::merge($errors);
Errors::display();
}
?>