Exemple #1
0
	public function search() {
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('cost',$this->cost);
		$criteria->compare('result',$this->result,true);
		$criteria->compare('createDate',$this->createDate);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('lastUpdated',$this->lastUpdated);
		$criteria->compare('updatedBy',$this->updatedBy,true);

		return new SmartDataProvider(get_class($this), array(
			'sort'=>array(
				'defaultOrder'=>'createDate ASC',
			),
			'pagination'=>array(
				'pageSize'=>ProfileChild::getResultsPerPage(),
			),
			'criteria'=>$criteria,
		));
	}
Exemple #2
0
	public function filterSetPortlets($filterChain){
		if(!Yii::app()->user->isGuest){
			$this->portlets=array();
			$this->portlets = ProfileChild::getWidgets();
			// $this->portlets=array();
			// $arr=ProfileChild::getWidgets(Yii::app()->user->getId());

			// foreach($arr as $key=>$value){
				// $config=ProfileChild::parseWidget($value,$key);
				// $this->portlets[$key]=$config;
			// }
		}
		$filterChain->run();
	}
	/**
	 * Load configuration that cannot be put in config/main
	 */
	public function beginRequest() {
	
		$prof=Profile::model()->findByPk(Yii::app()->user->getId());
		if (isset($prof->language))
			$this->owner->language=$prof->language;
                else{
                    $adminProf=ProfileChild::model()->findByPk(1);
                    $this->owner->language=$adminProf->language;
                }
		if(isset($prof->timeZone) && $prof->timeZone!='')
			date_default_timezone_set($prof->timeZone);
		$adminProf=ProfileChild::model()->findByAttributes(array('username'=>'admin'));
		$logo=Media::model()->findByAttributes(array('associationId'=>$adminProf->id,'associationType'=>'logo'));
		if(isset($logo)){
			$this->owner->params->logo=$logo->fileName;
		}
		
		$admin = CActiveRecord::model('Admin')->findByPk(1);
		$this->owner->params->currency = $admin->currency;
    }
Exemple #4
0
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('text',$this->text,true);
		$criteria->compare('createdBy',$this->createdBy,true);
		$criteria->compare('createDate',$this->createDate);
		$criteria->compare('updatedBy',$this->updatedBy,true);
		$criteria->compare('lastUpdated',$this->lastUpdated);
		$criteria->compare('editPermissions',$this->editPermissions,true);

		return new CActiveDataProvider(get_class($this), array(
			'pagination'=>array(
				'pageSize'=>ProfileChild::getResultsPerPage(),
			),
			'criteria'=>$criteria,
		));
	}
Exemple #5
0
 public function search()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     // $criteria->compare('id',$this->id);
     $criteria->compare('title', $this->title, true);
     // $criteria->compare('text',$this->text,true);
     $criteria->compare('createdBy', $this->createdBy, true);
     $criteria->compare('createDate', $this->createDate);
     $criteria->compare('updatedBy', $this->updatedBy, true);
     $criteria->compare('lastUpdated', $this->lastUpdated);
     $criteria->compare('type', $this->type);
     // $criteria->compare('editPermissions',$this->editPermissions,true);
     $dateRange = Yii::app()->controller->partialDateRange($this->createDate);
     if ($dateRange !== false) {
         $criteria->addCondition('createDate BETWEEN ' . $dateRange[0] . ' AND ' . $dateRange[1]);
     }
     $dateRange = Yii::app()->controller->partialDateRange($this->lastUpdated);
     if ($dateRange !== false) {
         $criteria->addCondition('lastUpdated BETWEEN ' . $dateRange[0] . ' AND ' . $dateRange[1]);
     }
     return new CActiveDataProvider(get_class($this), array('pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'criteria' => $criteria));
 }
Exemple #6
0
	public function actionToggleDefaultLogo() {
		
		$adminProf=ProfileChild::model()->findByAttributes(array('username'=>'admin'));
		$logo=Media::model()->findByAttributes(array('associationId'=>$adminProf->id,'associationType'=>'logo'));
		if(!isset($logo)) {

			$logo=new Media;
			$logo->associationType='logo';
			$name='yourlogohere.png';
			$logo->associationId=$adminProf->id;
			$logo->fileName='uploads/logos/'.$name;

			if($logo->save()) {

			}
		} else {
			$logo->delete();
		}
		$this->redirect(array('index'));
	}
Exemple #7
0
 public function searchBase($criteria)
 {
     $fields = Fields::model()->findAllByAttributes(array('modelName' => 'Actions'));
     foreach ($fields as $field) {
         $fieldName = $field->fieldName;
         switch ($field->type) {
             case 'boolean':
                 $criteria->compare($field->fieldName, $this->compareBoolean($this->{$fieldName}), true);
                 break;
             case 'link':
                 $criteria->compare($field->fieldName, $this->compareLookup($field, $this->{$fieldName}), true);
                 break;
             case 'assignment':
                 $criteria->compare($field->fieldName, $this->compareAssignment($this->{$fieldName}), true);
                 break;
             default:
                 $criteria->compare($field->fieldName, $this->{$fieldName}, true);
         }
     }
     $criteria->addCondition('(type != "workflow" AND type!="email") OR type IS NULL');
     $dataProvider = new SmartDataProvider('Actions', array('sort' => array('defaultOrder' => 'completeDate DESC, dueDate DESC'), 'pagination' => array('pageSize' => ceil(ProfileChild::getResultsPerPage())), 'criteria' => $criteria));
     return $dataProvider;
 }
 public function actionGetStageMembers($workflowId, $stage)
 {
     // $contactIds = Yii::app()->db->createCommand()->select('contactId')->from('x2_list_items')->where('x2_list_items.listId='.$id)->queryColumn();
     // die(var_dump($contactIds));
     // $search = CActiveRecord::model('ContactChild')->findAllByPk($contactIds);
     // return $search;
     if (!is_numeric($workflowId) || !is_numeric($stage)) {
         return new CActiveDataProvider();
     }
     $actionDescription = $workflowId . ':' . $stage;
     $contactsSql = Yii::app()->db->createCommand()->select('x2_contacts.*')->from('x2_contacts')->join('x2_actions', 'x2_contacts.id = x2_actions.associationId')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='contacts' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0) AND (x2_contacts.visibility=1 OR x2_contacts.assignedTo='" . Yii::app()->user->getName() . "')")->getText();
     $contactsCount = Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='contacts' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0)")->queryScalar();
     $contactsDataProvider = new CSqlDataProvider($contactsSql, array('totalItemCount' => $contactsCount, 'sort' => array('attributes' => array('firstName', 'lastName', 'phone', 'phone2', 'createDate', 'lastUpdated', 'leadSource'), 'defaultOrder' => 'lastUpdated DESC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage())));
     $salesSql = Yii::app()->db->createCommand()->select('x2_sales.*')->from('x2_sales')->join('x2_actions', 'x2_sales.id = x2_actions.associationId')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='sales' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0)")->getText();
     $salesCount = Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='sales' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0)")->queryScalar();
     $salesDataProvider = new CSqlDataProvider($salesSql, array('totalItemCount' => $salesCount, 'sort' => array('attributes' => array('firstName', 'lastName', 'phone', 'phone2', 'createDate', 'lastUpdated', 'leadSource'), 'defaultOrder' => 'lastUpdated DESC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage())));
     if (!empty($contactsDataProvider)) {
         $this->widget('zii.widgets.grid.CGridView', array('id' => 'contacts-grid', 'baseScriptUrl' => Yii::app()->theme->getBaseUrl() . '/css/gridview', 'template' => '<h2>' . Yii::t('contacts', 'Contacts') . '</h2><div class="title-bar">' . '{summary}</div>{items}{pager}', 'dataProvider' => $contactsDataProvider, 'enableSorting' => false, 'columns' => array(array('name' => 'lastName', 'header' => Yii::t('contacts', 'Name'), 'value' => 'CHtml::link($data["firstName"]." ".$data["lastName"],array("/contacts/default/view","id"=>$data["id"]))', 'type' => 'raw', 'htmlOptions' => array('width' => '30%')), array('name' => 'phone', 'header' => Yii::t('contacts', 'Work Phone')), array('name' => 'createDate', 'header' => Yii::t('contacts', 'Create Date'), 'value' => 'date("Y-m-d",$data["createDate"])', 'type' => 'raw', 'htmlOptions' => array('width' => '15%')), array('name' => 'lastUpdated', 'header' => Yii::t('contacts', 'Last Updated'), 'value' => 'date("Y-m-d",$data["lastUpdated"])', 'type' => 'raw', 'htmlOptions' => array('width' => '15%')), array('name' => 'leadSource', 'header' => Yii::t('contacts', 'Lead Source')))));
     }
     if (!empty($salesDataProvider)) {
         $this->widget('zii.widgets.grid.CGridView', array('id' => 'contacts-grid', 'baseScriptUrl' => Yii::app()->theme->getBaseUrl() . '/css/gridview', 'template' => '<h2>' . Yii::t('sales', 'Sales') . '</h2><div class="title-bar">' . '{summary}</div>{items}{pager}', 'dataProvider' => $salesDataProvider, 'columns' => array(array('header' => Sales::model()->getAttributeLabel('name'), 'name' => 'name', 'value' => 'CHtml::link($data["name"],array("/sales/default/view","id"=>$data["id"]))', 'type' => 'raw', 'htmlOptions' => array('width' => '40%')), array('header' => Sales::model()->getAttributeLabel('quoteAmount'), 'name' => 'quoteAmount', 'value' => 'Yii::app()->locale->numberFormatter->formatCurrency($data["quoteAmount"],Yii::app()->params->currency)', 'type' => 'raw'), array('header' => Sales::model()->getAttributeLabel('salesStage'), 'name' => 'salesStage', 'value' => 'Yii::t("sales",$data["salesStage"])', 'type' => 'raw'), array('header' => Sales::model()->getAttributeLabel('expectedCloseDate'), 'name' => 'expectedCloseDate', 'value' => 'empty($data->expectedCloseDate)?"":date("Y-m-d",$data["expectedCloseDate"])', 'type' => 'raw', 'htmlOptions' => array('width' => '13%')), array('header' => Sales::model()->getAttributeLabel('assignedTo'), 'name' => 'assignedTo', 'value' => 'empty($data["assignedTo"])?Yii::t("app","Anyone"):$data["assignedTo"]', 'type' => 'raw'))));
     }
 }
 public function init()
 {
     // $this->selectionChanged = 'js:function() { console.debug($.fn.yiiGridView.getSelection("'.$this->id.'")); }';
     // if(empty($this->modelName))
     // $this->modelName = $this->getId();
     if (empty($this->viewName)) {
         $this->viewName = $this->modelName;
     }
     if ($this->modelName == 'Quotes') {
         $this->modelName = 'Quote';
     }
     $this->columnSelectorId = $this->getId() . '-column-selector';
     if (isset($_GET['gvSettings']) && isset($_GET['viewName']) && $_GET['viewName'] == $this->viewName) {
         $this->gvSettings = json_decode($_GET['gvSettings'], true);
         // unset($_GET['gvSettings']);
         // die(var_dump($this->gvSettings));
         ProfileChild::setGridviewSettings($this->gvSettings, $this->viewName);
     } else {
         $this->gvSettings = ProfileChild::getGridviewSettings($this->viewName);
     }
     if ($this->gvSettings == null) {
         $this->gvSettings = $this->defaultGvSettings;
     }
     // die(var_dump($this->gvSettings));
     // die(var_dump(ProfileChild::getGridviewSettings($this->viewName)));
     // load names from $specialColumns into $specialColumnNames
     foreach ($this->specialColumns as $columnName => &$columnData) {
         if (isset($columnData['header'])) {
             $this->specialColumnNames[$columnName] = $columnData['header'];
         } else {
             $this->specialColumnNames[$columnName] = CActiveRecord::model($this->modelName)->getAttributeLabel($columnName);
         }
     }
     // start allFieldNames with the special fields
     if (!empty($this->specialColumnNames)) {
         $this->allFieldNames = $this->specialColumnNames;
     }
     // add controls column if specified
     if ($this->enableControls) {
         $this->allFieldNames['gvControls'] = Yii::t('app', 'Tools');
     }
     $this->allFieldNames['gvCheckbox'] = Yii::t('app', 'Checkbox');
     // load fields from DB
     // $fields=Fields::model()->findAllByAttributes(array('modelName'=>ucwords($this->modelName)));
     $fields = CActiveRecord::model($this->modelName)->getFields();
     foreach ($fields as $field) {
         $this->allFields[$field->fieldName] = $field;
     }
     // add tags column if specified
     if ($this->enableTags) {
         $this->allFieldNames['tags'] = Yii::t('app', 'Tags');
     }
     foreach ($this->allFields as $fieldName => &$field) {
         $this->allFieldNames[$fieldName] = CActiveRecord::model($this->modelName)->getAttributeLabel($field->fieldName);
     }
     // update columns if user has submitted data
     if (isset($_GET['columns']) && isset($_GET['viewName']) && $_GET['viewName'] == $this->viewName) {
         // has the user changed column visibility?
         foreach (array_keys($this->gvSettings) as $key) {
             $index = array_search($key, $_GET['columns']);
             // search $_GET['columns'] for the column
             if ($index === false) {
                 // if it's not in there,
                 unset($this->gvSettings[$key]);
             } else {
                 // othwerise, remove it from $_GET['columns']
                 unset($_GET['columns'][$index]);
             }
             // so the next part doesn't add it a second time
         }
         foreach (array_keys($this->allFieldNames) as $key) {
             // now go through $allFieldNames and add any fields that
             if (!isset($this->gvSettings[$key]) && in_array($key, $_GET['columns'])) {
                 // are present in $_GET['columns'] but not already in the list
                 $this->gvSettings[$key] = 80;
             }
             // default width of 80
         }
     }
     unset($_GET['columns']);
     // prevents columns data from ending up in sort/pagination links
     unset($_GET['viewName']);
     unset($_GET['gvSettings']);
     // adding/removing columns changes the total width,
     // so let's scale the columns to match the correct total (590px)
     $totalWidth = array_sum(array_values($this->gvSettings));
     if ($totalWidth > 0) {
         $widthFactor = 585 / $totalWidth;
         //- count($this->gvSettings)
         $sum = 0;
         $scaledSum = 0;
         foreach ($this->gvSettings as $columnName => &$columnWidth) {
             $sum += $columnWidth;
             $columnWidth = round($sum * $widthFactor) - $scaledSum;
             // map each point onto the nearest integer in the scaled space
             $scaledSum += $columnWidth;
         }
     }
     // die(var_dump($this->gvSettings).' '.$this->viewName);
     ProfileChild::setGridviewSettings($this->gvSettings, $this->viewName);
     // save the new Gridview Settings
     // die(var_dump($this->gvSettings));
     $columns = array();
     $datePickerJs = '';
     foreach ($this->gvSettings as $columnName => $width) {
         // $width = (!empty($width) && is_numeric($width))? 'width:'.$width.'px;' : null;	// make sure width is reasonable, then convert it to CSS
         $width = !empty($width) && is_numeric($width) ? $width : null;
         // make sure width is reasonable
         // $isDate = in_array($columnName,array('createDate','completeDate','lastUpdated','dueDate', 'expectedCloseDate', 'expirationDate', 'timestamp','lastactivity'));
         $isCurrency = in_array($columnName, array('annualRevenue', 'quoteAmount'));
         $lang = Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage();
         //if($isDate)
         //$datePickerJs .= ' $("#'.$columnName.'DatePicker").datepicker('
         //.'$.extend({showMonthAfterYear:false}, {"dateFormat":"'.$this->controller->formatDatePicker().'"})); ';
         // .'{"showAnim":"fold","dateFormat":"yy-mm-dd","changeMonth":"true","showButtonPanel":"true","changeYear":"true","constrainInput":"false"}));';
         $newColumn = array();
         if (array_key_exists($columnName, $this->specialColumnNames)) {
             $newColumn = $this->specialColumns[$columnName];
             // $newColumn['name'] = 'lastName';
             $newColumn['id'] = 'C_' . $columnName;
             // $newColumn['header'] = Yii::t('contacts','Name');
             $newColumn['headerHtmlOptions'] = array('colWidth' => $width);
             // $newColumn['value'] = 'CHtml::link($data->firstName." ".$data->lastName,array("view","id"=>$data->id))';
             // $newColumn['type'] = 'raw';
             // die(print_r($newColumn));
             $columns[] = $newColumn;
         } else {
             if (array_key_exists($columnName, $this->allFields)) {
                 // && $this->allFields[$columnName]->visible == 1)) {
                 $newColumn['name'] = $columnName;
                 $newColumn['id'] = 'C_' . $columnName;
                 $newColumn['header'] = CActiveRecord::model($this->modelName)->getAttributeLabel($columnName);
                 $newColumn['headerHtmlOptions'] = array('colWidth' => $width);
                 if ($isCurrency) {
                     $newColumn['value'] = 'Yii::app()->locale->numberFormatter->formatCurrency($data->' . $columnName . ',Yii::app()->params->currency)';
                     $newColumn['type'] = 'raw';
                 } else {
                     if ($columnName == 'assignedTo') {
                         $newColumn['value'] = 'empty($data->assignedTo)?Yii::t("app","Anyone"):UserChild::getUserLinks($data->assignedTo)';
                         $newColumn['type'] = 'raw';
                     } elseif ($this->allFields[$columnName]->type == 'date') {
                         $newColumn['value'] = 'empty($data["' . $columnName . '"])? "" : Yii::app()->dateFormatter->format(Yii::app()->locale->getDateFormat("medium"), $data["' . $columnName . '"])';
                     } elseif ($this->allFields[$columnName]->type == 'link') {
                         $newColumn['value'] = 'X2Model::getModelLink($data->' . $columnName . ',"' . $this->allFields[$columnName]->linkType . '")';
                         // $type=ucfirst($field->linkType);
                         // $newColumn['value']="!is_null($type::model()->findByPk(\$data->$columnName))?CHtml::link($type::model()->findByPk(\$data->$columnName)->name,array('/".$field->linkType."/default/view/id/'.\$data->$columnName),array('target'=>'_blank')):\$data->$columnName";
                         $newColumn['type'] = 'raw';
                     } elseif ($this->allFields[$columnName]->type == 'boolean') {
                         $field = $this->allFields[$columnName];
                         $type = ucfirst($field->linkType);
                         $newColumn['value'] = '$data->' . $columnName . '==1?Yii::t("actions","Yes"):Yii::t("actions","No")';
                         $newColumn['type'] = 'raw';
                     }
                 }
                 if (Yii::app()->language == 'en') {
                     $format = "M d, yy";
                 } else {
                     $format = Yii::app()->locale->getDateFormat('medium');
                     // translate Yii date format to jquery
                     $format = str_replace('yy', 'y', $format);
                     $format = str_replace('MM', 'mm', $format);
                     $format = str_replace('M', 'm', $format);
                 }
                 /*$newColumn['filter'] = $isDate? $this->widget("zii.widgets.jui.CJuiDatePicker",array(
                 			'model'=>$this->filter, //Model object
                 			// 'id'=>$columnName.'DatePicker',
                 			'attribute'=>$columnName, //attribute name
                 			// 'mode'=>'datetime', //use 'time','date' or 'datetime' (default)
                 			// 'htmlOptions'=>array('style'=>'width:80%;'),
                 			'options'=>array(
                 				'dateFormat'=>$format,
                 			), // jquery plugin options
                 			'language'=>$lang,
                 		),true) : null;*/
                 $columns[] = $newColumn;
             } else {
                 if ($columnName == 'gvControls') {
                     $newColumn['id'] = 'C_gvControls';
                     $newColumn['class'] = 'CButtonColumn';
                     $newColumn['header'] = Yii::t('app', 'Tools');
                     $newColumn['headerHtmlOptions'] = array('colWidth' => $width);
                     if (Yii::app()->user->getName() != 'admin') {
                         $newColumn['template'] = '{view}{update}';
                     }
                     $columns[] = $newColumn;
                 } else {
                     if ($columnName == 'tags') {
                         $newColumn['id'] = 'C_' . 'tags';
                         // $newColumn['class'] = 'CDataColumn';
                         $newColumn['header'] = Yii::t('app', 'Tags');
                         $newColumn['headerHtmlOptions'] = array('colWidth' => $width);
                         $newColumn['value'] = 'Tags::getTagLinks("' . $this->modelName . '",$data->id,2)';
                         $newColumn['type'] = 'raw';
                         $newColumn['filter'] = CHtml::textField('tagField', isset($_GET['tagField']) ? $_GET['tagField'] : '');
                         $columns[] = $newColumn;
                     } else {
                         if ($columnName == 'gvCheckbox') {
                             $newColumn['id'] = 'C_gvCheckbox';
                             $newColumn['class'] = 'CCheckBoxColumn';
                             $newColumn['selectableRows'] = 2;
                             $newColumn['headerHtmlOptions'] = array('colWidth' => $width);
                             $columns[] = $newColumn;
                         }
                     }
                 }
             }
         }
     }
     // $this->afterAjaxUpdate = 'function(id, data) { '.$datePickerJs.' }';
     if (!empty($this->afterAjaxUpdate)) {
         $this->afterAjaxUpdate = "var callback = " . $this->afterAjaxUpdate . "; if(typeof callback == 'function') callback();";
     }
     $this->afterAjaxUpdate = " function(id,data) { " . $this->afterAjaxUpdate . " " . $datePickerJs;
     if ($this->enableGvSettings) {
         $this->afterAjaxUpdate .= "\n\t\t\t\$('#" . $this->getId() . " table').gvSettings({\n\t\t\t\tviewName:'" . $this->viewName . "',\n\t\t\t\tcolumnSelectorId:'" . $this->columnSelectorId . "',\n\t\t\t\tajaxUpdate:true\n\t\t\t});";
     }
     $this->afterAjaxUpdate .= " } ";
     $this->columns = $columns;
     natcasesort($this->allFieldNames);
     // sort column names
     // generate column selector HTML
     $this->columnSelectorHtml = CHtml::beginForm(array('site/saveGvSettings'), 'get') . '<ul class="column-selector" id="' . $this->columnSelectorId . '">';
     foreach ($this->allFieldNames as $fieldName => &$attributeLabel) {
         $selected = array_key_exists($fieldName, $this->gvSettings);
         $this->columnSelectorHtml .= "<li>" . CHtml::checkbox('columns[]', $selected, array('id' => $fieldName . '_checkbox', 'value' => $fieldName)) . CHtml::label($attributeLabel, $fieldName . '_checkbox') . "</li>";
     }
     $this->columnSelectorHtml .= '</ul>' . CHtml::endForm();
     // Yii::app()->clientScript->renderBodyBegin($columnHtml);
     // Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->getId().'_columnSelector',
     // "$('#".$this->getId()." table').after('".addcslashes($columnHtml,"'")."');
     // ",CClientScript::POS_READY);
     $themeURL = Yii::app()->theme->getBaseUrl();
     Yii::app()->clientScript->registerScript('logos', "\n\t\t\$(window).load(function(){\n\t\t\tif((!\$('#main-menu-icon').length) || (!\$('#x2touch-logo').length) || (!\$('#x2crm-logo').length)){\n\t\t\t\t\$('a').removeAttr('href');\n\t\t\t\talert('Please put the logo back');\n\t\t\t\twindow.location='http://www.x2engine.com';\n\t\t\t}\n\t\t\tvar touchlogosrc = \$('#x2touch-logo').attr('src');\n\t\t\tvar logosrc=\$('#x2crm-logo').attr('src');\n\t\t\tif(logosrc!='{$themeURL}/images/x2footer.png'|| touchlogosrc!='{$themeURL}/images/x2touch.png'){\n\t\t\t\t\$('a').removeAttr('href');\n\t\t\t\talert('Please put the logo back');\n\t\t\t\twindow.location='http://www.x2engine.com';\n\t\t\t}\n\t\t});    \n\t\t");
     parent::init();
 }
Exemple #10
0
 *   specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 ********************************************************************************/
mb_internal_encoding('UTF-8');
mb_regex_encoding('UTF-8');
Yii::app()->params->profile = ProfileChild::model()->findByPk(1);
// jQuery and jQuery UI libraries
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerCoreScript('jquery.ui');
Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/backgroundImage.js');
// blueprint CSS framework
$themeURL = Yii::app()->theme->getBaseUrl();
Yii::app()->clientScript->registerCssFile($themeURL . '/css/screen.css', 'screen, projection');
Yii::app()->clientScript->registerCssFile($themeURL . '/css/print.css', 'print');
Yii::app()->clientScript->registerCssFile($themeURL . '/css/main.css', 'screen, projection');
Yii::app()->clientScript->registerCssFile($themeURL . '/css/form.css', 'screen, projection');
Yii::app()->clientScript->registerScript('checkImages', "\n\$(document).ready(function() {\n\t\$('#main-menu-icon, #footer-logo, #footer-logo img').css({'display':'inline','visibility':'visible','z-index':'2147483647'});\n           \n});\n", CClientScript::POS_END);
$backgroundImg = '';
$defaultOpacity = 1;
$themeCss = '';
$checkResult = false;
Exemple #11
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     $fields = Fields::model()->findAllByAttributes(array('modelName' => 'Templates'));
     foreach ($fields as $field) {
         $fieldName = $field->fieldName;
         switch ($field->type) {
             case 'boolean':
                 $criteria->compare($field->fieldName, $this->compareBoolean($this->{$fieldName}), true);
                 break;
             case 'link':
                 $criteria->compare($field->fieldName, $this->compareLookup($field, $this->{$fieldName}), true);
                 break;
             case 'assignment':
                 $criteria->compare($field->fieldName, $this->compareAssignment($this->{$fieldName}), true);
                 break;
             default:
                 $criteria->compare($field->fieldName, $this->{$fieldName}, true);
         }
     }
     return new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage())));
 }
Exemple #12
0
}
);");

if (!isset($isQuickCreate)) {	//check if this form is being recycled in the quickCreate view

	echo '<div class="form no-border">';
	$form=$this->beginWidget('CActiveForm', array(
		'id'=>'contacts-form',
		'enableAjaxValidation'=>false,
	));
	echo '<em>'.Yii::t('app','Fields with <span class="required">*</span> are required.')."</em>\n";
}

$attributeLabels = ContactChild::attributeLabels();

$showSocialMedia = ProfileChild::getSocialMedia();
?>
<?php
echo $form->errorSummary($contactModel);
?>

<table class="details">
	<tr>
		<td class="label"><?php echo $form->label($contactModel,'firstName'); ?></td>
		<td width="145" id="firstName">
			<?php
			echo $form->textField($contactModel, 'firstName', array(
				'size'=>15,
				'maxlength'=>40,
				'tabindex'=>1,
				'style'=>'width:135px;'
Exemple #13
0
	public function searchAdmin() {
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		//$criteria->compare('assignedTo',$this->assignedTo,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('quoteAmount',$this->quoteAmount);
		$criteria->compare('salesStage',$this->salesStage,true);
		$criteria->compare('expectedCloseDate',$this->expectedCloseDate,true);
		$criteria->compare('probability',$this->probability);
		$criteria->compare('leadSource',$this->leadSource,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('createDate',$this->createDate,true);

		return new SmartDataProvider(get_class($this), array(
			'sort'=>array(
				'defaultOrder'=>'createDate ASC',
			),
			'pagination'=>array(
				'pageSize'=>ProfileChild::getResultsPerPage(),
			),
			'criteria'=>$criteria,
		));
	}
Exemple #14
0
 public function compareAttributes(&$criteria)
 {
     $this->queryFields();
     foreach (self::$_fields[$this->tableName()] as &$field) {
         $fieldName = $field['fieldName'];
         switch ($field['type']) {
             case 'boolean':
                 $criteria->compare($fieldName, $this->compareBoolean($this->{$fieldName}), true);
                 break;
             case 'link':
                 $criteria->compare($fieldName, $this->compareLookup($field->linkType, $this->{$fieldName}), true);
                 $criteria->compare($fieldName, $this->{$fieldName}, true, 'OR');
                 break;
             case 'assignment':
                 $criteria->compare($fieldName, $this->compareAssignment($this->{$fieldName}), true);
                 break;
             default:
                 $criteria->compare($fieldName, $this->{$fieldName}, true);
         }
     }
     if (get_class($this) == 'Contacts') {
         $criteria->compare('CONCAT(firstName," ",lastName)', $this->name, true);
     }
     return new SmartDataProvider(get_class($this), array('sort' => array('defaultOrder' => 'createDate DESC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'criteria' => $criteria));
 }
Exemple #15
0
	public function search() {
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('website',$this->website,true);
		$criteria->compare('type',$this->type,true);
		$criteria->compare('annualRevenue',$this->annualRevenue);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('tickerSymbol',$this->tickerSymbol,true);
		$criteria->compare('employees',$this->employees);
		$criteria->compare('assignedTo',$this->assignedTo,true);
		$criteria->compare('associatedContacts',$this->associatedContacts,true);
		$criteria->compare('description',$this->description,true);

		$dataProvider=new SmartDataProvider(get_class($this), array(
			'sort'=>array('defaultOrder'=>'name ASC'),
			'pagination'=>array(
				'pageSize'=>ProfileChild::getResultsPerPage(),
			),
			'criteria'=>$criteria,
		));
		$arr=$dataProvider->getData();
		foreach($arr as $account){
			$account->assignedTo=UserChild::getUserLinks($account->assignedTo);
			$account->associatedContacts=ContactChild::getContactLinks($account->associatedContacts);
		}
		$dataProvider->setData($arr);

		return $dataProvider;
	}
 private function searchBase($criteria)
 {
     $criteria->compare('name', $this->name, true);
     return new SmartDataProvider(get_class($this), array('sort' => array('defaultOrder' => 'createDate ASC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'criteria' => $criteria));
 }
Exemple #17
0
	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate() {
		$model=new UserChild;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['UserChild'])) {
			$model->attributes=$_POST['UserChild'];
			$this->updateChangelog($model);
			$model->password = md5($model->password);

			$profile=new ProfileChild;
			$profile->fullName=$model->firstName." ".$model->lastName;
			$profile->username=$model->username;
                        $profile->allowPost=1;
			$profile->emailAddress=$model->emailAddress;
			$profile->status=$model->status;

			if($model->save() && $profile->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}
Exemple #18
0
	'id'=>'contacts-form',
	'enableAjaxValidation'=>false,
	'action'=>array('saveChanges','id'=>$model->id),
));

?>


<!--<h2><?php echo Yii::t('contacts','Contact:'); ?> <b><?php echo $model->firstName.' '.$model->lastName; ?></b></h2>-->
<?php

if(isset($_GET['detail'])) {
	$detailView = ($_GET['detail']=='1')? 1 : 0;
	ProfileChild::setDetailView($detailView);
} else {
	$detailView = ProfileChild::getDetailView();
}

$this->renderPartial($detailView? '_detailView' : '_simpleView',array('model'=>$model,'form'=>$form,'users'=>$users));

$this->endWidget(); ?>

	<a class="x2-button" id="save-changes" href="#" onClick="submitForm('contacts-form');return false;"><span><?php echo Yii::t('app','Save Changes'); ?></span></a>
	<?php /*<a class="x2-button" href="#" onClick="toggleForm('#note-form',400);return false;"><span><?php echo Yii::t('app','Add Comment'); ?></span></a>
	<a class="x2-button" href="#" onClick="toggleForm('#action-form',400);return false;"><span><?php echo Yii::t('app','Create Action'); ?></span></a> */ ?>
	<a class="x2-button" href="mailto:<?php echo $model->email; ?>?cc=dropbox@<?php echo substr(Yii::app()->request->getServerName(),4);?>"><span><?php echo Yii::t('app','Send Email'); ?></span></a>
	<a class="x2-button" href="#" onClick="toggleForm('#attachment-form',200);return false;"><span><?php echo Yii::t('app','Attach A File/Photo'); ?></span></a>
	<a class="x2-button" href="shareContact/<?php echo $model->id;?>"><span><?php echo Yii::t('contacts','Share Contact'); ?></span></a>
	<br />
<div id="attachment-form" style="display:none;">
	<?php $this->widget('Attachments',array('type'=>'contacts','associationId'=>$model->id)); ?>
 public function actionDelete($id)
 {
     $model = $this->loadModel($id);
     if (Yii::app()->request->isPostRequest) {
         $this->cleanUpTags($model);
         if (!is_numeric($model->assignedTo)) {
             // assigned to user
             $profile = ProfileChild::model()->findByAttributes(array('username' => $model->assignedTo));
             $profile->deleteGoogleCalendarEvent($model);
             // update action in Google Calendar if user has a Google Calendar
         }
         $model->delete();
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (isset($_GET['ajax'])) {
         echo 'Success';
     } else {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
     }
 }
Exemple #20
0
 * - Neither the name of X2Engine or X2CRM nor the names of its contributors may be 
 *   used to endorse or promote products derived from this software without 
 *   specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 ********************************************************************************/
$profile = ProfileChild::model()->findByPk(Yii::app()->user->id);
$this->showActions = $profile->showActions;
if (!$this->showActions) {
    // if user hasn't saved a type of action to show, show uncomple actions by default
    $this->showActions = 'uncomplete';
}
if ($this->showActions == 'uncomplete') {
    $model->complete = 'No';
} else {
    if ($this->showActions == 'complete') {
        $model->complete = 'Yes';
    } else {
        $model->complete = '';
    }
}
if ($this->route == 'actions/default/index') {
Exemple #21
0
	public function searchAdmin() {
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.
		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('firstName',$this->firstName,true);
		$criteria->compare('lastName',$this->lastName,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('company',$this->company,true);
		$criteria->compare('accountId',$this->accountId);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('phone2',$this->phone2,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('website',$this->website,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('city',$this->city,true);
		$criteria->compare('state',$this->state,true);
		$criteria->compare('zipcode',$this->zipcode,true);
		$criteria->compare('country',$this->country,true);
		$criteria->compare('visibility',$this->visibility);
		$criteria->compare('assignedTo',$this->assignedTo,true);
		$criteria->compare('backgroundInfo',$this->backgroundInfo,true);
		$criteria->compare('twitter',$this->twitter,true);
		$criteria->compare('linkedin',$this->linkedin,true);
		$criteria->compare('skype',$this->skype,true);
		$criteria->compare('googleplus',$this->googleplus,true);
		$criteria->compare('lastUpdated',$this->lastUpdated,true);
		$criteria->compare('updatedBy',$this->updatedBy,true);
		$criteria->compare('priority',$this->priority,true);
		$criteria->compare('leadSource',$this->leadSource,true);
		$criteria->compare('rating',$this->rating);
		$criteria->compare('createDate',$this->createDate);
		


		return new SmartDataProvider(get_class($this), array(
			'sort'=>array(
				'defaultOrder'=>'lastName ASC',
			),
			'pagination'=>array(
				'pageSize'=>ProfileChild::getResultsPerPage(),
			),
			'criteria'=>$criteria,
		));
	}
Exemple #22
0
 public function search()
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new CDbCriteria();
     $fields = Fields::model()->findAllByAttributes(array('modelName' => 'Accounts'));
     foreach ($fields as $field) {
         $fieldName = $field->fieldName;
         switch ($field->type) {
             case 'boolean':
                 $criteria->compare($field->fieldName, $this->compareBoolean($this->{$fieldName}), true);
                 break;
             case 'link':
                 $criteria->compare($field->fieldName, $this->compareLookup($field, $this->{$fieldName}), true);
                 break;
             case 'assignment':
                 $criteria->compare($field->fieldName, $this->compareAssignment($this->{$fieldName}), true);
                 break;
             default:
                 $criteria->compare($field->fieldName, $this->{$fieldName}, true);
         }
     }
     $dataProvider = new SmartDataProvider(get_class($this), array('sort' => array('defaultOrder' => 'name ASC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'criteria' => $criteria));
     $arr = $dataProvider->getData();
     foreach ($arr as $account) {
         $account->assignedTo = User::getUserLinks($account->assignedTo);
         $account->associatedContacts = Contacts::getContactLinks($account->associatedContacts);
     }
     $dataProvider->setData($arr);
     return $dataProvider;
 }
$layout = FormLayout::model()->findByAttributes(array('model' => ucfirst($modelName), 'defaultView' => 1));
if (isset($layout)) {
    echo '<div class="x2-layout">';
    $fields = array();
    // remove this later, once all models extend X2Models
    if (method_exists($model, 'getFields')) {
        foreach ($model->fields as $fieldModel) {
            $fields[$fieldModel->fieldName] = $fieldModel;
        }
    } else {
        foreach (Fields::model()->findAllByAttributes(array('modelName' => ucfirst($modelName))) as $fieldModel) {
            $fields[$fieldModel->fieldName] = $fieldModel;
        }
    }
    $layoutData = json_decode($layout->layout, true);
    $formSettings = ProfileChild::getFormSettings($modelName);
    if (isset($layoutData['sections']) && count($layoutData['sections']) > 0) {
        $fieldPermissions = array();
        if (!empty(Yii::app()->params->roles)) {
            $rolePermissions = Yii::app()->db->createCommand()->select('fieldId, permission')->from('x2_role_to_permission')->join('x2_fields', 'x2_fields.modelName="' . $modelName . '" AND x2_fields.id=fieldId AND roleId IN (' . implode(',', Yii::app()->params->roles) . ')')->queryAll();
            foreach ($rolePermissions as &$permission) {
                if (!isset($fieldPermissions[$permission['fieldId']]) || $fieldPermissions[$permission['fieldId']] < (int) $permission['permission']) {
                    $fieldPermissions[$permission['fieldId']] = (int) $permission['permission'];
                }
            }
        }
        $i = 0;
        foreach ($layoutData['sections'] as &$section) {
            // set defaults
            if (!isset($section['title'])) {
                $section['title'] = '';
Exemple #24
0
	/**
	 * Sets widgets on the page on a per user basis.
	 */
	public function filterSetPortlets($filterChain) {
		$this->portlets = ProfileChild::getWidgets();
		// foreach($widgets as $key=>$value) {
			// $options = ProfileChild::parseWidget($value,$key);
			// $this->portlets[$key] = $options;
		// }
		$filterChain->run();
	}
Exemple #25
0
	public function getWidgets() {
		
		$model = ProfileChild::model('ProfileChild')->findByPk(Yii::app()->user->getId());
		
		$registeredWidgets = array_keys(Yii::app()->params->registeredWidgets);
		
		$widgetNames = ($model->widgetOrder=='')? array() : explode(":",$model->widgetOrder);
		$visibility = ($model->widgets=='')? array() : explode(":",$model->widgets);
		
		$widgetList = array();
		
		$updateRecord = false;
		
		for($i=0;$i<count($widgetNames);$i++) {
		
			if(!in_array($widgetNames[$i],$registeredWidgets)) {	// check the main cfg file
				unset($widgetNames[$i]);							// if widget isn't listed,
				unset($visibility[$i]);								// remove it from database fields
				$updateRecord = true;
			} else {
				$widgetList[$widgetNames[$i]] = array('id'=>'widget_'.$widgetNames[$i],'visibility'=>$visibility[$i]);
			}
		}

		foreach($registeredWidgets as $class) {			// check list of widgets in main cfg file
			if(!in_array($class,array_keys($widgetList))) {								// if they aren't in the list,
				$widgetList[$class] = array('id'=>'widget_'.$class,'visibility'=>1);	// add them at the bottom
				
				$widgetNames[] = $class;	// add new widgets to widgetOrder array
				$visibility[] = 1;			// and visibility array
				
				$updateRecord = true;
			}
		}

		if($updateRecord) {
			$model->widgetOrder = implode(':',$widgetNames);	// update database fields
			$model->widgets = implode(':',$visibility);			// if there are new widgets
			$model->save();
		}
		
		return $widgetList;
	}
Exemple #26
0
 /**
  * Sets widgets on the page on a per user basis.
  */
 public function filterSetPortlets($filterChain)
 {
     $themeURL = Yii::app()->theme->getBaseUrl();
     Yii::app()->clientScript->registerScript('logos', "\n\t\t\t\$(window).load(function(){\n\t\t\t\tif((!\$('#main-menu-icon').length) || (!\$('#x2touch-logo').length) || (!\$('#x2crm-logo').length)){\n\t\t\t\t\t\$('a').removeAttr('href');\n\t\t\t\t\talert('Please put the logo back');\n\t\t\t\t\twindow.location='http://www.x2engine.com';\n\t\t\t\t}\n\t\t\t\tvar touchlogosrc = \$('#x2touch-logo').attr('src');\n\t\t\t\tvar logosrc=\$('#x2crm-logo').attr('src');\n\t\t\t\tif(logosrc!='{$themeURL}/images/x2footer.png'|| touchlogosrc!='{$themeURL}/images/x2touch.png'){\n\t\t\t\t\t\$('a').removeAttr('href');\n\t\t\t\t\talert('Please put the logo back');\n\t\t\t\t\twindow.location='http://www.x2engine.com';\n\t\t\t\t}\n\t\t\t});    \n\t\t\t");
     $this->portlets = ProfileChild::getWidgets();
     // foreach($widgets as $key=>$value) {
     // $options = ProfileChild::parseWidget($value,$key);
     // $this->portlets[$key] = $options;
     // }
     $filterChain->run();
 }
 public function actionSearch()
 {
     ini_set('memory_limit', -1);
     $term = $_GET['term'];
     if (substr($term, 0, 1) != "#") {
         /*$contactsCriteria = new CDbCriteria();
         
                                 $contactsCriteria->compare('firstName', $term, true, 'OR');
                                 $contactsCriteria->compare('lastName', $term, true, 'OR');
                                 $contactsCriteria->compare('name', $term, true, 'OR');
                                 $contactsCriteria->compare('backgroundInfo', $term, true, 'OR');
                                 $contactsCriteria->compare('email', $term, true, 'OR');
                                 $contactsCriteria->compare('phone', $term, true, 'OR');
                                 if(is_numeric($term)){
                                     $temp=$term;
                                     $first=substr($temp,0,3);
                                     $second=substr($temp,3,3);
                                     $third=substr($temp,6,4);
         
                                     $contactsCriteria->compare('phone', "($first) $second-$third", true, 'OR');
                                     $contactsCriteria->compare('phone', "$first-$second-$third", true, 'OR');
                                     $contactsCriteria->compare('phone', "$first $second $third", true, 'OR');
         
                                     $contactsCriteria->compare('phone2', "($first) $second-$third", true, 'OR');
                                     $contactsCriteria->compare('phone2', "$first-$second-$third", true, 'OR');
                                     $contactsCriteria->compare('phone2', "$first $second $third", true, 'OR');
         
                                 }
         						
                                 $contacts=Contacts::model()->findAll($contactsCriteria);
         
                                 
                                 $actionsCriteria=new CDbCriteria();
                                 $actionsCriteria->compare('actionDescription',$term,true,'OR');
                                 $actions=Actions::model()->findAll($actionsCriteria);
                                 
                                 $accountsCriteria=new CDbCriteria();
                                 $accountsCriteria->compare("name",$term,true,"OR");
                                 $accountsCriteria->compare("description",$term,true,"OR");
                                 $accountsCriteria->compare('tickerSymbol',$term,true,'OR');
                                 $accounts=Accounts::model()->findAll($accountsCriteria);
                                 
                                 $quotesCriteria=new CDbCriteria();
                                 $quotesCriteria->compare("name",$term,TRUE,"OR");
                                 $quotes=Quote::model()->findAll($quotesCriteria);
                                 
                                 $disallow=array(
                                     'contacts',
                                     'actions',
                                     'accounts',
                                     'quotes',
                                 );*/
         $modules = Modules::model()->findAllByAttributes(array('searchable' => 1));
         $comparisons = array();
         foreach ($modules as $module) {
             $module->name == 'products' ? $type = ucfirst('Product') : ($type = ucfirst($module->name));
             $module->name == 'quotes' ? $type = ucfirst('Quote') : ($type = $type);
             $criteria = new CDbCriteria();
             $fields = Fields::model()->findAllByAttributes(array('modelName' => $type, 'searchable' => 1));
             $temp = array();
             foreach ($fields as $field) {
                 $temp[] = $field->id;
                 $criteria->compare($field->fieldName, $term, true, "OR");
             }
             $arr = CActiveRecord::model($type)->findAll($criteria);
             $comparisons[$type] = $temp;
             $other[$type] = $arr;
         }
         $high = array();
         $medium = array();
         $low = array();
         $records = array();
         $regEx = "/{$term}/i";
         foreach ($other as $key => $recordType) {
             $fieldList = $comparisons[$key];
             foreach ($recordType as $otherRecord) {
                 foreach ($fieldList as $field) {
                     $fieldRecord = Fields::model()->findByPk($field);
                     $fieldName = $fieldRecord->fieldName;
                     if (preg_match($regEx, $otherRecord->{$fieldName}) > 0) {
                         switch ($fieldRecord->relevance) {
                             case "High":
                                 if (!in_array($otherRecord, $high) && !in_array($otherRecord, $medium) && !in_array($otherRecord, $low)) {
                                     $high[] = $otherRecord;
                                 }
                                 break;
                             case "Medium":
                                 if (!in_array($otherRecord, $high) && !in_array($otherRecord, $medium) && !in_array($otherRecord, $low)) {
                                     $medium[] = $otherRecord;
                                 }
                                 break;
                             case "Low":
                                 if (!in_array($otherRecord, $high) && !in_array($otherRecord, $medium) && !in_array($otherRecord, $low)) {
                                     $low[] = $otherRecord;
                                 }
                                 break;
                             default:
                                 $low[] = $otherRecord;
                         }
                     }
                 }
             }
         }
         $records = array_merge($high, $medium);
         $records = array_merge($records, $low);
         $records = Record::convert($records, false);
         $dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage())));
         $this->render('search', array('records' => $records, 'dataProvider' => $dataProvider, 'term' => $term));
     } else {
         $results = new CActiveDataProvider('Tags', array('criteria' => array('condition' => 'tag="' . $term . '"')));
         $this->render('searchTags', array('tags' => $results));
     }
 }
Exemple #28
0
	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('assignedTo',$this->assignedTo,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('fieldOne',$this->fieldOne,true);
		$criteria->compare('fieldTwo',$this->fieldTwo,true);
		$criteria->compare('fieldThree',$this->fieldThree,true);
		$criteria->compare('fieldFour',$this->fieldFour,true);
		$criteria->compare('fieldFive',$this->fieldFive,true);
		$criteria->compare('createDate',$this->createDate);
		$criteria->compare('lastUpdated',$this->lastUpdated);
		$criteria->compare('updatedBy',$this->updatedBy,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
			'pagination'=>array(
				'pageSize'=>ProfileChild::getResultsPerPage(),
			),
		));
	}
Exemple #29
0
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 ********************************************************************************/
//Reset widget settings if implementing TopSites
if (!isset(ProfileChild::getWidgetSettings()->TopSites)) {
    Yii::app()->params->profile->widgetSettings = null;
}
//Create variables corresponding to pre-defined heights gained
//through calling ProfileChild.
$widgetSettings = ProfileChild::getWidgetSettings();
$sitesSettings = $widgetSettings->TopSites;
$topsitesHeight = $sitesSettings->topsitesHeight;
$urlTitleHeight = $sitesSettings->urltitleHeight;
//Set variables to implement HTML divs
$topsitesContainerHeight = $topsitesHeight + 2;
$urlTitleContainerHeight = $urlTitleHeight + 30;
$siteContainerHeight = $topsitesHeight + $urlTitleHeight + 45;
$siteContainerFixHeight = 250;
?>
<div id="sites-container-fix" style="height:".<?php 
echo $siteContainerFixHeight;
?>
."px">
<div id="sites-container" style="height:".<?php 
echo $siteContainerHeight;
	/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 * @param integer the ID of the model to be loaded
	 */
	public function loadModel($id) {
		$model=ProfileChild::model('ProfileChild')->findByPk((int)$id);
		if($model===null)
			throw new CHttpException(404,Yii::t('app','The requested page does not exist.'));
		return $model;
	}