Пример #1
0
 public function create()
 {
     Order::createOrder();
     Customer::updateNotes();
     OrderDetail::createOrderDetail();
     Cart::deleteCartAfterCheckout();
     parent::redirectTo('indexHome');
 }
Пример #2
0
 protected function onGet(\Controllers\Request $input)
 {
     $id = $this->input->get('id');
     $this->data['order'] = Order::find($id);
     if (!$this->data['order']) {
         return $this->redirect($this->plugin->orders_url());
     }
     return parent::onGet($input);
 }
Пример #3
0
 public function showOrderDetail($init, $id)
 {
     if ($init == 'admin') {
         $idData = explode('/', $_SERVER['REQUEST_URI']);
         $idAny = end($idData);
         parent::routes()->render('admin_order_detail.twig', array('app_base' => $this->appBase, 'results' => OrderDetail::showOrderDetail($id), 'title' => 'Order Details #' . $idAny));
     } else {
         parent::routes()->render('order_detail.twig', array('app_base' => $this->appBase, 'carts' => Cart::countCart(), 'is_customer' => isset($_SESSION['emailCustomer']) ? sizeof($_SESSION['emailCustomer']) : 0, 'is_order' => Order::countOrder(), 'results' => OrderDetail::showOrderDetail($id), 'title' => 'Your Order Details'));
     }
 }
 public function getOrder($id)
 {
     $order = Order::where('id', $id)->first();
     if ($order === null) {
         $array = array('success' => false, 'message' => 'Order does not exist');
         return json_encode($array);
     }
     $array = array('success' => true, 'order' => $order);
     return json_encode($array);
 }
Пример #5
0
    public function createPaymentConfirmation()
    {
        $req = $this->app->request();
        $sql = 'INSERT INTO payment_confirmations(order_id, bank_name, bank_account, bank_account_name, transfer_date, status, transfer_nominal, total_payment)
						VALUES(:order_id, :bank_name, :bank_account, :bank_account_name, :transfer_date, :status, :transfer_nominal, :total_payment)';
        $this->payment_confirmations = parent::connect()->prepare($sql);
        $data = array('order_id' => $req->post('orderID'), 'bank_name' => $req->post('bankName'), 'bank_account' => $req->post('bankAccount'), 'bank_account_name' => $req->post('bankAccountName'), 'transfer_date' => $req->post('transferDate'), 'status' => 'Unverified', 'transfer_nominal' => $req->post('transferNominal'), 'total_payment' => Order::showTotal());
        try {
            $this->payment_confirmations->execute($data);
        } catch (PDOException $e) {
            die($e->getMessage());
        }
    }
Пример #6
0
 public function show($id)
 {
     $flash = $this->app->view()->getData('flash');
     $infoComment = '';
     $infoCart = '';
     if (isset($flash['infoComment'])) {
         $infoComment = $flash['infoComment'];
     }
     if (isset($flash['infoCart'])) {
         $infoCart = $flash['infoCart'];
     }
     parent::routes()->render('show_product.twig', array('app_base' => $this->appBase, 'bugs1' => true, 'carts' => Cart::countCart(), 'comments' => Comment::showComment($id), 'info_comment' => $infoComment, 'info_cart' => $infoCart, 'is_customer' => isset($_SESSION['emailCustomer']) ? sizeof($_SESSION['emailCustomer']) : 0, 'is_order' => Order::countOrder(), 'results' => Product::showProduct($id), 'related_product' => Product::showRelatedProduct(Product::showProductCategory($id), $id), 'title' => Product::showProductName($id)));
 }
Пример #7
0
 public function buy(Order $order)
 {
     $query = "INSERT INTO cartsproducts (cartId, productId, quantity)\n            VALUES (?, ?, ?)";
     $params = [$order->getCartId(), $order->getProductId(), $order->getQuantity()];
     $this->db->query($query, $params);
     $result = $this->db->row();
     $query = "UPDATE carts SET value = value + ?\n                  WHERE carts.id = ?";
     $params = [$order->getQuantity() * $order->getPrice(), $order->getCartId()];
     $this->db->query($query, $params);
     $query = "UPDATE products SET quantity = quantity - ?\n                  WHERE products.id = ?";
     $params = [$order->getQuantity(), $order->getProductId()];
     $this->db->query($query, $params);
     return $result;
 }
Пример #8
0
 public function hackable_create()
 {
     $args = $this->request->args;
     $token = $_COOKIE['user_token'];
     $user = User::retrieve_by_token(Validate::token($token));
     $username = $user->username;
     $total = Validate::udouble($args['total']);
     $products = $args['products'];
     foreach ($products as $id => $quantity) {
         Product::decrease_quantity(Validate::uint($id), Validate::uint($quantity));
     }
     $order = Order::create($username, $total);
     $this->response->set_header(Lib\Response::HTTP_CREATED);
     $this->response->set('order', $order);
 }
Пример #9
0
 private function finalize()
 {
     $user = new User(\Lib\Session::get('id'));
     $name = $user->getFirstName();
     $surname = $user->getSurname();
     $country = $user->getCountry();
     $zipcode = $user->getZipCode();
     $city = $user->getCity();
     $street = $user->getStreet();
     $house = $user->getHousNr();
     $appartment = $user->getAppartmentNr();
     $order_details = new Order_details();
     $order_details->setAddress('Imie: ' . $user->getFirstName() . ' Nazwisko: ' . $user->getSurname() . ' Kraj: ' . $user->getCountry() . ' Kod-Pocztowy: ' . $user->getZipCode() . ' Miasto: ' . $user->getCity() . ' Ulica : ' . $user->getStreet() . ' Nr domu: ' . $user->getHousNr() . ' Nr mieszkania: ' . $user->getAppartmentNr());
     $time = time();
     $id = \Lib\Session::get('id');
     $rand = rand(1, 100);
     $nr = $id . $time . $rand;
     $order_details->setOrderNr($nr);
     $order_details->setDisplaySeller(true);
     $order_details->setDisplayUser(true);
     $sm = $this->http->get('shipping_method');
     if (empty($sm)) {
         Location::To(URL . 'cart/show');
     }
     $order_details->setShippingMethodId($sm);
     $order_details->setDate();
     $order_details->setStatus(1);
     $cart = \Lib\Session::get('cart');
     if (!empty($cart)) {
         $db = Register::get('db');
         $db->query('START TRANSACTION');
         $id = $order_details->writeData();
         foreach ($cart as $product) {
             $order = new Order($product['order_id']);
             $order->setActive(1);
             $order->setOrderDetailsId($id);
             $order->writeData(true);
             if (!$order->writeData(true)) {
                 $db->query('ROLLBACK');
                 return false;
             }
         }
         if ($id) {
             $db->query('COMMIT');
         } else {
             $db->query('ROLLBACK');
             return false;
         }
         $mess = $this->http->get('message');
         if (!empty($mess)) {
             $mesage = new Message();
             $mesage->setUserId(\lib\Register::get('id'));
             $mesage->setReaded(false);
             $mesage->setSeller(false);
             $mesage->setMessage($order_details->getOrderNr() . ': ' . $this->http->get('message'));
             $mesage->setDate();
             $mesage->setDisplayUser(true);
             $mesage->setDisplaySeller(true);
             $mesage->writeData();
         }
         \Lib\Session::delete('cart');
         $this->ActNumberOfProducts();
         return true;
     }
 }
Пример #10
0
 protected function onGet(\Controllers\Request $input)
 {
     $this->data['orders'] = Order::all();
     return parent::onGet($input);
 }
Пример #11
0
<?php

require_once 'libchart/classes/libchart.php';
use models\Order;
$chart = new VerticalBarChart();
$dataSet = new XYDataSet();
foreach (Order::sumTotalOrder() as $row) {
    $dataSet->addPoint(new Point("{$row['order_year']} - {$row['order_month']}", $row['sum_total']));
}
$chart->setDataSet($dataSet);
$chart->setTitle("Chart for Orders");
$chart->render("assets/img_public/OrderGraph.png");
Пример #12
0
 protected function onGet(\Controllers\Request $input)
 {
     $this->data['orders'] = Order::orderBy('status', 'desc')->orderBy('created_at', 'asc')->paginate(25, ['*'], 'subpage');
     return parent::onGet($input);
 }
 public function add()
 {
     parent::routes()->render('new_payment_confirmation.twig', array('app_base' => $this->appBase, 'carts' => Cart::countCart(), 'is_customer' => isset($_SESSION['emailCustomer']) ? sizeof($_SESSION['emailCustomer']) : 0, 'is_order' => Order::countOrder(), 'orders' => Order::showOrderPaymentConfirmation(), 'title' => 'Payment Confirmation'));
 }
Пример #14
0
?>
">
        <label>Telefon</label>
        <input name="phone" type="tel" value="<?php 
echo old('phone', $order->phone);
?>
" class="form-control">
    </div>
    <div class="col-xs-12 form-group<?php 
echo $errors->has('status') ? ' has-error' : '';
?>
">
        <label>Stare</label>
        <select name="status" class="form-control">
            <?php 
$availableStatuses = Order::getStatusValues();
foreach ($availableStatuses as $status => $display) {
    ?>
                <option value="<?php 
    echo $status;
    ?>
"<?php 
    echo $status == $order->status ? ' selected' : '';
    ?>
><?php 
    echo $display;
    ?>
</option>
                        <?php 
}
?>
Пример #15
0
 public function indexByDate($id = null)
 {
     parent::routes()->render('sales_report.twig', array('app_base' => $this->appBase, 'grand_total' => Order::grandTotalSalesReportByDate(), 'results' => Order::salesReportByDate(), 'title' => 'Sales Report By Date'));
 }