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)); }
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; } }
public function orderDetails() { $http = new Http(); $id = $http->post('id'); $orders_m = new Orders(); $orders = $orders_m->getOrdersByDetailsId($id); $order_det = new Order_details($id); $order_data = array(); $order_details = array(); $shippment = new Shippment($order_det->getShippingMethodId()); $order_details['shipping_method'] = $shippment->getShippingName(); $order_details['address'] = $order_det->getAddress(); if (!empty($orders)) { foreach ($orders as $key => $o) { $order_data[$key]['product_name'] = $o->getProductName(); $order_data[$key]['product_quantity'] = $o->getQuantity(); $order_data[$key]['product_price'] = $o->getPrice(); $order_data[$key]['product_id'] = $o->getProductId(); } } echo $this->render('adminorder', array('order_data' => $order_data, 'order_details' => $order_details, 'order_nr' => $order_det->getOrderNr())); }
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; } } }