Exemplo n.º 1
0
 public function getUoms()
 {
     $uomDb = new Application_Model_DbTable_Uom();
     $uomsObject = $uomDb->fetchAll();
     $uoms = array();
     foreach ($uomsObject as $uom) {
         $uoms[$uom->id] = $uom->title;
     }
     return $uoms;
 }
Exemplo n.º 2
0
 public function getOptions($form, $clientid)
 {
     $options = array();
     //Get categories
     $categoriesDb = new Application_Model_DbTable_Category();
     $categoriesObject = $categoriesDb->fetchAll($categoriesDb->select()->where('type = ?', 'item')->where('clientid = ?', $clientid)->order('ordering'));
     $categories = array();
     foreach ($categoriesObject as $category) {
         if (!$category->parentid) {
             $categories[$category->id]['id'] = $category->id;
             $categories[$category->id]['title'] = $category->title;
             $categories[$category->id]['parent'] = $category->parentid;
             if ($category->parentid) {
                 if (!isset($categories[$category->parentid])) {
                     $categories[$category->parentid] = array();
                 }
                 if (!isset($categories[$category->parentid]['childs'])) {
                     $categories[$category->parentid]['childs'] = array();
                 }
                 array_push($categories[$category->parentid]['childs'], $category->id);
             }
         }
     }
     foreach ($categoriesObject as $category) {
         if ($category->parentid) {
             $categories[$category->id]['id'] = $category->id;
             $categories[$category->id]['title'] = $category->title;
             $categories[$category->id]['parent'] = $category->parentid;
             if ($category->parentid) {
                 if (!isset($categories[$category->parentid])) {
                     $categories[$category->parentid] = array();
                 }
                 if (!isset($categories[$category->parentid]['childs'])) {
                     $categories[$category->parentid]['childs'] = array();
                 }
                 array_push($categories[$category->parentid]['childs'], $category->id);
             }
         }
     }
     $options['categories'] = $categories;
     //Get manufacturers
     $manufacturerDb = new Application_Model_DbTable_Manufacturer();
     $manufacturersObject = $manufacturerDb->fetchAll();
     $manufacturers = array();
     foreach ($manufacturersObject as $manufacturer) {
         $manufacturers[$manufacturer->id] = $manufacturer->name;
     }
     $options['manufacturers'] = $manufacturers;
     //Get uoms
     $uomDb = new Application_Model_DbTable_Uom();
     $uomsObject = $uomDb->fetchAll();
     $uoms = array();
     foreach ($uomsObject as $uom) {
         $uoms[$uom->id] = $uom->title;
     }
     $options['uoms'] = $uoms;
     //Get tax rates
     $taxrateDb = new Application_Model_DbTable_Taxrate();
     $taxratesObject = $taxrateDb->fetchAll();
     $taxrates = array();
     $locale = Zend_Registry::get('Zend_Locale');
     foreach ($taxratesObject as $taxrate) {
         $taxrates[$taxrate->id] = Zend_Locale_Format::toNumber($taxrate->rate, array('precision' => 1, 'locale' => $locale)) . ' %';
     }
     $options['taxrates'] = $uoms;
     //Set form options
     $form->catid->addMultiOptions($this->getMenuStructure($categories));
     $form->manufacturerid->addMultiOptions($manufacturers);
     if (isset($form->uomid)) {
         $form->uomid->addMultiOptions($uoms);
     }
     if (isset($form->taxid)) {
         $form->taxid->addMultiOptions($taxrates);
     }
     return $options;
 }
Exemplo n.º 3
0
 public function viewAction()
 {
     $id = $this->_getParam('id', 0);
     $processDb = new Processes_Model_DbTable_Process();
     $process = $processDb->getProcess($id);
     $process['processdate'] = date('d.m.Y', strtotime($process['processdate']));
     //Get positions
     $positionsDb = new Processes_Model_DbTable_Processpos();
     $positionsObject = $positionsDb->fetchAll($positionsDb->select()->where('processid = ?', $id)->order('ordering'));
     $positions = array();
     foreach ($positionsObject as $positionObject) {
         foreach ($positionObject as $key => $value) {
             $positions[$positionObject->id][$key] = $value;
         }
         $positions[$positionObject->id]['price'] = $this->_currency->toCurrency($positions[$positionObject->id]['price']);
         $positions[$positionObject->id]['quantity'] = Zend_Locale_Format::toNumber($positions[$positionObject->id]['quantity'], array('precision' => 2, 'locale' => Zend_Registry::get('Zend_Locale')));
     }
     //Get units of measurement
     $uomDb = new Application_Model_DbTable_Uom();
     $uom = $uomDb->fetchAll();
     $uoms = array();
     foreach ($uom as $value) {
         $uoms[$value->title] = $value->title;
     }
     $toolbar = new Processes_Form_Toolbar();
     $this->view->toolbar = $toolbar;
     $this->view->process = $process;
     $this->view->positions = $positions;
     $this->view->uoms = $uoms;
     $this->view->evaluate = $this->evaluate($positionsObject, $process['taxfree']);
     $this->view->messages = $this->_flashMessenger->getMessages();
 }