本文整理汇总了PHP中order::ingredients_arrays方法的典型用法代码示例。如果您正苦于以下问题:PHP order::ingredients_arrays方法的具体用法?PHP order::ingredients_arrays怎么用?PHP order::ingredients_arrays使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类order
的用法示例。
在下文中一共展示了order::ingredients_arrays方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: order
function remove_from_waiter($order_id, $new_quantity)
{
$order_id = (int) $order_id;
$order = new order($order_id);
$dish_id = $order->data['dishid'];
if ($dish_id == MOD_ID) {
$arr_ingreds[] = $order->data['ingredid'];
$diffquantity = $order->data['quantity'] - $new_quantity;
$order_id = (int) $order->data['associated_id'];
$order = new order($order_id);
$dish_id = $order->data['dishid'];
} else {
$order->ingredients_arrays();
$arr_ingreds = $order->ingredients['contained'];
$diffquantity = $order->data['quantity'] - $new_quantity;
}
if (!$diffquantity) {
return 0;
}
// movements for all the contained ingredients
foreach ($arr_ingreds as $ingred_id) {
$stock_id = $this->find_external($ingred_id, TYPE_INGREDIENT);
// object not found in stock
if (!$stock_id) {
continue;
}
$mov = new stock_movement();
$mov_data['obj_id'] = $stock_id;
$mov_data['dish_id'] = $dish_id;
$mov_data['dish_quantity'] = $diffquantity;
$stock = new stock_object($stock_id);
$ingred_quantity = $stock->get_ingredient_quantity($dish_id);
$mov_data['quantity'] = $mov_data['dish_quantity'] * $ingred_quantity;
$mov_data['value'] = $stock->data['value'] * $mov_data['quantity'];
$mov_data['unit_type'] = $stock->data['unit_type'];
$mov->silent = true;
if ($err = $mov->insert($mov_data)) {
return $err;
}
}
return 0;
}
示例2: mods_update_ingred_qty
function mods_update_ingred_qty($ordid, $ingredid, $value)
{
$query = "SELECT * FROM `orders` WHERE `associated_id`='" . $ordid . "' AND `ingredid` = '" . $ingredid . "'";
$res = common_query($query, __FILE__, __LINE__);
if (!$res) {
return mysql_errno();
}
$arr = mysql_fetch_array($res);
if (!$arr && $value == 0) {
return 0;
} elseif (!$arr && $value != 0) {
$ord = new order($ordid);
$ord->ingredients_arrays();
if (in_array($ingredid, $ord->ingredients['nominal'])) {
$ord = new order($ordid);
$operation = 0;
$err = mods_create_ingreds($ord, $ingredid, $operation);
if ($err) {
return ERR_MOD_NOT_CREATED;
}
$query = "SELECT * FROM `orders` WHERE `associated_id`='" . $ordid . "' AND `ingredid` = '" . $ingredid . "'";
$res = common_query($query, __FILE__, __LINE__);
if (!$res) {
return mysql_errno();
}
$arr = mysql_fetch_array($res);
}
}
$id = (int) $arr['associated_id'];
$ord = new order($id);
$ord->ingredients_arrays();
if ($value == 0 && $arr['operation'] == 0) {
$query = "DELETE FROM `orders` WHERE `id`='" . $arr['id'] . "'";
$res = common_query($query, __FILE__, __LINE__);
if (!$res) {
return mysql_errno();
}
} elseif ($arr['operation'] != -1) {
$query = "UPDATE `orders` SET `ingred_qty`='" . $value . "' WHERE `id`='" . $arr['id'] . "'";
$res = common_query($query, __FILE__, __LINE__);
if (!$res) {
return mysql_errno();
}
}
return 0;
}