Exemple #1
0
 /**
  * @static
  * @return array
  */
 public static function collect()
 {
     if (null === self::$_collection) {
         self::$_collection = Axis::single('location/country')->select(array('id', 'name'))->fetchPairs();
     }
     return self::$_collection;
 }
Exemple #2
0
 public function init()
 {
     $configOptions = Axis::config('account/address_form')->toArray();
     $this->_fieldConfig = array_merge(array('firstname_sort_order' => -20, 'firstname_status' => 'required', 'lastname_sort_order' => -19, 'lastname_status' => 'required'), $configOptions);
     $form = $this;
     if ($subform = $this->getAttrib('subform')) {
         $form = new Axis_Form();
         // makes possible to use brackets in field names
         $form->setIsArray(true);
         $form->removeDecorator('Form');
         $this->addSubForm($form, $subform);
     }
     $countries = Axis_Collect_Country::collect();
     if (isset($countries['0']) && 'ALL WORLD COUNTRY' === $countries['0']) {
         unset($countries['0']);
     }
     $allowedCountries = $configOptions['country_id_allow'];
     if (!in_array(0, $allowedCountries)) {
         // ALL WORLD COUNTRIES is not selected
         $countries = array_intersect_key($countries, array_flip($allowedCountries));
     }
     $countryIds = array_keys($countries);
     $defaultCountry = current($countryIds);
     $zones = Axis_Collect_Zone::collect();
     $this->_zones = $zones;
     if ('billing_address' == $subform && !($customerId = Axis::getCustomerId())) {
         $form->addElement('text', 'email', array('required' => true, 'label' => 'Email', 'class' => 'input-text required email', 'validators' => array('EmailAddress')));
     }
     foreach ($this->_fields as $name => $values) {
         $status = $this->_fieldConfig[$name . '_status'];
         if ('disabled' == $status) {
             continue;
         }
         $fieldOptions = array('required' => 'required' === $status, 'label' => $values['label'], 'class' => $values['class'] . ('required' === $status ? ' required' : ''));
         if (isset($this->_fieldConfig[$name . '_sort_order'])) {
             $fieldOptions['order'] = $this->_fieldConfig[$name . '_sort_order'];
         }
         if ('country_id' == $name) {
             $fieldOptions['validators'] = array(new Zend_Validate_InArray(array_keys($countries)));
             $values['type'] = new Zend_Form_Element_Select($name, $fieldOptions);
             $values['type']->removeDecorator('HtmlTag')->addDecorator('HtmlTag', array('tag' => 'li', 'id' => "{$subform}-{$name}-row", 'class' => 'element-row'));
             $values['type']->options = $countries;
         } else {
             if ('zone_id' == $name) {
                 $values['type'] = new Zend_Form_Element_Select($name, $fieldOptions);
                 $values['type']->removeDecorator('HtmlTag')->addDecorator('HtmlTag', array('tag' => 'li', 'id' => "{$subform}-{$name}-row", 'class' => 'element-row'));
                 if (isset($zones[$defaultCountry]) && count($countries)) {
                     $values['type']->options = $zones[$defaultCountry];
                 }
                 // zone name field
                 $zoneNameOptions = $fieldOptions;
                 $zoneNameOptions['order']++;
                 $zoneNameOptions['class'] .= ' input-text';
                 $form->addElement('text', 'state', $zoneNameOptions);
             }
         }
         $form->addElement($values['type'], $name, $fieldOptions);
     }
     $form->addDisplayGroup($form->getElements(), $subform);
 }
Exemple #3
0
 public function init()
 {
     $this->addElement('hidden', 'id', array('validators' => array(new Axis_Account_Model_Form_Validate_AddressId())));
     $configOptions = Axis::config('account/address_form')->toArray();
     $this->_fieldConfig = array_merge(array('firstname_sort_order' => -20, 'firstname_status' => 'required', 'lastname_sort_order' => -19, 'lastname_status' => 'required'), $configOptions);
     $countries = Axis_Collect_Country::collect();
     if (isset($countries['0']) && 'ALL WORLD COUNTRY' === $countries['0']) {
         unset($countries['0']);
     }
     $allowedCountries = $configOptions['country_id_allow'];
     if (!in_array(0, $allowedCountries)) {
         // ALL WORLD COUNTRIES is not selected
         $countries = array_intersect_key($countries, array_flip($allowedCountries));
     }
     $countryIds = array_keys($countries);
     $defaultCountry = current($countryIds);
     $zones = Axis_Collect_Zone::collect();
     $this->_zones = $zones;
     foreach ($this->_fields as $name => $values) {
         $status = $this->_fieldConfig[$name . '_status'];
         if ('disabled' == $status) {
             continue;
         }
         $fieldOptions = array('required' => 'required' === $status, 'label' => $values['label'], 'class' => $values['class'] . ('required' === $status ? ' required' : ''));
         if (isset($this->_fieldConfig[$name . '_sort_order'])) {
             $fieldOptions['order'] = $this->_fieldConfig[$name . '_sort_order'];
         }
         if ('country_id' == $name) {
             $fieldOptions['validators'] = array(new Zend_Validate_InArray(array_keys($countries)));
             $values['type'] = new Zend_Form_Element_Select($name, $fieldOptions);
             $values['type']->removeDecorator('HtmlTag')->addDecorator('HtmlTag', array('tag' => 'li', 'id' => "{$name}-row", 'class' => 'element-row'));
             $values['type']->options = $countries;
         } else {
             if ('zone_id' == $name) {
                 $values['type'] = new Zend_Form_Element_Select($name, $fieldOptions);
                 $values['type']->removeDecorator('HtmlTag')->addDecorator('HtmlTag', array('tag' => 'li', 'id' => "{$name}-row", 'class' => 'element-row'));
                 if (isset($zones[$defaultCountry]) && count($countries)) {
                     $values['type']->options = $zones[$defaultCountry];
                 }
                 // zone name field
                 $zoneNameOptions = $fieldOptions;
                 $zoneNameOptions['order']++;
                 $zoneNameOptions['class'] .= ' input-text';
                 $this->addElement('text', 'state', $zoneNameOptions);
             }
         }
         $this->addElement($values['type'], $name, $fieldOptions);
     }
     $this->addDisplayGroup($this->getElements(), 'address', array('legend' => 'Address'));
     $this->addElement('checkbox', 'default_billing', array('label' => 'Use as my default billing address', 'class' => 'input-checkbox'));
     $element = $this->getElement('default_billing');
     $this->addElement('checkbox', 'default_shipping', array('label' => 'Use as my default shipping address', 'class' => 'input-checkbox'));
     $element = $this->getElement('default_shipping');
     $this->addElement('button', 'submit', array('type' => 'submit', 'class' => 'button', 'label' => 'Save'));
     $this->addActionBar(array('submit'));
 }
Exemple #4
0
 /**
  * @param mixed (int|bool) $siteId[optional]
  * @return array
  */
 public function getCompanyInfo($siteId = null)
 {
     $company = Axis::config('core/company', $siteId)->toArray();
     //@todo Use Axis_Object
     return array('email' => Axis_Collect_MailBoxes::getName($company['administratorEmail']), 'city' => $company['city'], 'country' => Axis_Collect_Country::getName($company['country']), 'fax' => $company['fax'], 'name' => $company['name'], 'phone' => $company['phone'], 'postcode' => $company['zip'], 'site' => $company['site'], 'zone' => Axis_Collect_Zone::getName($company['zone']), 'street_address' => $company['street'], 'customer_relation_email' => Axis_Collect_MailBoxes::getName($company['customerRelationEmail']), 'sales_email' => Axis_Collect_MailBoxes::getName($company['salesDepartmentEmail']), 'support_email' => Axis_Collect_MailBoxes::getName($company['supportEmail']));
 }