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


PHP Quote::setX2Fields方法代码示例

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


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

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Quote();
     $users = User::getNames();
     $currency = Yii::app()->params->currency;
     $productNames = Product::productNames();
     $productCurrency = Product::productCurrency();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Quote'])) {
         /*
                             foreach($_POST as $key=>$arr){
                                     $pieces=explode("_",$key);
                                     if(isset($pieces[0]) && $pieces[0]=='autoselect'){
                                         $newKey=$pieces[1];
                                         if(isset($_POST[$newKey."_id"]) && $_POST[$newKey."_id"]!=""){
                                             $val=$_POST[$newKey."_id"];
                                         }else{
                                             $field=Fields::model()->findByAttributes(array('fieldName'=>$newKey));
                                             if(isset($field)){
                                                 $type=ucfirst($field->linkType);
                                                 if($type!="Contacts"){
                                                     eval("\$lookupModel=$type::model()->findByAttributes(array('name'=>'$arr'));");
                                                 }else{
                                                     $names=explode(" ",$arr);
                                                     $lookupModel=Contacts::model()->findByAttributes(array('firstName'=>$names[0],'lastName'=>$names[1]));
                                                 }
                                                 if(isset($lookupModel))
                                                     $val=$lookupModel->id;
                                                 else
                                                     $val=$arr;
                                             }
                                         }
                                         $model->$newKey=$val;
                                     }
                                 }
         //			$this->render('test', array('model'=>$_POST));
                     $temp=$model->attributes;
         foreach(array_keys($model->attributes) as $field){
                                     if(isset($_POST['Quote'][$field])){
                                         $model->$field=$_POST['Quote'][$field];
                                         $fieldData=Fields::model()->findByAttributes(array('modelName'=>'Quotes','fieldName'=>$field));
                                         if($fieldData->type=='assignment' && $fieldData->linkType=='multiple'){
                                             $model->$field=Accounts::parseUsers($model->$field);
                                         }elseif($fieldData->type=='date'){
                                             $model->$field=strtotime($model->$field);
                                         }
                                         
                                     }
                                 }
                 	
         			$model->expirationDate = $this->parseDate($model->expirationDate);
         */
         /*
         if(isset($model->associatedContacts)) {
         	$contacts = $model->associatedContacts;
         	$model->associatedContacts = Quote::parseContacts($model->associatedContacts);
         } else {
         	$contacts = array();
         }
         */
         $temp = $model->attributes;
         $model->setX2Fields($_POST['Quote']);
         // get products
         $products = array();
         if (isset($_POST['ExistingProducts'])) {
             $ids = $_POST['ExistingProducts']['id'];
             $prices = $_POST['ExistingProducts']['price'];
             $quantities = $_POST['ExistingProducts']['quantity'];
             $adjustments = $_POST['ExistingProducts']['adjustment'];
             foreach ($ids as $key => $id) {
                 if ($id != 0) {
                     // remove blanks
                     $products[$key]['id'] = $id;
                     $products[$key]['name'] = $productNames[$id];
                     $products[$key]['price'] = $prices[$key];
                     $products[$key]['quantity'] = $quantities[$key];
                     if (strchr($adjustments[$key], '%')) {
                         // percent adjustment
                         $products[$key]['adjustment'] = intval(str_replace("%", "", $adjustments[$key]));
                         $products[$key]['adjustmentType'] = 'percent';
                     } else {
                         $products[$key]['adjustment'] = $adjustments[$key];
                         $products[$key]['adjustmentType'] = 'linear';
                     }
                 }
             }
             if (!empty($products)) {
                 $currency = $productCurrency[$products[0]['id']];
             }
         }
         $model->currency = $currency;
         $this->createQuote($model, $temp, $products);
     }
     $products = Product::activeProducts();
     $this->render('create', array('model' => $model, 'users' => $users, 'products' => $products, 'productNames' => $productNames));
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:X2Engine,代码行数:101,代码来源:DefaultController.php


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