function getItemInfo($vars, $responsetype) { global $db; $ar = $vars; if (empty($ar) || !isset($ar['VendorID']) || !isset($ar['ItemNumber'])) { RestLog("16584 - Insufficient data provided for creating order \n" . print_r($vars, true) . "\n"); RestUtils::sendResponse(400, "16584 - Insufficient data provided"); //Internal Server Error return false; } //now we grab inventory records for the requested item and build up our package to return //to the dealer //08.28.2015 ghh - added weight field $query = "select Items.ItemID, Items.MSRP, NLA, CloseOut,\n\t\t\t\tPriceCode, Cost, MAP, Category, \n\t\t\t\tManufItemNumber, ManufName, SupersessionID, Weight\n\t\t\t\tfrom Items\n\t\t\t\twhere \n\t\t\t\tItemNumber='{$ar['ItemNumber']}' and\n\t\t\t\tVendorID={$ar['VendorID']}"; if (!($result = $db->sql_query($query))) { RestLog("Error 16585 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16585 - There was a problem getting item information."); //Internal Server Error return false; } $row = $db->sql_fetchrow($result); $item['OrigManufName'] = $row['ManufName']; $item['OrigManufNumber'] = $row['ManufItemNumber']; $item['NLA'] = $row['NLA']; $item['CloseOut'] = $row['CloseOut']; $item['MSRP'] = $row['MSRP']; $item['Category'] = $row['Category']; $item['MAP'] = $row['MAP']; $item['Weight'] = $row['Weight']; //08.28.2015 ghh - if ($row['ItemID'] > 0) { $item['Cost'] = getItemCost($row['ItemID'], $ar['DealerID'], $row['PriceCode'], $row['Cost'], $row['MSRP']); } //08.25.2015 ghh - if BSV asked for full detail then we're also going to send back //images data and other items of interest if ($row['SupersessionID'] > 0) { $query = "select ItemNumber from Items where ItemID={$row['SupersessionID']}"; if (!($tmpresult = $db->sql_query($query))) { RestLog("Error 16586 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16586 - There was a problem retrieving the supersession number"); //Internal Server Error return false; } $tmprow = $db->sql_fetchrow($tmpresult); $item['SupersessionNumber'] = $tmprow['ItemNumber']; } RestLog("Successful Request\n"); //08.10.2012 naj - return code 200 OK. RestUtils::sendResponse(200, json_encode(stripHTML($item))); return true; }
function sendOrder($vars, $responsetype) { global $db; $ar = json_decode($vars['Data']['Data'], true, 5); if (empty($ar) || !isset($ar['PONumber']) || !isset($ar['Status']) || empty($ar['Items']) && empty($ar['Units'])) { RestLog("16521 - Insufficient data provided for creating order \n" . print_r($vars, true) . "\n"); RestUtils::sendResponse(400, "16521 - Insufficient data provided"); //Internal Server Error return false; } //08.21.2015 ghh - before we get started we need to see if the current dealer //already has a PO in the system matching what they are now sending. If so we're //going to be updating it if its pending or if it hasn't been pulled by the primary //vendor system yet. $query = "select POID, Status from PurchaseOrders where PONumber='{$ar['PONumber']}' and\n\t\t\t\tDealerID={$vars['DealerID']}"; if (!($result = $db->sql_query($query))) { RestLog("Error 16522 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16522 - There was a problem attempting to locate the PO"); //Internal Server Error return false; } //if we have no purchase order at all then we're going to be inserting a new one if ($db->sql_numrows($result) == 0) { $shiptofields = ''; $shiptovals = ''; if ($ar['ShipToAddress1'] != '') { $shiptofields = "ShipToFirstName, ShipToLastName, ShipToCompany,\n\t\t\t\t\t\t\t\tShipToAddress1, ShipToAddress2, ShipToCity, ShipToState,\n\t\t\t\t\t\t\t\tShipToZip, ShipToCountry, ShipToPhone, ShipToEmail,"; if ($ar['ShipToFirstName'] == '') { $shiptovals = "'',"; } else { $shiptovals = "'{$ar['ShipToFirstName']}',"; } if ($ar['ShipToLastName'] == '') { $shiptovals .= "'',"; } else { $shiptovals .= "'{$ar['ShipToLastName']}',"; } if ($ar['ShipToCompany'] == '') { $shiptovals .= "'',"; } else { $shiptovals .= "'{$ar['ShipToCompany']}',"; } if ($ar['ShipToAddress1'] == '') { $shiptovals .= "'',"; } else { $shiptovals .= "'{$ar['ShipToAddress1']}',"; } if ($ar['ShipToAddress2'] == '') { $shiptovals .= "'',"; } else { $shiptovals .= "'{$ar['ShipToAddress2']}',"; } if ($ar['ShipToCity'] == '') { $shiptovals .= "'',"; } else { $shiptovals .= "'{$ar['ShipToCity']}',"; } if ($ar['ShipToState'] == '') { $shiptovals .= "'',"; } else { $shiptovals .= "'{$ar['ShipToState']}',"; } if ($ar['ShipToZip'] == '') { $shiptovals .= "'',"; } else { $shiptovals .= "'{$ar['ShipToZip']}',"; } if ($ar['ShipToCountry'] == '') { $shiptovals .= "'',"; } else { $shiptovals .= "'{$ar['ShipToCountry']}',"; } if ($ar['ShipToPhone'] == '') { $shiptovals .= "'',"; } else { $shiptovals .= "'{$ar['ShipToPhone']}',"; } if ($ar['ShipToEmail'] == '') { $shiptovals .= "'',"; } else { $shiptovals .= "'{$ar['ShipToEmail']}',"; } if ($ar['PaymentMethod'] == '') { $shiptovals .= "1,"; } else { $shiptovals .= "'{$ar['PaymentMethod']}',"; } if ($ar['ShipMethod'] == '') { $shiptovals .= "1,"; } else { $shiptovals .= "'{$ar['ShipMethod']}',"; } } $query = "insert into PurchaseOrders (Status, DealerID, BSVKeyID, PONumber,\n\t\t\t\tDateCreated, {$shiptofields} LastFour,OrderType) values \n\t\t\t\t( {$ar['Status']}, {$vars['DealerID']}, {$vars['BSVKeyID']}, '{$ar['PONumber']}', now(),\n\t\t\t\t{$shiptovals} '{$ar['LastFour']}',{$ar['OrderType']} )\n\t\t\t\t"; } else { //if we do have a purchase order we need to determine if its ok to update it or not //and return error if its not. $row = $db->sql_fetchrow($result); $poid = $row['POID']; //08.21.2015 ghh - if the status is greater than 2 it means the supplier has already //started pulling the order and we can no longer update it. In this case we're going //to die and return error if ($row['Status'] > 2) { RestLog("Purchase has already been pulled by supplier {$ar['PONumber']}\n"); RestUtils::sendResponse(409, "Order has already been pulled by supplier"); //Internal Server Error return false; } //if we reach here then it must be ok to update the purchase order data so will build the //query here $query = "update PurchaseOrders set "; if ($ar['ShipToAddress1'] != '') { if ($ar['ShipToFirstName'] != '') { $query1 .= "ShipToFirstName='{$ar['ShipToFirstName']}',"; } if ($ar['ShipToLastName'] != '') { $query1 .= "ShipToLastName='{$ar['ShipToLastName']}',"; } if ($ar['ShipToCompany'] != '') { $query1 .= "ShipToCompany='{$ar['ShipToCompany']}',"; } if ($ar['ShipToAddress1'] != '') { $query1 .= "ShipToAddress1='{$ar['ShipToAddress1']}',"; } if ($ar['ShipToAddress2'] != '') { $query1 .= "ShipToAddress2='{$ar['ShipToAddress2']}',"; } if ($ar['ShipToCity'] != '') { $query1 .= "ShipToCity='{$ar['ShipToCity']}',"; } if ($ar['ShipToState'] != '') { $query1 .= "ShipToState='{$ar['ShipToState']}',"; } if ($ar['ShipToZip'] != '') { $query1 .= "ShipToZip='{$ar['ShipToZip']}',"; } if ($ar['ShipToCountry'] != '') { $query1 .= "ShipToCountry='{$ar['ShipToCountry']}',"; } if ($ar['ShipToPhone'] != '') { $query1 .= "ShipToPhone='{$ar['ShipToPhone']}',"; } if ($ar['ShipToEmail'] != '') { $query1 .= "ShipToEmail='{$ar['ShipToEmail']}',"; } } if ($ar['PaymentMethod'] != '') { $query1 .= "PaymentMethod={$ar['PaymentMethod']},"; } if ($ar['LastFour'] != '') { $query1 .= "LastFour='{$ar['LastFour']}',"; } if ($ar['ShipMethod'] != '') { $query1 .= "ShipMethod='{$ar['ShipMethod']}',"; } //if we are actually updating the PO then we're also going ot update the //poreceiveddate if ($query1 != '') { $query1 .= " DateLastModified=now() "; $query .= "{$query1} where DealerID={$vars['DealerID']} and PONumber='{$ar['PONumber']}'"; } else { $query = ''; } } //08.21.2015 ghh - now we execute either of the two queries above to update or insert //the purchase order itself. if ($query != '') { if (!($result = $db->sql_query($query))) { RestLog("Error 16523 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16523 - There was a problem attempting to insert/update the PO"); return false; } } //if we don't already have a poid then we must have done an insert so we'll grab it now if (!$poid > 0) { $poid = $db->sql_nextid($result); } ####################################################PARTS########################################### //now that the purchase order has been updated we'll next start taking a look //at the items and units arrays //08.21.2015 rch - we need to loop through each item that is passed in and evaluate whether or not //we are inserting the po or updating the po $i = 0; foreach ($ar['Items'] as $value => $key) { //08.21.2015 rch - first we need to see if the item is already on the order $query = "select POItemID, Quantity \n\t\t\t\t\tfrom PurchaseOrderItems\n\t\t\t\t\twhere POID='{$poid}' and ItemNumber = '{$key['ItemNumber']}'\n\t\t\t\t\tand VendorID = '{$key['VendorID']}'"; if (!($result = $db->sql_query($query))) { RestLog("Error 16524 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16524 - There was an error locating purchase order items"); return false; } //08.21.2015 rch - we want to make sure that we have a partnumber and vendorid //before attempting to insert. if ($key['ItemNumber'] != '' && $key['VendorID'] != '') { //08.21.2015 ghh - before we bother inserting the item we're going to first grab some //details from items so we can build up our response. $query = "select ItemID, NLA, CloseOut, PriceCode, Category, SupersessionID, \n\t\t\t\t\tMSRP, Cost\n\t\t\t\t\tfrom\n\t\t\t\t\tItems where ItemNumber='{$key['ItemNumber']}' and VendorID={$key['VendorID']}"; if (!($itemresult = $db->sql_query($query))) { RestLog("Error 16526 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16526 - There was an error locating the order item"); return false; } $itemrow = $db->sql_fetchrow($itemresult); if ($db->sql_numrows($itemresult) == 0) { RestLog("Error 16545 The ItemNumber or VendorID you sent are not valid"); RestUtils::sendResponse(500, "16545 - The Item Number or VendorID passed are invalid"); return false; } //now lets see if we can calculate the cost for the current dealer $cost = getItemCost($itemrow['ItemID'], $vars['DealerID'], $itemrow['PriceCode'], $itemrow['Cost'], $itemrow['MSRP']); } else { RestLog("{$row['PONumber']} is missing a vendor id\n"); RestUtils::sendResponse(409, "{$key['ItemNumber']} is missing a vendor id"); return false; } //08.21.2015 rch - if we enter here,the partnumber does not exist on the po if ($db->sql_numrows($result) == 0) { //08.21.2015 ghh - make sure the non required fields have a value if ($key['FillStatus'] == '') { $key['FillStatus'] = 0; } if ($key['OrderType'] == '') { $key['OrderType'] = 2; } $query = "insert into PurchaseOrderItems (POItemID,POID,ItemNumber,Quantity,\n\t\t\t\t\t FillStatus,ItemID,VendorID) values ( '','{$poid}','{$key['ItemNumber']}',{$key['Qty']},\n\t\t\t\t\t {$key['FillStatus']},{$itemrow['ItemID']}, {$key['VendorID']})"; } else { //08.21.2015 rch - if we enter here,the item is already in the table and just needs to be //updated $row = $db->sql_fetchrow($result); //08.21.2015 rch - here we are updating the purchase order items table $query = "update PurchaseOrderItems set "; if ($key['Qty'] != '') { $query1 = "Quantity={$key['Qty']}"; } if ($query1 != '') { $query .= "{$query1} where POItemID={$row['POItemID']}"; } else { $query = ''; } } //08.21.2015 rch - now we need to execute the query if ($query != '') { if (!($result = $db->sql_query($query))) { RestLog("Error 16525 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16525 - There was a problem attempting to insert/update the PO"); //Internal Server Error return false; } //08.24.2015 ghh - update the PO with the current time for last modified date $query = "update PurchaseOrders set DateLastModified=now() where POID = {$poid}"; if (!($result = $db->sql_query($query))) { RestLog("Error 16548 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16548 - There was a problem updating the last modified date"); //Internal Server Error return false; } } //08.21.2015 ghh - now we need to figure out what our current inventory is //minus any items already on orders so that we pass back a fairly reasonable //backorder response $query = "select (ifnull(sum(p1.Quantity), 0) - ifnull(sum(p2.QtyShipped),0)) as qty \n\t\t\t\t\tfrom PurchaseOrderItems p1 \n\t\t\t\t\tleft outer join PurchaseOrderShipped p2 on p1.POItemID=p2.POItemID \n\t\t\t\t\twhere ItemID={$itemrow['ItemID']}"; if (!($qtyresult = $db->sql_query($query))) { RestLog("Error 16529 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16529 - There was an error getting total on order"); return false; } $qtyrow = $db->sql_fetchrow($qtyresult); $qtyonorder = $qtyrow['qty']; $query = "select sum( Qty ) as Qty from ItemStock where ItemID={$itemrow['ItemID']}"; if (!($qtyresult = $db->sql_query($query))) { RestLog("Error 16530 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16530 - There was an error getting total stock qty"); return false; } $qtyrow = $db->sql_fetchrow($qtyresult); $qtyinstock = $qtyrow['Qty']; //08.21.2015 ghh - now we have all of our return information and have updated or //inserted into the items list for the purchase order so we only need to build our //response now. $items[$i]['VendorID'] = $key['VendorID']; $items[$i]['ItemNumber'] = $key['ItemNumber']; $items[$i]['Superseded'] = $itemrow['SupersessionID']; $items[$i]['NLA'] = $itemrow['NLA']; $items[$i]['Closeout'] = $itemrow['CloseOut']; $items[$i]['MSRP'] = $itemrow['MSRP']; $items[$i]['Cost'] = $cost; if ($qtyinstock - $qtyonorder < 0) { $items[$i]['BackorderQty'] = abs($qtyinstock - $qtyonorder); } else { $items[$i]['BackorderQty'] = 0; } $i++; } $rst['PONumber'] = $ar['PONumber']; $rst['InternalID'] = $poid; $rst['DealerKey'] = $vars['DealerKey']; $rst['Items'] = $items; ########################################UNITS################################### //08.25.2015 ghh - this section deals with unit purchase orders $i = 0; foreach ($ar['Units'] as $value => $key) { $key['ModelNumberNoFormat'] = preg_replace('/[^a-zA-Z0-9]/', '', $key['ModelNumber']); //strip formatting. //08.21.2015 rch - first we need to see if the item is already on the order $query = "select POUnitID\n\t\t\t\t\tfrom PurchaseOrderUnits\n\t\t\t\t\twhere POID='{$poid}' and ModelNumber = '{$key['ModelNumber']}'\n\t\t\t\t\tand VendorID = '{$key['VendorID']}'"; if (!($result = $db->sql_query($query))) { RestLog("Error 16549 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16549 - There was an error locating purchase order unit"); return false; } //08.21.2015 rch - we want to make sure that we have a partnumber and vendorid //before attempting to insert. if ($key['ModelNumberNoFormat'] != '' && $key['VendorID'] != '') { if (isset($key['Year'])) { $year = $key['Year']; } else { $year = 0; } //08.21.2015 ghh - before we bother inserting the item we're going to first grab some //details from items so we can build up our response. $query = "select ModelID, NLA, CloseOut, Cost, OrderCode \n\t\t\t\t\tMSRP from UnitModel \n\t\t\t\t\twhere ModelNumberNoFormat='{$key['ModelNumberNoFormat']}' and VendorID={$key['VendorID']}\n\t\t\t\t\tand Year={$year}"; if (!($unitresult = $db->sql_query($query))) { RestLog("Error 16560 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16560 - There was an error locating the order model"); return false; } $unitrow = $db->sql_fetchrow($unitresult); if ($db->sql_numrows($unitresult) == 0) { RestLog("Error 16561 The Unit Model you sent is not valid"); RestUtils::sendResponse(500, "16561 - The Model Number or VendorID passed are invalid"); return false; } //now lets see if we can calculate the cost for the current dealer $cost = getUnitCost($unitrow['ModelID'], $vars['DealerID'], $unitrow['Cost']); } else { RestLog("Error 16563 {$row['PONumber']} is missing a vendor id\n"); RestUtils::sendResponse(409, "Error 16563 {$key['ModelNumber']} is missing a vendor id"); return false; } //08.25.2015 ghh - if we have less line items on the PO than the qty we need then //we're going to insert a few more rows until they match. if ($db->sql_numrows($result) < $key['Qty']) { for ($i = 0; $i < $key['Qty'] - $db->sql_numrows($result); $i++) { $query = "insert into PurchaseOrderUnits (POID,ModelNumber,\n\t\t\t\t\t ModelID,OrderCode,Year, Colors, VendorID, Cost) values \n\t\t\t\t\t ( '{$poid}','{$key['ModelNumber']}',{$unitrow['ModelID']},'{$unitrow['OrderCode']}',\n\t\t\t\t\t {$year},'{$key['Colors']}', {$key['VendorID']}, '{$cost}')"; if (!($tmpresult = $db->sql_query($query))) { RestLog("Error 16564 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16564 - There was an error trying to add the unit to the order"); return false; } } //08.25.2015 ghh - update the PO with the current time for last modified date $query = "update PurchaseOrders set DateLastModified=now() where POID = {$poid}"; if (!($result = $db->sql_query($query))) { RestLog("Error 16565 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16565 - There was a problem updating the last modified date"); //Internal Server Error return false; } } else { if ($db->sql_numrows($result) > $key['Qty']) { $qtytoremove = $db->sql_numrows($result) - $key['Qty']; $query = "select POUnitID from PurchaseOrderUnits where POID={$poid}\n\t\t\t\t\t\tand ModelID={$unitrow['ModelID']} limit {$qtytoremove}"; if (!($tmpresult = $db->sql_query($query))) { RestLog("Error 16566 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16566 - There was a problem deleting changed models"); //Internal Server Error return false; } while ($tmprow = $db->sql_fetchrow($tmpresult)) { $query = "delete from PurchaseOrderUnits where POUnitID={$tmprow['POUnitID']}"; if (!($tmp2result = $db->sql_query($query))) { RestLog("Error 16567 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16567 - There was a problem deleting changed models"); //Internal Server Error return false; } } //08.25.2015 ghh - update the PO with the current time for last modified date $query = "update PurchaseOrders set DateLastModified=now() where POID = {$poid}"; if (!($result = $db->sql_query($query))) { RestLog("Error 16568 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16568 - There was a problem updating the last modified date"); //Internal Server Error return false; } } } //08.25.2015 ghh - first lets grab total qty for the current model $query = "select sum(Qty) as Qty from UnitModelStock where ModelID={$unitrow['ModelID']}"; if (!($qtyresult = $db->sql_query($query))) { RestLog("Error 16570 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16570 - There was an error getting total instock"); return false; } $tmprow = $db->sql_fetchrow($qtyresult); $stockqty = $tmprow['Qty']; $query = "select count(POUnitID) as Qty from PurchaseOrderUnits \n\t\t\t\twhere ModelID={$unitrow['ModelID']} and SerialVin is null"; if (!($qtyresult = $db->sql_query($query))) { RestLog("Error 16571 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16571 - There was an error getting total instock"); return false; } $tmprow = $db->sql_fetchrow($qtyresult); $orderqty = $tmprow['Qty']; //08.21.2015 ghh - now we have all of our return information and have updated or //inserted into the items list for the purchase order so we only need to build our //response now. $units[$i]['VendorID'] = $key['VendorID']; $units[$i]['ModelNumber'] = $key['ModelNumber']; $units[$i]['NLA'] = $unitrow['NLA']; $units[$i]['Closeout'] = $unitrow['CloseOut']; $units[$i]['MSRP'] = $unitrow['MSRP']; $units[$i]['Cost'] = $cost; if ($stockqty - $onorderqty < 0) { $units[$i]['BackorderQty'] = abs($stockqty - $onorderqty); } else { $units[$i]['BackorderQty'] = 0; } $i++; } $rst['Units'] = $units; RestLog("Successful Request\n"); //08.10.2012 naj - return code 200 OK. RestUtils::sendResponse(200, json_encode(stripHTML($rst))); return true; }
if ($gate != 0) { $sql = "UPDATE {$db_prefix}bookings SET bkDatePaymentConfirmed = '" . date('Y-m-d') . "', bkPayOnGate = 1, bkAmountPaid = {$amountpaid}, bkAmountExpected = {$amountexpected} " . "WHERE bkID = " . $iBookingID; } else { $sql = "UPDATE {$db_prefix}bookings SET bkPayOnGate = 0 WHERE bkID = " . $iBookingID; } //Run UPDATE query to set paid date ba_db_query($link, $sql); } } } $playermeal = getItemCost('meal', 'player', $eventid); $monstermeal = getItemCost('meal', 'monster', $eventid); $staffmeal = getItemCost('meal', 'staff', $eventid); $playerticket = getItemCost('ticket', 'player', $eventid); $monsterticket = getItemCost('ticket', 'monster', $eventid); $staffticket = getItemCost('ticket', 'staff', $eventid); echo '<script type="text/javascript">'; echo "\n\tfunction changeAmounts(id, bookingtype)\n\t{\n\t\tvar playermeal = {$playermeal};\n\t\tvar monstermeal = {$monstermeal};\n\t\tvar staffmeal = {$staffmeal};\n\t\tvar playerticket = {$playerticket}\n\t\tvar monsteticket = {$monsterticket};\n\t\tvar staffticket = {$staffticket};\n\n\t\tvar paid = document.forms[0].elements['chkPayPl' + id].checked;\n\t\tvar meal = document.forms[0].elements['chkMealPl' + id].checked;\n\t\tvar gate = document.forms[0].elements['chkGatePl' + id].checked;\n\t\tvar amount1 = 0;\n\t\tvar amount2 = 0;\n\n\t\tif (bookingtype == 'Staff')\n\t\t{\n\t\t\tamount1 = staffticket;\n\t\t\tamount2 = amount1 + staffmeal;\n\t\t}\n\t\telse if (bookingtype == 'Monster')\n\t\t{\n\t\t\tamount1 = monsterticket;\n\t\t\tamount2 = amount1 + monstermeal;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tamount1 = playerticket;\n\t\t\tamount2 = amount1 + playermeal;\n\t\t}\n\n\t\tamount1 = amount1.toFixed(2);\n\t\tamount2 = amount2.toFixed(2);\n\n\t\tif (meal)\n\t\t{\n\t\t\tdocument.forms[0].elements['txtAmountPaid' + id].value = amount2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdocument.forms[0].elements['txtAmountPaid' + id].value = amount1;\n\t\t}\n\n\t\tif (gate || !paid)\n\t\t{\n\t\t\tdocument.forms[0].elements['txtAmountPaid' + id].value = '0.00';\n\t\t}\n\n\t}\n"; echo "</script>"; //Get list of players booked but not marked as paid $sql = "SELECT plPlayerID, " . "plFirstName, " . "plSurname, " . "bkBookAs, " . "bkDateOOCConfirmed, " . "bkDateICConfirmed, " . "bkDatePaymentConfirmed, " . "bkAmountPaid, " . "bkAmountExpected, " . "bkID, " . "bkMealTicket " . "FROM {$db_prefix}players, {$db_prefix}bookings " . "WHERE plPlayerID = bkPlayerID AND " . "bkDateOOCConfirmed <> '0000-00-00' AND bkDateICConfirmed <> '0000-00-00' AND bkDatePaymentConfirmed = '0000-00-00'" . " AND bkEventID = {$eventid}" . " ORDER BY plPlayerID"; $result = ba_db_query($link, $sql); ?> <script src="../inc/sorttable.js" type="text/javascript"></script> <h1><?php echo TITLE; ?> - Payments Received</h1> <p> <a href = 'admin_manageevent.php?EventID=<?php
function getInventory($vars, $responsetype) { global $db; $ar = $vars; if (empty($ar) || !isset($ar['VendorID']) || !isset($ar['ItemNumber'])) { RestLog("16575 - Insufficient data provided for creating order \n" . print_r($vars, true) . "\n"); RestUtils::sendResponse(400, "16575 - Insufficient data provided"); //Internal Server Error return false; } //now we grab inventory records for the requested item and build up our package to return //to the dealer //08.26.2015 rch - Moving ItemStock,Warehouses,DaysToFullfill to left outer joins //to account for not stocking an item or not putting in warehouse //08.28.2015 ghh - added Weight $query = "select Items.ItemID, Items.MSRP, NLA, CloseOut,\n\t\t\t\tPriceCode, Cost, MAP, Category, WarehouseName, \n\t\t\t\tWarehouseState, Qty, DaysToArrive, Weight\n\t\t\t\tManufItemNumber, ManufName, SupersessionID\n\t\t\t\tfrom Items\n\t\t\t\tleft outer join ItemStock on ItemStock.ItemID = Items.ItemID \n\t\t\t\tleft outer join Warehouses on Warehouses.WarehouseID = ItemStock.WarehouseID\n\t\t\t\tleft outer join DaysToFullfill on DaysToFullfill.WarehouseID = ItemStock.WarehouseID\n\t\t\t\twhere Items.ItemNumber='{$ar['ItemNumber']}' and\n\t\t\t\tItems.VendorID={$ar['VendorID']} and\n\t\t\t\tDaysToFullfill.DealerID={$ar['DealerID']} order by DaysToArrive"; if (!($result = $db->sql_query($query))) { RestLog("Error 16576 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16576 - There was a problem getting inventory information."); //Internal Server Error return false; } $i = 0; $itemid = 0; while ($row = $db->sql_fetchrow($result)) { //grabbing our details on first run through as no sense in grabbing //more than once. if ($itemid == 0) { $itemid = $row['ItemID']; $OrigManufName = $row['ManufName']; $OrigManufNumber = $row['ManufItemNumber']; $NLA = $row['NLA']; $CloseOut = $row['CloseOut']; $MSRP = $row['MSRP']; $Category = $row['Category']; $MAP = $row['MAP']; $Weight = $row['Weight']; //08.28.2015 ghh - } $rst[$i]['WarehouseName'] = $row['WarehouseName']; $rst[$i]['WarehouseState'] = $row['WarehouseState']; $rst[$i]['Qty'] = $row['Qty']; $rst[$i]['DaysToArrive'] = $row['DaysToArrive']; $i++; } if ($itemid > 0) { $item['Warehouses'] = $rst; $item['MSRP'] = $MSRP; if ($itemid > 0) { $item['Cost'] = getItemCost($itemid, $ar['DealerID'], $row['PriceCode'], $row['Cost'], $row['MSRP']); } //08.25.2015 ghh - if BSV asked for full detail then we're also going to send back //images data and other items of interest if ($row['SupersessionID'] > 0) { $query = "select ItemNumber from Items where ItemID={$row['SupersessionID']}"; if (!($tmpresult = $db->sql_query($query))) { RestLog("Error 16578 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16578 - There was a problem retrieving the supersession number"); //Internal Server Error return false; } $tmprow = $db->sql_fetchrow($tmpresult); $item['SupersessionNumber'] = $tmprow['ItemNumber']; } $item['OrigManufName'] = $ManufName; $item['OrigManufNumber'] = $ManufItemNumber; $item['NLA'] = $NLA; $item['Category'] = $Category; $item['MAP'] = $MAP; //08.25.2015 ghh - now we're getting a list of images that may exist for this //item $query = "select * from ItemImages where ItemID={$itemid}"; if (!($result = $db->sql_query($query))) { RestLog("Error 16577 in query: {$query}\n" . $db->sql_error()); RestUtils::sendResponse(500, "16577 - There was a problem retrieving a list of images"); //Internal Server Error return false; } $i = 0; while ($row = $db->sql_fetchrow($result)) { $img[$i]['ImageURL'] = $row['ImageURL']; $img[$i]['ImageSize'] = $row['ImageSize']; $i++; } $item['Images'] = $img; } else { RestLog("Error 16635 The item number being requested doesn't exist\n"); RestUtils::sendResponse(500, "16635 - The Item you requested was not found."); //Internal Server Error return false; } RestLog("Successful Request\n"); //08.10.2012 naj - return code 200 OK. RestUtils::sendResponse(200, json_encode(stripHTML($item))); return true; }
if ($meal > 0) { addItem($iBookingID, 'meal'); } } } } //Get list of players that have confirmed their booking $sql = "SELECT plPlayerID, " . "plFirstName, " . "plSurname, " . "bkBookAs, " . "bkBunkRequested, " . "bkMealTicket, " . "chName, " . "bkDateOOCConfirmed, " . "bkDateICConfirmed, " . "bkDatePaymentConfirmed, " . "bkAmountPaid, " . "bkAmountExpected, " . "bkPayOnGate, " . "bkID " . "FROM {$db_prefix}players " . "LEFT JOIN {$db_prefix}characters ON plPlayerID = chPlayerID " . "INNER JOIN {$db_prefix}bookings ON plPlayerID = bkPlayerID " . "WHERE bkEventID = {$eventid} "; $result = ba_db_query($link, $sql); ?> <script src="../inc/sorttable.js" type="text/javascript"></script> <?php $playermeal = getItemCost('meal', 'player', $eventid); $monstermeal = getItemCost('meal', 'monster', $eventid); $staffmeal = getItemCost('meal', 'staff', $eventid); echo '<script type="text/javascript">'; echo "\r\n\tfunction changeAmounts(id, bookingtype, updateexpected)\r\n\t{\r\n\t\tvar playermeal = {$playermeal};\r\n\t\tvar monstermeal = {$monstermeal};\r\n\t\tvar staffmeal = {$staffmeal};\r\n\r\n\t\tvar meal = document.forms[0].elements['chkPl' + id].checked;\r\n\t\tvar gate = document.forms[0].elements['chkPayOnGate' + id].checked;\r\n\t\tvar amount1 = 0;\r\n\t\tvar amount2 = 0;\r\n\r\n\t\tif (bookingtype == 'Staff')\r\n\t\t{\r\n\t\t\tamount1 = staffmeal;\r\n\t\t}\r\n\t\telse if (bookingtype == 'Monster')\r\n\t\t{\r\n\t\t\tamount1 = monstermeal;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tamount1 = playermeal;\r\n\t\t}\r\n\r\n\t\tamount1 = amount1.toFixed(2);\r\n\r\n\t\tif (updateexpected)\r\n\t\t{\r\n\t\t\tif (meal)\r\n\t\t\t{\r\n\t\t\t\tdocument.forms[0].elements['txtAmountExpected' + id].value = Number(document.forms[0].elements['txtAmountExpected' + id].value) + Number(amount1);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tdocument.forms[0].elements['txtAmountExpected' + id].value -= Number(amount1);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (gate)\r\n\t\t{\r\n\t\t\tdocument.forms[0].elements['txtAmountPaid' + id].value = '0.00';\r\n\t\t}\r\n\t}\r\n"; echo "</script>"; ?> <h1><?php echo TITLE; ?> - Meal Tickets</h1> <p> <a href = 'admin_manageevent.php?EventID=<?php echo $eventinfo['evEventID']; ?> '>Return to event management for - <?php echo htmlentities(stripslashes($eventinfo['evEventName']));