\n"; } //debug(); if ($_REQUEST['jobNo']) { showLine( "017" ); $headerDat = getHeaderByJobNo( $_REQUEST['jobNo'] ); debugDump($headerDat, "headerDat"); } if (!empty($_REQUEST['func']) and !empty($_REQUEST['title'])) { showLine( "024" ); $refresh = false; if ($_REQUEST['func'] == "save") { showLine( "028" ); //=> TAGLINES ?????? //=> get current params //=> if Order was empty and is now linked, check order status. if it's not "SCHED", change it //=> if protectron is not empty, find the reference in the file system and provide link - SEE http://www.php.net/manual/en/function.glob.php //=> when showing a personal note, the tagline needs to be shown as the title and the note put in notes if ($_REQUEST['units'] == "d" and empty($_REQUEST['endTime'])) { showLine( "037" ); $_REQUEST['endTime'] = 1; } if (empty($_REQUEST['title'])) { showLine( "043" ); $_REQUEST['title'] = "Work"; } else if (!empty($_REQUEST['startDate'])) { showLine( "048" ); $_REQUEST['startDate'] = str_replace(array("/","\\"," ","-",".",":",","), "", $_REQUEST['startDate']); $y = substr($_REQUEST['startDate'], 0, 4); $m = substr($_REQUEST['startDate'], 4, 2); $d = substr($_REQUEST['startDate'], 6, 2); if ($_REQUEST['units'] == "d") { showLine( "056" ); if (empty($_REQUEST['endTime'])) $_REQUEST['endTime'] = 1; $start = mktime( 0, 0, 0, $m, $d, $y); $end = mktime( 0, 0, 0, $m, ($d + $_REQUEST['endTime']), $y); } else { showLine( "064" ); if ($_REQUEST['span'] == "u" and empty($_REQUEST['startTime'])) { // specified there should be an end time, but none was given // change this to "hours" - it will set to "1" later $_REQUEST['span'] = "f"; } $_REQUEST['startTime'] = substr("00".str_replace(array(":","/","\\","."," "),"", $_REQUEST['startTime']), -4); $h = substr($_REQUEST['startTime'], 0, 2); $i = substr($_REQUEST['startTime'], -2); $start = mktime( $h, $i, 0, $m, $d, $y); if ($_REQUEST['span'] == "u") { showLine( "079" ); $_REQUEST['endTime'] = substr("00".str_replace(array(":","/","\\","."," "),"", $_REQUEST['endTime']), -4); if ($_REQUEST['endTime'] <= $_REQUEST['startTime']) $d += 1; $h = substr($_REQUEST['endTime'], 0, 2); $i = substr($_REQUEST['endTime'], -2); // $end = mktime( $h, $i, 0, $m, $d, $y); } else { showLine( "089" ); // if endTime is not set, make it "1" (hour) if (empty($_REQUEST['endTime'])) $_REQUEST['endTime'] = 1; if ($_REQUEST['units'] == "u") { showLine( "095" ); // protectron order uses "units" of 10 min's $i += intval($_REQUEST['endTime'] * 10); } else { showLine( "101" ); // this is hours .... $i += intval($_REQUEST['endTime'] * 60); } } $end = mktime( $h, $i, 0, $m, $d, $y); } if ($_REQUEST['editable']) $editable = ''; else $editable = '1'; // a color code of FFFFFF is "invisible" on the calendar // SEE http://www.w3schools.com/html/html_colornames.asp if ($_REQUEST['colour'] == "FFFFFF" or empty($_REQUEST['colour'])) $_REQUEST['colour'] = "#4053FF"; $q = "`editable` = '$editable', "; $q .= "`title` = '".str_replace("'", "´",$_REQUEST['title'])."', "; $q .= "`city` = '".str_replace("'", "´",$_REQUEST['city'])."', "; $q .= "`oType` = '".$_REQUEST['oType']."', "; $q .= "`protectron` = '".$_REQUEST['protectron']."', "; $q .= "`jobNo` = '".$_REQUEST['jobNo']."', "; $q .= "`jobStart` = '$start', "; $q .= "`jobEnd` = '$end', "; $q .= "`color` = '#".$_REQUEST['colour']."', "; $q .= "`notes` = '".str_replace("'", "´",$_REQUEST['notes'])."', "; if (!empty($_REQUEST['empLst'])) { $emps = "|"; foreach ($_REQUEST['empLst'] as $emp) $emps .= "$emp|"; } else $emps = ""; $q .= "`empNo` = '$emps'"; // if an tid was NOT included, this is an insert if (empty($_REQUEST['tid'])) { showLine( "142" ); $r = sqlRecycle("events", $q, "`title` = ''"); $msgs[] = "130: ".$r['q']; } // otherwise, it is an update else { showLine( "149" ); $r = sqlUpdate("events", $q, "`tid` = '{$_REQUEST['tid']}'"); $msgs[] = "136: ".$r['q']; } $refresh = true; } else { showLine( "157" ); // missing data ? echo "Problems!!
\n"; debug( 2, true); exit(); } if (!empty($_REQUEST['jobNo']))// is jobNo set? { // yes => was status set before? $headerDat = getHeaderByJobNo( $_REQUEST['jobNo'] ); if ($headerDat['status'] != "SCHED") { //no => change status of jobNo to SCHED sqlUpdate("headers", "status='SCHED'", "tid='{$headerDat['tid']}'"); // log the change logEntry( $headerDat['tid'], "\nSTATUS CHANGED FROM \"{$headerDat['status']}\" TO \"SCHED\" BY CALENDAR EVENT" ); } } } else if ($_REQUEST['func'] == "delete") { showLine( "177" ); $eventDat = getEventById( $_REQUEST['tid'] ); // does this have a jobNo? if (!empty($eventDat['jobNo'])) { showLine( "182" ); // are there more scheduled events? $scheduledEvents = sqlSelect("events", "jobNo='{$eventDat['jobNo']}'"); // yes => are there any other scheduled events for this jobNo? if ($scheduledEvents['n'] < 2) // no more events { showLine( "188" ); $headerDat = getHeaderByJobNo( $eventDat['jobNo'] ); if ($headerDat['status'] == "SCHED") { showLine( "182" ); // no => change status of jobNo to "ready" // is shows as scheduled - so we will have to update this sqlUpdate("headers", "status='READY'", "tid='{$headerDat['tid']}'"); // log the change logEntry( $headerDat['tid'], "\nSTATUS CHANGED FROM \"SCHED\" TO \"READY\" BY CALENDAR EVENT DELETE" ); } } } // flag idx as deleted $r = sqlUpdate("events","`title` = ''", "`tid`='{$_REQUEST['tid']}'"); // $msgs[] = "114: ".$r['q']; // reload calendar $refresh = true; // exit(); } if ($refresh) { // refresh the calendar ? and close the window echo " \n"; } } else if (!empty($_REQUEST['func'])) { $msgs[] = "220:ERROR SAVING!
\n"; // this is an error caused by no title // reload the data from $_REQUEST? } else { if (!empty( $_REQUEST['id'] )) { $eventDat = getEventById( $_REQUEST['id'] ); } else if (!empty($_REQUEST['startDate'])) { $eventDat['color'] = "#2E0ABF"; if (strpos($_REQUEST['startDate'], "T") !== false) { $reqDat = explode("T", $_REQUEST['startDate']); $eventDat['startDate'] = $reqDat[0]; $eventDat['startTime'] = substr($reqDat[1], 0, 5); } else { $eventDat['startDate'] = $_REQUEST['startDate']; } } else { $eventDat['color'] = "#2E0ABF"; } } if ($eventDat['jobNo']) { $headerDat = getHeaderByJobNo( $eventDat['jobNo'] ); } ?> Add/Edit Event
\n"; ?> > > \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } ?>
Title City
Protectron Color > Locked
Start Date Start Time
Notes
\n"; echo " \n"; echo "
\n"; if (!empty($eventDat['empNo'])) { $empList = explode("|", trim($eventDat['empNo'],"|")); foreach ($empList as $empNo) { echo "".getEmployeeName( $empNo, "full")."
\n"; } } else $empList = array(); echo "
\n"; echo "
"; if ($_SESSION['user']['access'] & 0x0020) { $eList = sqlSelect("employees", "(access & 0x1000) and !(access & 0x0001)", "", "lName, fName"); echo " \n"; } echo "
(Trans ID: {$eventDat['tid']}"; echo "\n"; if ($_SESSION['user']['access'] & 0x0020) { $saveVisible = ""; if (empty($_REQUEST['id'])) $deleteVisible = " style=\"visibility: hidden;\""; else $deleteVisible = ""; } else { $deleteVisible = " style=\"visibility: hidden;\""; $saveVisible = " style=\"visibility: hidden;\""; } ?>
onClick="document.location.href='editClick.php?tid=&func=delete&title=na';"> >
\n"; // if (!empty($msgs)) // { foreach ($msgs as $msg) // echo "$msg
\n"; // } if (empty($_REQUEST['id'])) { // refresh the calendar ? and close the window // look at this - see if it's using _SESSION if (!empty($_REQUEST['linkRef']) and $_REQUEST['linkRef'] !== null) { echo " \n"; } ?>