Exemple #1
0
 public function last($arg = null)
 {
     $http = new Http();
     if ($http->isActive('to_delete')) {
         $to_delete = $http->post('to_delete');
         foreach ($to_delete as $del) {
             $detail = new Order_details();
             $detail->deleteOrder($del);
         }
         Location::To(URL . 'user/last');
     }
     $orders = new \Models\Orders(\lib\Register::get('id'));
     $pag = new \lib\Pagination(10, $orders->getUserNumberOfOrders());
     $orders_array = $orders->getOrders(10, $pag->page($arg[0]));
     $next = $pag->next();
     $prev = $pag->prev();
     $num_pages = $pag->getPages();
     $selected = $pag->getSelected();
     $data = array();
     if (!empty($orders_array)) {
         foreach ($orders_array as $key => $or) {
             $id = $or->getOrderDetailsId();
             $detail = new Order_details($id);
             $data[$key]['id'] = $id;
             $data[$key]['state'] = $detail->getStatus();
             $data[$key]['date'] = $detail->getDate();
             $data[$key]['nr'] = $detail->getOrderNr();
         }
     }
     $this->render('last', array('categories' => $this->categories, 'd_product' => $this->d_product, 'orders' => $data, 'ids' => $this->category_ids, 'next' => $next, 'prev' => $prev, 'num_pages' => $num_pages, 'selected' => $selected));
 }
Exemple #2
0
 public function checkingNewOrders()
 {
     $http = new Http();
     if ($http->post('max')) {
         $return = array();
         $messages_m = new Orders("noload");
         $return['maxid'] = $messages_m->getMaxValueOfOrderId();
         echo json_encode($return);
         return;
     }
     $messages_m = new Orders("noload");
     $messages = $messages_m->checkingNewOrders($http->post('v'));
     $return = array();
     foreach ($messages as $key => $m) {
         $return[$key]['id'] = $m->getId();
         $return[$key]['date'] = $m->getDate();
         $return[$key]['nr'] = $m->getOrderNr();
         $return[$key]['status'] = $m->getStatus();
     }
     echo json_encode($return);
 }
Exemple #3
0
 public function get_orders()
 {
     $orders = new Orders();
     return $this->app->parser->renderCode('index', ['orders' => $orders->find()->all()], false);
 }
Exemple #4
0
 public function details($arg = null)
 {
     $data = array();
     if (!empty($arg[0])) {
         $order = new Orders();
         $orders = $order->getOrdersByDetailsId($arg[0]);
         foreach ($orders as $key => $o) {
             $data[$key]['name'] = $o->getProductName();
             $data[$key]['quantity'] = $o->getQuantity();
             $data[$key]['price'] = $o->getPrice();
             $data[$key]['product_id'] = $o->getProductId();
         }
     }
     $this->render('order_details', array('categories' => $this->categories, 'd_product' => $this->d_product, 'orders' => $data, 'ids' => $this->category_ids));
 }
Exemple #5
0
function my_order_page()
{
    if (isset($_GET['del'])) {
        $oreder = new Orders();
        $oreder->deleteAll($_GET['del']);
    }
    $admin = new Admin();
    echo $admin->get_orders();
}
 public function deleteOrder($id, $user = true)
 {
     $details = new Order_details($id);
     if (!empty($details)) {
         if ($user) {
             $details->setDisplayUser(false);
             $details->writeData(true);
         } else {
             $details->setDisplaySeller(false);
             $details->writeData(true);
         }
         if (!$details->getDisplaySeller() && !$details->getDisplayUser()) {
             $ord = new Orders();
             $to_delate = $ord->getOrdersByDetailsId($details->getId());
             foreach ($to_delate as $d) {
                 $d->delete();
             }
             $details->delete();
             return;
         }
     }
 }