当前位置: 首页>>代码示例>>PHP>>正文


PHP State::fillFromStateCode方法代码示例

本文整理汇总了PHP中State::fillFromStateCode方法的典型用法代码示例。如果您正苦于以下问题:PHP State::fillFromStateCode方法的具体用法?PHP State::fillFromStateCode怎么用?PHP State::fillFromStateCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在State的用法示例。


在下文中一共展示了State::fillFromStateCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createAction

 public function createAction()
 {
     $model = new Tax();
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['model']) && $_POST['model'] == 'Tax') {
         $model->fillFromArray($_POST);
         if (isset($_POST['defaultCountryCheck']) && $_POST['defaultCountryCheck']) {
             $model->state_code = null;
         }
         $model->user_id_created = $this->user->user_id;
         $model->user_id_updated = $this->user->user_id;
         $model->updated = 'NOW():sql';
         $model->created = 'NOW():sql';
         $model->model_uset_id = $this->user->user_id;
         if (isset($_POST['ajax'])) {
             if ($model->save()) {
                 $link = AF::link(array('taxes' => 'view'), array('country_id' => $_POST['country_id']));
                 Message::echoJson('success', array('redirect' => $link));
             } else {
                 Message::echoJsonError(__('taxes_not_created') . '. ' . __('tax_record_exists'));
             }
             die;
         } else {
             if (!$model->save()) {
             } else {
                 $this->redirect('view/country_id=' . $_POST['country_id']);
             }
         }
         die;
     }
     $stateCode = AF::get($this->params, 'state_code', null);
     $countryID = AF::get($this->params, 'country_id', null);
     $stateModel = new State();
     if ($stateCode && !$countryID) {
         $stateModel->fillFromStateCode($stateCode);
         $countryID = $stateModel->country_id;
         $this->params['country_id'] = $countryID;
     }
     $countries = Country::model()->cache()->findAllInArray();
     $states = State::model()->getStates($countryID);
     //$countryDefault = Taxs::getCountryDefault($countryID);
     Assets::js('jquery.form');
     $this->addToPageTitle('Create Tax record');
     $this->render('create', array('model' => $model, 'states' => $states, 'countries' => $countries));
 }
开发者ID:,项目名称:,代码行数:46,代码来源:

示例2: getStateName

 public function getStateName()
 {
     $state = new State();
     $state->fillFromStateCode($this->state_id);
     return $state->state_name;
 }
开发者ID:,项目名称:,代码行数:6,代码来源:

示例3: payCreditCard

 public function payCreditCard()
 {
     $shipStateModel = new State();
     $shipStateModel->fillFromStateCode($this->shippingAddressModel->state_id);
     if ($this->shippingAddressModel->state_id == $this->billingAddressModel->state_id) {
         $billingStateModel = $shipStateModel;
     } else {
         $billingStateModel = new State();
         $billingStateModel->fillFromStateCode($this->billingAddressModel->state_id);
     }
     //set currency_id to options
     $pacnetOptions = $this->gatewayModel->getAttributes();
     $pacnetOptions['currency_id'] = $this->campaignModel->currency_id;
     $pacnetOptions['isTest'] = self::$isTest;
     // Create and populate a request object
     $pymtReq = new RavenRequest('submit', $pacnetOptions);
     $pymtReq->set('Currency', $this->campaignModel->currency_id);
     $pymtReq->set('RequestID', $this->attemptModel->getrequest_id('pn'));
     $pymtReq->set('Amount', $this->attemptModel->amount * 100);
     $pymtReq->set('PymtType', self::CC_DEBIT);
     $pymtReq->set('CardNumber', $this->paymentModel->cc_number);
     $pymtReq->set('ExpiryDate', $this->paymentModel->exp_date);
     $pymtReq->set('CVV2', $this->paymentModel->cc_cvv);
     /*$pymtReq->set('BillingAddressLine1', $this->billingAddressModel->address1);
       $pymtReq->set('BillingAddressLine2', $this->billingAddressModel->address2);
       $pymtReq->set('BillingCity', $this->billingAddressModel->city);
       $pymtReq->set('BillingRegion', $billingStateModel->state_name);
       $pymtReq->set('BillingPostal', $this->billingAddressModel->zip);
       $pymtReq->set('BillingCountry', $this->billingAddressModel->country_id);
       $pymtReq->set('ShipToRegion', $shipStateModel->state_name);
       $pymtReq->set('ShipToCity', $this->shippingAddressModel->city);
       $pymtReq->set('ShipToPostal', $this->shippingAddressModel->zip);
       $pymtReq->set('ShipToCountry', $this->shippingAddressModel->country_id);
       $pymtReq->set('ShippingAddressLine1', $this->shippingAddressModel->address1);
       $pymtReq->set('ShippingAddressLine2', $this->shippingAddressModel->address2);
       $pymtReq->set('ContactEmail', $this->customerModel->email);
       $pymtReq->set('CustomerPhone', $this->shippingAddressModel->phone);*/
     $pymtReq->set('Description', $this->campaignModel->profile->descriptor_name);
     $pymtReq->set('Description2', $this->campaignModel->profile->descriptor_phone);
     //Change Attempt Status to inprogress
     Attempt::setAttemptStatus($this->attemptModel, Attempt::INPROGRESS_STATUS);
     // Submit the request
     try {
         fb($pymtReq);
         //Send request
         $pymtResp = $pymtReq->send();
         fb($pymtResp);
     } catch (Exception $e) {
         //Change Attempt Status to unknown
         Attempt::setAttemptStatus($this->attemptModel, Attempt::UNKNOWN_STATUS);
         $this->_paymetnResponse->addError('error_processing_request');
         $this->_paymetnResponse->addAlert('error_processing_your_request');
         $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
         return false;
     }
     $errors = array();
     if ($pymtResp->get('httpStatus') == 'timeout') {
         $respReq = new RavenRequest('response', $this->gatewayModel->getAttributes());
         $respReq->set('RequestID', $pymtReq->get('RequestID'));
         $pymtResp = $respReq->send();
     }
     if ($pymtResp->get('httpStatus') != 200) {
         $errors['httpStatus'] = $pymtResp->get('httpStatus');
     }
     if ($pymtResp->get('ErrorCode')) {
         $errorCode = strtolower($pymtResp->get('ErrorCode'));
         if (!in_array($errorCode, $errors)) {
             $errors['ErrorCode'] = $errorCode;
         }
     }
     if ($pymtResp->get('Status') != 'Approved') {
         $statusCode = strtolower($pymtResp->get('Status'));
         if (!in_array($statusCode, $errors)) {
             $errors['Status'] = $statusCode;
         }
         if ($pymtResp->get('Message')) {
             $errors['Message'] = $pymtResp->get('Message');
         }
     }
     if ($errors) {
         //Change Attempt Status to decline and save status note
         //Attempt::setAttemptStatus($this->attemptModel, Attempt::DECLINED_STATUS);
         $this->attemptModel->status = Attempt::DECLINED_STATUS;
         // including try catch because I'm not sure the "get" command will work for all error statuses
         try {
             if ($pymtResp->get('TrackingNumber')) {
                 $this->attemptModel->tracking_number = $pymtResp->get('TrackingNumber');
             }
         } catch (Exception $e) {
             // do nothing
         }
         $this->attemptModel->status_note = implode(',', $errors);
         $this->attemptModel->save();
         foreach ($errors as $key => $error) {
             $this->_paymetnResponse->addError($key, $error);
         }
         $this->_paymetnResponse->addAlert('error_processing_your_request');
         $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
         $this->_paymetnResponse->attemptModel = $this->attemptModel;
         $this->_paymetnResponse->paymentModel = $this->paymentModel;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的State::fillFromStateCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。