Example #1
0
<?php

session_start();
require_once "../backend/model/Frontend.php";
$model = new Fontend();
$arrParam = $_POST;
$total_price = $total_amount = $total_pay = $customer_id = $code_id = $discount = 0;
/*$seed = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
                 .'0123456789'); // and any other characters
shuffle($seed); // probably optional since array_is randomized; this may be redundant
$rand = '';
foreach (array_rand($seed, 5) as $k) $rand .= $seed[$k];
*/
$order_code = "DH-" . date('Ym');
$idMax = $model->getOrderIdMax();
$order_code = "DH-" . date('Ym') . '-' . $idMax;
$arrParam['order_code'] = $order_code;
$arrParam['status'] = 1;
$arrParam['created_at'] = time();
$arrParam['delivery_date'] = strtotime($_POST['delivery_date']);
$back_url = $_POST['back_url'];
if (!empty($_SESSION['cart'])) {
    foreach ($_SESSION['cart'] as $product) {
        $total_price += $product['tientheosp'];
        $total_amount += $product['soluong'];
    }
}
$arrParam['sub_total'] = $total_price;
if (isset($_SESSION['pay'])) {
    $arrParam['total'] = $_SESSION['pay'];
} else {