/** * @param \Nette\Application\UI\Presenter $presenter */ protected function configure(\Nette\Application\UI\Presenter $presenter) { parent::configure($presenter); $orders = $this->ordersModel->getDriverOrders($presenter->getUser()->getId()); $driverPlan = array(); foreach ($orders as $temp) { $temp->from = $this->productsModel->getCityName($temp->from)->name; $temp->to = $this->productsModel->getCityName($temp->to)->name; $driverPlan[] = $temp; } $this->setModel($driverPlan); $this->setPrimaryKey($this->ordersModel->getPrimaryKeyName()); $this->setRememberState(TRUE); $this->setFilterRenderType(\Grido\Components\Filters\Filter::RENDER_INNER); $this->addColumnText('car_id', 'Evidenčné číslo auta')->setSortable()->setFilterText(); $this->addColumnText('product_id', 'ID objednávky')->setSortable()->setFilterText(); $this->addColumnText('name', 'Názov tovaru')->setSortable()->setFilterText(); $this->addColumnText('product_amount', 'Počet')->setSortable()->setFilterText(); $this->addColumnDate('date', 'Dátum dovozu')->setSortable()->setFilterText(); $this->addColumnText('from', 'Odvoz z')->setSortable()->setFilterText(); $this->addColumnText('to', 'Dovoz do')->setSortable()->setFilterText(); $this->addActionHref('add', '')->setDisable(function ($item) { if (isset($item->delivered)) { return true; } return false; })->setIcon('ok')->getElementPrototype()->setTitle('Doručené'); }
/** * @param int $order_id */ public function actionAdd($order_id) { ini_set('max_execution_time', 500); $data = $this->ordersModel->getOrder($order_id); $product = $this->productsModel->getProduct($data->product_id); $orders = $this->ordersModel->getOrdersProduct($data->product_id); $amount = $data->product_amount; foreach ($orders as $temp) { $amount += $temp->product_amount; } if ($product->amount == $amount) { $this->productsModel->update($data->product_id, array('status' => 2)); mail($product->email, 'Objednavka cislo' . $product->product_id, 'Celá Vaša objednávka s číslom ' . $product->product_id . ' bola úspešne doručená.', 'From: ltranstransportcompany@gmail.com'); } else { mail($product->email, 'Objednavka cislo' . $product->product_id, 'Časť Vašej objednávky s číslom ' . $product->product_id . ' a množstvom ' . $data->product_amount . ' bolo úspešne doručené.', 'From: ltranstransportcompany@gmail.com'); } $this->ordersModel->update($order_id, array('delivered' => new DateTime())); $this->flashMessage('Objednávka bola doručená!', 'success'); $this->redirect('Optimalization:driver'); }
/** * @param int $product_id */ public function handleDelete($product_id) { $this->productsModel->delete($product_id); $this->flashMessage('Produkt bol úspešne vymazaný!', 'success'); $this->redirect('Product:'); }
/** * @param \Nette\Application\UI\Presenter $presenter */ protected function configure(\Nette\Application\UI\Presenter $presenter) { parent::configure($presenter); if ($presenter->getUser()->isInRole(3)) { $products = $this->productsModel->getAllUserProducts($this->user); $temp = array(); foreach ($products as $product) { $product->from = $this->productsModel->getCityName($product->from)->name; $product->to = $this->productsModel->getCityName($product->to)->name; $product->size = $product->size . ' m³'; $product->weight = $product->weight . ' kg'; $product->price = $product->price . ' €'; if ($product->status) { $product->status = 'Odoslaný'; } else { $product->status = 'Nespracovaný'; } $temp[] = $product; } $this->setModel($temp); } else { $products = $this->productsModel->getAllProducts(); foreach ($products as $product) { $product->from = $this->productsModel->getCityName($product->from)->name; $product->to = $this->productsModel->getCityName($product->to)->name; $product->size = $product->size . ' m³'; $product->weight = $product->weight . ' kg'; $product->price = $product->price . ' €'; if ($product->status == 0) { $product->status = 'Nespracovaná'; } else { if ($product->status == 1) { $product->status = 'Odoslaná'; } else { if ($product->status == 2) { $product->status = 'Doručená'; } } } $temp[] = $product; } $this->setModel($temp); } $this->setPrimaryKey($this->productsModel->getPrimaryKeyName()); $this->setRememberState(TRUE); $this->setFilterRenderType(\Grido\Components\Filters\Filter::RENDER_INNER); $this->addColumnText('product_id', 'ID')->setSortable()->setFilterText(); $this->addColumnText('name', 'Názov')->setSortable()->setFilterText(); $this->addColumnText('amount', 'Počet')->setSortable()->setFilterText(); $this->addColumnText('weight', 'Váha')->setSortable()->setFilterText(); $this->addColumnText('size', 'Veľkosť')->setSortable()->setFilterText(); $this->addColumnText('from', 'Odvoz z mesta')->setSortable()->setFilterText(); $this->addColumnText('to', 'Odvoz do mesta')->setSortable()->setFilterText(); $this->addColumnDate('date', 'Dátum prepravy')->setSortable()->setFilterText(); $this->addColumnText('priority', 'Priorita')->setSortable()->setFilterText(); $this->addColumnText('price', 'Cena')->setSortable()->setFilterText(); $this->addColumnText('status', 'Status')->setSortable()->setFilterText(); $this->addActionHref('edit', '')->setDisable(function ($item) { if ($item->date > new \Dibi\DateTime() && $item->status == 'Nespracovaná') { return false; } return true; })->setIcon('pencil')->getElementPrototype()->setTitle('Upraviť'); $this->addActionHref('delete', '', 'delete!')->setDisable(function ($item) { if ($item->date > new \Dibi\DateTime() && $item->status == 'Nespracovaná') { return false; } return true; })->setIcon('trash icon-white')->setConfirm('Naozaj chcete odstrániť záznam?')->setElementPrototype(Html::el('a')->addClass('btn btn-danger btn-mini')->setTitle('Zmazať')); }