Esempio n. 1
0
 public static function taxDataHtml($field)
 {
     $listOfDest = array();
     if (!is_array($field->value)) {
         if (empty($field->value)) {
             $field->value = array();
         } else {
             $field->value = (array) json_decode($field->value, true);
         }
     }
     foreach (self::$userfieldDest as $d) {
         $listOfDest[] = array('id' => $d, 'text' => $d, 'checked' => is_array($field->value['dest']) && in_array($d, $field->value['dest']));
     }
     $categories = frameCsp::_()->getModule('products')->getCategories();
     $brands = frameCsp::_()->getModule('products')->getBrands();
     $cOptions = array();
     $bOptions = array();
     if (!empty($categories)) {
         if (!is_array($field->value['categories'])) {
             $field->value['categories'] = array();
         }
         foreach ($categories as $c) {
             $cOptions[] = array('id' => $c->term_taxonomy_id, 'text' => $c->cat_name, 'checked' => in_array($c->term_taxonomy_id, $field->value['categories']));
         }
     }
     if (!empty($brands)) {
         if (!is_array($field->value['brands'])) {
             $field->value['brands'] = array();
         }
         foreach ($brands as $b) {
             $bOptions[] = array('id' => $b->term_taxonomy_id, 'text' => $b->cat_name, 'checked' => in_array($b->term_taxonomy_id, $field->value['brands']));
         }
     }
     return '<div>' . langCsp::_('Apply To') . '
         <div id="tax_address">
             <b>' . langCsp::_('Address') . '</b><br />
             ' . langCsp::_('Destination') . ':' . htmlCsp::checkboxlist('params[dest]', array('optionsCsp' => $listOfDest)) . '<br />
             ' . langCsp::_('Country') . ':' . htmlCsp::countryList('params[country]', array('notSelected' => true, 'value' => $field->value['country'])) . '<br />
         </div>
         <div id="tax_category">
             <b>' . langCsp::_('Categories') . '</b><br />
             ' . (empty($cOptions) ? langCsp::_('You have no categories') : htmlCsp::checkboxlist('params[categories][]', array('optionsCsp' => $cOptions))) . '<br />
                 <b>' . langCsp::_('Brands') . '</b><br />
             ' . (empty($bOptions) ? langCsp::_('You have no brands') : htmlCsp::checkboxlist('params[brands][]', array('optionsCsp' => $bOptions))) . '<br />
         </div>
         <div>' . langCsp::_('Tax Rate') . ': ' . htmlCsp::text('params[rate]', array('value' => $field->value['rate'])) . '</div>
         <div>' . langCsp::_('Absolute') . ': ' . htmlCsp::checkbox('params[absolute]', array('checked' => $field->value['absolute'])) . '</div>
     </div>';
 }