$v) { // echo "\n"; if (array_key_exists($k, $_REQUEST)) { if (strtolower($_REQUEST[$k]) == $dVal[$k]) $_REQUEST[$k] = ""; } } unset($dVal); // end of housekeeping ................ if (empty($_REQUEST['usePrintDate'])) $_SESSION['usePrintDate'] = ""; else $_SESSION['usePrintDate'] = "1"; if (array_key_exists("newOrder", $_REQUEST)) { unset($_SESSION['jobRef']); unset($_REQUEST['sjobNo']); unset($_REQUEST['cCode']); unset($_REQUEST['sfsp']); unset($_SESSION['lastSearch']['sfsp']); unset($job); } if (($_REQUEST['sp'] == "search" or $_REQUEST['p'] == "orders") and $_SESSION['history']['orders']['sp'] == "search") { // echo "\n"; unset($_SESSION['jobRef']); unset($_REQUEST['sjobNo']); unset($_REQUEST['cCode']); unset($_REQUEST['sfsp']); unset($_SESSION['lastSearch']['sfsp']); unset($job); if (!(array_key_exists("showAll", $_REQUEST)) and !array_key_exists("newOrder", $_REQUEST) and array_key_exists("lastSearch", $_SESSION)) { foreach ($_SESSION['lastSearch'] as $k => $v) $_REQUEST[$k] = $v; // echo "\n"; } } if (empty($_REQUEST['lName']) and !empty($_REQUEST['jobRef']) and !empty($_REQUEST['status']) and $_REQUEST['status'] != "CLOSED") // and !empty($_REQUEST['cCode']) { // reopen closed order sqlUpdate("headers", "status='".$_REQUEST['status']."'", "tid='".$_REQUEST['jobRef']."'"); sqlRecycle("logents", "eType='s', linkRef='".$_REQUEST['jobRef']."', empNo='".$_SESSION['user']['empNo']."', note='\nORDER REOPENED TO \"".$_REQUEST['status']."\"', tagLine='', wDate='".date("Ymd")."', gst='', hst='', pst=''", "linkRef='' and eType='r'"); } if (!empty($_REQUEST['lName'])) { if (!empty($_REQUEST['jobNo'])) // catcher for slave, where you can enter a work order number manually $_REQUEST['jobNo'] = expandShortJobNo($_REQUEST['jobNo']); if ($_REQUEST['oType'] == "Notes") $_REQUEST['jobNo'] = ""; if ($_REQUEST['assignto'] == "") $_REQUEST['assignto'] = 0; // does this call exist? if (!empty($_REQUEST['jobRef']) and !array_key_exists("forceNew", $_REQUEST)) $r = sqlSelect("headers", "tid = '".$_REQUEST['jobRef']."'"); else $r['n'] = 0; $_REQUEST['assignment'] = addslashes($_REQUEST['assignment']); if ($r['n']) // ok, so this entry exists. What, if anything, changed? { $hData = mysql_fetch_assoc($r['r']); $chgs = ""; $chgd = false; $_REQUEST['pc'] = strtoupper(str_replace(array(" ","-"), "", $_REQUEST['pc'])); if ($hData['fName'] != $_REQUEST['fName'] or $hData['lName'] != $_REQUEST['lName']) { if ($hData['fName'] != $_REQUEST['fName']) $c1 = ", fName = '".addslashes($_REQUEST['fName'])."'"; if ($hData['lName'] != $_REQUEST['lName']) $c1 .= ", lName = '".addslashes($_REQUEST['lName'])."'"; $chgs = "\nNAME FROM: \"".addslashes($hData['fName'])." ".addslashes($hData['LName'])."\" TO \"".addslashes($_REQUEST['fName'])." ".addslashes($_REQUEST['LName'])."\""; $chgd = true; } if ($hData['address'] != $_REQUEST['address'] or $hData['city'] != $_REQUEST['city'] or $hData['pc'] != $_REQUEST['pc'] ) { if ($hData['address'] != $_REQUEST['address']) $c1 .= ", address = '".addslashes($_REQUEST['address'])."'"; if ($hData['city'] != $_REQUEST['city']) $c1 .= ", city = '".addslashes($_REQUEST['city'])."'"; if ($hData['pc'] != $_REQUEST['pc']) $c1 .= ", pc = '".addslashes($_REQUEST['pc'])."'"; $chgs = "\nADDRESS: FROM \"".addslashes($hData['address']).", ".addslashes($hData['city'])." ".addslashes($hData['pc'])."\" TO \"".addslashes($_REQUEST['address']).", ".addslashes($_REQUEST['city'])." ".addslashes($_REQUEST['pc'])."\""; $chgd = true; } if ($hData['cCode'] != $_REQUEST['cCode'] and ($_SESSION['user']['access'] & 0x0080) )//$_SESSION['user']['empNo'] == 3) { $c1 .= ", cCode = '".$_REQUEST['cCode']."'"; $chgs .= "\cCODE FROM \"".$hData['cCode']."\" TO \"".$_REQUEST['cCode']."\""; $chgd = true; } $_REQUEST['csid'] = strtoupper($_REQUEST['csid']); if ($hData['csid'] != $_REQUEST['csid']) { $c1 .= ", csid = '".$_REQUEST['csid']."'"; $chgs .= "\nCSID FROM \"".$hData['csid']."\" TO \"".$_REQUEST['csid']."\""; $chgd = true; } if (!empty($_REQUEST['oType']) and $hData['oType'] != $_REQUEST['oType']) { $c1 = ", oType = '".$_REQUEST['oType']."'"; $chgs .= "\nORD TYPE FROM \"".$hData['oType']."\" TO \"".$_REQUEST['oType']."\""; $chgd = true; } if ($hData['protectron'] != $_REQUEST['protectron']) { $c1 .= ", protectron = '".$_REQUEST['protectron']."'"; $chgs .= "\nPROTECTRON_REQUEST \"FROM ".$hData['protectron']."\" TO \"".$_REQUEST['protectron']."\""; $chgd = true; } if ($hData['pwoNo'] != $_REQUEST['pwoNo']) { $c1 .= ", pwoNo = '".$_REQUEST['pwoNo']."'"; $chgs .= "\nWORK_ORDER _NUMBER FROM \"".$hData['pwoNo']."\" TO \"".$_REQUEST['pwoNo']."\""; $chgd = true; } if ($hData['assignment'] != $_REQUEST['assignment']) { $c1 .= ", assignment = '".$_REQUEST['assignment']."'"; $chgs .= "\nASSIGNMENT FROM \"".addslashes($hData['assignment'])."\" TO \"".addslashes($_REQUEST['assignment'])."\""; $chgd = true; } if ($hData['ccu'] != $_REQUEST['ccu']) { $c1 .= ", ccu = '".$_REQUEST['ccu']."'"; $chgs .= "\nCCU CODE FROM \"".$hData['ccu']."\" TO \"".$_REQUEST['ccu']."\""; $chgd = true; } if ($hData['instCode'] != $_REQUEST['instCode']) { $c1 .= ", instCode = '".$_REQUEST['instCode']."'"; $chgs .= "\nINST CODE FROM \"".$hData['instCode']."\" TO \"".$_REQUEST['instCode']."\""; $chgd = true; } if ($hData['dlsCode'] != $_REQUEST['dlsCode']) { $c1 .= ", dlsCode = '".$_REQUEST['dlsCode']."'"; $chgs .= "\nDLS CODE FROM \"".$hData['dlsCode']."\" TO \"".$_REQUEST['dlsCode']."\""; $chgd = true; } if ($hData['testTime'] != $_REQUEST['testTime']) { $c1 .= ", testTime = '".$_REQUEST['testTime']."'"; $chgs .= "\nAUTOPHONE TEST FROM \"".$hData['testTime']."\" TO \"".$_REQUEST['testTime']."\""; $chgd = true; } if ($hData['status'] != $_REQUEST['status']) { $c1 .= ", status = '".$_REQUEST['status']."'"; $chgs .= "\nSTATUS CHANGED FROM \"".$hData['status']."\" TO \"".$_REQUEST['status']."\""; $chgd = true; if ($_REQUEST['status'] == "SCHED") $hasBeenScheduled = true; if ($hData['status'] == "SCHED" or $_REQUEST['status'] == "CLOSED" or $_REQUEST['status'] == "VOID") { if ($_REQUEST['status'] == "CLOSED") $doParts = "INS"; if ($_REQUEST['status'] == "VOID") $doParts = true; // if old staus was "scheduled", remove all schedules if there ARE any $r = sqlSelect("events", "jobNo='{$hData['jobNo']}' and title != ''"); if ($r['n']) // there are scheduled events { sqlUpdate("events", "title=''", "jobNo='{$hData['jobNo']}'"); logEntry( $_REQUEST['jobRef'], "\nALL SCHEDULED CALLS CANCELED by STATUS CHANGE" ); } } if (in_array($_REQUEST['status'], array("PRELIM", "WAITINFO", "WALK", "SUBMITTED", "APPROVED"))) { sqlUpdate("clientdat", "fspDate='".$_REQUEST['fspDate']."'", "cCode='{$_REQUEST['oCode']}'"); $chgs .= "\nFSPDATE FROM \"".$fspData['fspDate']."\" TO \"".$_REQUEST['fspDate']."\""; } } if ($hData['assignto'] != $_REQUEST['assignto']) { $c1 .= ", assignto = '".$_REQUEST['assignto']."'"; $chgs .= "\nLEAD CHANGED FROM \"".getEmployeeName($hData['assignto'], "full")."\" TO \"".getEmployeeName($_REQUEST['assignto'], "full")."\""; $chgd = true; // update lead assignment too sqlReplace("assignments", "empNo='".$_REQUEST['assignto']."', jobNo='".$_REQUEST['jobNo']."', role='lead'", "jobNo='".$_REQUEST['jobNo']."' and role='lead'"); } if ($hData['oType'] == "FSP" or $hData['oType'] == "PIP") { $fspData = sqlSelect("clientdat", "cCode='{$_REQUEST['oCode']}'"); $fspData = mysql_fetch_assoc($fspData['r']); if ($fspData['fspDate'] != $_REQUEST['fspDate']) { sqlUpdate("clientdat", "fspDate='".$_REQUEST['fspDate']."'", "cCode='{$_REQUEST['oCode']}'"); $chgs .= "\nFSPDATE FROM \"".$fspData['fspDate']."\" TO \"".$_REQUEST['fspDate']."\""; } } if ($chgd) { sqlUpdate("headers", substr($c1, 2, strlen($c1)), "tid='".$_REQUEST['jobRef']."'"); // make log entry about changes sqlRecycle("logents", "eType='s', linkRef='".$_REQUEST['jobRef']."', empNo='".$_SESSION['user']['empNo']."', note='$chgs', tagLine='', wDate='".date("Ymd")."', wStart = '".date("Hi")."', gst='', hst='', pst=''", "linkRef=''"); if ($doParts) { // marks all the reserved parts as expended here workorder_close_parts($doParts); } } $cCode = $_REQUEST['cCode']; if (!empty($_REQUEST['updateClient'])) { $c1 = "fName = '".$_REQUEST['fName']."', "; $c1 .= "lName = '".$_REQUEST['lName']."', "; $c1 .= "address = '".$_REQUEST['address']."', "; $c1 .= "city = '".$_REQUEST['city']."', "; $c1 .= "pc = '".strtoupper(str_replace(" ", "", $_REQUEST['pc']))."', "; $c1 .= "csid = '".strtoupper($_REQUEST['csid'])."'"; sqlUpdate("clientdat", $c1, "cCode='$cCode'"); } } else // new entry { echo "\n"; if (empty($_REQUEST['cCode'])) $cCode = nextClientNumber(); // new client else $cCode = $_REQUEST['cCode']; // existing client // echo "\n"; if (empty($_REQUEST['estTravel'])) $_REQUEST['estTravel'] = "0"; if (empty($_REQUEST['estLabor'])) $_REQUEST['estLabor'] = "0"; if (!empty($_REQUEST['pc'])) { $pc = strtoupper(str_replace(" ", "", $_REQUEST['pc'])); $pc = substr($pc, 0, 3)." ".substr($pc, -3); } else $pc = ""; //if ($_REQUEST['assignto'] == 3) // $_REQUEST['assignto'] = 0; //$c1 = "cCode = '$cCode', "; =============== filtered against the Protectron field - see below //$c1 .= "oCode = '$cCode', "; =============== clientdat does not have an oCode field $c1 .= "fName = '".$_REQUEST['fName']."', "; $c1 .= "lName = '".$_REQUEST['lName']."', "; $c1 .= "address = '".$_REQUEST['address']."', "; $c1 .= "city = '".$_REQUEST['city']."', "; $c1 .= "prov = '".strtoupper(substr($_REQUEST['prov'], 0, 2))."', "; $c1 .= "pc = '$pc', "; //$c1 .= "fspDate = '', "; //$c1 .= "flags = '0', "; $c1 .= "csid = '".strtoupper($_REQUEST['csid'])."'"; $c2 = "author = '".$_SESSION['user']['empNo']."', "; $c2 .= "jobNo = '".$_REQUEST['jobNo']."', "; $c2 .= "oType = '".$_REQUEST['oType']."', "; $c2 .= "protectron = '".$_REQUEST['protectron']."', "; $c2 .= "pwoNo = '".$_REQUEST['pwoNo']."', "; $c2 .= "ccu = '".$_REQUEST['ccu']."', "; $c2 .= "instCode = '".$_REQUEST['instCode']."', "; $c2 .= "dlsCode = '".$_REQUEST['dlsCode']."', "; $c2 .= "testTime = '".$_REQUEST['testTime']."', "; $c2 .= "assignment = '".addslashes($_REQUEST['assignment'])."', "; $c2 .= "source = '".$_REQUEST['source']."', "; if ($_REQUEST['oType'] == "FSP") $c2 .= "status = 'PRELIM', "; else $c2 .= "status = 'READY', "; $c2 .= "estTravel = '".$_REQUEST['estTravel']."', "; $c2 .= "estLabor = '".$_REQUEST['estLabor']."', "; $c2 .= "assignto = '".$_REQUEST['assignto']."'"; // is this client in the client list? if no, insert if (empty($_REQUEST['cCode'])) { $ncn = sqlRecycle("clientdat", "cCode = '$cCode', $c1, flags = '0', fspDate = ''", "cCode = ''"); } else { // client is on file... updated? if (!empty($_REQUEST['updateClient'])) { $c1 = "fName = '".$_REQUEST['fName']."', "; $c1 .= "lName = '".$_REQUEST['lName']."', "; $c1 .= "address = '".$_REQUEST['address']."', "; $c1 .= "city = '".$_REQUEST['city']."', "; $c1 .= "prov = '".strtoupper(substr($_REQUEST['prov'], 0, 2))."', "; $c1 .= "pc = '".strtoupper(str_replace(" ", "", $_REQUEST['pc']))."', "; $c1 .= "csid = '".strtoupper($_REQUEST['csid'])."'"; $ncn = sqlUpdate("clientdat", $c1, "cCode='$cCode'"); // echo "\n"; } } if (empty($_REQUEST['protectron'])) $r = sqlInsert("headers", "cCode = '$cCode', $c1, oCode = '$cCode', $c2"); else { //<============= HERE ============================= if ($_REQUEST['lName'] == "Dollarama" or $_REQUEST['lName'] == "Reitmans" or $_REQUEST['lName'] == "Beacon") { $r = sqlInsert("headers", "cCode = '033000004', $c1, oCode = '$cCode', $c2"); //$protectronStr = str_replace("/", "\\", $_SESSION['instance']['repository'])."FSP\\$cCode\\".date("Ymd").".".$_REQUEST['protectron']; $protectronStr = str_replace("/", "\\", $_SESSION['instance']['repository'])."FSP\\$cCode\\".$_REQUEST['protectron']; } else { $r = sqlInsert("headers", "cCode = '03500001C', $c1, oCode = '$cCode', $c2"); $isProtectron = true; $protectronStr = str_replace("/", "\\", $_SESSION['instance']['repository'])."FSP\\$cCode\\".date("Y-m-d").".".$_REQUEST['protectron']; } } // make a tracking record sqlRecycle("logents", "eType='s', linkRef='".$r['t']."', empNo='".$_SESSION['user']['empNo']."', note='ORDER CREATED', wDate='".date("Ymd")."', tStart='', tEnd='', wStart='', wEnd='', tagLine='', locked='1', gst='', hst='', pst=''", "wDate=''");//, "linkRef='' by ".getEmployeeName($_SESSION['user']['empNo'])." // add it to "assignments $q = "jobNo='".$_REQUEST['jobNo']."', empNo='".$_REQUEST['assignto']."', role='lead'"; sqlRecycle("assignments", $q, "jobNo=''"); $_REQUEST['jobRef'] = $r['t']; $_SESSION['jobRef'] = $_REQUEST['jobRef']; if ($_REQUEST['oType'] == "FSP" or $isProtectron or $_REQUEST['lName'] == "Dollarama" or $_REQUEST['lName'] == "Reitmans") { //================================================== if ($_REQUEST['lName'] == "Dollarama" or $_REQUEST['lName'] == "Reitmans") $Dollarama = $_REQUEST['fName']; else $Dollarama = ""; if ($_REQUEST['oType'] == "FSP" or $_REQUEST['oType'] == "PIP") $mkFSP = 1; else $mkFSP = 0; createClientDirectory($cCode, $mkFSP, $Dollarama); } } } if (!empty($_REQUEST['sjobNo']) and $_REQUEST['sjobNo'] != "Job Number") { $jobNo = expandShortJobNo($_REQUEST['sjobNo']); $job = sqlSelect("headers", "jobNo = '$jobNo'"); if ($job['n']) { $job = mysql_fetch_assoc($job['r']); $_SESSION['jobRef'] = $job['tid']; $_SESSION['history'][$_SESSION['current']['p']]['sp'] = "calls"; } else { $sjobList = sqlSelect("headers", "jobNo like '%".$_REQUEST['sjobNo']."'"); if ($sjobList['n'] == 1) { // found it! $job = mysql_fetch_assoc($sjobList['r']); $_SESSION['jobRef'] = $job['tid']; $_SESSION['history'][$_SESSION['current']['p']]['sp'] = "calls"; } } } else if (!empty($_REQUEST['sfsp']) and strtoupper($_REQUEST['sfsp']) != "FSP #") { $sjobList = sqlSelect("headers", "oCode like '%{$_REQUEST['sfsp']}' and oType='FSP'"); if ($sjobList['n'] == 1) { // found it! $job = mysql_fetch_assoc($sjobList['r']); $_SESSION['jobRef'] = $job['tid']; $_SESSION['history'][$_SESSION['current']['p']]['sp'] = "calls"; } else if ($sjobList['n'] > 1) { while ($job = mysql_fetch_assoc($sjobList['r'])) $jobs[] = $job['jobNo']; $_REQUEST['showAll'] = 1; } } else if (!empty($_REQUEST['sProNo']) and $_REQUEST['sProNo'] != "Service Req") { // search for protectron $sjobList = sqlSelect("headers", "protectron like '%".$_REQUEST['sProNo']."%'"); if ($sjobList['n'] == 1) { // found it! $job = mysql_fetch_assoc($sjobList['r']); $_SESSION['jobRef'] = $job['tid']; $_SESSION['history'][$_SESSION['current']['p']]['sp'] = "calls"; } } else if ((!empty($_REQUEST['slName']) and $_REQUEST['slName'] != "Last Name") or (!empty($_REQUEST['sfName']) and $_REQUEST['sfName'] != "First Name") or (!empty($_REQUEST['saddress']) and $_REQUEST['saddress'] != "Address") or (!empty($_REQUEST['scity']) and $_REQUEST['scity'] != "City")) { //search by name, address or city $q = ""; if (!empty($_REQUEST['slName']) and $_REQUEST['slName'] != "Last Name") $q = "lName like '%".$_REQUEST['slName']."%'"; if (!empty($_REQUEST['sfName']) and $_REQUEST['sfName'] != "First Name") { if ($q) $q .= " and "; $q .= "fName like '%".$_REQUEST['sfName']."%'"; } if (!empty($_REQUEST['saddress']) and $_REQUEST['saddress'] != "Address") { if ($q) $q .= " and "; $q .= "address like '%".$_REQUEST['saddress']."%'"; } if (!empty($_REQUEST['scity']) and $_REQUEST['scity'] != "City") { if ($q) $q .= " and "; $q .= "city like '%".$_REQUEST['scity']."%'"; } $sjobList = sqlSelect("headers", $q, "", "lastmod"); if ($sjobList['n'] == 0) { // no listings were found with this criteria $jobsNotFound = true; } else { while ($job = mysql_fetch_assoc($sjobList['r'])) $jobs[] = $job['jobNo']; } } else if (!empty($_REQUEST['jobRef'])) { $job = sqlSelect("headers", "tid = '".$_REQUEST['jobRef']."'"); if ($job['n']) { $job = mysql_fetch_assoc($job['r']); $_SESSION['jobRef'] = $job['tid']; $_SESSION['history'][$_SESSION['current']['p']]['sp'] = "calls"; } else { $msgs[] = "421 Job Reference does not exist"; $_SESSION['history'][$_SESSION['current']['p']]['sp'] = "search"; } } else if (!empty($_SESSION['jobRef'])) { $job = sqlSelect("headers", "tid = '".$_SESSION['jobRef']."'"); if ($job['n']) { $job = mysql_fetch_assoc($job['r']); } else { $msgs[] = "313 Job Reference does not exist"; $_SESSION['history'][$_SESSION['current']['p']]['sp'] = "search"; } } else $jobNo = "Job Number"; if (!empty($_REQUEST['pNumber'])) { $_REQUEST['pNumber'] = compressPhoneNumber($_REQUEST['pNumber']); // attach phone number to client if this is NOT a result of an edit if (empty($_REQUEST['pLink'])) { // find an empty slot if one exists $slot = sqlSelect("phones", "pNumber=''"); if ($slot['n']) { $slot = mysql_fetch_assoc($slot['r']); sqlUpdate("phones", "cType = 'c', pLink = '$cCode', pType = '".$_REQUEST['pType']."', pNumber = '".$_REQUEST['pNumber']."'", "tid = '".$slot['tid']."'"); } else sqlInsert("phones", "cType = 'c', pLink = '$cCode', pType = '".$_REQUEST['pType']."', pNumber = '".$_REQUEST['pNumber']."'"); $note = "PHONE ".$_REQUEST['pType'].": \"".displayPhoneNumber($_REQUEST['pNumber'])."\" ADDED by ".getEmployeeName($_SESSION['user']['empNo']); } // attach phone to order // find an empty slot if one exists $slot = sqlSelect("phones", "pNumber=''"); if ($slot['n']) { $slot = mysql_fetch_assoc($slot['r']); sqlUpdate("phones", "cType = 'o', pLink = '".$_SESSION['jobRef']."', pType = '".$_REQUEST['pType']."', pNumber = '".$_REQUEST['pNumber']."'", "tid = '".$slot['tid']."'"); } else sqlInsert("phones", "cType = 'o', pLink = '".$_SESSION['jobRef']."', pType = '".$_REQUEST['pType']."', pNumber = '".$_REQUEST['pNumber']."'"); $note = "PHONE ".$_REQUEST['pType'].": \"".displayPhoneNumber($_REQUEST['pNumber'])."\" ADDED by ".getEmployeeName($_SESSION['user']['empNo']); sqlInsert("logents", "eType = 's', linkRef = '".$_SESSION['jobRef']."', empNo = '".$_SESSION['user']['empNo']."', note = '$note'"); unset($_REQUEST['pType']); unset($_REQUEST['pNumber']); } // routine to move marked comments from one workorder to another if (!empty($_REQUEST['movecommenttarget']) and is_array($_REQUEST[movelist])) { foreach ($_REQUEST['movelist'] as $commentId) { sqlUpdate("logents", "linkRef='{$_REQUEST['movecommenttarget']}'", "tid='$commentId'"); } } if (!empty($_REQUEST['note']) or !empty($_REQUEST['tagLine']) or (!empty($_REQUEST['wStart']) and !empty($_REQUEST['wEnd']))) { if (empty($_REQUEST['kmStart'])) $_REQUEST['kmStart'] = "0.0"; if(empty($_REQUEST['kmEnd'])) $_REQUEST['kmEnd'] = "0.0"; if (empty($_REQUEST['commentRef'])) { $ref = sqlRecycle("logents", "eType='".$_REQUEST['eType']."', linkRef='".$_SESSION['jobRef']."', empNo='".$_REQUEST['tEmpNo']."', wDate='".$_REQUEST['wDate']."', kmStart='".$_REQUEST['kmStart']."', tStart='".$_REQUEST['tStart']."', wStart='".$_REQUEST['wStart']."', wEnd='".$_REQUEST['wEnd']."', tEnd='".$_REQUEST['tEnd']."', kmEnd='".$_REQUEST['kmEnd']."', tagLine='".$_REQUEST['tagLine']."', note='".addslashes($_REQUEST['note'])."', gst='', hst='', pst=''", "empNo='0'"); //===> check to see if this call was scheduled; if it was, remove the schedule $r = sqlSelect("schedule", "linkRef = '".$_SESSION['jobRef']."' and wDate = '".$_REQUEST['wDate']."' and empNo = '".$_REQUEST['tEmpNo']."'"); if ($r['n']) { sqlRecycle("logents", "eType='s', linkRef='".$_SESSION['jobRef']."', empNo='1', wDate='".$_REQUEST['wDate']."', kmStart='0.0', tStart='', wStart='', wEnd='', tEnd='', kmEnd='0.00', tagLine='', note='SCHEDULED CALL FOR ".getEmployeeName($_REQUEST['tEmpNo'])." COMPLETED', gst='', hst='', pst=''", "empNo='1'"); sqlUpdate("schedule", "linkRef = '', wDate = '', tStart = '', wStart = '', wEnd='', tEnd = '', empNo = '0', role = '', lName = '', fName = '', city = '', oType = ''", "linkRef = '".$_SESSION['jobRef']."' and wDate = '".$_REQUEST['wDate']."' and empNo = '".$_REQUEST['tEmpNo']."'"); } } else { // check to see if "empNo" is being changed; if it is, make a note of the change sqlUpdate("logents", "empNo='".$_REQUEST['tEmpNo']."', wDate='".$_REQUEST['wDate']."', kmStart='".$_REQUEST['kmStart']."', tStart='".$_REQUEST['tStart']."', wStart='".$_REQUEST['wStart']."', wEnd='".$_REQUEST['wEnd']."', tEnd='".$_REQUEST['tEnd']."', kmEnd='".$_REQUEST['kmEnd']."', tagLine='".$_REQUEST['tagLine']."', note='".addslashes($_REQUEST['note'])."', gst='', hst='', pst=''", "tid='".$_REQUEST['commentRef']."'"); } if ($_REQUEST['btnSubmit'] == "Save and Close") // save a work order work entry and close the order simultaneously - option added 2011.10.11 - Fabian's suggestion { // check for open work schedules - cancel any that exist $r = sqlSelect("schedule", "linkRef='".$_SESSION['jobRef']."' and wDate != ''"); if ($r['n']) // there are still calls scheduled { // cancel the call sqlUpdate("schedule", "linkRef = '', wDate = '', tStart = '', wStart = '', wEnd='', tEnd = '', empNo = '0', role = '', lName = '', fName = '', city = '', oType = ''", "linkRef = '".$_SESSION['jobRef']."'"); // log the cancelation sqlRecycle("logents", "eType='s', linkRef='".$_SESSION['jobRef']."', empNo='1', note='ALL SCHEDULED CALLS CANCELED by STATUS CHANGE', tagLine='', wDate='".date("Ymd")."', wStart = '".date("Hi")."', gst='', hst='', pst=''", "linkRef=''"); } // log it $job['status'] = "CLOSED"; sqlRecycle("logents", "eType='s', linkRef='".$_SESSION['jobRef']."', empNo='".$_SESSION['user']['empNo']."', note='\nSTATUS CHANGED FROM \"".$job['status']."\" TO \"CLOSED\" (SIMULTANEOUS)', tagLine='', wDate='".date("Ymd")."', wStart = '".date("Hi")."', gst='', hst='', pst=''", "linkRef=''"); // close the order sqlUpdate("headers", "status = 'CLOSED'", "jobNo='".$job['jobNo']."'"); } } if (array_key_exists("hasbeencalled", $_REQUEST)) { $note = "Called by ".getEmployeeName($_SESSION['user']['empNo'])."; left message at ".date("H:i"); $timeNow = time(); sqlRecycle("logents", "eType='', linkRef='".$_SESSION['jobRef']."', empNo='".$_SESSION['user']['empNo']."', note='$note', wDate='".date("Ymd")."', tStart='', tEnd='', wStart='".date("Hi", $timeNow - 180)."', wEnd='".date("Hi", $timeNow)."', tagLine='$note', locked='1'", "wDate=''"); sqlUpdate("headers", "status = 'CALLED'", "jobNo='".$job['jobNo']."'"); } $has_files = false; if (!empty($_SESSION['jobRef']))// and $_SESSION['instance']['isLocalInterface'] { $fileListRoot = sqlSelect("headers", "tid='{$_SESSION['jobRef']}'"); $fileListRoot = mysql_fetch_assoc($fileListRoot['r']); $pathToFiles = $_SESSION['instance']['repository']."FSP/".$fileListRoot['oCode']; $has_files = file_exists($pathToFiles); } // ********************************* End "Calls" Preprocessing *********************************** echo "\t\t\t\n"; echo "\t\t\t\t
\n"; echo "\t\t\t\n"; echo "\t\t\t\n"; echo "\t\t\t
\n\n"; echo "\t\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\t\n";// $inc_pg = "modules/".$_SESSION['current']['p']."/".$_SESSION['history'][$_SESSION['current']['p']]['sp'].".php"; if (file_exists($inc_pg)) { include $inc_pg; } else { echo "\t\t\t\tModule $inc_pg does not exist\n"; } echo "\t\t\t\n"; ?>