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


PHP Quote::hasErrors方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a new model.
  *
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @param bool $quick If true, this indicates the action is being requested via AJAX
  */
 public function actionCreate($quick = false, $duplicate = false)
 {
     $model = new Quote();
     if ($duplicate && !isset($_POST['Quote'])) {
         $copiedModel = Quote::model()->findByPk($duplicate);
         if (!empty($copiedModel)) {
             foreach ($copiedModel->attributes as $name => $value) {
                 if ($name != 'id') {
                     $model->{$name} = $value;
                 }
             }
             $model->setLineItems($this->duplicateLineItems($copiedModel), false, true);
         }
     }
     $users = User::getNames();
     if ($quick && !Yii::app()->request->isAjaxRequest) {
         throw new CHttpException(400);
     }
     $currency = Yii::app()->params->currency;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Quote'])) {
         $model->setX2Fields($_POST['Quote']);
         $model->currency = $currency;
         $model->createDate = time();
         $model->lastUpdated = $model->createDate;
         $model->createdBy = Yii::app()->user->name;
         $model->updatedBy = $model->createdBy;
         if (empty($model->name)) {
             $model->name = '';
         }
         if (isset($_POST['lineitem'])) {
             $model->lineItems = $_POST['lineitem'];
         }
         if (!$model->hasLineItemErrors) {
             if ($model->save()) {
                 $model->createEventRecord();
                 $model->createActionRecord();
                 $model->saveLineItems();
                 if (!$quick) {
                     $this->redirect(array('view', 'id' => $model->id));
                 } else {
                     if (isset($_GET['recordId']) && isset($_GET['recordType'])) {
                         $recordId = $_GET['recordId'];
                         $recordType = $_GET['recordType'];
                         $relatedModel = X2Model::model($_GET['recordType'])->findByPk($recordId);
                         // tie record to quote
                         if ($relatedModel) {
                             $relate = new Relationships();
                             $relate->firstId = $model->id;
                             $relate->firstType = "Quote";
                             $relate->secondId = $relatedModel->id;
                             $relate->secondType = $recordType;
                             $relate->save();
                             $model->createAssociatedAction(X2Model::getAssociationType(get_class($relatedModel)), $relatedModel->id);
                         }
                     }
                     return;
                 }
             }
         }
     }
     // get products
     $products = Product::activeProducts();
     $viewData = array('model' => $model, 'users' => $users, 'products' => $products, 'quick' => $quick);
     if (!$quick) {
         $this->render('create', $viewData);
     } else {
         if ($model->hasErrors() || $model->hasLineItemErrors) {
             // Sneak into the response that validation failed via setting
             // the response code manually:
             header('HTTP/1.1 400 Validation Error');
         }
         $this->renderPartial('create', $viewData, false, true);
     }
 }
开发者ID:xl602,项目名称:X2CRM,代码行数:83,代码来源:QuotesController.php


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