Esempio n. 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,
		));
	}
Esempio n. 2
0
 public function actionWhatsNew()
 {
     if (!Yii::app()->user->isGuest) {
         $user = User::model()->findByPk(Yii::app()->user->getId());
         $lastLogin = $user->lastLogin;
         $contacts = Contacts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $actions = Actions::model()->findAll("lastUpdated > {$lastLogin} AND (assignedTo='" . Yii::app()->user->getName() . "' OR assignedTo='Anyone') ORDER BY lastUpdated DESC LIMIT 50");
         $sales = Sales::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $accounts = Accounts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $arr = array_merge($contacts, $actions, $sales, $accounts);
         $records = Record::convert($arr);
         $dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'sort' => array('attributes' => array('lastUpdated', 'name'))));
         $this->render('whatsNew', array('records' => $records, 'dataProvider' => $dataProvider));
     } else {
         $this->redirect('login');
     }
 }
Esempio n. 3
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,
		));
	}
Esempio n. 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('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));
 }
Esempio n. 5
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'))));
     }
 }
Esempio n. 7
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,
		));
	}
Esempio n. 8
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;
 }
Esempio n. 9
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));
 }
Esempio n. 10
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,
		));
	}
Esempio n. 11
0
 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));
 }
Esempio n. 12
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;
	}
Esempio n. 13
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())));
 }
Esempio n. 14
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('actionDescription',$this->actionDescription,true);
		$criteria->compare('visibility',$this->visibility);
		$criteria->compare('associationId',$this->associationId);
		$criteria->compare('associationType',$this->associationType,true);
		$criteria->compare('associationName',$this->associationName,true);
		$criteria->compare('dueDate',$this->dueDate,true);
		$criteria->compare('priority',$this->priority,true);
		$criteria->compare('type',$this->type,true);
		$criteria->compare('createDate',$this->createDate,true);
		$criteria->compare('complete',$this->complete,true);
		$criteria->compare('reminder',$this->reminder,true);
		$criteria->compare('completedBy',$this->completedBy,true);
		$criteria->compare('completeDate',$this->completeDate,true);

		return new SmartDataProvider(get_class($this), array(
			'sort'=>array(
				'defaultOrder'=>'createDate DESC',
			),
			'pagination'=>array(
				'pageSize'=>ProfileChild::getResultsPerPage(),
			),
			'criteria'=>$criteria,
		));
	}
Esempio n. 15
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(),
			),
		));
	}
Esempio n. 16
0
 public function searchBase($criteria)
 {
     // $criteria->compare('id',$this->id);
     $criteria->compare('name', $this->name, true);
     $criteria->compare('accountName', $this->accountName, true);
     $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('assignedTo', $this->assignedTo, true);
     // $criteria->compare('createDate',$this->createDate);
     $criteria->compare('associatedContacts', $this->associatedContacts, true);
     // $criteria->compare('lastUpdated',$this->lastUpdated);
     $criteria->compare('updatedBy', $this->updatedBy, true);
     $dateRange = Yii::app()->controller->partialDateRange($this->expectedCloseDate);
     if ($dateRange !== false) {
         $criteria->addCondition('expectedCloseDate BETWEEN ' . $dateRange[0] . ' AND ' . $dateRange[1]);
     }
     $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 SmartDataProvider(get_class($this), array('sort' => array('defaultOrder' => 'createDate ASC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'criteria' => $criteria));
 }
Esempio n. 17
0
 public function searchBase($criteria)
 {
     $fields = Fields::model()->findAllByAttributes(array('modelName' => 'Sales'));
     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 SmartDataProvider(get_class($this), array('sort' => array('defaultOrder' => 'createDate ASC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'criteria' => $criteria));
 }
Esempio n. 18
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();
     $parameters = array('limit' => ceil(ProfileChild::getResultsPerPage()));
     $criteria->scopes = array('findAll' => array($parameters));
     $criteria->compare('id', $this->id);
     $criteria->compare('type', $this->type, true);
     $criteria->compare('itemId', $this->itemId);
     $criteria->compare('changedBy', $this->changedBy, true);
     $criteria->compare('changed', $this->changed, true);
     $criteria->compare('timestamp', $this->timestamp);
     return new SmartDataProvider(get_class($this), array('sort' => array('defaultOrder' => 'timestamp DESC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'criteria' => $criteria));
 }
Esempio n. 19
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($id)
 {
     $criteria = new CDbCriteria(array('condition' => 'workflowId=' . $id, 'order' => 'stageNumber ASC'));
     return new CActiveDataProvider(get_class($this), array('criteria' => $criteria, 'pagination' => array('pageSize' => ceil(ProfileChild::getResultsPerPage()))));
 }
Esempio n. 20
0
 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));
     }
 }
 public function actionLists()
 {
     // Yii:app()->params->groups
     $criteria = new CDbCriteria(array());
     $criteria->addCondition('type="static" OR type="dynamic"');
     $criteria->addCondition('x2_checkViewPermission(visibility,assignedTo,"' . Yii::app()->user->getName() . '") > 0');
     $contactLists = new CActiveDataProvider('X2List', array('sort' => array('defaultOrder' => 'createDate DESC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'criteria' => $criteria));
     $totalContacts = CActiveRecord::model('Contacts')->count();
     $totalMyContacts = CActiveRecord::model('Contacts')->count('assignedTo="' . Yii::app()->user->getName() . '"');
     $totalNewContacts = CActiveRecord::model('Contacts')->count('assignedTo="' . Yii::app()->user->getName() . '" AND createDate >= ' . mktime(0, 0, 0));
     $allContacts = new X2List();
     $allContacts->attributes = array('id' => 'all', 'name' => Yii::t('contacts', 'All Contacts'), 'description' => '', 'type' => 'dynamic', 'visibility' => 1, 'count' => $totalContacts, 'createDate' => 0, 'lastUpdated' => 0);
     $newContacts = new X2List();
     $newContacts->attributes = array('id' => 'new', 'assignedTo' => Yii::app()->user->getName(), 'name' => Yii::t('contacts', 'New Contacts'), 'description' => '', 'type' => 'dynamic', 'visibility' => 1, 'count' => $totalNewContacts, 'createDate' => 0, 'lastUpdated' => 0);
     $myContacts = new X2List();
     $myContacts->attributes = array('id' => 'my', 'assignedTo' => Yii::app()->user->getName(), 'name' => Yii::t('contacts', 'My Contacts'), 'description' => '', 'type' => 'dynamic', 'visibility' => 1, 'count' => $totalMyContacts, 'createDate' => 0, 'lastUpdated' => 0);
     $contactListData = $contactLists->getData();
     // $contactListData[] = $allContacts3;
     $contactListData[] = $newContacts;
     $contactListData[] = $myContacts;
     $contactListData[] = $allContacts;
     $contactLists->setData($contactListData);
     $this->render('listIndex', array('contactLists' => $contactLists));
 }