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


PHP Customer::getErrors方法代码示例

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


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

示例1: __construct

 /** Override __construct() because we're not passing user/pass
  */
 public function __construct()
 {
     $user = new Customer();
     $user->record_type = Customer::GUEST;
     $user->last_login = new CDbExpression('NOW()');
     if ($user->save() === false) {
         print_r($user->getErrors());
     }
     $this->setState('fullname', 'Guest');
     $this->setState('firstname', 'Guest');
     $this->_id = $user->id;
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:14,代码来源:GuestIdentity.php

示例2: authenticate

 /**
  * Authenticate user
  * @return type
  */
 public function authenticate()
 {
     $user = Customer::model()->findByAttributes(array('facebook' => $this->password));
     if ($user instanceof Customer) {
         $this->loginHousekeeping($user);
     } else {
         //We didn't find the Facebook ID in the database, but let's see if the user has an account already
         $user = Customer::model()->findByAttributes(array('email' => $this->username));
         if ($user instanceof Customer) {
             //We found an existing account under this email
             if (is_null($user->facebook)) {
                 //We found an account, merge them
                 $user->facebook = $this->password;
                 $user->save();
                 $this->loginHousekeeping($user);
             } else {
                 //Somehow we've found an existing account with an email from facebook but not the same ID
                 //Clear Facebook ID and bail, this is a serious conflict
                 $user->facebook = $this->password;
                 $user->save();
                 $this->redirect(Yii::app()->homeUrl);
             }
         } else {
             //New user to our site using Facebook, so set up an account
             $model = new Customer();
             $model->scenario = 'createfb';
             $results = Yii::app()->facebook->api('/me');
             $model->first_name = $results['first_name'];
             $model->last_name = $results['last_name'];
             $model->email = $results['email'];
             $model->email_repeat = $results['email'];
             $model->record_type = Customer::REGISTERED;
             $model->newsletter_subscribe = 1;
             $model->facebook = $results['id'];
             if (_xls_get_conf('MODERATE_REGISTRATION', 0) == 1) {
                 $this->errorCode = self::ERROR_NOT_APPROVED;
                 $model->allow_login = Customer::UNAPPROVED_USER;
             } else {
                 $model->allow_login = Customer::NORMAL_USER;
                 if (!$model->save()) {
                     Yii::log("Error creating Facebook account " . print_r($model->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
                     die("A serious error has occurred creating a Facebook account");
                 }
                 $this->loginHousekeeping($model);
             }
         }
     }
     return $this->errorCode;
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:53,代码来源:FBIdentity.php

示例3: actionUpload

 public function actionUpload()
 {
     parent::actionUpload();
     $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/';
     // folder for uploaded files
     $allowedExtensions = array("csv");
     $sizeLimit = (int) Yii::app()->params['sizeLimit'];
     // maximum file size in bytes
     $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
     $result = $uploader->handleUpload($folder, true);
     $row = 0;
     if (($handle = fopen($folder . $uploader->file->getName(), "r")) !== FALSE) {
         while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
             if ($row > 0) {
                 $model = Customer::model()->findByPk((int) $data[0]);
                 if ($model === null) {
                     $model = new Customer();
                 }
                 $model->addressbookid = (int) $data[0];
                 $model->fullname = $data[1];
                 $model->recordstatus = (int) $data[2];
                 try {
                     if (!$model->save()) {
                         $errormessage = $model->getErrors();
                         if (Yii::app()->request->isAjaxRequest) {
                             echo CJSON::encode(array('status' => 'failure', 'div' => $errormessage));
                         }
                     }
                 } catch (Exception $e) {
                     $errormessage = $e->getMessage();
                     if (Yii::app()->request->isAjaxRequest) {
                         echo CJSON::encode(array('status' => 'failure', 'div' => $errormessage));
                     }
                 }
             }
             $row++;
         }
         fclose($handle);
     }
     $result = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
     echo $result;
 }
开发者ID:bylinggha,项目名称:Capella-ERP-Indonesia,代码行数:42,代码来源:CustomerController.php

示例4: actionRequestPickUp

 public function actionRequestPickUp()
 {
     $req = Yii::app()->request;
     $shipment_id = $req->getQuery('shipment_id');
     if (!isset($_POST['Booking'])) {
         echo CJSON::encode($this->statusError('Must be in POST method'));
         Yii::app()->end();
     }
     $booking = new Booking();
     $booking->setAttributes($_POST['Booking']);
     $booking->setAttribute('booking_code', dechex(time()));
     if ($shipment_id != null) {
         $shipment = Shipment::model()->findByPk($shipment_id);
         if (!$shipment instanceof Shipment) {
             echo CJSON::encode($this->statusError('Your Shipment is invalid'));
             Yii::app()->end();
         }
     }
     $trans = Yii::app()->db->beginTransaction();
     try {
         if ($booking->save()) {
             if (isset($shipment) && $shipment instanceof Shipment) {
                 Booking::model()->updateByPk($booking->id, array('customer_id' => $shipment->customer_id));
                 $shipment->setAttribute('booking_id', $booking->id);
                 if (!$shipment->save()) {
                     throw ServiceControllerException($shipment->getErrors());
                 }
             } else {
                 if ($this->token instanceof Token) {
                     $customer = Customer::model()->findByPk($this->token->customer_id);
                     if (!$customer instanceof Customer) {
                         throw new ServiceControllerException('You have to login first');
                     } else {
                         Booking::model()->updateByPk($booking->id, array('customer_id' => $customer->id));
                     }
                 } else {
                     $customer = new Customer();
                     $customer->name = $booking->name;
                     $customer->type = 'personal';
                     $customer->accountnr = 'WEB' . time();
                     if ($customer->save()) {
                         $contact = new Contact();
                         $contact->parent_id = $customer->id;
                         $contact->parent_model = 'Customer';
                         $contact->full_name = $booking->name;
                         $contact->address = $booking->address;
                         $contact->country = $booking->country;
                         $contact->city = $booking->city;
                         $contact->postal = $booking->postal;
                         if ($contact->save()) {
                             Booking::model()->updateByPk($booking->id, array('customer_id' => $customer->id));
                         } else {
                             throw new ServiceControllerException($contact->getErrors());
                         }
                     } else {
                         throw new ServiceControllerException($customer->getErrors());
                     }
                 }
             }
             $data = array('booking_code' => $booking->booking_code);
         } else {
             throw ServiceControllerException($booking->getErrors());
         }
         $trans->commit();
     } catch (ServiceControllerException $e) {
         $errors = $e->errors;
         $trans->rollback();
         echo CJSON::encode($this->statusError($errors));
         Yii::app()->end();
     }
     echo CJSON::encode($this->statusSuccess($data));
     Yii::app()->end();
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:73,代码来源:ServiceController.php

示例5: actionEditableCreator

 public function actionEditableCreator()
 {
     if (isset($_POST['Customer'])) {
         $model = new Customer();
         $model->attributes = $_POST['Customer'];
         if ($model->save()) {
             echo CJSON::encode($model->getAttributes());
         } else {
             $errors = array_map(function ($v) {
                 return join(', ', $v);
             }, $model->getErrors());
             echo CJSON::encode(array('errors' => $errors));
         }
     } else {
         throw new CHttpException(400, 'Invalid request');
     }
 }
开发者ID:schmunk42,项目名称:yii-sakila-crud,代码行数:17,代码来源:CustomerController.php

示例6: actionAddCust

 /**
  * 添加顾客
  */
 public function actionAddCust()
 {
     $user_model = new User();
     $addr_model = new Address();
     $cust_model = new Customer();
     $custhi_model = new Cust_Health_Info();
     if (isset($_POST["User"]) && isset($_POST["Customer"])) {
         $user_model->attributes = $_POST["User"];
         //设定用户种别为:顾客
         $user_model->usr_kind = 2;
         //设定用户密码为:xyz123456
         $user_model->usr_password = md5("xyz123456");
         $user_model->user_chg_pwd_old = "oldpassword";
         $user_model->user_chg_pwd_new = "newpassword";
         $user_model->user_chg_pwd_new_cfm = "newpassword";
         //设置用户头像的默认值
         if ($user_model->usr_pic_id == '') {
             $user_model->usr_pic_id = '100000';
         }
         if ($user_model->save()) {
             $cust_model->attributes = $_POST["Customer"];
             //customer表里面的主键是user表的外键,user表的外键又是自增的,所以要先保存完user表才能保存customer表
             $cust_model->pk_cust_id = $user_model->pk_usr_id;
             //将作为用户名的手机号填入顾客信息里
             $cust_model->cust_mobile1 = $_POST['User']['usr_username'];
             //将用户喜爱的项目按位计算并保存
             $cust_prefer = 0;
             //如果啥都没选的话,下记字符串应该为空,否则为数组(内容为数字)
             if ($_POST['Customer']['cust_prefer'] != '') {
                 for ($i = 0; $i < count($_POST['Customer']['cust_prefer']); $i++) {
                     if ($_POST['Customer']['cust_prefer'][$i]) {
                         $cust_prefer |= (int) $_POST['Customer']['cust_prefer'][$i];
                     }
                 }
             } else {
                 $cust_prefer = 0;
             }
             $cust_model->cust_prefer = $cust_prefer;
             //将用户喜爱的美疗师按位计算并保存
             $cust_beautician = 0;
             //如果啥都没选的话,下记字符串应该为空,否则为字符串数组(内容为数字)
             if ($_POST['Customer']['cust_beautician'] != '') {
                 for ($i = 0; $i < count($_POST['Customer']['cust_beautician']); $i++) {
                     if ($_POST['Customer']['cust_beautician'][$i]) {
                         $cust_beautician |= (int) $_POST['Customer']['cust_beautician'][$i];
                     }
                 }
             } else {
                 $cust_beautician = 0;
             }
             $cust_model->cust_beautician = $cust_beautician;
             if ($cust_model->save()) {
                 $addr_model->attributes = $_POST['Address'];
                 $addr_model->addr_cust_id = $user_model->pk_usr_id;
                 if (!$addr_model->save()) {
                     $cust_model->delete();
                     $user_model->delete();
                     echo "<script>alert('地址信息添加失败!');</script>";
                 }
                 $custhi_model->attributes = $_POST['Cust_Health_Info'];
                 $custhi_model->pk_custhi_cust_id = $user_model->pk_usr_id;
                 $custhi_model->custhi_height = (double) $_POST['Cust_Health_Info']['custhi_height'];
                 $custhi_model->custhi_weight = (double) $_POST['Cust_Health_Info']['custhi_weight'];
                 $custhi_model->custhi_date = date("Y-m-d H:i:s", time());
                 if (!$custhi_model->save()) {
                     $addr_model->delete();
                     $cust_model->delete();
                     $user_model->delete();
                     echo "<script>alert('用户健康信息添加失败!');</script>";
                 }
                 $this->redirect("./index.php?r=user/showCust");
             } else {
                 $user_model->delete();
                 var_dump($cust_model->getErrors());
                 echo "<script>alert('顾客信息添加失败!');</script>";
             }
         } else {
             //				var_dump($user_model->getErrors());
             echo "<script>alert('用户信息添加失败!');</script>";
         }
     }
     $this->renderPartial('addCust', array('user_info' => $user_model, 'cust_info' => $cust_model, 'addr_info' => $addr_model, 'custhi_info' => $custhi_model));
 }
开发者ID:hirvonen,项目名称:backStage_yii,代码行数:86,代码来源:UserController.php

示例7: CreateFromCheckoutForm

 public static function CreateFromCheckoutForm($checkoutForm)
 {
     $obj = new Customer();
     $obj->first_name = $checkoutForm->contactFirstName;
     $obj->last_name = $checkoutForm->contactLastName;
     $obj->company = $checkoutForm->contactCompany;
     $obj->mainphone = $checkoutForm->contactPhone;
     $obj->email = $checkoutForm->contactEmail;
     $obj->email_repeat = $checkoutForm->contactEmail_repeat;
     $obj->password = $checkoutForm->createPassword;
     $obj->password_repeat = $checkoutForm->createPassword_repeat;
     $obj->newsletter_subscribe = $checkoutForm->receiveNewsletter;
     $obj->record_type = Customer::NORMAL_USER;
     $obj->currency = _xls_get_conf('CURRENCY_DEFAULT');
     $obj->pricing_level = 1;
     $obj->allow_login = Customer::NORMAL_USER;
     $obj->scenario = Customer::SCENARIO_INSERT;
     if (!$obj->save()) {
         Yii::log("Error creating user " . print_r($obj->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
     } else {
         Yii::log(sprintf("Created user from checkout %s %s id# %d ", $obj->first_name, $obj->last_name, $obj->id), 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
     }
     return $obj;
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:24,代码来源:Customer.php

示例8: actionConvertAddressBook

 /**
  * Extract shipping and billing address information, create address book and map to the carts
  */
 protected function actionConvertAddressBook()
 {
     $sql = "select * from xlsws_cart where billaddress_id IS NULL and address_bill IS NOT NULL order by id limit 500";
     $arrProducts = Yii::app()->db->createCommand($sql)->query();
     while (($result = $arrProducts->read()) !== false) {
         $result['email'] = strtolower($result['email']);
         //verify that Customer ID really exists in customer table
         $objCust = Customer::model()->findByPk($result['customer_id']);
         if (!$objCust instanceof Customer) {
             $result['customer_id'] = 0;
         }
         if (strlen($result['address_bill']) > 0) {
             $arrAddress = explode("\n", $result['address_bill']);
             if (count($arrAddress) == 5) {
                 //old format address, should be 6 pieces
                 $arrAddress[5] = $arrAddress[4];
                 $strSt = $arrAddress[3];
                 if ($strSt[0] == " ") {
                     //no state on this address
                     $arrAddress[4] = substr($strSt, 1, 100);
                     $arrAddress[3] = "";
                 } else {
                     $arrSt = explode(" ", $strSt);
                     $arrAddress[3] = $arrSt[0];
                     $arrAddress[4] = str_replace($arrSt[0] . " ", "", $strSt);
                 }
             }
             $objAddress = new CustomerAddress();
             if (count($arrAddress) >= 5) {
                 $objCountry = Country::LoadByCode($arrAddress[5]);
                 if ($objCountry) {
                     $objAddress->country_id = $objCountry->id;
                     $objState = State::LoadByCode($arrAddress[3], $objCountry->id);
                     if ($objState) {
                         $objAddress->state_id = $objState->id;
                     }
                 }
                 $objAddress->address1 = $arrAddress[0];
                 $objAddress->address2 = $arrAddress[1];
                 $objAddress->city = $arrAddress[2];
                 $objAddress->postal = $arrAddress[4];
                 $objAddress->first_name = $result['first_name'];
                 $objAddress->last_name = $result['last_name'];
                 $objAddress->company = $result['company'];
                 $objAddress->phone = $result['phone'];
                 $objAddress->residential = CustomerAddress::RESIDENTIAL;
                 $objAddress->created = $result['datetime_cre'];
                 $objAddress->modified = $result['datetime_cre'];
                 $objAddress->active = 1;
                 if (empty($objAddress->address2)) {
                     $objAddress->address2 = null;
                 }
                 if (empty($objAddress->company)) {
                     $objAddress->company = null;
                 }
                 $blnFound = false;
                 if ($result['customer_id'] > 0) {
                     //See if this is already in our database
                     $objPriorAddress = CustomerAddress::model()->findByAttributes(array('address1' => $objAddress->address1, 'address2' => $objAddress->address2, 'city' => $objAddress->city, 'postal' => $objAddress->postal, 'first_name' => $objAddress->first_name, 'last_name' => $objAddress->last_name, 'company' => $objAddress->company, 'phone' => $objAddress->phone));
                     if ($objPriorAddress instanceof CustomerAddress) {
                         Yii::app()->db->createCommand("update xlsws_cart set billaddress_id=" . $objPriorAddress->id . " where id=" . $result['id'])->execute();
                         $blnFound = true;
                     } else {
                         $objAddress->customer_id = $result['customer_id'];
                     }
                 } else {
                     //We need a shell customer record just for the email
                     $objC = Customer::model()->findByAttributes(array('email' => $result['email']));
                     if ($objC instanceof Customer) {
                         Yii::app()->db->createCommand("UPDATE xlsws_cart set customer_id=" . $objC->id . " where id=" . $result['id'])->execute();
                     } else {
                         $objC = new Customer();
                         $objC->record_type = Customer::GUEST;
                         $objC->email = $result['email'];
                         $objC->first_name = $objAddress->first_name;
                         $objC->last_name = $objAddress->last_name;
                         $objC->company = $objAddress->company;
                         if (!$objC->validate()) {
                             $arrErr = $objC->getErrors();
                             if (isset($arrErr['email'])) {
                                 $objC->email = $result['id'] . ".invalid@example.com";
                             }
                             if (!$objC->validate()) {
                                 return print_r($objC->getErrors(), true);
                             }
                         }
                         if (!$objC->save()) {
                             Yii::log("Import Error " . print_r($objC->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
                             return print_r($objC->getErrors(), true);
                         } else {
                             $cid = $objC->id;
                         }
                         Yii::app()->db->createCommand("UPDATE xlsws_cart set customer_id=" . $cid . " where id=" . $result['id'])->execute();
                     }
                     $result['customer_id'] = $objC->id;
                     $objAddress->customer_id = $result['customer_id'];
                 }
//.........这里部分代码省略.........
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:101,代码来源:InstallController.php

示例9: importCompany

 private function importCompany($fileNameAndPath)
 {
     $allAccounts = array();
     $dom = new domDocument();
     if (!$dom->load($fileNameAndPath)) {
         throw new CException(Yii::t('lazy8', 'input file could not be xml parsed'));
     }
     $root = $dom->documentElement;
     if ($root->nodeName != "lazy8webport") {
         $this->hasErrors = true;
         $this->errors = array(array(Yii::t('lazy8', 'Upload failed.  This is not a valid file.'), Yii::t('lazy8', 'Select a file and try again')));
         $this->render('showimport');
         return 0;
     }
     if ($root->getAttribute('version') > 1.0) {
         $this->errors = array(array(Yii::t('lazy8', 'There maybe problems because this is a file version greater then this programs version'), Yii::t('lazy8', 'Select a file and try again')));
     }
     $nodeCompanys = $root->getElementsByTagName('company');
     unset($root);
     unset($dom);
     $this->lastImportedPeriod = 0;
     foreach ($nodeCompanys as $nodeCompany) {
         //make sure the company code is unique
         $modelCompany = new Company();
         $code = $nodeCompany->getAttribute('code');
         $code--;
         //make sure the company code is valid. Change if not.
         do {
             $code++;
             $comptest = Company::model()->find(array('condition' => 'code=' . $code));
         } while ($comptest !== null);
         //create the company
         $modelCompany = new Company();
         $modelCompany->code = $code;
         $modelCompany->name = $nodeCompany->getAttribute('name');
         $modelCompany->lastAbsTransNum = $nodeCompany->getAttribute('lastAbsTransNum');
         if (!$modelCompany->save()) {
             throw new CException(Yii::t('lazy8', 'Could not create the company, bad paramters') . ';' . var_export($modelCompany->getErrors()));
         }
         try {
             $allAccounts = array();
             $nodesAccountTypes = $nodeCompany->getElementsByTagName('accounttype');
             foreach ($nodesAccountTypes as $nodeAccountType) {
                 $modelAccountType = new AccountType();
                 $modelAccountType->companyId = $modelCompany->id;
                 $modelAccountType->code = $nodeAccountType->getAttribute('code');
                 $modelAccountType->name = $nodeAccountType->getAttribute('name');
                 $modelAccountType->sortOrder = $nodeAccountType->getAttribute('sortorder');
                 $modelAccountType->isInBalance = $nodeAccountType->getAttribute('isinbalance') == "1" ? 1 : 0;
                 if (!$modelAccountType->save()) {
                     $modelCompany->delete();
                     throw new CException(Yii::t('lazy8', 'Could not create the AccountType, bad paramters') . ';name=' . $modelAccountType->name . ';' . serialize($modelAccountType->getErrors()));
                 }
                 $nodesAccounts = $nodeAccountType->getElementsByTagName('account');
                 foreach ($nodesAccounts as $nodeAccount) {
                     $modelAccount = new Account();
                     $modelAccount->companyId = $modelCompany->id;
                     $modelAccount->code = $nodeAccount->getAttribute('code');
                     $modelAccount->accountTypeId = $modelAccountType->id;
                     $modelAccount->name = $nodeAccount->getAttribute('name');
                     if (!$modelAccount->save()) {
                         $modelCompany->delete();
                         throw new CException(Yii::t('lazy8', 'Could not create the Account, bad paramters') . ';' . serialize($modelAccount->getErrors()));
                     }
                     $allAccounts[$modelAccount->code] = $modelAccount->id;
                     unset($nodeAccount);
                     unset($modelAccount);
                 }
                 unset($modelAccountType);
                 unset($nodeAccountType);
             }
             unset($nodesAccountTypes);
             $allCustomers = array();
             $nodesCustomers = $nodeCompany->getElementsByTagName('customer');
             foreach ($nodesCustomers as $nodeCustomer) {
                 $modelCustomer = new Customer();
                 $modelCustomer->companyId = $modelCompany->id;
                 $modelCustomer->code = $nodeCustomer->getAttribute('code');
                 $modelCustomer->accountId = $this->FindAccountIdFromCode($nodeCustomer->getAttribute('accountcode'), $modelCompany->id, $allAccounts, 'customercode=' . $modelCustomer->code, $this->errors, true);
                 $modelCustomer->name = $nodeCustomer->getAttribute('name');
                 $modelCustomer->desc = $nodeCustomer->getAttribute('desc');
                 if (!$modelCustomer->save()) {
                     $modelCompany->delete();
                     throw new CException(Yii::t('lazy8', 'Could not create the Customer, bad paramters') . ';' . serialize($modelCustomer->getErrors()));
                 }
                 $allCustomers[$modelCustomer->code] = $modelCustomer->id;
                 unset($modelCustomer);
                 unset($nodeCustomer);
             }
             unset($nodesCustomers);
             $nodesPeriods = $nodeCompany->getElementsByTagName('period');
             foreach ($nodesPeriods as $nodePeriod) {
                 $modelPeriod = new Period();
                 $modelPeriod->companyId = $modelCompany->id;
                 $modelPeriod->dateStart = $nodePeriod->getAttribute('datestart');
                 $modelPeriod->dateEnd = $nodePeriod->getAttribute('dateend');
                 $modelPeriod->lastPeriodTransNum = $nodePeriod->getAttribute('lastperiodtransnum');
                 if (!$modelPeriod->save()) {
                     $modelCompany->delete();
                     throw new CException(Yii::t('lazy8', 'Could not create the period, bad paramters') . ';' . serialize($modelPeriod->getErrors()));
//.........这里部分代码省略.........
开发者ID:Jride,项目名称:accounting-thaiconnections,代码行数:101,代码来源:CompanyController.php


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