Example #1
0
 /**
  * (non-PHPdoc)
  * @see \library\BaseModel::getElementsRender()
  */
 public function getElementsRender()
 {
     $output = array('address_id' => array('__tid__' => 'main', 'type' => 'hidden', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDRESS_ID_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDRESS_ID_HINT')), 'address_name' => array('__tid__' => 'main', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDRESS_NAME_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDRESS_NAME_HINT'), 'disable' => true), 'member_id' => array('__tid__' => 'main', 'type' => 'hidden', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_MEMBER_ID_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_MEMBER_ID_HINT')), 'consignee' => array('__tid__' => 'main', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_CONSIGNEE_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_CONSIGNEE_HINT'), 'required' => true), 'mobiphone' => array('__tid__' => 'main', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_MOBIPHONE_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_MOBIPHONE_HINT')), 'telephone' => array('__tid__' => 'main', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_TELEPHONE_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_TELEPHONE_HINT')), 'email' => array('__tid__' => 'main', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_EMAIL_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_EMAIL_HINT')), 'addr_country_id' => array('__tid__' => 'main', 'type' => 'select', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_COUNTRY_ID_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_COUNTRY_ID_HINT')), 'addr_country' => array('__tid__' => 'main', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_COUNTRY_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_COUNTRY_HINT')), 'addr_province_id' => array('__tid__' => 'main', 'type' => 'select', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_PROVINCE_ID_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_PROVINCE_ID_HINT')), 'addr_province' => array('__tid__' => 'main', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_PROVINCE_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_PROVINCE_HINT')), 'addr_city_id' => array('__tid__' => 'main', 'type' => 'select', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_CITY_ID_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_CITY_ID_HINT')), 'addr_city' => array('__tid__' => 'main', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_CITY_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_CITY_HINT')), 'addr_district_id' => array('__tid__' => 'main', 'type' => 'select', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_DISTRICT_ID_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_DISTRICT_ID_HINT')), 'addr_district' => array('__tid__' => 'main', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_DISTRICT_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_DISTRICT_HINT')), 'addr_street' => array('__tid__' => 'main', 'type' => 'textarea', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_STREET_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_STREET_HINT'), 'required' => true), 'addr_zipcode' => array('__tid__' => 'main', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_ZIPCODE_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_ADDR_ZIPCODE_HINT')), 'when' => array('__tid__' => 'main', 'type' => 'radio', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_WHEN_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_WHEN_HINT'), 'options' => DataAddresses::getWhenEnum(), 'value' => DataAddresses::WHEN_ANYONE), 'is_default' => array('__tid__' => 'main', 'type' => 'switch', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_IS_DEFAULT_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_IS_DEFAULT_HINT'), 'options' => DataAddresses::getIsDefaultEnum(), 'value' => DataAddresses::IS_DEFAULT_Y), 'dt_created' => array('__tid__' => 'system', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_DT_CREATED_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_DT_CREATED_HINT'), 'disabled' => true), 'dt_last_modified' => array('__tid__' => 'system', 'type' => 'text', 'label' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_DT_LAST_MODIFIED_LABEL'), 'hint' => Text::_('MOD_MEMBER_MEMBER_ADDRESSES_DT_LAST_MODIFIED_HINT'), 'disabled' => true));
     return $output;
 }
Example #2
0
 /**
  * (non-PHPdoc)
  * @see \libsrv\FormProcessor::_cleanPostProcess()
  */
 public function _cleanPostProcess()
 {
     if (isset($this->when)) {
         $enum = DataAddresses::getWhenEnum();
         if (!isset($enum[$this->when])) {
             $this->when = DataAddresses::WHEN_ANYONE;
         }
     }
     if (isset($this->is_default)) {
         $enum = DataAddresses::getIsDefaultEnum();
         if (!isset($enum[$this->is_default])) {
             $this->is_default = DataAddresses::IS_DEFAULT_N;
         }
     }
     if ($this->isUpdate()) {
         $row = $this->_object->findByPk($this->id);
         if (!$row || !is_array($row) || !isset($row['address_id']) || !isset($row['mobiphone']) || !isset($row['telephone'])) {
             Log::warning(sprintf('FpAddresses is unable to find the result by id "%d"', $this->id), ErrorNo::ERROR_DB_SELECT, __METHOD__);
             return false;
         }
         if (isset($this->mobiphone) && $this->mobiphone === '') {
             if (!isset($this->telephone) && $row['telephone'] === '') {
                 $this->addError('mobiphone', Lang::_('SRV_FILTER_MEMBER_ADDRESSES_MOBIPHONE_TELEPHONE_NOTEMPTY'));
                 return false;
             }
         }
         if (isset($this->telephone) && $this->telephone === '') {
             if (!isset($this->mobiphone) && $row['mobiphone'] === '') {
                 $this->addError('telephone', Lang::_('SRV_FILTER_MEMBER_ADDRESSES_MOBIPHONE_TELEPHONE_NOTEMPTY'));
                 return false;
             }
         }
         $consignee = isset($this->consignee) ? $this->consignee : $row['consignee'];
     }
     if (isset($this->mobiphone) && $this->mobiphone === '' && (isset($this->telephone) && $this->telephone === '')) {
         $this->addError('mobiphone', Lang::_('SRV_FILTER_MEMBER_ADDRESSES_MOBIPHONE_TELEPHONE_NOTEMPTY'));
         $this->addError('telephone', Lang::_('SRV_FILTER_MEMBER_ADDRESSES_MOBIPHONE_TELEPHONE_NOTEMPTY'));
         return false;
     }
     if ($this->isInsert()) {
         $consignee = $this->consignee;
     }
     if ($this->isUpdate()) {
         if (!isset($this->addr_country_id) && !isset($this->addr_province_id) && !isset($this->addr_city_id) && !isset($this->addr_district_id)) {
             $this->address_name = $consignee . '-' . $row['addr_city'];
             return true;
         }
     }
     if (!isset($this->addr_country_id)) {
         $this->addr_country_id = 1;
     }
     if (!isset($this->addr_province_id)) {
         $this->addr_province_id = 0;
     }
     if (!isset($this->addr_city_id)) {
         $this->addr_city_id = 0;
     }
     if (!isset($this->addr_district_id)) {
         $this->addr_district_id = 0;
     }
     $addrCountryId = $this->addr_country_id;
     $addrProvinceId = $this->addr_province_id;
     $addrCityId = $this->addr_city_id;
     $addrDistrictId = $this->addr_district_id;
     $srv = Service::getInstance('Regions', 'system');
     $this->addr_country = $this->addr_province = $this->addr_city = $this->addr_district = '';
     $row = $srv->findByPk($addrCountryId);
     if ($row && is_array($row) && isset($row['region_pid'], $row['region_name'], $row['region_type'])) {
         if ((int) $row['region_pid'] === 0 && (int) $row['region_type'] === 0) {
             $this->addr_country = $row['region_name'];
         }
     }
     if ($this->addr_country === '') {
         $this->addError('addr_country_id', Lang::_('SRV_FILTER_MEMBER_ADDRESSES_ADDR_ID_INTEGER'));
         return false;
     }
     $row = $srv->findByPk($addrProvinceId);
     if ($row && is_array($row) && isset($row['region_pid'], $row['region_name'], $row['region_type'])) {
         if ((int) $row['region_pid'] === $addrCountryId && (int) $row['region_type'] === 1) {
             $this->addr_province = $row['region_name'];
         }
     }
     if ($this->addr_province === '') {
         $this->addError('addr_province_id', Lang::_('SRV_FILTER_MEMBER_ADDRESSES_ADDR_ID_INTEGER'));
         return false;
     }
     $row = $srv->findByPk($addrCityId);
     if ($row && is_array($row) && isset($row['region_pid'], $row['region_name'], $row['region_type'])) {
         if ((int) $row['region_pid'] === $addrProvinceId && (int) $row['region_type'] === 2) {
             $this->addr_city = $row['region_name'];
         }
     }
     if ($this->addr_city === '') {
         $this->addError('addr_city_id', Lang::_('SRV_FILTER_MEMBER_ADDRESSES_ADDR_ID_INTEGER'));
         return false;
     }
     $row = $srv->findByPk($addrDistrictId);
     if ($row && is_array($row) && isset($row['region_pid'], $row['region_name'], $row['region_type'])) {
         if ((int) $row['region_pid'] === $addrCityId && (int) $row['region_type'] === 3) {
             $this->addr_district = $row['region_name'];
         }
     }
     if ($this->addr_district === '') {
         $this->addError('addr_district_id', Lang::_('SRV_FILTER_MEMBER_ADDRESSES_ADDR_ID_INTEGER'));
         return false;
     }
     $this->address_name = $consignee . '-' . $this->addr_city;
     return true;
 }
Example #3
0
 /**
  * 获取“收货最佳时间”
  * @param string $when
  * @return string
  */
 public function getWhenLangByWhen($when)
 {
     $enum = DataAddresses::getWhenEnum();
     return isset($enum[$when]) ? $enum[$when] : '';
 }