Beispiel #1
0
function displayExtras($menu_sides, $useradio)
{
    $input_type = $useradio ? "radio" : "checkbox";
    $ids = array();
    $strt = '<div class="section group">';
    $end = '</div>';
    if ($useradio) {
        $fmt = '<div class="col span_1_of_2">
                        <div class="6u$ 12u$(small)">
                            <input type="radio" id="side-%(id)s" name="side" value="%(id)s">
                            <label for="side-%(id)s">%(name)s<span id="xprice">+%(price)s</span></label>
                        </div>
                    </div>';
    } else {
        $fmt = '<div class="col span_1_of_2">
                        <div class="6u$ 12u$(small)">
                            <input type="checkbox" id="side-%(id)s" name="%(id)s">
                            <label for="side-%(id)s">%(name)s<span id="xprice">+%(price)s</span></label>
                        </div>
                    </div>';
    }
    $cnt = count($menu_sides);
    if (count($menu_sides) > 0) {
        if ($cnt % 2 != 0) {
            $dec = 1;
        } else {
            $dec = 0;
        }
        for ($i = 0; $i < $cnt - $dec; $i += 2) {
            $arr_slice = array_slice($menu_sides, $i, 2);
            echo htmlLoopNamed($arr_slice, $strt, $fmt, $end);
            $ids[] = $arr_slice[0]["id"];
            $ids[] = $arr_slice[1]["id"];
            //            if ($arr_slice[0]["required"] === "1") {
            //                $required_sides_ids[] = $arr_slice[0]["id"];
            //            }
            //            if ($arr_slice[1]["required"] === "1") {
            //                $required_sides_ids[] = $arr_slice[1]["id"];
            //            }
        }
        if ($dec === 1) {
            $arr_slice = array_slice($menu_sides, $cnt - 1, $cnt);
            echo htmlLoopNamed($arr_slice, $strt, $fmt, $end);
            $ids[] = $arr_slice[0]["id"];
            // deal with the +1 scenario
        }
    } else {
        echo '<div class="section group"><label>No sides available for this item</label></div>';
    }
    if ($useradio) {
        global $required_sides_ids;
        $required_sides_ids = $ids;
    }
    global $all_side_ids;
    $all_side_ids = array_merge($all_side_ids, $ids);
}
Beispiel #2
0
function displayAdminServicesPage()
{
    $service_id = isset($_GET['sid']) ? $_GET['sid'] : null;
    $service_id = $service_id != "-1" ? $service_id : null;
    $all_services = DB::query("SELECT * FROM categories ORDER BY displayorder");
    if ($service_id) {
        $service = DB::queryOneRow("SELECT * FROM categories WHERE id=%s", $service_id);
    } else {
        $service = $all_services[0];
        $service_id = $service["id"];
    }
    if (!$service) {
        return "";
    }
    $sname = $service['name'];
    $checked = $service["active"] == "1" ? " checked" : "";
    global $sorder;
    $sorder = $service['displayorder'];
    // get current user
    $cookies = new Cookies();
    $user = $cookies->user_from_cookie();
    $html = "";
    $service_header_option_html = htmlLoopNamed($all_services, "", "<option value='%(id)s'>%(name)s</option>", "");
    $service_header_select_html = "\n        <select id='select_service_id'>\n            <option value='0' selected='selected'>Show Category</option>\n            {$service_header_option_html}\n        </select>\n    ";
    $service_header_html = "\n    <div id='admin-services'>\n        <span id='service-title'>{$sname}</span>\n        <div id='service-options'>\n            <div id='service-select'>\n                {$service_header_select_html}\n            </div>";
    if ($user->data['permission'] === '4') {
        $service_header_html .= "\n            <div id='addService'>+ Add Service</div>";
    }
    $service_header_html .= "\n        </div>\n    </div>";
    $scategories = $user->data['permission'] === '3' ? DB::query("SELECT * FROM category_items WHERE id=%s", $user->data['service_id']) : DB::query("SELECT * FROM category_items WHERE category_id=%s", $service_id);
    $service_subcategories_html = "";
    $chunks = array_chunk($scategories, 3);
    foreach ($chunks as $chunk) {
        $strt = "<div class='section group'>";
        $end = "</div>";
        $fmt = "<div id='service-%(id)s' class='col gen_1_of_3'><span id='cat-name'>%(name)s</span><br><img src='images/%(image)s'></div>";
        $service_subcategories_html .= htmlLoopNamed($chunk, $strt, $fmt, $end) . "<br>";
    }
    $service_html = "\n    <div id='service-container'>\n        <div id='service-info'>\n            <div id='general-actions'>";
    if ($user->data['permission'] === '4') {
        $service_html .= "\n                <div class='general-info'>\n                    General info\n                    <input type='hidden' name='category_id' value='{$service_id}'>\n                </div>\n                <div id='general-select'>\n                    <input type='text' name='sitename' placeholder='Category: {$sname}'>\n                </div>\n                <div id='active-check'>\n                    <input type='checkbox' id='active' name='active' value='1' {$checked}>\n                    <label for='active'>Active</label>\n                </div>\n                <div id='placement-select'>\n                    <select name='displayorder'>";
        $ends = array('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th');
        for ($i = 1; $i <= count($all_services); $i++) {
            $ordinal = $i % 100 >= 11 && $i % 100 <= 13 ? $i . 'th' : $i . $ends[$i % 10];
            $service_html .= '<option value="' . $i . '"';
            $service_html .= $sorder == $i ? ' selected' : '';
            $service_html .= '>Display as ' . $ordinal . ' service</option>';
        }
        $service_html .= "\n                    </select>\n                </div>\n                <div id='category-save'>Save Category</div>\n                <div id='category-new'>Create as New</div>";
        if (0 === count($scategories)) {
            $service_html .= "&nbsp;<div id='category-delete'>Delete</div>";
        }
        $service_html .= "<br>";
    }
    $service_html .= "\n                <div class='general-info'>Services</div>\n                {$service_subcategories_html}\n                </div>\n        </div>\n    </div>\n    ";
    $html .= $service_header_html . "<br><br>" . $service_html;
    return $html;
}
Beispiel #3
0
<?php 
    }
    ?>
              </form>
              <div id="required"></div>
              <a id="orderflow2_next" class="remodal-confirm" href="#">NEXT</a>
            </div>
<?php 
}
if ($page === "3") {
    $fmt = "\n        <p>\n            <div id='item1'>%(name)s<span id='item-price'> \$%(tprice)s</span></div>\n            <div>%(sidestr)s</div>\n        </p>\n    ";
    $minprice = DB::queryOneRow("SELECT * FROM category_items WHERE id=%s", $ctype);
    $minprice = floatval($minprice["minimum_price"]);
    $tcart = json_decode($usr->get_cart($ctype), true)["data"];
    $cart = $tcart["cart"];
    $order_html = htmlLoopNamed($cart, "", $fmt, "");
    foreach ($cart as $item) {
        $total += $item["tprice"];
    }
    if (isset($item)) {
        $total += floatval(DB::queryOneRow("SELECT * FROM category_items WHERE id=%s", $item["service_id"])["delivery_fee"]);
    }
    if ($total < $minprice) {
        $validPrice = false;
    } else {
        $validPrice = true;
    }
    $total = strval(sprintf("%0.2f", $total));
    $minprice_f = sprintf("%0.2f", $minprice);
    $validPriceHTML = !$validPrice ? "<div>This order does not meet the minimum price of \${$minprice_f}, please add more items to place your order</div>" : "";
    $button_text = $validPrice ? "CONFIRM ORDER" : "CONTINUE ORDERING";