Example #1
0
 public static function create(Customer $cus, Product $prd, $opts)
 {
     $material = $opts['material'];
     $order_sn = self::makeOrderSn();
     Pdb::insert(array_merge($opts, array('order_no' => $order_sn, 'customer' => $cus->id, 'product' => $prd->id, 'state' => 'InCart', 'estimate_price' => $prd->estimatePrice(compact('material')), 'add_cart_time=NOW()' => null)), self::$table);
     return new self(Pdb::lastInsertId());
 }
Example #2
0
<?php

!defined('IN_PTF') && exit('ILLEGAL EXECUTION');
/**
 * @author  ryan <*****@*****.**>
 */
if ($by_ajax && $action === 'get_price') {
    $prd = new Product($target);
    $material = _get('material');
    echo $prd->estimatePrice(compact('material'));
    exit;
}
if ($user_type !== 'Admin') {
    die('you should be Admin');
}
if ($by_ajax) {
    switch ($action) {
        case 'del':
            $ids = _get('ids');
            $ids = json_decode($ids);
            $admin->delProduct($ids);
            exit;
            break;
        default:
            throw new Exception("unkown action: {$action}");
            break;
    }
}
$types = Product::types();
switch ($target) {
    case '':