Exemple #1
0
<?php

/**
 * File: available.php
 *
 * Created by PhpStorm.
 * User: ArtofWack
 * Date: 1/24/2016
 * Time: 11:35 PM
 */
require_once '../config.php';
$checkIN = $_POST['checkIN'];
$checkOUT = $_POST['checkOUT'];
$checkIN = convertDates($checkIN);
$checkOUT = convertDates($checkOUT);
for ($type = 1; $type < 6; $type++) {
    $res = checkAvailability($checkIN, $checkOUT, $type);
    $arr[$type] = mysqli_num_rows($res);
}
if (isset($arr)) {
    $result = json_encode($arr);
    header('Content-Type: application/json');
    echo $result;
}
function submitOrderToDB($iAmSeller = false)
{
    global $db;
    $orderid = createOrder($iAmSeller);
    foreach (@$_SESSION['catering']['order']['products'] as $product) {
        if (checkAvailability($product['quantity'], $product['productid'], @$product['ingredients'])) {
            $product_DB = $db->selectOneRow("catering_products", '*', "`productid`=" . $product['productid']);
            $db->insert('catering_items', array('orderid', 'productid', 'amount', 'state', 'price'), array($orderid, $product['productid'], $product['quantity'], 0, $product_DB['price']));
            $itemid = mysql_insert_id();
            if (isset($product['ingredients'])) {
                foreach ($product['ingredients'] as $ingredientid) {
                    $ingredient_DB = $db->selectOneRow("catering_ingredients", '*', "`ingredientid`=" . $ingredientid);
                    $db->insert('catering_items_ingredients', array('itemid', 'ingredientid', 'price'), array($itemid, (int) $ingredientid, $ingredient_DB['price']));
                }
            }
        }
    }
    unset($_SESSION['catering']);
}
Exemple #3
0
function checkCharAvailability($value)
{
    checkAvailability('chars', 'name', $value);
}