public function renderDefault() { $this->template->categories_count = mapper::categories()->countAll(); $this->template->manufacturers_count = mapper::manufacturers()->countAll(); $this->template->pages_count = mapper::pages()->countNotRef(); $this->template->products_count = mapper::products()->countAll(); $this->template->pictures_count = mapper::pictures()->countAll(); $this->template->orders_count = mapper::orders()->countAll(); $this->template->orders_initial_count = mapper::orders()->countWithInitialStatus(); }
public function beforeRender() { // curly brackets $this->template->registerFilter('Nette\\Templates\\CurlyBracketsFilter::invoke'); // texy $texy = new Texy(); $this->template->registerHelper('texy', array($texy, 'process')); // side $side = array(); $side['categories'] = mapper::categories()->findMain(); $side['manufacturers'] = mapper::manufacturers()->findAll(); $side['pages'] = mapper::pages()->findNotRef(); $side['cart'] = Environment::getSession(SESSION_ORDER_NS); $side['recent_products'] = Environment::getSession(SESSION_RECENTPRODUCTS_NS)->recent; $this->template->side = (object) $side; }
public function onManufacturerEditSubmit(Form $form) { if (!$form->isValid()) { return; } mapper::manufacturers()->updateOne($form->getValues()); adminlog::log(__('Updated manufacturer "%s"'), $form['nice_name']->getValue()); $this->redirect('manufacturers'); $this->terminate(); }
public function onImportManufacturersFormSubmit(Form $form) { if (!$form->isValid()) { return; } // read imported manufacturers if (!($handle = @fopen('safe://' . $form['file']->getValue()->getTemporaryFile(), 'r'))) { $form->addError(__('Cannot read file.')); return; } $import = array(); while (($_ = fgetcsv($handle)) !== FALSE) { $manufacturer = array(); list(, $manufacturer['name'], $manufacturer['nice_name']) = $_; $import[] = $manufacturer; } fclose($handle); adminlog::log(__('About to import manufacturers')); $manufacturers_added = 0; // import them foreach ($import as $manufacturer) { if (($_ = mapper::manufacturers()->findByNiceName($manufacturer['nice_name'])) === NULL) { mapper::manufacturers()->insertOne($manufacturer); $manufacturers_added++; } } adminlog::log(__('Added %d new manufacturers'), $manufacturers_added); }