Created
February 28, 2014 17:43
-
-
Save jdkealy/9275784 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#$result = shell_exec("C:\cygwin\bin\bash.exe --login -c '/cygdrive/c/cygwin/bin/convert.exe --version'"); | |
$result = shell_exec("cp virtual_receipt.txt virtual_receipt_use.txt"); | |
$file = 'micros/virtual_receipt.txt'; | |
$lockfile = 'micros/virtual_receipt_lock.txt'; | |
if (!copy($file, $lockfile)) { | |
echo "failed to copy $file...\n"; | |
} | |
$file = file($lockfile); | |
/* mappings */ | |
$items_to_micros_items = array( | |
"housepizza" => "pizza", | |
"redpizza" => "pizza", | |
"zucchini" => "pizza", | |
"cheesepiz" => "pizza", | |
"posaip" => "pizza", | |
"marinarapizza" => "pizza", | |
"marinarapiz" => "pizza", | |
"mushroompizza" => "pizza", | |
"shrimppizza" => "pizza", | |
"meatballpizza" => "pizza", | |
"cucumber" => "salad", | |
"flambepizza" => "pizza", | |
"hamapp" => "pizza", | |
"hawaiianpizza" => "pizza", | |
"potatopizza" => "pizza", | |
"americanode" => "coffee" | |
); | |
/* functions */ | |
function stripAndLower($var) | |
{ | |
$zname_clean = preg_replace('/\s*/', '', $var); | |
$zname_clean = strtolower($zname_clean); | |
return $zname_clean; | |
} | |
function stripAndLowerAndRemoveNums($var){ | |
$var = stripAndLower($var); | |
return preg_replace('/[^\\/\-a-z\s]/i', '', $var); | |
} | |
function isNewOrder($var) | |
{ | |
return stripAndLower($var) == "takeout" || stripAndLower($var) == "dining"; | |
} | |
function isOrderId($var) | |
{ | |
$pattern = '/Chk/'; | |
return preg_match($pattern, $var); | |
} | |
function getFireTimeItem($var) | |
{ | |
var_dump($items_to_micros_items); | |
return $items_to_micros_items[$var]; | |
} | |
function getFireTimeFromConfg($var) | |
{ | |
/* | |
PIZZA 600 seconds | |
BREAKFAST PIZZA 480 seconds | |
TO SHARE 300 seconds | |
SALAD 240 seconds | |
SOUP 180 seconds | |
VEGETABLES 240 seconds | |
GELATO PANINI 240 seconds | |
BOMBOLONI 240 seconds | |
PARFAITS 300 seconds | |
ALL COFFE DRINKS 240 seconds | |
ALL TEA DRINKS 240 seconds | |
SODA/JUICE 180 seconds | |
*/ | |
} | |
function getFireTime($var) | |
{ | |
return getFireTimeItem($var); | |
}; | |
function getOrderType($var) | |
{ | |
return $var; | |
} | |
function isOrderItem($var) | |
{ | |
$arr = ["housepizza", "redpizza", "zucchini", "pepperonipi", "cheesepiz", "posaip", "marinarapiz", "pepperonipizza", "mushroompiz", "shrimppizza", "meatballpizza", "cucumber", "mushroompizza", "flambepizza", "marinarapizza", "hamapp", "sausagepizza", "cheesepizza", "hawaiianpizza", "potatopizza", "americanode"]; | |
return in_array($var, $arr); | |
} | |
function hasBeenRead($var){ | |
} | |
for($x=0; $x < count($file); $x++){ | |
/* IS IT A NEW ORDER? */ | |
$node = $file[$x]; | |
if(isNewOrder($node)){ | |
// set the flag as new order | |
$new_order = true; | |
// set the contents | |
$order_contents = []; | |
// get the current order type | |
$order_type = getOrderType($node); | |
} else { | |
$new_order = false; | |
} | |
if(isOrderId($node)){ | |
$order_id = $node; | |
} | |
if(isOrderItem(stripAndLowerAndRemoveNums($node))){ | |
array_push($order_contents, getFireTime(stripAndLowerAndRemoveNums($node))); | |
} | |
//var_dump($order_contents); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment