示例#1
0
文件: TaxRate.php 项目: dewawi/dewawi
 public function getTaxRateIDs($locale = null)
 {
     $taxrateDb = new Application_Model_DbTable_Taxrate();
     $taxratesObject = $taxrateDb->fetchAll();
     $taxrates = array();
     if ($locale) {
         foreach ($taxratesObject as $taxrate) {
             $taxrates[$taxrate->id] = Zend_Locale_Format::toNumber($taxrate->rate, array('precision' => 1, 'locale' => $locale)) . ' %';
         }
     } else {
         foreach ($taxratesObject as $taxrate) {
             $taxrates[$taxrate->id] = $taxrate->rate;
         }
     }
     return $taxrates;
 }
示例#2
0
文件: Options.php 项目: dewawi/dewawi
 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;
 }