function priority_radio($data) { // code modded from get to post. !!CHECK THIS!! if (table_is_takeaway($_SESSION['sourceid'])) { $output = ' <input type="hidden" name="data[priority]" value=1>'; return $output; } if ((!isset($data['priority']) || !$data['priority']) && $data['category']) { $cat = new category($data['category']); if ($cat->data['priority']) { $data['priority'] = $cat->data['priority']; } elseif ($tmp = get_conf(__FILE__, __LINE__, "default_priority")) { $data['priority'] = $tmp; } } for ($i = 1; $i < 4; $i++) { $chk[$i] = ""; } if (isset($data['priority'])) { $chk[$data['priority']] = "checked"; } $output = ' ' . ucfirst(phr('PRIORITY')) . ': <label for="priority1">1</label><input type="radio" ' . $chk[1] . ' name="data[priority]" id="priority1" value="1"></input> <label for="priority2">2</label><input type="radio" ' . $chk[2] . ' name="data[priority]" id="priority2" value="2"></input> <label for="priority3">3</label><input type="radio" ' . $chk[3] . ' name="data[priority]" id="priority3" value="3"></input> '; return $output; }
function print_orders($sourceid) { /* name: print_orders($sourceid) returns: 0 - no error 1 - no orders to be printed 2 - template parsing error 3 - error setting orders printed other - mysql error number */ $sourceid = $_SESSION['sourceid']; debug_msg(__FILE__, __LINE__, "BEGIN PRINTING"); $query = "SELECT * FROM `orders` WHERE `sourceid`='{$sourceid}' AND `printed` IS NULL AND `suspend`='0' ORDER BY dest_id ASC, priority ASC, associated_id ASC, id ASC"; $res = common_query($query, __FILE__, __LINE__); if (!$res) { return mysql_errno(); } if (!mysql_num_rows($res)) { return ERR_ORDER_NOT_FOUND; } $newassociated_id = ""; $tablenum = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'sources', "name", $sourceid); $tpl_print = new template(); $output['orders'] = ''; $msg = ""; while ($arr = mysql_fetch_array($res)) { $oldassociated_id = $newassociated_id; $newassociated_id = $arr['associated_id']; if (isset($priority)) { $oldpriority = $priority; } else { $oldpriority = 0; } $priority = $arr['priority']; if ($oldassociated_id != "") { $olddestid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $oldassociated_id)); $olddest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $olddestid); $olddestname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $olddestid); } else { $olddestid = 0; } $destid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $newassociated_id)); $dest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $destid); $destname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $destid); $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid); if ($destid != $olddestid || $priority != $oldpriority) { if ($destid != $olddestid && $olddestid != "") { $tpl_print->assign("date", printer_print_date()); $tpl_print->assign("gonow", printer_print_gonow($oldpriority, $dest_language)); $tpl_print->assign("page_cut", printer_print_cut()); // strips the last newline that has been put $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1); if (table_is_takeaway($sourceid)) { $print_tpl_file = 'ticket_takeaway'; } else { $print_tpl_file = 'ticket'; } if ($err = $tpl_print->set_print_template_file($olddestid, $print_tpl_file)) { return $err; } if ($err = $tpl_print->parse()) { $msg = "Error in " . __FUNCTION__ . " - "; $msg .= 'error: ' . $err . "\n"; echo nl2br($msg) . "\n"; error_msg(__FILE__, __LINE__, $msg); return ERR_PARSING_TEMPLATE; } $tpl_print->restore_curly(); $msg = $tpl_print->getOutput(); $tpl_print->reset_vars(); $output['orders'] = ''; $msg = str_replace("'", "", $msg); if ($outerr = print_line($olddestid, $msg)) { return $outerr; } } elseif ($priority != $oldpriority && $oldpriority != "") { $tpl_print->assign("date", printer_print_date()); $tpl_print->assign("gonow", printer_print_gonow($oldpriority, $dest_language)); $tpl_print->assign("page_cut", printer_print_cut()); // strips the last newline that has been put $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1); if (table_is_takeaway($sourceid)) { $print_tpl_file = 'ticket_takeaway'; } else { $print_tpl_file = 'ticket'; } if ($err = $tpl_print->set_print_template_file($destid, $print_tpl_file)) { return $err; } if ($err = $tpl_print->parse()) { $msg = "Error in " . __FUNCTION__ . " - "; $msg .= 'error: ' . $err . "\n"; error_msg(__FILE__, __LINE__, $msg); echo nl2br($msg) . "\n"; return ERR_PARSING_TEMPLATE; } $tpl_print->restore_curly(); $msg = $tpl_print->getOutput(); $tpl_print->reset_vars(); $output['orders'] = ''; $msg = str_replace("'", "", $msg); if ($outerr = print_line($destid, $msg)) { return $outerr; } } if (table_is_takeaway($sourceid)) { $takeaway_data = takeaway_get_customer_data($sourceid); $output['takeaway'] = ucfirst(lang_get($dest_language, 'PRINTS_TAKEAWAY')) . " - "; $output['takeaway'] .= $takeaway_data['takeaway_hour'] . ":" . $takeaway_data['takeaway_minute'] . "\n"; $output['takeaway'] .= $takeaway_data['takeaway_surname'] . "\n"; $tpl_print->assign("takeaway", $output['takeaway']); } $output['table'] = ucfirst(lang_get($dest_language, 'PRINTS_TABLE')) . ": " . $tablenum; $tpl_print->assign("table", $output['table']); $user = new user($_SESSION['userid']); $output['waiter'] = ucfirst(lang_get($dest_language, 'PRINTS_WAITER')) . ": " . $user->data['name']; $tpl_print->assign("waiter", $output['waiter']); $output['priority'] = ucfirst(lang_get($dest_language, 'PRINTS_PRIORITY')) . ": " . $priority . "\n"; $tpl_print->assign("priority", $output['priority']); $output['people'] = ucfirst(lang_get($dest_language, 'PRINTS_PEOPLE')) . ": " . table_people_number($sourceid) . "\n"; $tpl_print->assign("people", $output['people']); $table = new table($sourceid); $table->fetch_data(true); if ($cust_id = $table->data['customer']) { $cust = new customer($cust_id); $output['customer'] = ucfirst(lang_get($dest_language, 'CUSTOMER')) . ": " . $cust->data['surname'] . ' ' . $cust->data['name']; $tpl_print->assign("customer_name", $output['customer']); $output['customer'] = $cust->data['address']; $tpl_print->assign("customer_address", $output['customer']); $output['customer'] = $cust->data['zip']; $tpl_print->assign("customer_zip_code", $output['customer']); $output['customer'] = $cust->data['city']; $tpl_print->assign("customer_city", $output['customer']); $output['customer'] = ucfirst(lang_get($dest_language, 'VAT_ACCOUNT')) . ": " . $cust->data['vat_account']; $tpl_print->assign("customer_vat_account", $output['customer']); } } $output['orders'] .= printer_print_row($arr, $destid); $printed_orders[] = $arr['id']; if ($newassociated_id != $oldassociated_id) { // if we're in this function, it means that we changed associated_id id // and also that mods have been printed on the same sheet if (CONF_PRINT_BARCODES && $arr['dishid'] != MOD_ID) { $output['orders'] .= print_barcode($newassociated_id); } } if (CONF_PRINT_BARCODES && $arr['dishid'] != MOD_ID) { $output['orders'] .= print_barcode($newassociated_id); } $tpl_print->assign("orders", $output['orders']); } $destid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $newassociated_id)); $dest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $destid); $destname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $destid); $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid); if (CONF_PRINT_BARCODES) { $tpl_print->assign("barcode", print_barcode($newassociated_id)); } $tpl_print->assign("date", printer_print_date()); $tpl_print->assign("gonow", printer_print_gonow($priority, $dest_language)); $tpl_print->assign("page_cut", printer_print_cut()); // strips the last newline that has been put $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1); if (table_is_takeaway($sourceid)) { $print_tpl_file = 'ticket_takeaway'; } else { $print_tpl_file = 'ticket'; } if ($err = $tpl_print->set_print_template_file($destid, $print_tpl_file)) { return $err; } if ($err = $tpl_print->parse()) { $err_msg = "Error in " . __FUNCTION__ . " - "; $err_msg .= 'error: ' . $err . "\n"; error_msg(__FILE__, __LINE__, $err_msg); echo nl2br($err_msg) . "\n"; return ERR_PARSING_TEMPLATE; } $tpl_print->restore_curly(); $msg = $tpl_print->getOutput(); $tpl_print->reset_vars(); $output['orders'] = ''; $msg = str_replace("'", "", $msg); if ($outerr = print_line($destid, $msg)) { return $outerr; } foreach ($printed_orders as $val) { if ($err = print_set_printed($val)) { return $err; } } // there was an error setting orders as printed if ($err) { return ERR_ORDER_NOT_SET_AS_PRINTED; } return 0; }
function bill_type_selection($sourceid) { /* sets the bill/invoice type in waiter's session environment types: 1. bill 2. invoice 3. receipt */ for ($i = 1; $i <= 3; $i++) { $chk[$i] = ''; } if (isset($_SESSION['type'])) { $type = $_SESSION['type']; } else { $type = 1; // if type is not set, it automatically sets it to 1; if (table_is_takeaway($_SESSION['sourceid'])) { $type = 3; // if type is not set and table is takeaway type is set to 3; } $_SESSION['type'] = $type; } // Next is a micro-form to set a discount in percent value $output = ' <form action="orders.php" NAME="form_type" method=post> <input type="hidden" name="command" VALUE="bill_print"> <INPUT TYPE="HIDDEN" NAME="keep_separated" VALUE="1"> <div align="center"> ' . ucfirst(phr('ACCOUNT')) . ': <table> <tr> <td rowspan="3">' . ucfirst(phr('TYPE')) . ':</td> <td><input type="radio" name="type" value="1" ' . $chk[1] . '> ' . ucfirst(phr('BILL')) . '</td></tr> <tr> <td><input type="radio" name="type" value="2" ' . $chk[2] . '> ' . ucfirst(phr('INVOICE')) . '</td> </tr> <tr> <td><input type="radio" name="type" value="3" ' . $chk[3] . '> ' . ucfirst(phr('RECEIPT')) . '</td> </tr> </table> </div> </form> '; $table = new table($_SESSION['sourceid']); $table->fetch_data(true); if ($cust_id = $table->data['customer']) { $cust = new customer($cust_id); $tmp = ucphr('CUSTOMER') . ': ' . $cust->data['surname']; $tmp .= ' <a href="orders.php?command=customer_search">' . ucphr('EDIT') . '</a>/'; $tmp .= '<a href="orders.php?command=set_customer&data[customer]=0">' . ucphr('REMOVE') . '</a>'; $tmp .= '<br/>'; } else { $tmp = '<a href="orders.php?command=customer_search">' . ucfirst(phr('INSERT_CUSTOMER_DATA')) . '</a><br/>'; } $output .= $tmp; return $output; }
orders_service_fee_questions(); } else { orders_list(); } break; case 'dissociate': $err = table_dissociate(); status_report('DISSOCIATION', $err); if (!$err) { $redirect = redirect_waiter('tables.php'); $tpl->append('scripts', $redirect); } orders_list(); break; case 'set_customer': if (table_is_takeaway($_SESSION['sourceid'])) { $err = takeaway_set_customer_data($_SESSION['sourceid'], $start_data); status_report('TAKEAWAY_DATA', $err); } else { $err = table_set_customer($_SESSION['sourceid'], $start_data); status_report('CUSTOMER', $err); } if (isset($_SESSION['select_all'])) { $err = bill_select(); if ($err) { error_display($err); } } else { orders_list(); } break;
function toplist_show() { global $tpl; $_SESSION['order_added'] = 0; $query = "SELECT * FROM `last_orders`"; $res = common_query($query, __FILE__, __LINE__); if (!$res) { return ERR_MYSQL; } if (!mysql_num_rows($res)) { return 1; } while ($arr = mysql_fetch_array($res)) { $dishid = $arr['dishid']; if ($dishid == MOD_ID || $dishid == SERVICE_ID) { continue; } if (!isset($toplist[$dishid])) { $toplist[$dishid] = 0; } $toplist[$dishid]++; } if (!is_array($toplist)) { return 0; } arsort($toplist); reset($toplist); $chk[1] = ""; $chk[2] = ""; $chk[3] = ""; $tmp = ' <form action="orders.php" method="POST" name="toplist_form"> <INPUT TYPE="HIDDEN" NAME="command" VALUE="create"> <INPUT TYPE="HIDDEN" NAME="dishid" VALUE="0">'; if (CONF_TOPLIST_HIDE_QUANTITY) { $tmp .= ' <INPUT TYPE="HIDDEN" NAME="data[quantity]" VALUE="1">'; } if (CONF_TOPLIST_HIDE_PRIORITY) { $tmp .= ' ' . ucfirst(phr('PRIORITY')) . ': <input type="radio" ' . $chk[1] . ' name="data[priority]" value=1>1 <input type="radio" ' . $chk[2] . ' name="data[priority]" value=2>2 <input type="radio" ' . $chk[3] . ' name="data[priority]" value=3>3'; } $tmp .= ' <table bgcolor="' . COLOR_TABLE_GENERAL . '"> <tbody> <tr align="center"> <td colspan="4"> <b>' . ucfirst(phr('TOPLIST')) . '(' . ucfirst(phr('LASTS')) . ' ' . CONF_TOPLIST_SAVED_NUMBER . ')</b> <a href="orders.php?command=set_show_toplist"> <img src="' . ROOTDIR . '/images/waiter/fileclose.png" border="0" alt="' . ucphr('HIDE_TOPLIST') . '"> </a> </td> </tr> '; $i = 0; while ($i < get_conf(__FILE__, __LINE__, "top_list_show_top")) { if (list($key, $value) = each($toplist)) { $category = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', 'category', $key); $bgcolor = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'categories', 'htmlcolor', $category); $tmp .= ' <tr bgcolor="' . $bgcolor . '">'; if (table_is_takeaway($_SESSION['sourceid'])) { $tmp .= ' <input type="hidden" name="data[priority]" value=1>'; } elseif (!$i && !CONF_TOPLIST_HIDE_PRIORITY) { $tmp .= ' <td rowspan="' . (get_conf(__FILE__, __LINE__, "top_list_show_top") + 1) . '" bgcolor="' . COLOR_TABLE_GENERAL . '"> 1<input type="radio" ' . $chk[1] . ' name="data[priority]" value=1><br /> 2<input type="radio" ' . $chk[2] . ' name="data[priority]" value=2><br /> 3<input type="radio" ' . $chk[3] . ' name="data[priority]" value=3><br /> </td>'; } if (!$i && !CONF_TOPLIST_HIDE_QUANTITY) { $qtydata['nolabel'] = 1; $tmp .= ' <td rowspan="' . (get_conf(__FILE__, __LINE__, "top_list_show_top") + 1) . '" bgcolor="' . COLOR_TABLE_GENERAL . '"> ' . quantity_list($qtydata) . ' </td>'; } $dishobj = new dish($key); $dishname = $dishobj->name($_SESSION['language']); $tmp .= ' <td> ' . $value . ' </td>'; $tmp .= ' <td valign="middle" onclick="order_select(\'' . $key . '\',\'toplist_form\');"> <a href="#" onclick="JavaScript:order_select(\'' . $key . '\',\'toplist_form\'); return false;"> ' . $dishname . ' </a> </td>'; $tmp .= ' </tr>'; } $i++; } $tmp .= ' </table> </form>'; $tpl->assign('toplist', $tmp); return 0; }
function table_ask_association_pos() { global $tpl; if (table_is_takeaway($_SESSION['sourceid'])) { $err = table_associate(); status_report('ASSOCIATION', $err); orders_list(); return 0; } $tpl->set_waiter_template_file('question'); $tmp = ' <table> <tr> <td width=35> <a href="tables.php"><img src="' . IMAGE_MENU . '" alt="' . ucfirst(phr('BACK_TO_TABLES')) . '" border=0></a> </td> <td width=35> </td> <td width=35> </td> <td width=35> </td> <td width=35>'; if (get_conf(__FILE__, __LINE__, "service_fee_use")) { $tmp .= ' <a href="orders.php?command=service_fee"><img src="' . IMAGE_NO . '" alt="' . ucfirst(phr('NO')) . '" border=0></a>'; } else { $tmp .= ' <a href="orders.php"><img src="' . IMAGE_NO . '" alt="' . ucfirst(phr('NO')) . '" border=0></a>'; } $tmp .= ' </td> <td width=35> <a href="orders.php?command=associate"><img src="' . IMAGE_OK . '" alt="' . ucfirst(phr('YES')) . '" border=0></a> </td> </tr> </table> '; $tpl->assign('navbar', $tmp); $tmp = ucfirst(phr('ASSOCIATE_ASK')) . '<br/>' . "\n"; $tpl->assign('question', $tmp); return 0; }