function write_log_discount($discount_value, $receipt_id)
{
    $log_table = "account_log";
    $log["waiter"] = $_SESSION['userid'];
    $log["destination"] = 0;
    $log["dish"] = DISCOUNT_ID;
    $log["category"] = 0;
    $log["quantity"] = 1;
    $log["price"] = -1 * abs($discount_value);
    $log["payment"] = $receipt_id;
    $query = "INSERT INTO `{$log_table}` (";
    for (reset($log); list($key, $value) = each($log);) {
        $value = str_replace("'", "\\'", $value);
        $query .= "`" . $key . "`,";
    }
    // strips the last comma that has been put
    $query = substr($query, 0, strlen($query) - 1);
    $query .= ") VALUES (";
    for (reset($log); list($key, $value) = each($log);) {
        $value = str_replace("'", "\\'", $value);
        $query .= "'" . $value . "',";
    }
    // strips the last comma that has been put
    $query = substr($query, 0, strlen($query) - 1);
    $query .= ")";
    // CRYPTO
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return 0;
    }
    return 0;
}
 function list_rates()
 {
     $ret = array();
     $query = "SELECT * FROM `" . $this->table . "`";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return 0;
     }
     while ($arr = mysql_fetch_array($res)) {
         $ret[] = $arr['id'];
     }
     return $ret;
 }
 function find($obj_id, $dish_id)
 {
     $query = "SELECT `id` FROM `" . $this->table . "`\n\t\t\t\tWHERE `obj_id`='" . $obj_id . "'\n\t\t\t\tAND `dish_id`='" . $dish_id . "'";
     if ($this->db == 'common') {
         $res = common_query($query, __FILE__, __LINE__);
     } else {
         $res = accounting_query($query, __FILE__, __LINE__);
     }
     if (!$res) {
         return 0;
     }
     if ($arr = mysql_fetch_assoc($res)) {
         return $arr['id'];
     }
     return 0;
 }
 function set_print_template_file($destination, $type)
 {
     $query = "SELECT * FROM `dests` WHERE `id`='{$destination}'";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return ERR_MYSQL;
     }
     if (!($arr = mysql_fetch_array($res))) {
         $error_msg = 'Printer not found id: ' . $destination;
         error_msg(__FILE__, __LINE__, $error_msg);
         echo $error_msg;
         return ERR_PRINTER_NOT_FOUND;
     }
     $this->filename = ROOTDIR . '/templates/' . $arr['template'] . '/prints/' . $type . '.tpl';
     return 0;
 }
 function max_quantity()
 {
     $query = "SELECT * FROM `autocalc`";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return 0;
     }
     if (mysql_num_rows($res) == 0) {
         return -1;
     }
     while ($arr = mysql_fetch_array($res)) {
         $autocalc[$arr['quantity']] = $arr['price'];
     }
     // quantity not found, we look for the highest quantiy available,
     // then add the remaining price (based on the 0 quantity record)
     $keys = array_keys($autocalc);
     $maxquantity = max($keys);
     return $maxquantity;
 }
 function sync_external($obj_type)
 {
     if ($obj_type == TYPE_DISH) {
         $query = "SELECT * FROM dishes WHERE `deleted`='0'";
     } elseif ($obj_type == TYPE_INGREDIENT) {
         $query = "SELECT * FROM ingreds WHERE `deleted`='0'";
     }
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return ERR_MYSQL;
     }
     while ($arr = mysql_fetch_array($res)) {
         $err = $this->create_from_external($arr['id'], $obj_type);
         if ($err && $err != ERR_OBJECT_ALREADY_EXISTS) {
             return $err;
         }
     }
     return 0;
 }
/**
* My Handy Restaurant
*
* http://www.myhandyrestaurant.org
*
* My Handy Restaurant is a restaurant complete management tool.
* Visit {@link http://www.myhandyrestaurant.org} for more info.
* Copyright (C) 2003-2005 Fabio De Pascale
* 
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
* @author		Fabio 'Kilyerd' De Pascale <*****@*****.**>
* @package		MyHandyRestaurant
* @copyright		Copyright 2003-2005, Fabio De Pascale
* @copyright	Copyright 2006-2012, Gjergj Sheldija
*/
function common_allowed_ip($host)
{
    // next is an IP-based access control
    // reads IPs from the allowed_clients table
    // and only allows IPs present in that table to go on
    // if the table is empty, any host is allowed
    $query = "SELECT * FROM `allowed_clients`";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return 0;
    }
    // table is empty, everyone is allowed
    if (mysql_num_rows($res) == 0) {
        return true;
    }
    $host = sprintf("%u", ip2long($host));
    $query = "SELECT * FROM `allowed_clients` WHERE `host`='" . $host . "'";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return 0;
    }
    return mysql_num_rows($res);
}
function dishes_list_search($data)
{
    $output = '';
    $search = strtolower(trim($data['search']));
    if (empty($search)) {
        return '';
    }
    $query = "SELECT dishes.*\n\tFROM `dishes`\n\tWHERE (LCASE(`name`) LIKE '" . $search . "%'\n\t\tOR LCASE(`name`) LIKE '% " . $search . "%'\n\t\t)";
    if (!get_conf(__FILE__, __LINE__, "invisible_show")) {
        $query .= "AND `visible`='1'";
    }
    $query .= "\n\tAND dishes.deleted='0'\n\tORDER BY name ASC";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return '';
    }
    $output .= '<table bgcolor="' . COLOR_TABLE_GENERAL . '">
	<tr>
	<th scope=col>' . ucfirst(phr('ID')) . '</th>
	<th scope=col>' . ucfirst(phr('NAME')) . '</th>
	<th scope=col>' . country_conf_currency(true) . '</th>
	</tr>
	';
    // ascii letter A
    $i = 65;
    unset($GLOBALS['key_binds_letters']);
    while ($arr = mysql_fetch_array($res)) {
        $class = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], "categories", "htmlcolor", $arr['category']);
        $dishcat = $arr['category'];
        $dishid = $arr['id'];
        $dishobj = new dish($arr['id']);
        $dishname = $dishobj->name($_SESSION['language']);
        if ($dishname == null || strlen(trim($dishname)) == 0) {
            $dishname = $arr['name'];
        }
        $dishprice = $arr['price'];
        if ($dishcat > 0) {
            // letters array follows
            if ($i < 91) {
                $GLOBALS['key_binds_letters'][$i] = $dishid;
                $local_letter = chr($i);
                $i++;
            } else {
                $local_letter = '';
            }
            $output .= '<tr>
			<td bgcolor="' . $class . '">' . $local_letter . '</td>';
            $output .= '<td bgcolor="' . $class . '" onclick="order_select(' . $dishid . ',\'order_form\'); return false;"><a href="#" onclick="JavaScript:order_select(' . $dishid . ',\'order_form\'); return false;">' . $dishname . '</a></td>';
            $output .= '<td bgcolor="' . $class . '">' . $dishprice . '</td>
			</tr>';
        }
    }
    $output .= '
	</table>';
    return $output;
}
function receipt_update_amounts($accountdb, $total, $receipt_id)
{
    $total_total = $total['total'];
    $taxable = $total['taxable'];
    $vat = $total['tax'];
    $table = 'account_mgmt_main';
    $query = "UPDATE {$table} SET `waiter_income` = '1',`cash_amount` = '{$total_total}',`cash_taxable_amount` = '{$taxable}',`cash_vat_amount` = '{$vat}' WHERE `id` = '{$receipt_id}'";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return 0;
    }
    return 0;
}
function letters_list_creator()
{
    $invisible_show = get_conf(__FILE__, __LINE__, "invisible_show");
    if ($invisible_show) {
        $query = "SELECT `name` FROM `dishes`\n\t\t\tWHERE dishes.deleted='0'";
    } else {
        $query = "SELECT `name` FROM `dishes`\n\t\t\tWHERE `visible`='1'\n\t\t\tAND dishes.deleted='0'";
    }
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return ERR_MYSQL;
    }
    $dishes_letters = array();
    while ($arr = mysql_fetch_array($res)) {
        $name = trim($arr['name']);
        if ($name == null || strlen($name) == 0) {
            $name = trim($arr['name']);
        }
        //if no name in the fixed lang, use the main name
        array_push($dishes_letters, substr($name, 0, 1));
    }
    return $dishes_letters;
}
示例#11
0
            $remaining_time = 1;
        }
        $error_msg = common_header('Tavolina ne perdorim');
        $error_msg .= navbar_lock_retry_pos('');
        $error_msg .= ucfirst(phr('TABLE_ALREADY_IN_USE_ERROR')) . ' ' . '.<br><br>' . "\n";
        $error_msg .= ucfirst(phr('IF_YOU_ARE_NOT_DISCONNECT_0')) . ' <b>' . $user->data['name'] . '</b> ' . ucfirst(phr('IF_YOU_ARE_NOT_DISCONNECT_1')) . '<br>' . "\n";
        $error_msg .= common_bottom();
        die($error_msg);
    }
}
/*
We get the printed categories flag, and write to $_SESSION['catprinted'][]
*/
if (isset($_SESSION['sourceid'])) {
    $query = "SELECT * FROM `sources` WHERE `id`='" . $_SESSION['sourceid'] . "'";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return ERR_MYSQL;
    }
    $arr = mysql_fetch_array($res);
    $catprinted_total = $arr['catprinted'];
    $catprinted_total = explode(" ", $catprinted_total);
    for ($i = 1; $i <= 3; $i++) {
        if (in_array("{$i}", $catprinted_total)) {
            $_SESSION['catprinted'][$i] = true;
        } else {
            $_SESSION['catprinted'][$i] = false;
        }
    }
    unset($res);
    unset($arr);
    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 toplist_delete($dishid, $quantity = 1)
{
    if (!$dishid) {
        return 0;
    }
    $query = "DELETE FROM `last_orders` WHERE `dishid`='" . $dishid . "' LIMIT {$quantity}";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return ERR_MYSQL;
    }
    return 0;
}
示例#14
0
    function printDailyIncome($user)
    {
        $fillimi = date('Y-m-d') . " 00:00:01";
        $fundi = date('Y-m-d') . " 23:59:00";
        $userName = $user->data['name'];
        $table = 'account_mgmt_main';
        $queryMoney = "SELECT date, who, description, cash_amount ";
        $queryMoney .= "FROM `account_mgmt_main`";
        $queryMoney .= "WHERE who = '" . $userName . "' AND ";
        $queryMoney .= "date > '" . $fillimi . "' AND date < '" . $fundi . "'";
        $resMoney = common_query($queryMoney, __FILE__, __LINE__);
        if (!$resMoney) {
            return '';
        }
        $therearerecordsMoney = mysql_num_rows($resMoney);
        if ($therearerecordsMoney) {
            $output = '
			<span class="style1">Xhiroja Ditore e ' . $userName . '  nga ' . $fillimi . '  ne ' . $fundi . '</span><br><br><br>
			<table>
			<tr>
				<td height="31" width="100"><strong>Data - Ora</strong></td>
				<td width="145"><div align="right"><strong>Nr i fatures</strong></div></td>
				<td width="80"><div align="right"><strong>Vlera lek</strong></div></td>
			</tr>';
            while ($arr = mysql_fetch_array($resMoney)) {
                $output .= '	
			 <tr>
			  	<td width="200"><div align="left">' . $arr['date'] . '</div></td>
			    <td width="145"><div align="right">' . $arr['description'] . '</div></td>
			    <td width="80"><div align="right">' . $arr['cash_amount'] . '</div></td>
			  </tr>';
                $totali += $arr['cash_amount'];
            }
            $output .= '</table>
			<br><br>
			' . ucfirst(phr('CONNECTED_AS')) . ' ' . $userName . '<strong>' . $totali . '  LEK</strong>';
        }
        return $output;
    }
示例#15
0
 function move($destination)
 {
     // copies old table info
     $query = "SELECT * FROM `sources` WHERE `id`='" . $this->id . "'";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return mysql_errno();
     }
     $arr_old = mysql_fetch_array($res, MYSQL_ASSOC);
     //delete the info we don't want to copy
     unset($arr_old['id']);
     unset($arr_old['name']);
     unset($arr_old['takeaway']);
     $query = "SELECT * FROM `sources` WHERE `id`='" . $destination . "'";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return mysql_errno();
     }
     $arr_new = mysql_fetch_array($res, MYSQL_ASSOC);
     // last check before begin: is the table really empty?
     if ($arr_new['userid'] != 0 || $arr_new['toclose'] != 0 || $arr_new['discount'] != 0 || $arr_new['paid'] != 0 || $arr_new['catprinted'] != '') {
         return 1;
     }
     // moves all the orders
     $query = "UPDATE `orders` SET `sourceid` = '" . $destination . "' WHERE `sourceid`='" . $this->id . "'";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return mysql_errno();
     }
     // copies table properties
     $query = "UPDATE `sources` SET ";
     foreach ($arr_old as $key => $value) {
         $query .= "`" . $key . "`='" . $value . "',";
     }
     // strips the last comma that has been put
     $query = substr($query, 0, strlen($query) - 1);
     $query .= " WHERE `id`='" . $destination . "'";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return mysql_errno();
     }
     // empties the old table
     $query = "UPDATE `sources` SET `userid`='0',`toclose`='0',`discount` = '0.00',`paid` = '0',`catprinted` = '',`last_access_userid` = '0' WHERE `id` = '" . $this->id . "'";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return mysql_errno();
     }
     return 0;
 }
示例#16
0
function get_conf($file, $line, $name)
{
    $cache = new cache();
    $cache_out = $cache->get('conf', $name, 'value');
    if ($cache_out != '') {
        return $cache_out;
    }
    $query = "SELECT * FROM `conf` WHERE `name`='{$name}'";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return 0;
    }
    $arr = mysql_fetch_array($res);
    $ret = $arr['value'];
    $cache->set('conf', $name, 'value', $ret);
    return $ret;
}
示例#17
0
function bill_reset($sourceid)
{
    $query = "UPDATE `orders` SET `paid` = '0' WHERE `sourceid` = '{$sourceid}'";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return mysql_errno();
    }
    return 0;
}
function access_allowed($level)
{
    $query = "SELECT `value` FROM `system` WHERE `name`='upgrade_last_key'";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return true;
    }
    $arr = mysql_fetch_array($res);
    // system version is before user zones -> disable access control
    if ($arr['value'] < 4) {
        return true;
    }
    $user = new user();
    // no user found, auth ok anyway (to allow recovering from lost passwords)
    if (!$user->count_users()) {
        return true;
    }
    // not authenticated
    if (!isset($_SESSION['userid'])) {
        return false;
    }
    $user = new user($_SESSION['userid']);
    // disabled user, deny
    if ($user->data['disabled']) {
        return false;
    }
    //doesn't have the flag
    if (!$user->level[$level]) {
        return false;
    }
    // the flag is waiter or cashier or any other that doesn't need a password, ok
    if ($level == USER_BIT_WAITER || $level == USER_BIT_CASHIER || $level == USER_BIT_MONEY) {
        return true;
    }
    // other flags need password
    if (isset($_SESSION['passworded']) && $_SESSION['passworded']) {
        return true;
    }
    // password not set
    return false;
}
示例#19
0
function mods_list_delete($ord)
{
    $linecounter = 0;
    $divider = 10;
    $output = '';
    $ord->ingredients_arrays();
    $output .= '
<table class="receipt-table">
	<tbody>
	<tr>
		<td></td>	
		<td><strong>' . ucfirst(phr('CONTAINED')) . '</strong></td>
		<td style="text-align:center"><img src="' . IMAGE_PLUS . '" width="16" border="0" height="16"></td>
		<td style="text-align:center"><img src="' . IMAGE_FIELD . '" width="16" border="0" height="16"></td>
		<td style="text-align:center"><img src="' . IMAGE_MINUS . '" width="16" border="0" height="16"></td>
	</tr>
	';
    foreach ($ord->ingredients['contained'] as $name => $ingredid) {
        $ingr = new ingredient($ingredid);
        $price = $ingr->get('price');
        $query = "SELECT `ingred_qty` FROM `orders` WHERE `associated_id`='" . $ord->id . "' AND `ingredid` = '" . $ingredid . "'";
        $res = common_query($query, __FILE__, __LINE__);
        if (!$res) {
            return mysql_errno();
        }
        $arr = mysql_fetch_array($res);
        $qty = $arr['ingred_qty'];
        if ($qty == 1) {
            $checked_lot = ' checked';
            $checked_normal = '';
            $checked_few = '';
        } elseif ($qty == -1) {
            $checked_lot = '';
            $checked_normal = '';
            $checked_few = ' checked';
        } else {
            $checked_lot = '';
            $checked_normal = ' checked';
            $checked_few = '';
        }
        $output .= '
		<tr>
			<td>
				<input class="largerInput" type="checkbox" name="data[ingreds][' . $ingredid . ']" value="' . $ingredid . '" checked>
			</td>
			<td onClick="check_elem(\'form1\',\'data[ingreds]\',' . $ingredid . ');return false;">
				' . ucfirst($name) . ' ' . $price . '
			</td>
			<td>
				<input class="largerInput" type="radio" name="data[ingred_qty][' . $ingredid . ']" value="1"' . $checked_lot . '>
			</td>
			<td>
				<input class="largerInput" type="radio" name="data[ingred_qty][' . $ingredid . ']" value="0"' . $checked_normal . '>
			</td>
			<td>
				<input class="largerInput" type="radio" name="data[ingred_qty][' . $ingredid . ']" value="-1"' . $checked_few . '>
			</td>
		</tr>';
        $linecounter++;
        $modulo = $linecounter % $divider;
        if ($modulo == 0) {
            $output .= '
	</tbody>
</table>';
            $output .= navbar_form('form1', 'orders.php?command=list');
            $output .= '
<table>
	<tbody>';
        }
    }
    $output .= '
	</tbody>
</table>';
    return $output;
}
 function find_connected_dishes($show_deleted = false, $link = false)
 {
     $output = array();
     $query = "SELECT dishes.id, dishes.table_id, dishes.table_name FROM `dishes`";
     $query .= " JOIN `dishes` WHERE dishes.table_id=dishes.id";
     $query .= " AND (`ingreds` LIKE '% " . $this->id . " %'";
     $query .= " OR `ingreds` LIKE '" . $this->id . " %'";
     $query .= " OR `ingreds` LIKE '" . $this->id . "'";
     $query .= " OR `ingreds` LIKE '% " . $this->id . "')";
     if (!$show_deleted) {
         $query .= " AND dishes.deleted='0'";
     }
     $query .= " ORDER BY dishes.table_name ASC";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return ERR_MYSQL;
     }
     while ($arr = mysql_fetch_array($res)) {
         $dish = new dish($arr['id']);
         $tmp = '';
         if ($link) {
             $tmp .= '<a href="' . $this->file . '?class=dish&command=edit&data[id]=' . $dish->id . '">';
         }
         $tmp .= $dish->name($_SESSION['language']);
         if ($link) {
             $tmp .= '</a>';
         }
         $output['included'][$dish->id] = $tmp;
     }
     $query = "SELECT dishes.id, dishes.table_id, dishes.table_name FROM `dishes`";
     $query .= " JOIN `dishes` WHERE table_id=dishes.id";
     $query .= " AND (`dispingreds` LIKE '% " . $this->id . " %'";
     $query .= " OR `dispingreds` LIKE '" . $this->id . " %'";
     $query .= " OR `dispingreds` LIKE '" . $this->id . "'";
     $query .= " OR `dispingreds` LIKE '% " . $this->id . "')";
     if (!$show_deleted) {
         $query .= " AND dishes.deleted='0'";
     }
     $query .= " ORDER BY dishes.table_name ASC";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return ERR_MYSQL;
     }
     while ($arr = mysql_fetch_array($res)) {
         $dish = new dish($arr['id']);
         $ingreds = $dish->dispingredients($arr['dispingreds']);
         if (!empty($ingreds) && is_array($ingreds)) {
             if (in_array($this->id, $ingreds)) {
                 $tmp = '';
                 if ($link) {
                     $tmp .= '<a href="' . $this->file . '?class=dish&command=edit&data[id]=' . $dish->id . '">';
                 }
                 $tmp .= $dish->name($_SESSION['language']);
                 if ($link) {
                     $tmp .= '</a>';
                 }
                 $output['available'][$dish->id] = $tmp;
             }
         }
     }
     return $output;
 }
 function price_zero()
 {
     $price = 0;
     $query = "UPDATE `orders` SET `price`='" . $price . "'\n\t\tWHERE `associated_id` = '" . $this->id . "'\n\t\tAND `deleted`='1'";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return ERR_MYSQL;
     }
     return 0;
 }
示例#22
0
 function possible_ingredients()
 {
     $all = array();
     $ingreds = array();
     $dispingreds = array();
     $ingreds = $this->ingredients();
     $dispingreds = $this->dispingredients();
     $not_poss = array_merge($ingreds, $dispingreds);
     $query = "SELECT * FROM `ingreds`";
     $query .= " WHERE `category` = '" . $this->data['category'] . "' OR `category` = '0'";
     $query .= " AND `deleted` = '0'";
     $res = common_query($query, __FILE__, __LINE__);
     if (!$res) {
         return 0;
     }
     while ($arr = mysql_fetch_array($res)) {
         $all[] = $arr['id'];
     }
     $poss = array_diff($all, $not_poss);
     sort($poss);
     return $poss;
 }
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 table_there_are_orders($sourceid)
{
    $query = "SELECT * FROM `orders` WHERE `sourceid`='{$sourceid}'";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return 0;
    }
    return mysql_num_rows($res);
}
function takeaway_get_customer_data($sourceid)
{
    $query = "SELECT * FROM `sources` WHERE `id`={$sourceid}";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return ERR_MYSQL;
    }
    $arr = mysql_fetch_array($res);
    if (!$arr) {
        return ERR_TABLE_NOT_FOUND;
    }
    $data['takeaway_surname'] = $arr['takeaway_surname'];
    $data['customer'] = $arr['customer'];
    $takeaway_time = $arr['takeaway_time'];
    if ($takeaway_time) {
        $data['takeaway_year'] = substr($takeaway_time, 0, 4);
        $data['takeaway_month'] = substr($takeaway_time, 4, 2);
        $data['takeaway_day'] = substr($takeaway_time, 6, 2);
        $data['takeaway_hour'] = substr($takeaway_time, 8, 2);
        $data['takeaway_minute'] = substr($takeaway_time, 10, 2);
    }
    // some data is found. we return it.
    if ($takeaway_time && !empty($data['takeaway_surname'])) {
        return $data;
    }
    // we create a dataset with the actual time
    $data['takeaway_day'] = date("d", time());
    $data['takeaway_month'] = date("m", time());
    $data['takeaway_year'] = date("Y", time());
    $data['takeaway_hour'] = date("H", time());
    $data['takeaway_minute'] = date("i", time());
    return $data;
}