= '".$_REQUEST['bcdFrom']."' and slocation <= '".$_REQUEST['bcdTo']."'";
}
else if (!empty($_REQUEST['bcdFrom']))
{
$q = "delete from cycle where slocation >= '".$_REQUEST['bcdFrom']."'";
}
else if (!empty($_REQUEST['bcdTo']))
{
$q = "delete from cycle where slocation <= '".$_REQUEST['bcdTo']."'";
}
else
{
$q = "TRUNCATE TABLE `cycle`";
}
sqlEx($q);
//debugMessage(true, $q);
}
if (!empty($_REQUEST['slocation']))
{
// an entry of some sort has been submitted
if (empty($_REQUEST['scankode']))
{
// this is a location change; is this location on record already?
$q = "select * from `cycle` where slocation = '{$_REQUEST['slocation']}'";
$rItem = sqlEx($q);
if (mysql_num_rows($rItem) == 0)
{
// not on record
$q = "insert into `cycle` set slocation = '{$_REQUEST['slocation']}', skode = '', scount = 0";
}
else
$q = "";
echo "\n";
}
else
{
// get the "real" product code
if (false === ($kode = getInventoryReference($_REQUEST['scankode'], true)))
$kode = $_REQUEST['scankode'];
// we have a location and a code. Is this combo on record already?
$q = "select * from `cycle` where slocation = '{$_REQUEST['slocation']}' and skode = '$kode'";
$rItem = sqlEx($q);
if (mysql_num_rows($rItem) == 0)
{ // not on record. Is the location with no code on record?
$q = "select * from `cycle` where slocation = '{$_REQUEST['slocation']}' and skode = ''";
$rItem = sqlEx($q);
if (mysql_num_rows($rItem) == 0)
{ // location with blank code also not on file, so add an entry
$q = "insert into `cycle` set slocation = '{$_REQUEST['slocation']}', skode = '$kode', scount = '{$_REQUEST['count']}'";
}
else
{
// blank location location on record; use it
$rItem = mysql_fetch_assoc($rItem);
$q = "update `cycle` set skode = '$kode', scount = '{$_REQUEST['count']}' where idx = '{$rItem['idx']}'";
}
}
else
{
// item/location on record; increment it
$rItem = mysql_fetch_assoc($rItem);
$q = "update `cycle` set skode = '$kode', scount = ".($rItem['scount'] + $_REQUEST['count'])." where idx = '{$rItem['idx']}'";
}
}
sqlEx($q);
}
echo "