"; } else { $head = ""; } echo "\n".$head."************************** DEBUG ************************".$tail."\n"; $root = getcwd(); echo "\n".$head."ROOT: $root -->\n"; if ($rLink) echo "\n".$head."remote connection available".$tail."\n"; else echo "\n".$head."remote connection is NOT available".$tail."\n"; if (($option & 0x01) and is_array($_SESSION)) { echo "\n".$head."************************ SESSION ************************".$tail."\n"; $arrayValues[0]['v'] = $_SESSION; $arrayValues[0]['k'] = "\$_SESSION"; $idx = 0; while ($idx < count($arrayValues)) { foreach ($arrayValues[$idx]['v'] as $k => $v) { if ($k != "debugMsgs") { if (is_array($v)) { $nv = count($arrayValues); $arrayValues[$nv]['v'] = $v; $arrayValues[$nv]['k'] = $arrayValues[$idx]['k']."[$k]"; } else echo $head.$arrayValues[$idx]['k']."[$k] => $v".$tail."\n"; } } $idx++; } unset($arrayValues); } if (($option & 0x02) and is_array($_REQUEST)) { unset($arrayValues); echo "\n".$head."************************ REQUEST ************************".$tail."\n"; $arrayValues[0]['v'] = $_REQUEST; $arrayValues[0]['k'] = "\$_REQUEST"; $idx = 0; while ($idx < count($arrayValues)) { foreach ($arrayValues[$idx]['v'] as $k => $v) { if (is_array($v)) { $nv = count($arrayValues); $arrayValues[$nv]['v'] = $v; $arrayValues[$nv]['k'] = $arrayValues[$idx]['k']."[$k]"; } else echo $head.$arrayValues[$idx]['k']."[$k] => $v".$tail."\n"; } $idx++; } } if (($option & 0x04) and is_array($_FILES)) { unset($arrayValues); echo "\n".$head."************************ FILES ************************".$tail."\n"; $arrayValues[0]['v'] = $_FILES; $arrayValues[0]['k'] = "\$_FILES"; $idx = 0; while ($idx < count($arrayValues)) { foreach ($arrayValues[$idx]['v'] as $k => $v) { if (is_array($v)) { $nv = count($arrayValues); $arrayValues[$nv]['v'] = $v; $arrayValues[$nv]['k'] = $arrayValues[$idx]['k']."[$k]"; } else echo $head.$arrayValues[$idx]['k']."[$k] => $v".$tail."\n"; } $idx++; } } if (($option & 0x08) and !empty($_SESSION['debugMsgs'])) { $title = "DEBUG MSGS"; if ($prompt) $title .= " $prompt"; $tLen = 30 - intval((strlen($title) + 3) / 2); $title = str_repeat("*", $tLen)." $title ".str_repeat("*", $tLen); echo "\n".$head.$title.$tail."\n"; foreach ( $_SESSION['debugMsgs'] as $idx => $msg ) { echo "\n".$head."DEBUG".substr("0000".$idx, -4).": $msg".$tail."\n"; } if ($clear) { unset($_SESSION['debugMsgs']); echo "\n".$head."DEBUG~~~~: Message queue cleared".$tail."\n"; } } echo "\n".$head."********************** END DEBUG ************************".$tail."\n"; } function debugDump($myArray, $arrayName, $Show=false) { if ($Show) { $head = ""; $tail = "
"; } else { $head = ""; } if (is_array($myArray)) { // cosmetics ...... $reps = intval((62 - strlen($arrayName)) / 2); echo "\n".$head.str_repeat("*", $reps)." $arrayName ".str_repeat("*", $reps).$tail."\n"; $arrayValues[0]['v'] = $myArray; $arrayValues[0]['k'] = "\$$arrayName"; $idx = 0; while ($idx < count($arrayValues)) { foreach ($arrayValues[$idx]['v'] as $k => $v) { if (is_array($v)) { $nv = count($arrayValues); $arrayValues[$nv]['v'] = $v; $arrayValues[$nv]['k'] = $arrayValues[$idx]['k']."[$k]"; } else echo $head.$arrayValues[$idx]['k']."['$k'] => $v".$tail."\n"; } $idx++; } echo $head.str_repeat("*", (2 * $reps) + strlen($arrayName) + 2).$tail."\n"; } else echo $head."(DEBUGDUMP):$arrayName is not an array".$tail."\n"; } function debugMarker($msg) { // if (strlen($msg) > 60) // $reps = intval((62 - strlen($msg)) / 2); // else $reps = 1; echo "\n\n"; } function decodeCalendarDat( $event ) { $event['today'] = date("Y-m-d"); $event['duration'] = $event['jobEnd'] - $event['jobStart']; $event['days'] = intval($event['duration'] / 86400); $event['hours'] = sprintf("%1\$.2f", ($event['duration'] / 3600)); $event['units'] = sprintf("%1\$.2f", ($event['duration'] / 600)); $event['startDate'] = date("Y-m-d", $event['jobStart']); if ($event['days']) { $event['startTime'] = ""; $event['endTime'] = ""; } else { $event['startTime'] = date("H:i", $event['jobStart']); $event['endTime'] = date("H:i", $event['jobEnd']); if ($event['endTime'] == "00:00") $event['endTime'] = ""; } return $event; } function calcDates($seed = "") { if (empty($seed)) $seed = date("Ymd"); else $seed = str_replace("-", "", $seed); $start_date = "20070714"; // a known "end of period' date in the fairly distant past $dInfo['cStart'] = $start_date; //!D $today = date("Ymd"); while ($start_date <= $seed) { // loop cycles until the "start date" is "less than or equal to" the seed date $dInfo['cStart'] = $start_date; $start_date = date("Ymd", mktime(12, 0, 0, substr($start_date, 4, 2), (substr($start_date, 6, 2) + 14), substr($start_date, 0, 4))); } $dInfo['pStart'] = date("Ymd",mktime(12, 0, 0, substr($dInfo['cStart'], 4, 2), (substr($dInfo['cStart'], 6, 2) - 14), substr($dInfo['cStart'], 0, 4))); $dInfo['pMid'] = date("Ymd",mktime(12, 0, 0, substr($dInfo['cStart'], 4, 2), (substr($dInfo['cStart'], 6, 2) - 7), substr($dInfo['cStart'], 0, 4))); $dInfo['pEnd'] = date("Ymd",mktime(12, 0, 0, substr($dInfo['cStart'], 4, 2), (substr($dInfo['cStart'], 6, 2) - 1), substr($dInfo['cStart'], 0, 4))); $dInfo['pGrace'] = date("Ymd",mktime( 0, 0, 0, substr($dInfo['cStart'], 4, 2), (substr($dInfo['cStart'], 6, 2) + 2), substr($dInfo['cStart'], 0, 4))); $dInfo['cMid'] = date("Ymd",mktime(12, 0, 0, substr($dInfo['cStart'], 4, 2), (substr($dInfo['cStart'], 6, 2) + 6), substr($dInfo['cStart'], 0, 4))); $dInfo['cMidFlag'] = date("Ymd",mktime(12, 0, 0, substr($dInfo['cStart'], 4, 2), (substr($dInfo['cStart'], 6, 2) + 7), substr($dInfo['cStart'], 0, 4))); $dInfo['cEnd'] = date("Ymd",mktime(12, 0, 0, substr($dInfo['cStart'], 4, 2), (substr($dInfo['cStart'], 6, 2) + 13), substr($dInfo['cStart'], 0, 4))); $dInfo['cEndFlag'] = date("Ymd",mktime(12, 0, 0, substr($dInfo['cStart'], 4, 2), (substr($dInfo['cStart'], 6, 2) + 14), substr($dInfo['cStart'], 0, 4))); $dInfo['cGrace'] = date("Ymd",mktime( 0, 0, 0, substr($dInfo['cStart'], 4, 2), (substr($dInfo['cStart'], 6, 2) + 16), substr($dInfo['cStart'], 0, 4))); $dInfo['tomarrow'] = date("Ymd",mktime(12, 0, 0, date("m"), date("d") + 1, date("Y"))); $dInfo['yesterday'] = date("Ymd",mktime(12, 0, 0, date("m"), date("d") - 1, date("Y"))); $dInfo['lastmonth'] = date("Ymd",mktime(12, 0, 0, date("m") - 1, date("d"), date("Y"))); return $dInfo; } function compressPhoneNumber($p) { $p = str_replace(array(" ", "(", ")", "[", "]", ".", "-", "\\", "/"), "", $p); return $p; } function date2time($d) { $t = mktime(substr($d, 8,2), substr($d,10,2), substr($d,12,2), substr($d, 4,2), substr($d, 6,2), substr($d, 0,4)); return $t; } function displayPhoneNumber($pn) { if (strlen($pn) == 11) $pn = substr($pn, 0, 1)." ".substr($pn, 1, 3)." ".substr($pn, 4, 3)."-".substr($pn, -4); else if (strlen($pn) == 10) $pn = substr($pn, 0, 3)." ".substr($pn, 3, 3)."-".substr($pn, -4); else if (strlen($pn) == 7) $pn = "250 ".substr($pn. 0, 3)."-".substr($pn, -4); return $pn; } function doItq($oldEnt, $newEnt, $opCode) { // compare current settings to old settings to generate // an ITQ entry automatically. if (true) { debugDump($oldEnt, "oldEnt"); debugDump($newEnt, "newEnt"); } $args['uid'] = $newEnt['uid']; $args['item'] = $newEnt['item']; $args['sn'] = $newEnt['sn']; $args['owner'] = $newEnt['owner']; $args['oloc'] = $oldEnt['iloc']; $args['opCode'] = $opCode; $args['workorder'] = $newEnt['workorder']; $args['transfer'] = $newEnt['transfer']; $args['nloc'] = $newEnt['iloc']; $args['empNo'] = $_SESSION['user']['empNo']; $str = ""; foreach ($args as $k => $v) { if ($str) $str .= ", "; $str .= "$k = '$v'"; } return sqlInsert("itq", $str); } function doItq2($oldEnt, $newEnt, $opCode) { // compare current settings to old settings to generate // an ITQ entry automatically. if (true) { debugDump($oldEnt, "oldEnt"); debugDump($newEnt, "newEnt"); } $args['uid'] = $oldEnt['uid']; $args['item'] = $oldEnt['item']; $args['sn'] = $oldEnt['sn']; $args['owner'] = $oldEnt['owner']; $args['oloc'] = $oldEnt['iloc']; $args['opCode'] = $opCode; $args['workorder'] = $oldEnt['workorder']; $args['transfer'] = $oldEnt['transfer']; $args['nloc'] = $newEnt['iloc']; $args['empNo'] = $_SESSION['user']['empNo']; $str = ""; foreach ($args as $k => $v) { if ($str) $str .= ", "; $str .= "$k = '$v'"; } return sqlInsert("itq", $str); } function doITQprefetch($tid) { $oldEnt = sqlEx("select * from inventory where tid='$tid' limit 1"); return mysql_fetch_assoc($oldEnt); } function doLocList($name, $extra, $header = "") { $list = locList(); echo "\n"; } function dumpMessages($msgs) { if (count($msgs)) { foreach ($msgs as $msg) echo "$msg
\n"; echo "
\n"; } } function duration($start, $end, $d = 0) { $start = str_replace(array(".", "/", "-", " "), "", $start); $end = str_replace(array(".", "/", "-", " "), "", $end); if (!empty($start) and !empty($end)) { $sts = mktime(substr($start, 8, 2), substr($start, 10, 2), substr($start, 12, 2), substr($start, 4, 2), substr($start, 6, 2), substr($start, 0, 4)); $ets = mktime(substr($end, 8, 2), substr($end, 10, 2), substr($end, 12, 2), substr($end, 4, 2), substr($end, 6, 2), substr($end, 0, 4)); $d = $ets - $sts; } $r['d'] = $d; if ($d) { $r['h'] = intval($d / 3600); $d -= ($r['h'] * 3600); $r['m'] = substr("00".intval($d / 60), -2); $r['s'] = substr("00".($d - ($r['m'] * 60)), -2); } else { $r['h'] = "0"; $r['m'] = "00"; $r['s'] = "00"; } return $r; } function expandESN($esn) { return substr("0000000000".$esn, -10); } function expandShortJobNo($jn) { if (empty($jn)) return ""; $partial = substr($jn, 3, 10); $partial = substr("000000$partial", -7); return substr($jn, 0, 3).$partial; } function fixName($f, $l, $delm = ',') { if (empty($f)) return $l; if (empty($l)) return $f; return $l.$delm." ".$f; } function formatDate($date) { $date = str_replace(array("-",".","/","\\"), "", $date); return substr($date, 0, 4)."-".substr($date, 4, 2)."-".substr($date, 6, 2); } function formatDateAndTime($date) { $date = str_replace(array("-",".","/","\\",":"), "", $date); return substr($date, 0, 4)."-".substr($date, 4, 2)."-".substr($date, 6, 2)." ".substr($date, 8, 2).":".substr($date, 10, 2); } function formatPostalCode($pc) { $pc = str_replace(" ", "", $pc); return strtoupper($pc); } function formatTime($time, $default=false) { if ($time) return substr($time, 0, 2).":".substr($time, -2); else if ($default) return date("H:i"); else return ""; } function getcCodeFromRef( $ref ) { $r = sqlEx("select cCode from `headers` where `tid`='$ref'"); if (mysql_num_rows($r)) { $r = mysql_fetch_assoc($r); return $r['cCode']; } return false; } function getoCodeFromRef( $ref ) { $r = sqlEx("select oCode from `headers` where `tid`='$ref'"); if (mysql_num_rows($r)) { $r = mysql_fetch_assoc($r); return $r['oCode']; } return false; } function getClientNameByCode( $code ) { $r = sqlEx("select fName, lName from clientdat where cCode='$code'"); if (mysql_num_rows($r)) { $r = mysql_fetch_assoc($r); return fixName($r['fName'], $r['lName'], ', '); } return false; } function getDayOfWeek($d) { $d = str_replace(array("-",".","/","\\"), "", $d); $dow['l'] = date("l",mktime(12,0,0,substr($d,4,2),substr($d,6,2),substr($d,0,4))); // Full name for day of week: "Sunday" $dow['w'] = date("w",mktime(12,0,0,substr($d,4,2),substr($d,6,2),substr($d,0,4))); // Number for day of week: Sun = 0, Sat = 6 $dow['s'] = substr($d,0,8); // "short" version of date; "time" is stripped off $dow['f'] = substr($d,0,4)."-".substr($d,4,2)."-".substr($d,6,2); // formatted date with "time" is stripped off $dow['t'] = date("Ymd",mktime(12,0,0,substr($d,4,2),substr($d,6,2) + 1,substr($d,0,4))); // "tomarrow's date" $dow['stat'] = false; // default is "not a statuary holiday" $dow['dateName'] = ""; // default is "not a holiday"; // holiday names and definitions $found = true; switch (substr($dow['s'],4,4)) // holidays with fixed dates { case '0101': $dow['l'] = "New Years Day"; $dow['dateName'] = $dow['l']; $dow['stat'] = true; break; case '0214': $dow['l'] = "Valentines Day"; $dow['dateName'] = $dow['l']; $dow['stat'] = false; break; case '0701': $dow['l'] = "Canada Day"; $dow['dateName'] = $dow['l']; $dow['stat'] = true; break; case '1031': $dow['l'] = "Halloween"; $dow['dateName'] = $dow['l']; $dow['stat'] = false; break; case '1111': $dow['l'] = "Remembrance Day"; $dow['dateName'] = $dow['l']; $dow['stat'] = true; break; case '1224': $dow['l'] = "Christmas Eve"; $dow['dateName'] = $dow['l']; $dow['stat'] = false; break; case '1225': $dow['l'] = "Christmas"; $dow['dateName'] = $dow['l']; $dow['stat'] = true; break; case '1226': $dow['l'] = "Boxing Day"; $dow['dateName'] = $dow['l']; $dow['stat'] = false; break; case '1231': $dow['l'] = "New Years Eve"; $dow['dateName'] = $dow['l']; $dow['stat'] = false; break; } if (empty($dow['dateName'])) // holidays with floating dates { switch(substr($d, 4, 2)) { case "02": // Family Day (est 2013) if ($dow['w'] == 1 and substr($d, 6, 2) > 7 and substr($d, 6, 2) < 16) { $dow['l'] = "Family Day"; $dow['dateName'] = $dow['l']; $dow['stat'] = true; } break; case "03": case "04": //Easter .. this is a tough one... // This script isn't mine (I'm not THAT smart), but I've lost where I got it from $y = substr($d, 0, 4); $c = intval($y / 100); $n = $y - 19 * intval( $y / 19 ); $k = intval(( $c - 17 ) / 25); $i = $c - intval($c / 4) - intval(( $c - $k ) / 3) + 19 * $n + 15; $i = $i - 30 * intval( $i / 30 ); $i = $i - intval( $i / 28 ) * ( 1 - intval( $i / 28 ) * intval( 29 / ( $i + 1 ) ) * intval( ( 21 - $n ) / 11 ) ); $j = $y + intval($y / 4) + $i + 2 - $c + intval($c / 4); $j = $j - 7 * intval( $j / 7 ); $l = $i - $j; $em = 3 + intval(( $l + 40 ) / 44); $ed = $l + 28 - 31 * intval( $em / 4 ); $EasterDate = $y.substr("0".$em, -2).substr("0".$ed, -2); $GoodFriday = date("Ymd", mktime(12,0,0, $em, $ed - 2, $y)); if ($EasterDate == substr($d, 0, 8)) { $dow['l'] = "Easter Sunday"; $dow['dateName'] = $dow['l']; $dow['stat'] = false; } else if ($GoodFriday == substr($d, 0, 8)) { $dow['l'] = "Good Friday"; $dow['dateName'] = $dow['l']; $dow['stat'] = true; } break; case "05": // Victoria day if ($dow['w'] == 1 and substr($d, 6, 2) > 17 and substr($d, 6, 2) < 25) { $dow['l'] = "Victoria Day"; $dow['dateName'] = $dow['l']; $dow['stat'] = true; } break; case "08": // BC Day if ($dow['w'] == 1 and substr($d, 6, 2) < 8) { $dow['l'] = "BC Day"; $dow['dateName'] = $dow['l']; $dow['stat'] = true; } break; case "09": // Labour Day if ($dow['w'] == 1 and substr($d, 6, 2) < 8) { $dow['l'] = "Labour Day"; $dow['dateName'] = $dow['l']; $dow['stat'] = true; } break; case "10": // Thanksgiving Day if ($dow['w'] == 1 and substr($d, 6, 2) > 7 and substr($d, 6, 2) < 16) { $dow['l'] = "Thanksgiving"; $dow['dateName'] = $dow['l']; $dow['stat'] = true; } break; } } return($dow); } function getEmployeeData($empNo) { $r = sqlSelect("employees", "empNo = '$empNo'"); return mysql_fetch_assoc($r['r']); } function getEmployeeName($empNo, $mode = "") { $n = sqlSelect("employees", "empNo = '$empNo'"); $n = mysql_fetch_assoc($n['r']); if ($mode == "full") $name = $n['fName']." ".$n['lName']; else $name = substr($n['fName'], 0, 1)." ".$n['lName']; return $name; } function getEventById( $id ) { $id = sqlEx("SELECT * FROM `events` where `tid`='$id'", $mLink); $id = mysql_fetch_assoc($id); $id = noNull( $id ); $id['duration'] = $id['jobEnd'] - $id['jobStart']; $id['days'] = intval($id['duration'] / 86400); $id['hours'] = sprintf("%1\$.2f", ($id['duration'] / 3600)); $id['units'] = sprintf("%1\$.2f", ($id['duration'] / 600)); $id['startDate'] = date("Y-m-d", $id['jobStart']); if ($id['days']) { $id['startTime'] = ""; $id['endTime'] = ""; } else { $id['startTime'] = date("H:i", $id['jobStart']); $id['endTime'] = date("H:i", $id['jobEnd']); if ($id['endTime'] == "00:00") $id['endTime'] = ""; } return $id; } function getFullOwnersName($shortcode) { $r = sqlEx("select full_name from iowners where short_name='$shortcode'"); if (mysql_num_rows($r)) { $r = mysql_fetch_assoc($r); return $r['full_name']; } return false; } function getHeaderByJobNo( $jobNo ) { if (!empty( $jobNo )) { $q = "select * from headers where jobNo = '$jobNo'"; $jobNo = sqlEx($q); $jobNo = mysql_fetch_assoc($jobNo); $jobNo = noNull( $jobNo ); return $jobNo; } else return array(); } function getInventoryReference($scancode, $show=false) { $q = "select tid from idesc where tid='$scancode'"; if ($show) echo "\n"; $r = sqlEx($q); if (mysql_num_rows($r)) { $r = mysql_fetch_assoc($r); if ($show) echo "\n"; return $r['tid']; } $q = "select tid from idesc where vsn='$scancode'"; if ($show) echo "\n"; $r = sqlEx($q); if (mysql_num_rows($r)) { $r = mysql_fetch_assoc($r); if ($show) echo "\n"; return $r['tid']; } $q = "select linkref from ivsn where scancode='$scancode'"; if ($show) echo "\n"; $r = sqlEx($q); if (mysql_num_rows($r)) { $r = mysql_fetch_assoc($r); if ($show) echo "\n"; return $r['linkref']; } if ($show) echo "\n"; return false; } function getJobByRef( $ref ) { $r = sqlEx("select * from `headers` where `tid`='$ref'"); if (mysql_num_rows($r)) { return mysql_fetch_assoc($r); } return false; } function getNextUID() { // this is a unique ID (for parts). Every REAL part has one $uid = mysql_fetch_assoc(sqlEx("select uid from system")); $uid = nextRef($uid['uid']); sqlEx("update system set uid='$uid'"); return $_SESSION['instance']['prefix'].$uid; } function getOrderStatus($tid) { $oStatus = sqlSelect("headers", "tid = '$tid'", "", "", "status"); $oStatus = mysql_fetch_assoc($oStatus['r']); return $oStatus['status']; } function getProductInfo($pc) { $dat = sqlEx("select * from idesc where tid='$pc'"); $dat = mysql_fetch_assoc($dat); return $dat; } function getScheduleList() { $uList = sqlSelect("employees", "", "", "lName, fName"); while ($u = mysql_fetch_assoc($uList['r'])) { if (($u['access'] & 0x4000) and !($u['access'] & 0x0001)) $users[] = $u['empNo']; } return $users; } function getSystemLastMod() { $lastmod = sqlEx("select lastmod from system"); $lastmod = mysql_fetch_assoc($lastmod); return $lastmod['lastmod']; } function getSystemLastPageMod() { $lastPageMod = sqlEx("select lastPageMod from system"); $lastPageMod = mysql_fetch_assoc($lastPageMod); return $lastPageMod['lastPageMod']; } function inventoryCatelogue($locationId, $pCodeId, $onlyinstock = false, $infinate_stockroom = true) { $q = "select category from idesc group by category order by category"; $grpList = sqlEx($q); while ($grpItem = mysql_fetch_assoc($grpList)) { $q = "select * from idesc where category='{$grpItem['category']}' order by idesc.description"; $itemList = sqlEx($q); unset($items); while ($item = mysql_fetch_assoc($itemList)) $items[] = $item['tid']; if (!empty($items)) $catelogue[$grpItem['category']] = $items; } $rows = 1; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " "; if ($onlyinstock) echo" "; echo " \n"; echo " \n"; echo "\n"; echo "\n"; foreach ($catelogue as $cat => $items) { if (count($items)) { $rows++; echo " \n"; echo " \n"; echo " \n"; foreach ($items as $pCode) { $rows++; $itemInfo = getProductInfo($pCode); $bulk = ($itemInfo['pkg'] & 0x02) ? true: false; $sCode = $itemInfo['vsn']; $q = "select * from iloc, inventory where iloc.shortname = inventory.iloc and sof='' and "; if ($infinate_stockroom) $q .= "(shortname = 'STOCK' or (item='$pCode' and workorder = '' and iloc != ''))"; else { $q .= "item='$pCode'"; if (!$bulk) $q .= " and workorder = '' and iloc != ''"; } $q .= " group by iloc.shortname order by iloc.shortname"; $lList = sqlEx($q); $hasStock = mysql_num_rows($lList); if ($onlyinstock and $hasStock) $extraStyle = "cursor: pointer;"; else $extraStyle = ""; echo " \n"; echo " \n"; // this is the indent! echo " \n"; echo " \n"; echo " \n"; if ($onlyinstock and $hasStock) { echo " \n"; } echo " \n"; } } } echo "\n"; echo "
VENDVSNDESCRIPTIONLOCATION
$cat
   {$itemInfo['vend']}{$itemInfo['vsn']}{$itemInfo['description']}\n"; echo "\n"; echo "
\n"; } function isOpen($linkref = "", $mode = true) { if ($linkref == "") $linkref = $_SESSION['jobRef']; return ($mode xor (in_array(getOrderStatus($linkref), array("VOID", "CLOSED", "CANCLOSE")))); } function isTrackable($owner, $item, $iType) { // does this owner require tracking? if ($owner = sqlEx("select force_track from iowners where short_name='$owner'")) { $owner = mysql_fetch_assoc($owner); if (!empty($owner['force_track'])) { return true; } } // does this ITEM require tracking? $q = "select is_tracked from idesc where $iType='$item'"; echo "\n"; if ($item = sqlEx($q)) { $item = mysql_fetch_assoc($item); if ($item['is_tracked']) { return true; } } // tracking is not required return false; } function limitInput( $inputLine, $maxSize, $notAllowed = array( "'", "/"), $replacement = array("´","\\")) { $inputLine = str_replace( $notAllowed, $replacement, $inputLine ); return substr( $inputLine, 0, $maxSize ); } function limitInputHTML( $inputLine, $maxSize) { return substr( htmlentities( $inputLine, ENT_QUOTES ), 0, $maxSize ); } function locAssention($seed) { while ($seed['iLoc']) { $seed = sqlSelect("items", "esn='".$seed['iLoc']."'"); $seed = mysql_fetch_assoc($seed['r']); } return $seed['esn']; } function locList() { $locList = array(); $seed = expandESN($_SESSION['user']['defaultLoc']); $locs = sqlSelect("items", "iCat='location' or iCat='container'", "", "iDes"); while ($loc = mysql_fetch_assoc($locs['r'])) { $iLoc = locAssention($loc); if ($seed == "0000000000" or $loc['esn'] == $seed or $iLoc == $seed) { $locList[$loc['esn']] = $loc['iDes']; } } return $locList; } function logEntry( $linkRef = "system", $chgs, $eType = "s", $empNo = "" ) { if (empty($empNo)) $empNo = $_SESSION['user']['empNo']; $q = "eType='$eType', "; $q .= "linkRef='$linkRef', "; $q .= "empNo='$empNo', "; $q .= "wDate='".date("Ymd")."', "; $q .= "wStart = '".date("Hi")."', "; $q .= "tagLine='', "; $q .= "note='$chgs'"; $r = sqlInsert("logents", $q); //echo "\n"; } function needsParts($order) { $needsParts = sqlSelect("inventory", "iloc='' and workorder='$order' and sof=''"); if ($needsParts['n']) return " color: #900;"; else { $needsParts = sqlSelect("inventory", "iloc!='' and workorder='$order' and status='' and sof=''"); if ($needsParts['n']) return " color: #366;"; } return ""; } function mkLink($id, $args, $display = "") { echo "
\n"; foreach($args as $k => $v) echo "\n"; echo "
\n"; if (!empty($display)) echo "$display\n"; } function mkTab($p, $display, $formName, $element, $source) { echo "\t\t\t\t\t\n"; echo "\t\t\t\t\t\t$display"; echo "\n\t\t\t\t\t\n"; } function mkTrkRecord($linkRef, $note) { sqlRecycle("logents", "eType='s', linkRef='$linkRef', empNo='".$_SESSION['user']['empNo']."', note='\n$note', tagLine='', wDate='".date("Ymd")."', wStart = ='".date("Hi")."'", "linkRef=''"); } function nextClientNumber() { // *********************** each proposed value has to be tested to ensure that it doesn't already exist (even though it shouldn't ) $r = sqlSelect("clientdat", "cCode like '".$_SESSION['instance']['prefix']."%' and CHAR_LENGTH(cCode) = 9", "", "cCode desc"); if ($r['n']) { $r = mysql_fetch_assoc($r['r']); $r = nextRef(substr($r['cCode'], -6)); //$r = nextRef($r['cCode']); } else { $r = nextRef("000000"); //$r = nextRef($_SESSION['instance']['prefix']."000000"); } return $_SESSION['instance']['prefix'].$r; //return $r; } function nextESN() { $r = sqlSelect("items", "", "", "esn desc"); if ($r['n']) { $r = mysql_fetch_assoc($r['r']); $r = nextRef($r['esn']); } else $r = nextRef("0000000000"); return $r; } function nextSID() { $r = sqlSelect("skus", "sid != ''", "", "sid desc"); if ($r['n']) { $r = mysql_fetch_assoc($r['r']); $r = nextRef($r['sid']); } else $r = "000001"; return $r; } function nextJobNumber() { $r = sqlSelect("headers", "jobNo like '".$_SESSION['instance']['prefix']."%'", "jobNo", "jobNo desc limit 1"); if ($r['n']) { $r = mysql_fetch_assoc($r['r']); $r = nextRef(substr($r['jobNo'], -6)); } else $r = nextRef("000000"); return $_SESSION['instance']['prefix'].$r; } function nextPONumber() { $r = sqlSelect("ipo", "poNo like 'P".$_SESSION['instance']['prefix']."%'", "poNo", "poNo desc limit 1"); if ($r['n']) { $r = mysql_fetch_assoc($r['r']); $r = nextRef(substr($r['poNo'], -6)); } else $r = nextRef("000000"); return "P".$_SESSION['instance']['prefix'].$r; } function nextRef($lastRef) { $baseStr = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $notDone = strlen($lastRef); $i = $notDone - 1; while ($notDone) { $c = $lastRef[$i]; $tIdx = 1 + strpos($baseStr, $c); if ($tIdx >= 36) { $tIdx = 0; $notDone -= 1; } else $notDone = 0; $lastRef[$i--] = $baseStr[$tIdx]; } return $lastRef; } function noNull( $list ) { foreach ($list as $k => $v) { if (!isset($v)) { $list[$k] = ''; } } return $list; } function processTimeDif($begin, $end) { $begin = (substr($begin,0,2) * 60) + substr($begin, -2); $end = (substr($end, 0, 2) * 60) + substr($end, -2); return (($end - $begin) / 60); } function scan_dir($d, $m = "") { // replaces the scandir() function of PHP5 (not in PHP4) // reads all entries in the directory ($d) and loads them into // an array ($filelist) which is returned by the funtion $filelist = array(); if (($h = @opendir($d)) !== false) { while (false != ($fname = readdir($h))) { if ($fname != "." and $fname != "..") { if ($m) { if (false !== (strpos($fname, $m))) $filelist[] = $fname; } else { $filelist[] = $fname; } } } return $filelist; } else return false; } function selectorPhoneType($pType, $da = "") { echo "\n"; } function selectTech($empNo, $name, $leader = "", $action = "", $style = "") { $eList = sqlSelect("employees", "(access & 0x1000) and !(access & 0x0001)", "", "lName, fName"); echo " \n"; } function selectTimeSheetUsers($empNo, $name, $leader = "", $action = "", $style = "") { $eList = sqlSelect("employees", "(access & 0x0004) and !(access & 0x0001)", "", "lName, fName"); echo " \n"; } function setFocus($name) { echo " \n"; } function timeBank($empNo, $pStart, $pEnd) { $empDat = sqlSelect("employees", "empNo='$empNo'"); $empDat = mysql_fetch_assoc($empDat['r']); // this block fetches all banking with dates NEWER than the specified period so that it can be allowed for in the reporting $cumAdj = 0; $adjs = sqlSelect("timebank", "tDate>'$pEnd' and empNo='$empNo'"); // this will fetch all entries NEWER than the selected period while ($adj = mysql_fetch_assoc($adjs['r'])) $cumAdj += ($adj['intAdj'] + $adj['extAdj']); $adjs = sqlSelect("times", "wDate>'$pEnd' and empNo='empNo'"); // this will fetch all entries NEWER than the selected period while ($adj = mysql_fetch_assoc($adjs['r'])) $cumAdj += $adj['dailyAdj']; // end of block $intAdj = sqlSelect("timebank", "tDate='$pEnd' and empNo='$empNo'"); if ($intAdj['n']) { $intAdj = mysql_fetch_assoc($intAdj['r']); $extAdj = $intAdj['extAdj']; $intComment = $intAdj['intComment']; $extComment = $intAdj['extComment']; $intAdj = $intAdj['intAdj']; // this must be LAST because the value is assigned to the container variable } else { $intAdj = 0; $extAdj = 0; $intComment = ""; $extComment = ""; } $tb['pOpenBal'] = sprintf("%01.2f", ($empDat['bank'] - $intAdj - $extAdj - $dailyAdjTtl)); $tb['openBal'] = sprintf("%01.2f", ($tb['pOpenBal'] - $cumAdj)); $tb['extAdj'] = sprintf("%01.2f", $extAdj); $tb['intAdj'] = sprintf("%01.2f", $intAdj); $tb['intComment'] = $intComment; $tb['closeBal'] = sprintf("%01.2f", ($empDat['bank'] - $cumAdj)); // get daily adjustmest for this period $dAdjList = sqlSelect("times", "empNo='$empNo' and wDate>='$pStart' and wDate <='$pEnd'", "", "wDate", "wDate,dailyAdj"); while (list($wDate, $dailyAdj) = mysql_fetch_row($dAdjList['r'])) { $tb[$wDate] = $dailyAdj; } return $tb; } function tomarrow($seed = "") { if (empty($seed)) $seed = date("Ymd"); else $seed = str_replace("-", "", $seed); return date("Ymd",mktime(12, 0, 0, substr($seed, 4, 2), (substr($seed, 6, 2) + 1), substr($seed, 0, 4))); } function updatePhoneEntry($cType, $pLink, $pType, $pNumber) { $q = "cType = '$cType', pLink = '$pLink', pType = '$pType', pNumber = '".str_replace(array(" ","-","(",")",".","[","]"), "", $pNumber)."'"; // look for a vacant spot to put it into ... $vacant = sqlSelect("phones", "pLink = ''"); if ($vacant['n']) //use vacant slot { $vacant = mysql_fetch_assoc($vacant['r']); sqlUpdate("phones", $q, "tid = '".$vacant['tid']."'"); } else sqlInsert("phones", $q); } function workorder_close_parts($option="INS") { // when a workorder is closed, parts cannot be left "dangling" - they have to be marked as INStalled or unreserved // In either case, backordered parts need to be dropped completely so they no longer appear on the parts order. $pList = sqlSelect("inventory", "workorder='{$_SESSION['jobRef']}' and iloc!='' and sof=''"); if ($pList['n']) { // there are reserved parts while ($part = mysql_fetch_assoc($pList['r'])) { //$toDoDat = mysql_fetch_assoc($toDoDat); if ($option == "INS") { //=>> doITQ("opCode=AINS&nTrans=", $part['tid']); sqlUpdate("inventory", "sof='AINS'", "tid='{$part['tid']}'"); } else { //=>> doITQ("opCode=UNRV&workorder=", $part['tid']); sqlUpdate("inventory", "sof='UNRV', workorder=''", "tid='{$part['tid']}'"); } } } $pList = sqlSelect("inventory", "workorder='{$_SESSION['jobRef']}' and iloc='' and sof=''"); if ($pList['n']) { // there are parts backordered while ($part = mysql_fetch_assoc($pList['r'])) { //=>> doITQ("opCode=DRPV&nRes=",$part['tid'] ); slqUpdate("inventory", "sof='CDRP', workorder=''", "tid='{$part['tid']}'"); } } } function yesterday($seed = "") { if (empty($seed)) $seed = date("Ymd"); else $seed = str_replace("-", "", $seed); return date("Ymd",mktime(12, 0, 0, substr($seed, 4, 2), (substr($seed, 6, 2) - 1), substr($seed, 0, 4))); } ?>