function list_search($search) { $query = ''; $table = $this->table; $query = "SELECT\n\t\t\t\t{$table}.`id`,\n\t\t\t\t{$table}.`name`,\n\t\t\t\tRPAD('" . ucphr('VAT_RATES') . "',30,' ') as `table`,\n\t\t\t\t" . TABLE_VAT_RATES . " as `table_id`\n\t\t\t\tFROM `{$table}`\n\t\t\t\tWHERE {$table}.`name` LIKE '%{$search}%'\n\t\t\t\t"; return $query; }
function search($id = 0) { $this->db = 'common'; $this->title = ucphr('SEARCH_RESULTS'); $this->file = ROOTDIR . '/admin/admin.php'; $this->fields_width = array('name' => '85%'); $this->fields_names = array('id' => ucphr('ID'), 'name' => ucphr('NAME'), 'table' => ucphr('TYPE')); $this->hide = array('table_id'); $this->disable_new = true; $this->disable_mass_delete = true; }
function currencies($id = 0) { $this->db = 'common'; $this->table = 'currencies'; $this->id = $id; $this->title = ucphr('EXCHANGE'); $this->file = ROOTDIR . '/admin/admin.php'; $this->fields_names = array('id' => ucphr('ID'), 'name' => ucphr('NAME'), 'rate' => ucphr('VALUE'), 'active' => ucphr('ACTIVE')); $this->fields_width = array('name' => '95%', 'rate' => '5%'); $this->fetch_data(); }
function stock_ingredient_quantity($id = 0) { $this->db = 'common'; $this->table = 'stock_ingredient_quantities'; $this->id = $id; $this->fields_names = array('id' => ucphr('ID')); $this->title = ucphr('INGREDIENTS'); $this->file = ROOTDIR . '/include/stock/index.php'; $this->fields_width = array('name' => '80%'); $this->disable_mass_delete = true; $this->fetch_data(); }
function category($id = 0) { $this->db = 'common'; $this->table = $GLOBALS['table_prefix'] . 'categories'; $this->id = $id; $this->flag_delete = true; $this->fields_names = array('id' => ucphr('ID'), 'name' => ucphr('NAME'), 'vat_rate' => ucphr('VAT_RATE'), 'priority' => ucphr('PRIORITY'), 'image' => ucphr('IMAGE')); $this->fields_width = array('name' => '80%', 'vat_rate' => '20%'); $this->title = ucphr('CATEGORIES'); $this->file = ROOTDIR . '/admin/admin.php'; $this->fetch_data(); }
function autocalc($id = 0) { $this->db = 'common'; $this->table = 'autocalc'; $this->id = $id; $this->title = ucphr('AUTOCALC_LEVELS'); $this->file = ROOTDIR . '/admin/admin.php'; $this->fields_names = array('id' => ucphr('ID'), 'name' => ucphr('NAME'), 'quantity' => ucphr('QUANTITY'), 'price' => ucphr('PRICE')); $this->fields_width = array('name' => '100%'); $this->disable_mass_delete = true; $this->fetch_data(); }
function stock_object($id = 0) { $this->db = 'common'; $this->table = 'stock_objects'; $this->id = $id; $this->title = ucphr('STOCK'); $this->referring_name = true; $this->flag_delete = true; $this->fields_names = array('id' => ucphr('ID'), 'name' => ucphr('NAME'), 'ref_type' => ucphr('TYPE'), 'ref_id' => ucphr('INGREDIENT'), 'unit_type' => '', 'quantity' => ucphr('QUANTITY'), 'value' => ucphr('VALUE') . ' [' . country_conf_currency(true) . ']'); $this->fields_width = array('name' => '75%'); $this->hide = array('ref_id'); $this->file = ROOTDIR . '/include/stock/index.php'; $this->disable_new = true; $this->fetch_data(); }
function show_receipt($id) { if (!$id) { return 1; } $table = 'account_mgmt_main'; $query = "SELECT * FROM {$table} WHERE `id`='{$id}'"; $res = mysql_db_query($_SESSION['common_db'], $query); $row = mysql_fetch_array($res); if ($row['annulled']) { switch ($row['type']) { case 4: echo ucphr('RECEIPT_ANNULLED_OK') . ".<br>\n"; break; case 3: echo ucphr('INVOICE_ANNULLED_OK') . ".<br>\n"; break; case 5: echo ucphr('BILL_ANNULLED_OK') . ".<br>\n"; break; } echo GLOBALMSG_RECORD_DELETE_OK_FROM_LOG_MANY_2 . ".<br><br>"; echo "<form name=\"form1\" action=\"receipt.php\" method=\"post\">\n"; echo "<input type=\"hidden\" name=\"command\" value=\"delete\">\n"; echo "<input type=\"hidden\" name=\"delete[" . $id . "]\" value=\"1\">\n"; echo "<input type=\"submit\" value=\"" . GLOBALMSG_RECORD_DELETE . "\">"; echo "</form>\n"; return 0; } $table = 'account_log'; $query = "SELECT * FROM {$table} WHERE `payment`='{$id}'"; $res = mysql_db_query($_SESSION['common_db'], $query); if (!mysql_num_rows($res)) { return 2; } echo "<table bgcolor=\"" . color(-1) . "\">\n"; echo "<thead ><tr>\n\t<td>" . ucfirst(phr('QUANTITY')) . "</a></td>\n\t<td>" . ucfirst(phr('DESCRIPTION')) . "</td>\n\t<td>" . ucfirst(phr('AMOUNT')) . "</td>\n\t</tr></thead>\n\t<tbody>\n"; $i = 0; while ($row = mysql_fetch_array($res)) { if ($row['operation'] == 1) { $ingred = new ingredient($row['ingredient']); $description = " " . ucphr('PLUS') . " " . $ingred->name($_SESSION['language']); unset($ingred); } elseif ($row['operation'] == -1) { $ingred = new ingredient($row['ingredient']); $description = " " . ucphr('MINUS') . " " . $ingred->name($_SESSION['language']); unset($ingred); } else { $dish = new dish($row['dish']); $description = $dish->name($_SESSION['language']); unset($dish); } $total += $row['price']; $color = color($i); echo '<tr bgcolor="', $color, '"> <td>', $row['quantity'], '</td> <td>', $description, '</td> <td align="right">', $row['price'], '</td> </tr> '; $i++; } echo '<tr bgcolor="', color(-1), '"> <td></td> <td>' . ucfirst(phr('TOTAL')) . '</td> <td align="right">', sprintf("%0.2f", $total), '</td> </tr> '; echo "</tbody></table>"; echo "<form name=\"form1\" action=\"receipt.php\" method=\"post\">\n"; echo "<input type=\"hidden\" name=\"command\" value=\"delete\">\n"; echo "<input type=\"hidden\" name=\"delete[" . $id . "]\" value=\"1\">\n"; echo "<input type=\"submit\" value=\"" . GLOBALMSG_RECORD_DELETE . "\">"; echo "</form>\n"; echo "<form name=\"form1\" action=\"receipt.php\" method=\"post\">\n"; echo "<input type=\"hidden\" name=\"command\" value=\"annul\">\n"; echo "<input type=\"hidden\" name=\"annul[" . $id . "]\" value=\"1\">\n"; echo "<input type=\"submit\" value=\"" . ucphr('ANNULL') . "\">"; echo "</form>\n"; }
function input_dish_id($data) { $output = ''; //$output .= ucphr('DISH').': <input onChange="document.order_form.submit()" type="text" name="dishid" id="dishid" value="" size="6" maxlength="6">'; $output .= ucphr('DISH') . ': <input type="text" name="dishid" id="quickdishid" value="" size="6" maxlength="6">'; return $output; }
function print_test_page() { $print_tpl = new template(); $msg = ""; $query = "SELECT * FROM `dests` WHERE `deleted`='0'"; $res_dest = common_query($query, __FILE__, __LINE__); if (!$res_dest) { return ERR_MYSQL; } while ($arr_dest = mysql_fetch_array($res_dest)) { $destid = $arr_dest['id']; $print_tpl->reset_vars(); $print_tpl->string = ' ****************** ' . ucphr('PRINTER_TEST_PAGE') . ' ****************** ' . ucphr('PRINTER_INTERNAL_NAME') . ': {tpl_print_name} ' . ucphr('PRINTING_QUEUE') . ': {tpl_print_queue} ' . ucphr('PRINTING_DRIVER') . ': {tpl_print_driver} ' . ucphr('PRINTING_TEMPLATE') . ': {tpl_print_template} ' . ucphr('DATE') . ': ' . date('d F Y H:i') . ' ****************** ' . ucphr('PRINTER_TEST_PAGE_END') . ' ******************{end}'; // next line is needed to make the template parser leave the line without deleting it, so that it gets to the driver level $print_tpl->assign("end", '{page_cut}'); $print_tpl->assign("tpl_print_queue", $arr_dest['dest']); $print_tpl->assign("tpl_print_name", $arr_dest['name']); $print_tpl->assign("tpl_print_driver", $arr_dest['driver']); $print_tpl->assign("tpl_print_template", $arr_dest['template']); if ($err = $print_tpl->parse()) { $msg = "Error in " . __FUNCTION__ . " - "; $msg .= 'error: ' . $err . "\n"; error_msg(__FILE__, __LINE__, $msg); echo nl2br($msg) . "\n"; return 3; } $print_tpl->restore_curly(); $msg = $print_tpl->getOutput(); $msg = str_replace("'", "", $msg); if ($err = print_line($destid, $msg)) { return $err; } } unset($print_tpl); return 0; }
function customer_edit_form($data) { global $tpl; $query = "SELECT * FROM `customers` WHERE `id`='" . $data['id'] . "'"; $res = common_query($query, __FILE__, __LINE__); if (!$res) { return ERR_MYSQL; } if (!mysql_num_rows($res)) { $msg = ucphr('ERR_NO_CUSTOMER_FOUND'); $msg = '<font color="Red">' . $msg . '</font>'; $tpl->append('messages', $msg); return ''; } $arr = mysql_fetch_array($res); $msg = ' <form action="orders.php" method="post" name="form1"> <input type="hidden" name="command" value="customer_edit"> <input type="hidden" name="data[id]" value="' . $arr['id'] . '"> '; $msg .= customer_form_data($arr); $msg .= '</form> '; return $msg; }
function error_display($number, $silent = false, $level = ERROR_LEVEL_USER) { global $tpl; $tmp = ''; if (!$silent) { $tmp = '<script>$.growl("' . ucphr("Information") . '","<font color="red">' . ucfirst(error_get($number)) . ucphr($name) . ' ' . ucphr('ERROR') . '</font>","' . IMAGE_ERROR . '")</script>'; } $tpl->append('messages', $tmp); if ($level == ERROR_LEVEL_USER) { return 0; } elseif ($level == ERROR_LEVEL_DEBUG) { debug_msg(__FILE__, __LINE__, $msg); } elseif ($level == ERROR_LEVEL_ERROR) { error_msg(__FILE__, __LINE__, $msg); } return 0; }
function list_rows($arr, $row) { global $tpl; global $display; $col = 0; if (!$this->disable_mass_delete) { $display->rows[$row][$col] = '<input type="checkbox" name="delete[]" value="' . $arr['id'] . '">'; $display->width[$row][$col] = '1%'; $col++; } foreach ($arr as $field => $value) { if (isset($this->fields_boolean) && in_array($field, $this->fields_boolean)) { if ($value) { $value = ucfirst(phr('YES')); } else { $value = ucfirst(phr('NO')); } } if (isset($this->allow_single_update) && in_array($field, $this->allow_single_update)) { $link_update_field = $this->link_base . '&command=update_field&data[id]=' . $arr['id'] . '&data[field]=' . $field; if ($this->limit_start) { $link_update_field .= '&data[limit_start]=' . $this->limit_start; } if ($this->orderby) { $link_update_field .= '&data[orderby]=' . $this->orderby; } if ($this->sort) { $link_update_field .= '&data[sort]=' . $this->sort; } $display->links[$row][$col] = $link_update_field; } elseif (method_exists($this, 'form')) { $link = $this->file . '?class=' . get_class($this) . '&command=edit&data[id]=' . $arr['id']; } else { $link = ''; } $display->rows[$row][$col] = $value; if ($link && $field == 'name') { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } if ($field == 'level') { $user = new user($arr['id']); $user->get_level(); if ($user->level[USER_BIT_WAITER]) { $value = ucphr('YES'); } else { $value = ucphr('NO'); } $display->rows[$row][$col] = $value; $link = $link_update_field . '&data[subfield]=' . USER_BIT_WAITER; if ($link) { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } $col++; if ($user->level[USER_BIT_CASHIER]) { $value = ucphr('YES'); } else { $value = ucphr('NO'); } $display->rows[$row][$col] = $value; $link = $link_update_field . '&data[subfield]=' . USER_BIT_CASHIER; if ($link) { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } $col++; if ($user->level[USER_BIT_STOCK]) { $value = ucphr('YES'); } else { $value = ucphr('NO'); } $display->rows[$row][$col] = $value; $link = $link_update_field . '&data[subfield]=' . USER_BIT_STOCK; if ($link) { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } $col++; if ($user->level[USER_BIT_CONTACTS]) { $value = ucphr('YES'); } else { $value = ucphr('NO'); } $display->rows[$row][$col] = $value; $link = $link_update_field . '&data[subfield]=' . USER_BIT_CONTACTS; if ($link) { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } $col++; if ($user->level[USER_BIT_MENU]) { $value = ucphr('YES'); } else { $value = ucphr('NO'); } $display->rows[$row][$col] = $value; $link = $link_update_field . '&data[subfield]=' . USER_BIT_MENU; if ($link) { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } $col++; if ($user->level[USER_BIT_USERS]) { $value = ucphr('YES'); } else { $value = ucphr('NO'); } $display->rows[$row][$col] = $value; $link = $link_update_field . '&data[subfield]=' . USER_BIT_USERS; if ($link) { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } $col++; if ($user->level[USER_BIT_ACCOUNTING]) { $value = ucphr('YES'); } else { $value = ucphr('NO'); } $display->rows[$row][$col] = $value; $link = $link_update_field . '&data[subfield]=' . USER_BIT_ACCOUNTING; if ($link) { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } $col++; if ($user->level[USER_BIT_TRANSLATION]) { $value = ucphr('YES'); } else { $value = ucphr('NO'); } $display->rows[$row][$col] = $value; $link = $link_update_field . '&data[subfield]=' . USER_BIT_TRANSLATION; if ($link) { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } $col++; if ($user->level[USER_BIT_CONFIG]) { $value = ucphr('YES'); } else { $value = ucphr('NO'); } $display->rows[$row][$col] = $value; $link = $link_update_field . '&data[subfield]=' . USER_BIT_CONFIG; if ($link) { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } $col++; if ($user->level[USER_BIT_MONEY]) { $value = ucphr('YES'); } else { $value = ucphr('NO'); } $display->rows[$row][$col] = $value; $link = $link_update_field . '&data[subfield]=' . USER_BIT_MONEY; if ($link) { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } } $col++; } }
function tables_list_all_pos($cols = 1, $show = 0, $quiet = true) { /* $show possible values: 0 shows all but takeaway 1 shows takeaway 2 shows mine */ $output = ''; if (!$quiet) { $query = "SELECT * FROM `sources`"; $res = common_query($query, __FILE__, __LINE__); if (!$res) { return ''; } if (!mysql_num_rows($res)) { return ucphr('NO_TABLE_FOUND') . "<br/>\n"; } } switch ($show) { case 0: $query = "SELECT `sources`.`id`, `name`, `userid`, `toclose`,`locktouser`, `sources`.`paid`, `orders`.`id` AS `order` FROM `sources` LEFT JOIN `orders` ON `sourceid`=`sources`.`id` WHERE `takeaway` = '0'"; $query .= " AND `visible` = '1'"; $query .= " AND ( `locktouser` = '" . $_SESSION['userid'] . "' ) "; $query .= " AND ( `userid` = '" . $_SESSION['userid'] . "' OR `userid` = '0' )"; $query .= " GROUP BY `sources`.`id` ASC"; $query .= " ORDER BY `sources`.`ordernum` ASC"; break; case 1: $query = "SELECT `sources`.`id`, `name`, `userid`, `toclose`,`locktouser`, `sources`.`paid`, `orders`.`id` AS `order` FROM `sources` LEFT JOIN `orders` ON `sourceid`=`sources`.`id` WHERE `takeaway` = '1'"; $query .= " AND `visible` = '1'"; $query .= " AND ( `locktouser` = '" . $_SESSION['userid'] . "' ) "; $query .= " AND ( `userid` = '" . $_SESSION['userid'] . "' OR `userid` = '0' )"; $query .= " GROUP BY `sources`.`id` ASC"; $query .= " ORDER BY `sources`.`ordernum` ASC"; break; case 2: $query = "SELECT `sources`.`id`, `name`, `userid`, `toclose`,`locktouser`, `sources`.`paid`, `orders`.`id` AS `order` FROM `sources` LEFT JOIN `orders` ON `sourceid`=`sources`.`id` WHERE `userid`='" . $_SESSION['userid'] . "'"; $query .= " AND `visible` = '1'"; $query .= " AND ( `locktouser` = '" . $_SESSION['userid'] . "' ) "; $query .= " AND ( `userid` = '" . $_SESSION['userid'] . "' OR `userid` = '0' )"; $query .= " GROUP BY `sources`.`id` ASC"; $query .= " ORDER BY `sources`.`ordernum` ASC"; break; } $res = common_query($query, __FILE__, __LINE__); if (!$res) { return ''; } $therearerecords = mysql_num_rows($res); if (!$therearerecords) { return ''; } switch ($show) { case 0: $output .= '<div class="tabbertab">'; $output .= '<h4>' . ucfirst(phr('ALL_TABLES')) . '</h4>'; break; case 1: $output .= '<div class="tabbertab">'; $output .= '<h4>' . ucfirst(phr('TAKEAWAY_TABLES')) . '</h4>'; break; case 2: $output .= '<div class="tabbertab tabbertabdefault">'; $output .= '<h4>' . ucfirst(phr('MY_TABLES')) . '</h4>'; break; } $output .= ': <table cellspacing="2" bgcolor="' . COLOR_TABLE_GENERAL . '" width="100%"> <tbody>' . "\n"; while ($arr = mysql_fetch_array($res)) { $output .= ' <tr>' . "\n"; for ($i = 0; $i < $cols; $i++) { $output .= tables_list_cell_pos($arr); if ($i != $cols - 1) { $arr = mysql_fetch_array($res); } } $output .= ' </tr>' . "\n"; } $output .= ' </tbody> </table> </div>' . "\n"; return $output; }
function list_query_all() { $table = "sources"; $query = "SELECT\n\t\t\t\t{$table}.`id`,\n\t\t\t\t{$table}.`ordernum`,\n\t\t\t\t{$table}.`name`,\n\t\t\t\t{$table}.`locktouser`,\n\t\t\t\tIF({$table}.`takeaway`='0','" . ucphr('NO') . "','" . ucphr('YES') . "') as `takeaway`,\n\t\t\t\tIF({$table}.`visible`='0','" . ucphr('NO') . "','" . ucphr('YES') . "') as `visible`\n\t\t\t\t FROM `{$table}`\n\t\t\t\t"; return $query; }
function list_rows($arr, $row) { global $tpl; global $display; $col = 0; if (!$this->disable_mass_delete) { $display->rows[$row][$col] = '<input type="checkbox" name="delete[]" value="' . $arr['id'] . '">'; $display->width[$row][$col] = '1%'; $col++; } foreach ($arr as $field => $value) { if (isset($this->allow_single_update) && in_array($field, $this->allow_single_update)) { $link = $this->link_base . '&command=update_field&data[id]=' . $arr['id'] . '&data[field]=' . $field; if ($this->limit_start) { $link .= '&data[limit_start]=' . $this->limit_start; } if ($this->orderby) { $link .= '&data[orderby]=' . $this->orderby; } if ($this->sort) { $link .= '&data[sort]=' . $this->sort; } $display->links[$row][$col] = $link; } elseif (method_exists($this, 'form')) { $link = $this->file . '?class=' . get_class($this) . '&command=edit&data[id]=' . $arr['id']; } else { $link = ''; } if ($field == 'name' && CONF_SHOW_SUMMARY_ON_LIST) { $dish = new dish($arr['id']); $value .= '<span class="admin_ingreds_list">'; $ingreds = $dish->ingredients_names(); if (!empty($ingreds) && is_array($ingreds)) { $value .= '<br/>' . ucphr('INCLUDED') . ': '; foreach ($ingreds as $key2 => $value2) { $value .= ucfirst($value2) . ", "; } $value = substr($value, 0, -2); $value .= ''; } $ingreds = $dish->dispingredients_names(); if (!empty($ingreds) && is_array($ingreds)) { $value .= '<br/>' . ucphr('AVAILABLE') . ': '; foreach ($ingreds as $key2 => $value2) { $value .= ucfirst($value2) . ", "; } $value = substr($value, 0, -2); $value .= ''; } $value .= '</span>'; } $display->rows[$row][$col] = $value; if ($link && $field == 'name') { $display->links[$row][$col] = $link; } if ($link) { $display->clicks[$row][$col] = 'redir(\'' . $link . '\');'; } $col++; } }
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 list_query_all() { $table = $this->table; $query = "SELECT\n\t\t\t\t{$table}.`id`,\n\t\t\t\t{$table}.`name`,\n\t\t\t\t{$table}.`dest`,\n\t\t\t\t{$table}.`driver`,\n\t\t\t\tIF({$table}.`bill`='0','" . ucphr('NO') . "','" . ucphr('YES') . "') as `bill`,\n\t\t\t\tIF({$table}.`invoice`='0','" . ucphr('NO') . "','" . ucphr('YES') . "') as `invoice`,\n\t\t\t\tIF({$table}.`receipt`='0','" . ucphr('NO') . "','" . ucphr('YES') . "') as `receipt`,\n\t\t\t\t{$table}.`template`\n\t\t\t\t FROM `{$table}`\n\t\t\t\t WHERE `deleted`='0'\n\t\t\t\t"; return $query; }
function check_values($input_data) { $msg = ""; if ($input_data['value'] === "") { $msg = ucphr('CHECK_VALUE'); } $input_data['value'] = eq_to_number($input_data['value']); if ($input_data['quantity'] === "") { $msg = ucphr('CHECK_QUANTITY'); } if (!isset($input_data['unit_type'])) { $input_data['unit_type'] = get_unit_from_eq($input_data['quantity']); } // should before modification of quantity $input_data['quantity'] = convert_units($input_data['quantity']); $stock = new stock_object($input_data['obj_id']); if ($stock->data['quantity'] + $input_data['quantity'] < 0 && $stock->data['quantity'] >= 0) { $msg = ucphr('CHECK_QUANTITY'); } $input_data['user'] = $_SESSION['userid']; if ($msg) { echo "<script language=\"javascript\">\n\t\t\t\twindow.alert(\"" . $msg . "\");\n\t\t\t</script>\n"; return -2; } return $input_data; }
function admin_page($class, $command, $start_data) { global $tpl; if (defined('SECURITY_STOP')) { $command = 'access_denied'; } switch ($command) { case 'access_denied': if (!$this->silent) { $tmp = access_denied_admin(); $tpl->append("messages", $tmp); } break; case 'new': $tpl->set_admin_template_file('standard'); $obj = new $class(); $tmp = $obj->form(); $tpl->assign("content", $tmp); break; case 'insert': $obj = new $class(); if (!$obj->insert($start_data)) { if (method_exists($obj, 'post_insert_page')) { $obj->post_insert_page($class); } else { $obj->admin_list_page($class); } } break; case 'edit': if (!isset($this->templates['edit'])) { $this->templates['edit'] = 'menu'; } $tpl->set_admin_template_file($this->templates['edit']); $obj = new $class($start_data['id']); $tmp = $obj->form(); $tpl->assign("content", $tmp); if (method_exists($obj, 'post_edit_page')) { $obj->post_edit_page($class); } break; case 'update': $obj = new $class($start_data['id']); if ($err = $obj->update($start_data)) { if (!$this->silent) { $tmp = '<span class="error_msg">Error updating: ' . $err . '</span><br>'; $tpl->append("messages", $tmp); } } if (method_exists($obj, 'post_update_page')) { $obj->post_update_page($class); } else { $obj->admin_list_page($class); } break; case 'update_field': $obj = new $class($start_data['id']); if (method_exists($obj, 'update_field')) { if ($err = $obj->update_field($start_data['field'])) { if (!$this->silent) { $tmp = '<span class="error_msg">Error updating: ' . $err . '</span><br>'; $tpl->append("messages", $tmp); } } } $obj->admin_list_page($class); break; case "delete": if (isset($_GET['deleteconfirm'])) { $deleteconfirm = $_GET['deleteconfirm']; } elseif (isset($_POST['deleteconfirm'])) { $deleteconfirm = $_POST['deleteconfirm']; } if ($deleteconfirm) { $tpl->set_admin_template_file('menu'); $delete = $_SESSION["delete"]; unset($_SESSION["delete"]); if (is_array($delete)) { for (reset($delete); list($key, $value) = each($delete);) { $obj = new $class($value); if ($err = $obj->delete($start_data)) { if (!$this->silent) { $tmp = '<span class="error_msg">Error deleting: ' . $err . '</span><br>'; $tpl->append("messages", $tmp); } } unset($rate); } } if (count($delete) == 1) { if (method_exists($obj, 'post_delete_page')) { $obj->post_delete_page($class); } else { $obj->admin_list_page($class); } } else { $obj = new $class(); $obj->admin_list_page($class); } } else { $tpl->set_admin_template_file('standard'); if (isset($_REQUEST['delete'])) { $delete = $_REQUEST['delete']; } if (is_array($delete) || $delete == 'all') { if ($delete == 'all') { $query = "SELECT `id` FROM " . $this->table; if ($this->flag_delete) { $query .= " WHERE `deleted`=0"; } if ($this->db == 'common') { $res = common_query($query, __FILE__, __LINE__); } else { $res = accounting_query($query, __FILE__, __LINE__); } if (!$res) { return ERR_MYSQL; } $delete_all = true; unset($delete); while ($arr = mysql_fetch_array($res)) { $delete[] = $arr['id']; } } $tmp = '<div align=center>'; if ($delete_all) { $tmp .= ucphr('DELETE_ALL_CONFIRM'); } else { $tmp .= ucphr('DELETE_RECORD_CONFIRM'); } $tmp .= ' (' . count($delete) . ' ' . ucphr('RECORDS') . ')'; $tmp .= "<br>\n"; $tmp .= ucphr('ACTION_IS_DEFINITIVE') . ".<br><br>\n"; $_SESSION["delete"] = $delete; if (!$delete_all) { for (reset($delete); list($key, $value) = each($delete);) { $obj = new $class($value); if (!$obj->no_name) { $description = $obj->name($_SESSION['language']); unset($obj); $tmp .= "<LI>" . $description . "</LI>"; } } } $tmp .= ' <table> <tr> <td> <form action="' . $this->file . '?" method="GET"> <input type="hidden" name="class" value="' . $class . '"> <input type="hidden" name="command" value="delete"> <input type="hidden" name="deleteconfirm" value="1">'; foreach ($start_data as $key => $value) { $tmp .= ' <input type="hidden" name="data[' . $key . ']" value="' . $value . '">'; } $tmp .= ' <input type="submit" value="' . ucphr('YES') . '"> </form> </td> <td> <form action="' . $this->file . '?" method="GET"> <input type="hidden" name="class" value="' . $class . '"> <input type="submit" onclick="history.go(-1);return false;" value="' . ucphr('NO') . '"> </form> </td> </tr> </table>'; $tmp .= '</div>'; $tpl->assign("content", $tmp); } else { if (!$this->silent) { $tmp = '<span class="error_msg">' . ucphr('NO_RECORD_SELECTED') . '.</span><br>'; $tpl->append("messages", $tmp); } } } break; case 'stop': break; default: $obj = new $class(); $obj->admin_list_page($class); break; } if ($command != "delete") { unset($_SESSION["delete"]); } }
function bill_total() { $output = ''; $total = 0; $class = COLOR_TABLE_TOTAL; $currencies = new currencies(); $curr_value = $currencies->list_search_active(); for (reset($_SESSION['separated']); list($key, $value) = each($_SESSION['separated']);) { $total += $_SESSION['separated'][$key]['finalprice']; } $output .= ' <tr bgcolor=' . $class . '> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '>' . ucfirst(phr('TOTAL')) . '</td> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '>' . sprintf("%0.2f", $total) . '</td> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '></td> </tr> '; if (SHOW_CHANGE == 1) { //mizuko:needed to show exchange... for ($i = 0; $i < count($curr_value); $i++) { $output .= ' <tr bgcolor=' . $class . '> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '>' . $curr_value[$i]['name'] . '</td> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '>' . sprintf("%0.2f", $total / $curr_value[$i]['rate']) . '</td> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '></td> </tr> '; } } if (!isset($_SESSION['discount']) || !isset($_SESSION['discount']['type']) || empty($_SESSION['discount']['type'])) { return $output; } if ($_SESSION['discount']['type'] == "amount") { $total_discounted = $total + $_SESSION['discount']['amount']; $discount_label = ""; $discount_number = -$_SESSION['discount']['amount']; } elseif ($_SESSION['discount']['type'] == "percent") { $total_discounted = $total - $total / 100 * $_SESSION['discount']['percent']; $discount_label = $_SESSION['discount']['percent'] . ' %'; $discount_number = $total / 100 * $_SESSION['discount']['percent']; } $output .= ' <tr bgcolor=' . $class . '> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '> ' . ucphr('DISCOUNT') . ' ' . $discount_label . '</td> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '>-' . sprintf("%0.2f", $discount_number) . '</td> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '></td> </tr> <tr bgcolor=' . $class . '> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '>' . ucphr('TOTAL') . '</td> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '>' . sprintf("%0.2f", $total_discounted) . '</td> <td bgcolor=' . $class . '></td> <td bgcolor=' . $class . '></td> </tr> '; return $output; }
} elseif ($num == 0) { // found none $tmp = '<b><font color="Red">' . ucfirst(phr('ERROR_NONE_FOUND')) . "</font></b><br>\n"; $tpl->append('messages', $tmp); //orders_list_pos(); //gjergji : remove it or not ?! //orders_list_pos (true); break; } else { // found one, we directly assume that's the dish the user wanted $dishid = $num; } } $dish = new dish($dishid); if (!$dish->exists()) { $tmp = '<script>$.growl("' . ucphr("Information") . '","<b><font color=\\"Red\\">' . ucfirst(phr('DISH_DOES_NOT_EXIST')) . '</font>","' . IMAGE_ERROR . '")</script>'; $tpl->append('messages', $tmp); //orders_list_pos (); orders_list_pos(true); break; } //create the order removing the quantity from the stock if ($dishid) { $id = orders_create($dishid, $start_data); } if ($id) { $err = 0; } else { $err = ERR_UNKNOWN; } status_report('CREATION', $err);