コード例 #1
0
ファイル: FieldFormatterTest.php プロジェクト: keyeMyria/CRM
 private static function tryAddCol($model, $col, $type)
 {
     if (!Fields::model()->findByAttributes(array('fieldName' => $col, 'modelName' => get_class($model)))) {
         $field = new Fields();
         $field->setAttributes(array('modelName' => get_class($model), 'fieldName' => $col, 'attributeLabel' => $col, 'modified' => '1', 'custom' => 1, 'type' => $type, 'required' => '0', 'uniqueConstraint' => '0', 'safe' => '1', 'readOnly' => '0', 'linkType' => NULL, 'searchable' => '0', 'relevance' => 'Low', 'isVirtual' => '0', 'defaultValue' => NULL, 'keyType' => '', 'data' => NULL), false);
         if (!$field->save()) {
             AuxLib::debugLogR('$col = ');
             AuxLib::debugLogR($col);
             AuxLib::debugLogR($field->getErrors());
         }
     }
 }
コード例 #2
0
ファイル: AdminController.php プロジェクト: xl602/X2CRM
 /**
  * General field management.
  *
  * This action serves as the landing page for all of the custom field related
  * actions within the software.
  */
 public function actionManageFields()
 {
     // New model for the form:
     $model = new Fields();
     // Set up grid view:
     $searchModel = new Fields('search');
     $criteria = new CDbCriteria();
     $criteria->addCondition('modified=1');
     $searchModel->setAttributes(isset($_GET['Fields']) ? $_GET['Fields'] : array(), false);
     foreach ($searchModel->attributes as $name => $value) {
         $criteria->compare($name, $value);
     }
     $pageSize = Profile::getResultsPerPage();
     $dataProvider = new SmartActiveDataProvider('Fields', array('criteria' => $criteria, 'pagination' => array('pageSize' => Profile::getResultsPerPage())));
     // Set up fields list
     $fields = Fields::model()->findAllByAttributes(array('custom' => '1'));
     $arr = array();
     foreach ($fields as $field) {
         $arr[$field->id] = $field->attributeLabel;
     }
     $this->render('manageFields', array('dataProvider' => $dataProvider, 'model' => $model, 'searchModel' => $searchModel, 'fields' => $arr));
 }
コード例 #3
0
 public function testCheckConversionCompatibility()
 {
     $field = Fields::model()->findByAttributes(array('modelName' => 'X2Leads', 'fieldName' => 'description'));
     $field->type = 'boolean';
     $this->assertSaves($field);
     Yii::app()->cache->flush();
     X2Leads::model()->resetFieldsPropertyCache();
     // ensure that conversion fails due to field type mismatch
     $lead = $this->x2Leads('1');
     $leadAttrs = $lead->getAttributes();
     $this->assertFalse($lead->checkConversionCompatibility('Contacts'));
     $this->assertFalse($lead->checkConversionCompatibility('Opportunity'));
     self::restoreFields();
     $this->assertTrue($lead->checkConversionCompatibility('Contacts'));
     $this->assertTrue($lead->checkConversionCompatibility('Opportunity'));
     // ensure that conversion fails due presence of extra field
     $extraField = new Fields();
     $extraField->setAttributes(array('modelName' => 'X2Leads', 'fieldName' => 'extraField', 'type' => 'boolean', 'attributeLabel' => 'Extra Field'));
     $this->assertSaves($extraField);
     Yii::app()->db->schema->refresh();
     $lead->refreshMetaData();
     Yii::app()->cache->flush();
     X2Leads::model()->resetFieldsPropertyCache();
     $lead->c_extraField = true;
     $this->assertFalse($lead->checkConversionCompatibility('Contacts'));
     $this->assertFalse($lead->checkConversionCompatibility('Opportunity'));
     self::restoreFields();
     $lead->refresh();
     $this->assertTrue($lead->checkConversionCompatibility('Contacts'));
     $this->assertTrue($lead->checkConversionCompatibility('Opportunity'));
 }