コード例 #1
0
ファイル: cartdetails.php プロジェクト: lxthien/batdongsan
 function list_by_parent($id, $customer_id)
 {
     $cartdetails = new Cartdetail();
     $cartdetails->order_by('id', 'desc');
     $cartdetails->where('cart_id', $id);
     $cartdetails->get();
     $customers = new Customer($customer_id);
     $customers->order_by('id', 'asc');
     $customers->where('id', $customer_id);
     $customers->get();
     $dis['base_url'] = base_url();
     $dis['view'] = "cartdetail/listbyparent";
     $dis['menu_active'] = 'Giỏ hàng';
     $dis['title'] = "Chi tiết giỏ hàng";
     $dis['title_customer'] = "Thông tin khách hàng";
     $dis['cartdetails'] = $cartdetails;
     $dis['customers'] = $customers;
     $dis['nav_menu'] = array(array("type" => "back", "text" => "Back", "link" => "{$this->admin_url}carts/list_all/", "onclick" => ""));
     $this->viewadmin($dis);
 }
コード例 #2
0
ファイル: carts.php プロジェクト: lxthien/batdongsan
 function deleteDetail($cartId)
 {
     $cart = new cartitem($cartId);
     $detailId = $this->input->post('detailId');
     $detail = new Cartdetail($detailId);
     if (!$detail->exists()) {
         show_404();
     }
     $detail->delete();
     $cartDetail = $cart->cartdetail;
     $dis['cartdetail'] = $cartDetail;
     $dis['object'] = $cart;
     $dis['cart'] = $cart;
     $dis['base_url'] = base_url();
     echo $this->load->view('admin/cart/listDetail', $dis, true);
     exit;
 }
コード例 #3
0
ファイル: cart.php プロジェクト: lxthien/batdongsan
 function showCart()
 {
     $step = 1;
     if ($this->uri->segment(2, "") != "") {
         $stepStr = $this->uri->segment(2, "");
         $stepStr = explode("-", $stepStr);
         $step = $stepStr[1];
         if ($step != '2' && $step != '3') {
             show_404();
         }
         if (!$this->_checkLogin()) {
             redirect('dang-nhap/' . 'gio-hang/buoc-' . $step);
         }
     }
     //get product from cookie
     $cartDetail = $this->getCartCookie();
     $product = new product();
     $productList = array(0);
     $store = new store();
     $store->get_iterated();
     $dis['store'] = $store;
     foreach ($cartDetail as $key => $value) {
         array_push($productList, $key);
     }
     $product->where_in('id', $productList);
     $product->get();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $cart = new Cartitem();
         $cart->customer_id = $this->customer->id;
         $cart->shipType = $this->input->post('receiveType');
         $cart->paymentType = $this->input->post('payment');
         $cart->deliverStore_id = $this->input->post('branchReceive');
         $cart->paymentStore_id = $this->input->post('branchPayment');
         $cart->shipName = $this->input->post('info_name');
         $cart->shipEmail = $this->input->post('info_email');
         $cart->shipPhone = $this->input->post('info_phone');
         $cart->shipDescription = $this->input->post('info_description');
         $cart->shipAddress = $this->input->post('info_address');
         $cart->status = enum::CART_WAIT_FOR_PROCESS;
         $cart->save();
         $sum = 0;
         foreach ($product as $row) {
             $cartDetailItem = new Cartdetail();
             $cartDetailItem->cartitem_id = $cart->id;
             $cartDetailItem->product_id = $row->id;
             $cartDetailItem->quantity = $cartDetail[$row->id];
             $cartDetailItem->price = $row->getRealPriceNum();
             $cartDetailItem->productName = $row->name;
             $cartDetailItem->inBox = $row->inBox;
             $cartDetailItem->status = enum::CARTDETAIL_AVAILABLE;
             $cartDetailItem->save();
             $cartDetailItem->clear();
             $itemTotal = $cartDetail[$row->id] * $row->getRealPriceNum();
             $sum += $itemTotal;
         }
         $cart->total = $sum;
         $cart->save();
         $this->sendMailCustomer($cart->id);
         $this->sendMailCustomerService($cart->id);
         //save cart detail
         setcookie("userCart", json_encode(array()), mktime() . time() + 60 * 60 * 24 * 7, "/");
         $dis['view'] = 'cart/cart4';
     } else {
         $dis['step'] = $step;
         $dis['product'] = $product;
         $dis['cartDetail'] = $cartDetail;
         $dis['view'] = 'cart/cart1';
     }
     $dis['base_url'] = base_url();
     $this->viewfront($dis);
 }