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


PHP Contacts::setX2Fields方法代码示例

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


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

示例1: actionNew

 public function actionNew()
 {
     $model = new Contacts();
     $attributeLabels = $model->attributeLabels();
     /*if(isset($_POST['ajax']) && $_POST['ajax']=='quick-contact-form') {
     			echo CActiveForm::validate($model);
     			Yii::app()->end();
     		}*/
     // collect user input data
     if (isset($_POST['Contacts'])) {
         // $this->redirect('http://www.google.com/');
         //$model->attributes = $_POST['Contacts'];
         $model->setX2Fields($_POST['Contacts']);
         //
         // $model->firstName = 'bob';
         // $model->lastName = 'dole';
         // $model->phone = '';
         // $model->email = '';
         $model->visibility = 1;
         // reset to blank if it's the default value
         /*if($model->firstName == $attributeLabels['firstName'])
         			$model->firstName = '';
         		if($model->lastName == $attributeLabels['lastName'])
         			$model->lastName = '';
         		if($model->phone == $attributeLabels['phone'])
         			$model->phone = '';
         		if($model->email == $attributeLabels['email'])
         			$model->email = '';*/
         $model->createDate = time();
         // validate user input and save contact
         if ($model->save()) {
             echo "1";
             $this->redirect(array('/mobile/contacts/view', 'id' => $model->id));
         }
         //else print_r($model->getErrors());
     }
     $this->render('quickContact', array('model' => $model));
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:38,代码来源:ContactsController.php

示例2: testDefaultValues

 /**
  * Test setting default values in new records
  */
 public function testDefaultValues()
 {
     foreach (X2Model::model('Contacts')->getFields() as $field) {
         // Retrieve new values:
         $field->refresh();
     }
     // Setting default values in the constructor
     $contact = new Contacts();
     $this->assertEquals('Gustavo', $contact->firstName);
     $this->assertEquals('Fring', $contact->lastName);
     // Setting default values in setX2Fields
     $contact->firstName = '';
     $contact->lastName = '';
     $input = array();
     $contact->setX2Fields($input);
     $this->assertEquals('Gustavo', $contact->firstName);
     $this->assertEquals('Fring', $contact->lastName);
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:21,代码来源:X2ModelTest.php

示例3: actionQuickContact

 /**
  * Method of creating a Contact called by the Quick Create widget
  */
 public function actionQuickContact()
 {
     $model = new Contacts();
     // collect user input data
     if (isset($_POST['Contacts'])) {
         // clear values that haven't been changed from the default
         //$temp=$model->attributes;
         $model->setX2Fields($_POST['Contacts']);
         $model->visibility = 1;
         // validate user input and save contact
         // $changes = $this->calculateChanges($temp, $model->attributes, $model);
         // $model = $this->updateChangelog($model, $changes);
         $model->createDate = time();
         //if($model->validate()) {
         if ($model->save()) {
         } else {
             //echo CHtml::errorSummary ($model);
             echo CJSON::encode($model->getErrors());
         }
         return;
         //}
         //echo '';
         //echo CJSON::encode($model->getErrors());
     }
     $this->renderPartial('application.components.views.quickContact', array('model' => $model));
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:29,代码来源:ContactsController.php

示例4: actionCreateRecords

 public function actionCreateRecords()
 {
     $contact = new Contacts();
     $account = new Accounts();
     $opportunity = new Opportunity();
     $users = User::getNames();
     if (isset($_POST['Contacts']) && isset($_POST['Accounts']) && isset($_POST['Opportunity'])) {
         $contact->setX2Fields($_POST['Contacts']);
         $account->setX2Fields($_POST['Accounts']);
         $opportunity->setX2Fields($_POST['Opportunity']);
         $validAccount = true;
         if ($account->validate() == false) {
             $validAccount = false;
             // validate other models so that the user gets feedback
             $contact->validate();
             $opportunity->validate();
         }
         if ($validAccount) {
             $allValid = true;
             $a = $this->createAccount($account, $account->attributes, '1');
             // Contact and Opportunity require Account id for lookup field
             $contact->company = Fields::nameId($account->name, $account->id);
             if ($contact->validate() == false) {
                 $allValid = false;
             }
             $c = $this->createContact($contact, $contact->attributes, '1');
             $opportunity->accountName = Fields::nameId($account->name, $account->id);
             $opportunity->contactName = Fields::nameId($contact->name, $contact->id);
             if ($opportunity->validate() == false) {
                 $allValid = false;
             }
             $o = $this->createOpportunity($opportunity, $opportunity->attributes, '1');
             if ($allValid && $c && $a && $o) {
                 // all records created?
                 Relationships::create('Contacts', $contact->id, 'Accounts', $account->id);
                 Relationships::create('Opportunity', $opportunity->id, 'Contacts', $contact->id);
                 Relationships::create('Opportunity', $opportunity->id, 'Accounts', $account->id);
                 if (isset($_GET['ret'])) {
                     if ($_GET['ret'] == 'contacts') {
                         $this->redirect(array("/contacts/contacts/view", 'id' => $contact->id));
                     } else {
                         if ($_GET['ret'] == 'accounts') {
                             $this->redirect(array("/accounts/accounts/view", 'id' => $account->id));
                         } else {
                             if ($_GET['ret'] == 'opportunities') {
                                 $this->redirect(array("/opportunities/opportunities/view", 'id' => $opportunity->id));
                             }
                         }
                     }
                 } else {
                     $this->redirect(array("/contacts/contacts/view", $contact->id));
                 }
             } else {
                 // otherwise clean up
                 $types = array('account' => 'Accounts', 'contact' => 'Contacts', 'opportunity' => 'Opportunity');
                 foreach ($types as $model => $type) {
                     if (${$model} && isset(${$model}->id)) {
                         $modelId = ${$model}->id;
                         ${$model}->delete();
                         // delete all new actions and events from creating/deleting records
                         foreach (array('Actions', 'Events') as $meta) {
                             X2Model::model($meta)->deleteAllByAttributes(array('associationId' => $modelId, 'associationType' => $type));
                         }
                     }
                 }
             }
         }
     }
     $this->render('createRecords', array('contact' => $contact, 'account' => $account, 'opportunity' => $opportunity, 'users' => $users));
 }
开发者ID:shayanyi,项目名称:CRM,代码行数:70,代码来源:SiteController.php

示例5: actionCreate

 public function actionCreate()
 {
     $model = new Contacts();
     $name = 'Contacts';
     $users = User::getNames();
     $accounts = Accounts::getNames();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Contacts'])) {
         $model->setX2Fields($_POST['Contacts']);
         /*// clear values that haven't been changed from the default
         		 foreach($_POST['Contacts'] as $name => &$value) {
         			if($value == $model->getAttributeLabel($name))
         				$value = '';
         		}
         		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);
         							if(count($names)>1) 
         								$lookupModel=Contacts::model()->findByAttributes(array('firstName'=>$names[0],'lastName'=>$names[1]));
         						}
         						if(isset($lookupModel))
         							$val=$lookupModel->id;
         						else
         							$val=$arr;
         					}
         				}
         				$model->$newKey=$val;
         			}
         		}
         		
         		$temp=$model->attributes;
         		foreach(array_keys($model->attributes) as $field){
         			if(isset($_POST['Contacts'][$field])){
         				$model->$field=$_POST['Contacts'][$field];
         				$fieldData=Fields::model()->findByAttributes(array('modelName'=>'Contacts','fieldName'=>$field));
         				if($fieldData->type=='assignment' && $fieldData->linkType=='multiple'){
         					$model->$field=Accounts::parseUsers($model->$field);
         				}elseif($fieldData->type=='date'){
         					$model->$field=strtotime($model->$field);
         				}
         				
         			}
         		}
         		if(!isset($model->visibility))
         			$model->visibility=1; */
         $this->create($model, $model->attributes, '0');
     }
     $this->render('create', array('model' => $model, 'users' => $users, 'accounts' => $accounts));
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:61,代码来源:DefaultController.php


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