[".strtoupper($alias['owner'])."] "; } $s .= $alias['scancode']; if (!empty($alias['owner'])) { $s .= " "; } } $str .= "$s)"; } } //-> debugMessage("str -> $str"); return $str; } function getSelectedCode($linkref) { debugMessage($showDebugMessage, "67 getSelectedCode(".$linkref.")"); if ($_REQUEST['owner'] == "vsn") { $str = getSelectedVSN($linkref); } else { $q = debugMessage($showDebugMessage, "select * from ivsn where linkref = '$linkref' and owner = '{$_REQUEST['owner']}'"); $aliasList = sqlEx($q); if (mysql_num_rows($aliasList)) { $alias = mysql_fetch_assoc($aliasList); $q = debugMessage($showDebugMessage, "select * from idesc where tid = '$linkref'"); $idesc = sqlEx($q); $idesc = mysql_fetch_assoc($idesc); $str = "".$alias['scancode']." \"".$idesc['description']."\" (".$idesc['vsn'].")"; } else { debugMessage($showDebugMessage, "86 FALLBACK: getSelectedCode(".$linkref.")"); $str = getSelectedVSN($linkref); } } return $str; } function itqFixUp($linkRef) { $oldEnt = doITQprefetch($linkRef); $args['uid'] = $oldEnt['uid']; $args['item'] = $oldEnt['item']; $args['sn'] = $oldEnt['sn']; $args['owner'] = $oldEnt['owner']; $args['oloc'] = $oldEnt['iloc']; $args['workorder'] = $oldEnt['workorder']; $args['transfer'] = $oldEnt['transfer']; $args['nloc'] = ''; $args['empNo'] = $_SESSION['user']['empNo']; if (!empty($args['transfer'])) { $str = ""; $args['opCode'] = "TUR"; foreach ($args as $k => $v) { if ($str) $str .= ", "; $str .= "$k = '$v'"; } sqlInsert("itq", $str); $args['transfer'] = ""; } if (!empty($args['workorder'])) { $str = ""; $args['opCode'] = "UNR"; foreach ($args as $k => $v) { if ($str) $str .= ", "; $str .= "$k = '$v'"; } sqlInsert("itq", $str); $args['workorder'] = ""; } $str = ""; $args['opCode'] = "CSHT"; foreach ($args as $k => $v) { if ($str) $str .= ", "; $str .= "$k = '$v'"; } sqlInsert("itq", $str); } function makeInventoryAdjustment($owner, $linkref, $qty, $loc) { GLOBAL $showDebugMessage; debugMessage($showDebugMessage, "inside makeInventoryAdjustment"); if ($qty > 0) { debugMessage($showDebugMessage, "- do overs"); if (isTrackable($owner, $linkref, "tid")) { echo "\n"; $q = "`qty` ='1', "; $q .= "`item` ='$linkref', "; $q .= "`sn` ='', "; $q .= "`owner` ='$owner', "; $q .= "`iloc` ='$loc', "; $q .= "`workorder` ='', "; $q .= "`purchaseorder` ='', "; $q .= "`transfer` ='', "; $q .= "`status` ='', "; $q .= "`sof` ='', "; $q .= "`retail` ='0.00', "; $q .= "`hst` ='0.00', "; $q .= "`gst` ='0.00', "; $q .= "`pst` ='0.00'"; while ($qty > 0) { $uid = getNextUID(); $r = sqlRecycle("inventory", "uid='$uid', $q", "item=''"); doItq("", doITQprefetch($r['t']), "COVR"); $qty -= 1; } } else debugMessage($showDebugMessage, "Item $linkref is not tracked"); } else if ($qty < 0) { debugMessage($showDebugMessage, "- do shorts"); $iList = sqlEx(debugMessage($showDebugMessage, "select * from inventory where item = '$linkref' and workorder = '' and transfer = '' and status = '' and sof = '' and iloc = '$loc' and owner = '$owner'")); while (($qty != 0) and ($item = mysql_fetch_assoc($iList))) { debugMessage($showDebugMessage, "Qty = $qty"); itqFixUp($item['tid']); sqlEx(debugMessage($showDebugMessage, "update inventory set uid = '', item = '', iloc = '', owner = '' where tid = '{$item['tid']}'")); $qty += 1; } if ($qty) { debugMessage($showDebugMessage, "Qty = $qty"); $iList = sqlEx(debugMessage($showDebugMessage, "select * from inventory where item = '$linkref' and workorder = '' and status = '' and sof = '' and iloc = '$loc' and owner = '$owner'")); while (($qty != 0) and ($item = mysql_fetch_assoc($iList))) { itqFixUp($item['tid']); sqlEx(debugMessage($showDebugMessage, "update inventory set uid = '', item = '', iloc = '', owner = '' where tid = '{$item['tid']}'")); $qty += 1; } } if ($qty) { debugMessage($showDebugMessage, "Qty = $qty"); $iList = sqlEx(debugMessage($showDebugMessage, "select * from inventory where item = '$linkref' and status = '' and sof = '' and iloc = '$loc' and owner = '$owner'")); while (($qty != 0) and ($item = mysql_fetch_assoc($iList))) { itqFixUp($item['tid']); sqlEx(debugMessage($showDebugMessage, "update inventory set uid = '', item = '', iloc = '', owner = '' where tid = '{$item['tid']}'")); $qty += 1; } } } } function getSrtKode($kode) { GLOBAL $showDebugMessage; debugMessage($showDebugMessage, "============== getSrtKode entry =============="); $result = $kode; debugMessage($showDebugMessage, "REQ[owner] = ".$_REQUEST['owner']); if (!empty($_REQUEST['owner']) and $_REQUEST['owner'] != "vsn") { debugMessage($showDebugMessage, "Owner specified"); // all but generics $q = debugMessage($showDebugMessage, "select scancode from ivsn where linkref = '$kode' and owner = '{$_REQUEST['owner']}'"); $r = sqlEx($q); if (mysql_num_rows($r)) { $r = mysql_fetch_assoc($r); $result = $r['scancode']; } else debugMessage($showDebugMessage, "No Kode found"); } if (($result == $kode) or empty($_REQUEST['owner']) or ($_REQUEST['owner'] == "vsn")) { debugMessage($showDebugMessage, "VSN or generic"); // get the generic vsn $q = debugMessage($showDebugMessage, "select vsn from idesc where tid = '$kode'"); $r = sqlEx($q); if (mysql_num_rows($r)) { $r = mysql_fetch_assoc($r); $result = $r['vsn']; } else debugMessage($showDebugMessage, "No Kode found"); } return $result; } ?> Inventory Report Inventory Report
$commit = array_key_exists("commit", $_REQUEST); if ($commit) echo "\n"; else echo "\n"; debug(2); // get a list of locations that were checked $q = debugMessage($showDebugMessage, "select slocation from cycle group by slocation order by slocation"); $lList = sqlEx($q); if (mysql_num_rows($lList) == 0) { echo "No records
\n"; } else { // create a temp table to correlate data while ($loc = mysql_fetch_assoc($lList)) { debugMessage($showDebugMessage, $loc['slocation']); // for each location, get a list of what was found there $q = debugMessage($showDebugMessage, "select * from cycle where slocation = '{$loc['slocation']}' and skode != '' and scount != 0"); // $q = debugMessage($showDebugMessage, "select * from cycle,idesc where idesc.tid=cycle.linkref and slocation = '{$loc['slocation']}' and skode != '' and scount != 0 order by idesc.vsn"); $icList = sqlEx($q); if (mysql_num_rows($icList)) { // there were items while ($icTem = mysql_fetch_assoc($icList)) { $q = debugMessage($showDebugMessage, "insert into correlate set slocation = '{$icTem['slocation']}', skode = '{$icTem['skode']}', srtkode = '".getSrtKode($icTem['skode'])."', scount = '{$icTem['scount']}', sreal = '0'"); sqlEx($q); } } // get a list of items that should be in that location $q = debugMessage($showDebugMessage, "select *, count(*) as scount from inventory where iloc = '{$loc['slocation']}' and item != '' and status != 'INS' and sof = '' group by item order by item"); $iiList = sqlEx($q); while ($item = mysql_fetch_assoc($iiList)) { $q = debugMessage($showDebugMessage, "select idx from correlate where slocation = '{$loc['slocation']}' and skode = '{$item['item']}'"); $cUpdate = sqlEx($q); if (mysql_num_rows($cUpdate)) { // we found some of this item $cUpdate = mysql_fetch_assoc($cUpdate); $q = debugMessage($showDebugMessage, "update correlate set sreal = '{$item['scount']}' where idx = '{$cUpdate['idx']}'"); } else { // we didn't find any of this item $q = debugMessage($showDebugMessage, "insert into correlate set slocation = '{$loc['slocation']}', skode = '{$item['item']}', srtkode = '".getSrtKode($item['item'])."', scount = '0', sreal = '{$item['scount']}'"); } sqlEx($q); } } // ================ generate report ================ $rowCount = 0; $lineNo = 1; if ($_REQUEST['sortord'] == "item") { echo "\n"; //
Inventory Report

echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $q = debugMessage($showDebugMessage, "select * from correlate order by srtkode, skode, slocation"); $fList = sqlEx($q); while ($entry = mysql_fetch_assoc($fList)) { $difference = ($entry['scount'] - $entry['sreal']); if ($difference > 0) { $cstr = "OVR"; $c = " style=\"color: red;\""; } else if ($difference < 0) { $cstr = "SHT"; $c = " style=\"color: red;\""; } else { $cstr = ""; $c = ""; } // if ($_REQUEST['repttype'] != "diff" or $difference != 0) // if ($difference != 0) { if ($lastItem != $entry['skode']) { if ($rowCount > 43) { $rowCount = 0; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; } echo " \n"; echo " \n"; echo " \n"; $rowCount += 1; } $lastItem = $entry['skode']; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " $difference\n"; echo " $cstr\n"; echo " \n"; $rowCount += 1; //echo "
\n"; if ($commit) { debugMessage($showDebugMessage, "initiate commit from 337"); if ($difference) { debugMessage($showDebugMessage, "jump to makeInventoryAdjustment from 340"); makeInventoryAdjustment($_REQUEST['owner'], $entry['skode'], $difference, $entry['slocation']); } else debugMessage($showDebugMessage, "abort commit"); } else debugMessage($showDebugMessage, "did not do commit"); } } echo "
Inventory Report\n"; echo "
ItemLocationStockCountDiff
Inventory Report\n"; echo "
ItemLocationStockCountDiff
".getSelectedCode($entry['skode'])."
(Ln ".substr("000".$lineNo++, -3)."){$entry['slocation']}{$entry['sreal']}{$entry['scount']}
\n"; } else { // by location echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $q = debugMessage($showDebugMessage, "select * from correlate order by slocation, srtkode, skode"); $fList = sqlEx($q); while ($entry = mysql_fetch_assoc($fList)) { $difference = ($entry['scount'] - $entry['sreal']); if ($difference > 0) { $cstr = "OVR"; $c = " style=\"color: red;\""; } else if ($difference < 0) { $cstr = "SHT"; $c = " style=\"color: red;\""; } else { $cstr = ""; $c = ""; } // if ($_REQUEST['repttype'] != "diff" or $difference != 0) // if ($difference) { if ($rowCount > 43) { $rowCount = 0; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $lastLoc = ""; } if ($lastLoc != $entry['slocation']) { echo " \n"; echo " \n"; echo " \n"; $rowCount += 1; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " $difference\n"; echo " $cstr\n"; echo " \n"; $rowCount += 1; if ($commit) { debugMessage($showDebugMessage, "initiate commit from 329"); if ($difference) { debugMessage($showDebugMessage, "jump to makeInventoryAdjustment from 331"); makeInventoryAdjustment($_REQUEST['owner'], $entry['skode'], $difference, $entry['slocation']); } else debugMessage($showDebugMessage, "abort commit"); } else debugMessage($showDebugMessage, "did not do commit"); $lastLoc = $entry['slocation']; } } echo "
Inventory Report\n"; echo "
LocationItemStockCountDiff
Inventory Report\n"; echo "
ItemLocationStockCountDiff
".$entry['slocation']."
(Ln ".substr("000".$lineNo++, -3).")".getSelectedCode($entry['skode'])."{$entry['sreal']}{$entry['scount']}
\n"; } } ?>