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; } }