Esempio n. 1
0
 public function actionRemove($instagram_id = 0)
 {
     $user = User::model()->findByPk(Yii::app()->user->id);
     $user_child_id = User::instagramIdToId($instagram_id);
     UserChild::model()->deleteAll('user_id=:user_id AND user_child_id=:user_child_id', array(':user_child_id' => $user_child_id, ':user_id' => $user->id));
     $this->redirect('/user/account');
 }
Esempio n. 2
0
	public static function convert($records) {
		$arr=array();
		$id=1;
		
		foreach ($records as $record) {
			$user=UserChild::model()->findByAttributes(array('username'=>$record->updatedBy));
			$name=$user->firstName." ".$user->lastName;
			if ($record instanceof Contacts) {
				$temp=array();
				$temp['id']=$id;
					$id++;
				$temp['name']=$record->firstName.' '.$record->lastName;
				$temp['description']=$record->backgroundInfo;
				$temp['link']='/contacts/'.$record->id;
				$temp['type']='Contact';
				$temp['lastUpdated']=$record->lastUpdated;
				$temp['updatedBy']=$name;
				$arr[]=$temp;
			} elseif ($record instanceof Actions) {
				$temp=array();
				$temp['id']=$id;
					$id++;
				$temp['name']=empty($record->type)? Yii::t('actions','Action') : Yii::t('actions','Action: ').ucfirst($record->type);
				$temp['description']=$record->actionDescription;
				$temp['link']='/actions/'.$record->id;
				$temp['type']='Action';
				$temp['lastUpdated']=$record->lastUpdated;
				$temp['updatedBy']=$name;
				$arr[]=$temp;
			} else {
				$temp=array();
				$temp['id']=$id;
					$id++;
				$temp['name']=$record->name;
				$temp['description']=$record->description;
				
				$temp['lastUpdated']=$record->lastUpdated;
				$temp['updatedBy']=$name;
				
				if($record instanceof Sales){
					$temp['link']='/sales/'.$record->id;
					$temp['type']='Sale';
				}
				elseif ($record instanceof Accounts){
					$temp['link']='/accounts/'.$record->id;
					$temp['type']='Account';
				}
				elseif($record instanceof Projects)
					$temp['link']='/projects/'.$record->id;
				elseif($record instanceof Cases)
					$temp['link']='/cases/'.$record->id;
				elseif($record instanceof Marketing)
					$temp['link']='/marketing/'.$record->id;

				$arr[]=$temp;
			}
		}
		return $arr;
	}
Esempio n. 3
0
	public function authenticate() {
		$user = UserChild::model()->findByAttributes(array('username' => $this->username));
		if ($user === null || $user->status < 1)
			$this->errorCode = self::ERROR_USERNAME_INVALID;
		else if ($user->password !== md5($this->password))
			$this->errorCode = self::ERROR_PASSWORD_INVALID;
		else {
			$this->_id = $user->id;
			//$this->setState('lastLoginTime', $user->lastLoginTime); //not yet set up
			$this->errorCode = self::ERROR_NONE;
		}
		return !$this->errorCode;
	}
Esempio n. 4
0
	public function actionIndex(){
		
		$user=UserChild::model()->findByPk(Yii::app()->user->getId());
		$topList=$user->topContacts;
		$pieces=explode(',',$topList);
		$contacts=array();
		foreach($pieces as $piece){
			$contact=ContactChild::model()->findByPk($piece); 
			if(isset($contact))
				$contacts[]=$contact;
		}
		$dataProvider=new CActiveDataProvider('Contacts');
		$dataProvider->setData($contacts);
		
		$this->render('index',array(
			'dataProvider'=>$dataProvider,
		));
	}
Esempio n. 5
0
	public function actionChangePermissions($id){
		$model=$this->loadModel($id);
		if(Yii::app()->user->getName()=='admin' || Yii::app()->user->getName()==$model->createdBy){
			$users=UserChild::getNames();
			unset($users['admin']);
			unset($users['Anyone']);
			$str=$model->editPermissions;
			$pieces=explode(", ",$str);
			$model->editPermissions=$pieces;
			
			if(isset($_POST['DocChild'])){
				$model->attributes=$_POST['DocChild'];
				$arr=$model->editPermissions;
				
				$model->editPermissions=AccountChild::parseUsers($arr);
				if($model->save()){
					$this->redirect(array('view','id'=>$id));
				}
			}
			
			$this->render('editPermissions',array(
				'model'=>$model,
				'users'=>$users,
			));
		}else{
			$this->redirect(array('view','id'=>$id));
		}
	}
Esempio n. 6
0
	public static function getEmails(){
		$userArray=UserChild::model()->findAll();
		$emails=array('Anyone'=>Yii::app()->params['adminEmail']);
		foreach($userArray as $user){
			$emails[$user->username]=$user->emailAddress;
		}
		return $emails;
	}
Esempio n. 7
0
	protected function renderContent() {
		$this->render('topContacts',array(
			'topContacts'=>UserChild::getTopContacts()
		));
	}
Esempio n. 8
0
 /**
  * save a child user of current user
  * @param  int id of child user
  * @return void
  */
 public function saveChild($id_child = 0)
 {
     $user_child = new UserChild();
     $user_child->user_id = Yii::app()->user->id;
     $user_child->user_child_id = $id_child;
     $user_child->save();
 }
Esempio n. 9
0
    public function actionGetMessages() {
        $time=time();
		$sinceMidnight=(3600*date("H"))+(60*date("i"))+date("s");
        $latest = '';
        if (isSet($_GET['latest']))
            $latest = $_GET['latest'];
        $retrys = 20;
        $content = array();
        $records = array();
        while (true) {
            $str = '';
            $chatLog = new CActiveDataProvider('Social', array(
                        'criteria' => array(
                            'order' => 'timestamp DESC',
                            'condition' => 'type="chat" AND timestamp > '. (($latest != '') ? (''.$latest) : ''.($time-$sinceMidnight))
                        ),
                        'pagination' => array(),
                    ));
            $records = $chatLog->getData();
            if (sizeof($records) > 0) {
                foreach ($records as $chat) {
                    if ($latest != '' && $chat->timestamp < $latest)
                        continue;
                    $user = UserChild::model()->findByAttributes(array('username' => $chat->user));
                    if ($user != null)
                        $content[] = array('username' => $chat->user,
                            'userid' => $user->id,
                            'message' => $chat->data,
                            'timestamp' => $chat->timestamp,
                            'when' => date('g:i:s A',$chat->timestamp));
                }
                if (sizeof($content) > 0) {
                    $str = json_encode($content);
                    echo $str;
                    break;
                }
            }
            if (--$retrys > 0) {
                sleep(1);
            } else {
                echo $str;
                break;
            }
        }
    }
Esempio n. 10
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. 11
0
	public function actionAddUser($id) {
		$users=UserChild::getNames();
		$contacts=ContactChild::getAllNames();
		$model=$this->loadModel($id);
		$users=AccountChild::editUserArray($users, $model);

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

		if(isset($_POST['Projects'])) {
			$temp=$model->assignedTo; 
			$model->attributes=$_POST['Projects'];  
			$arr=$model->assignedTo;
			$this->updateChangelog($model);

			$model->assignedTo=ProjectChild::parseUsers($arr);
			$temp.=', '.$model->assignedTo;
			$model->assignedTo=$temp;
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('addUser',array(
			'model'=>$model,
			'users'=>$users,
			'contacts'=>$contacts
		));
	}
Esempio n. 12
0
	private function renderTopContacts() {
		$this->renderPartial('application.components.views.topContacts',array(
			'topContacts'=>UserChild::getTopContacts(),
			//'viewId'=>$viewId
		));
	}
Esempio n. 13
0
	return false;
});
");

$cs=Yii::app()->getClientScript();
$cs->registerScriptFile(Yii::app()->request->baseUrl.'/assets/js/test.js');
?>

<h2><?php echo Yii::t('contacts','Manage Contacts'); ?></h2>
<?php echo Yii::t('app','You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.'); ?>
<br />
<div class="search-form" style="display:none">
<?php
$this->renderPartial('_search',array(
	'model'=>$model, 
        'users'=>UserChild::getNames(),
)); ?>
</div><!-- search-form -->
<?php 
    $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'contacts-grid',
	'baseScriptUrl'=>Yii::app()->request->baseUrl.'/themes/'.Yii::app()->theme->name.'/css/gridview',
	'template'=> '<div class="title-bar">'
		.CHtml::link(Yii::t('app','Advanced Search'),'#',array('class'=>'search-button')) . ' | '
		.CHtml::link(Yii::t('app','Clear Filters'),array('index','clearFilters'=>1))
		.'{summary}</div>{items}{pager}',
	'dataProvider'=>$model->searchAdmin(),
	'filter'=>$model,
	'columns'=>array(
		//'id',
		'firstName',
Esempio n. 14
0
	/**
	 * Updates a particular model.
	 * If update is successful, the browser will be redirected to the 'view' page.
	 * @param integer $id the ID of the model to be updated
	 */
	public function actionUpdate($id) {
		$model=$this->loadModel($id);
		$names=$this->parseType($model->type);
		$users=UserChild::getNames();

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

		if(isset($_POST['ActionChild'])) {
                        $temp=$model->attributes;
			$model->attributes=$_POST['ActionChild'];
                        

			$dueDate = strtotime($model->dueDate);
			$model->dueDate = ($dueDate===false)? '' : $dueDate; //date('Y-m-d',$dueDate).' 23:59:59';	// default to being due by 11:59 PM

			$association = $this->getAssociation($model->associationType,$model->associationId);
			
			if($association != null) {
				$model->associationName = $association->name;
			} else {
				$model->associationName = 'None';
				$model->associationId = 0;
			}
                        $changes=$this->calculateChanges($temp,$model->attributes);
			$model=$this->updateChangelog($model,$changes);
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('update',array(
			'model'=>$model,
			'names'=>$names,
			'users'=>$users,
		));
	}
Esempio n. 15
0
	public function actionAddContact($id) {
		$users=UserChild::getNames();
		$contacts=ContactChild::getAllNames();
		$model=$this->loadModel($id);

		$contacts=SaleChild::editContactArray($contacts, $model);

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

		if(isset($_POST['Sales'])) {
			$temp=$model->associatedContacts; 
                        $tempArr=$model->attributes;
			$model->attributes=$_POST['Sales'];  
			$arr=$model->associatedContacts;
			

			$model->associatedContacts=SaleChild::parseContacts($arr);
			$temp.=" ".$model->associatedContacts;
			$model->associatedContacts=$temp;
                        $changes=$this->calculateChanges($tempArr,$model->attributes);
                        $model=$this->updateChangelog($model,$changes);
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('addContact',array( 
			'model'=>$model,
			'users'=>$users,
			'contacts'=>$contacts,
			'action'=>'Add'
		));
	}
Esempio n. 16
0
 public static function convert($records, $whatsNew = true)
 {
     $arr = array();
     foreach ($records as $record) {
         $user = UserChild::model()->findByAttributes(array('username' => $record->updatedBy));
         if (isset($user)) {
             $name = $user->firstName . " " . $user->lastName;
             $userId = $user->id;
         } else {
             $name = 'web admin';
             $userId = 1;
         }
         if ($record instanceof Contacts) {
             $temp = array();
             $temp['id'] = $record->id;
             $temp['name'] = $record->firstName . ' ' . $record->lastName;
             $temp['description'] = $record->backgroundInfo;
             $temp['link'] = '/contacts/default/view/id/' . $record->id;
             $temp['type'] = 'Contact';
             $temp['lastUpdated'] = $record->lastUpdated;
             $temp['updatedBy'] = CHtml::link($name, array('profile/' . $userId));
             while (isset($arr[$temp['lastUpdated']])) {
                 $temp['lastUpdated']++;
             }
             $arr[$temp['lastUpdated']] = $temp;
         } elseif ($record instanceof Actions) {
             $temp = array();
             $temp['id'] = $record->id;
             $temp['name'] = empty($record->type) ? Yii::t('actions', 'Action') : Yii::t('actions', 'Action: ') . ucfirst($record->type);
             $temp['description'] = $record->actionDescription;
             $temp['link'] = '/actions/default/view/id/' . $record->id;
             $temp['type'] = 'Action';
             $temp['lastUpdated'] = $record->lastUpdated;
             $temp['updatedBy'] = $name;
             while (isset($arr[$temp['lastUpdated']])) {
                 $temp['lastUpdated']++;
             }
             $arr[$temp['lastUpdated']] = $temp;
         } else {
             $temp = array();
             $temp['id'] = $record->id;
             $temp['name'] = $record->name;
             if (!is_null($record->description)) {
                 $temp['description'] = $record->description;
             } else {
                 $temp['description'] = "";
             }
             $temp['lastUpdated'] = $record->lastUpdated;
             $temp['updatedBy'] = $name;
             if ($record instanceof Sales) {
                 $temp['link'] = '/sales/default/view/id/' . $record->id;
                 $temp['type'] = 'Sale';
             } elseif ($record instanceof Accounts) {
                 $temp['link'] = '/accounts/default/view/id/' . $record->id;
                 $temp['type'] = 'Account';
             } else {
                 $temp['link'] = '/' . strtolower(get_class($record)) . '/default/view/id/' . $record->id;
             }
             while (isset($arr[$temp['lastUpdated']])) {
                 $temp['lastUpdated']++;
             }
             if ($whatsNew) {
                 $arr[$temp['lastUpdated']] = $temp;
             } else {
                 $arr[] = $temp;
             }
         }
     }
     if ($whatsNew) {
         ksort($arr);
         return array_values(array_reverse($arr));
     } else {
         return array_values($arr);
     }
 }
Esempio n. 17
0
	private function globalExport() {
		
		$file='file.csv';
		$fp = fopen($file, 'w+');
		
		$users=UserChild::model()->findAll();
		$contacts=ContactChild::model()->findAll();
		$actions=ActionChild::model()->findAll();
		$sales=SaleChild::model()->findAll();
		$accounts=AccountChild::model()->findAll();
		$docs=Docs::model()->findAll();
		$profiles=Profile::model()->findAll();
		
		fputcsv($fp,array("0.9.1"));
		
		$userList=array();
		foreach($users as $user) {
			$userList[]=$user->attributes;
		}
		foreach ($userList as $fields) {
			unset($fields['id']);
			unset($fields['updatePassword']);
			$fields[]='user';
			fputcsv($fp, $fields);
			
		}
		
	
		$contactList=array();
		foreach($contacts as $contact) {
			$contactList[]=$contact->attributes;
		}
		foreach ($contactList as $fields) {
			unset($fields['id']);
			$fields[]='contact';
			fputcsv($fp, $fields);
			
		}
		
		$actionList=array();
		foreach($actions as $action) {
			$actionList[]=$action->attributes;
		}
		foreach ($actionList as $fields) {
			unset($fields['id']);
			$fields[]='action';
			fputcsv($fp, $fields);
			
		}
		
		$saleList=array();
		foreach($sales as $sale) {
			$saleList[]=$sale->attributes;
		}
		foreach ($saleList as $fields) {
			unset($fields['id']);
			$fields[]='sale';
			fputcsv($fp, $fields);
			
		}
		
		$accountList=array();
		foreach($accounts as $account) {
			$accountList[]=$account->attributes;
		}
		foreach ($accountList as $fields) {
			unset($fields['id']);
			$fields[]='account';
			fputcsv($fp, $fields);
			
		}
		
		$docList=array();
		foreach($docs as $doc) {
			$docList[]=$doc->attributes;
		}
		foreach ($docList as $fields) {
			unset($fields['id']);
			$fields[]='doc';
			fputcsv($fp, $fields);
			
		}
		
		$profileList=array();
		foreach($profiles as $profile) {
			if($profile->username!='admin')
				$profileList[]=$profile->attributes;
		}
		foreach ($profileList as $fields) {
			unset($fields['id']);
			unset($fields['avatar']);
			$fields[]='profile';
			fputcsv($fp, $fields);
			
		}


		fclose($fp);

	}
Esempio n. 18
0
	public static function editUsersInverse($arr) {
		
		$data=array();
		
		foreach($arr as $username){
			if($username!='')
				$data[]=UserChild::model()->findByAttributes(array('username'=>$username));
		}
		
		$temp=array();
		if(isset($data)){
			foreach($data as $item){
				if(isset($item))
					$temp[$item->username]=$item->firstName.' '.$item->lastName;
			}
		}
		return $temp;
	}
Esempio n. 19
0
	<!-- sidebar -->
	<?php 
if (isset($this->actionMenu)) {
    $this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('app', 'Actions'), 'id' => 'actions'));
    $this->widget('zii.widgets.CMenu', array('items' => $this->actionMenu));
    $this->endWidget();
}
if (isset($this->modelClass) && $this->modelClass == 'Actions' && $this->showActions !== null) {
    $this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('actions', 'Show Actions'), 'id' => 'actions-filter'));
    echo '<div class="form" style="border: none;">';
    echo CHtml::dropDownList('show-actions', $this->showActions, array('uncomplete' => Yii::t('actions', 'Uncomplete'), 'complete' => Yii::t('actions', 'Complete'), 'all' => Yii::t('actions', 'All')), array('id' => 'dropdown-show-actions', 'onChange' => 'toggleShowActions();'));
    echo '</div>';
    $this->endWidget();
}
if (isset($this->modelClass) && $this->modelClass == 'Calendar') {
    $user = UserChild::model()->findByPk(Yii::app()->user->getId());
    $showCalendars = json_decode($user->showCalendars, true);
    $editableCalendars = X2Calendar::getEditableCalendarNames();
    // list of calendars current user can edit
    $editableUserCalendars = X2Calendar::getEditableUserCalendarNames();
    // list of user calendars current user can edit
    if (isset($this->sharedCalendars) && $this->sharedCalendars !== null) {
        $this->beginWidget('zii.widgets.CPortlet', array('title' => Yii::t('calendar', 'Calendars'), 'id' => 'shared-calendar'));
        $showSharedCalendars = $showCalendars['sharedCalendars'];
        echo '<ul style="font-size: 0.8em; font-weight: bold; color: black;">';
        foreach ($this->sharedCalendars as $calendarId => $calendarName) {
            if (isset($editableCalendars[$calendarId])) {
                // check if current user has permission to edit calendar
                $editable = 'true';
            } else {
                $editable = 'false';
    public function actionLeadPerformance()
    {
        $dateRange = $this->getDateRange();
        $model = new Contacts('search');
        if (isset($_GET['Contacts'])) {
            $model->attributes = $_GET['Contacts'];
        }
        if (isset($_GET['Contacts']['company_id'], $_GET['Contacts']['company']) && !empty($_GET['Contacts']['company'])) {
            // check the ID, if provided
            $linkId = $_GET['Contacts']['company_id'];
            if (!empty($linkId) && CActiveRecord::model('Accounts')->countByAttributes(array('id' => $linkId))) {
                // if the link model actually exists,
                $model->company = $linkId;
            }
            // then use the ID as the field value
        }
        if (!empty($_GET['Contacts']['company']) && !ctype_digit($_GET['Contacts']['company'])) {
            // if the field is sitll text, try to find the ID based on the name
            $linkModel = CActiveRecord::model('Accounts')->findByAttributes(array('name' => $_GET['Contacts']['company']));
            if (isset($linkModel)) {
                $model->company = $linkModel->id;
            }
        }
        $attributeConditions = '';
        $attributeParams = array();
        // $attributeConditions = array();
        //$model->attributes
        foreach ($model->attributes as $key => $value) {
            if (!empty($value)) {
                $attributeConditions .= ' AND x2_contacts.' . $key . '=:' . $key;
                $attributeParams[':' . $key] = $value;
            }
        }
        $workflow = 1;
        if (isset($_GET['workflow'])) {
            if (ctype_digit($_GET['workflow'])) {
                $workflow = $_GET['workflow'];
            }
            if ($workflow != 1 && $workflow != 2) {
                // only these 2 workflows are allowed
                $workflow = 1;
            }
            $stageIds = array(1 => array('i' => 3, 'e' => 12, 's' => 16), 2 => array('i' => 3, 'e' => 7, 's' => 10));
            // SELECT COUNT(`a`.*) as `count1`, COUNT(`b`.*) as `count2`, assignedTo, stageNumber FROM `x2_actions` `a`, `x2_actions` `b` WHERE a.type="workflow" AND b.type="workflow" AND a.workflowId=1 AND b.workflowId=1 AND `a`.stageNumber=1 AND `b`.stageNumber=2 GROUP BY a.assignedTo, a.stageNumber, b.stageNumber
            $users = UserChild::getNames();
            // $groups = Groups::getNames();
            // $assignedTo = array_keys($groups) + array_keys($users);
            $assignedTo = array_keys($users);
            $data = array();
            $totals = array('id' => '', 'name' => Yii::t('dashboard', 'Total'), 'leads' => 0, 'interviewed' => 0, 'enrolled' => 0, 'started' => 0);
            for ($i = 0, $size = sizeof($assignedTo); $i < $size; $i++) {
                $data[$i]['id'] = $assignedTo[$i];
                $data[$i]['name'] = $users[$assignedTo[$i]];
                if ($data[$i]['id'] == 'Anyone') {
                    $assignmentCheck = '(x2_contacts.assignedTo IS NULL OR x2_contacts.assignedTo="" OR x2_contacts.assignedTo="Anyone")';
                    $data[$i]['id'] = '';
                } else {
                    $assignmentCheck = 'x2_contacts.assignedTo="' . $data[$i]['id'] . '"';
                }
                $data[$i]['leads'] = Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_contacts')->where('assignedTo="' . $assignedTo[$i] . '" AND createDate BETWEEN ' . $dateRange['start'] . ' AND ' . $dateRange['end'] . $attributeConditions, $attributeParams)->queryScalar();
                $totals['leads'] += $data[$i]['leads'];
                $row = Yii::app()->db->createCommand()->select('SUM(IF(x2_actions.stageNumber=' . $stageIds[$workflow]['i'] . ',1,0)) AS interviewed, 
					SUM(IF(x2_actions.stageNumber=' . $stageIds[$workflow]['e'] . ',1,0)) AS enrolled,
					SUM(IF(x2_actions.stageNumber=' . $stageIds[$workflow]['s'] . ',1,0)) AS started,
					x2_contacts.assignedTo AS assignedTo')->from('x2_contacts')->join('x2_actions', 'x2_actions.associationId=x2_contacts.id AND x2_actions.associationType="contacts"')->where('x2_actions.type="workflow" AND x2_actions.workflowId=' . $workflow . ' AND x2_actions.completeDate BETWEEN ' . $dateRange['start'] . ' AND ' . $dateRange['end'] . ' AND ' . $assignmentCheck . ' AND (SELECT COUNT(*) FROM x2_contacts WHERE x2_contacts.id=x2_actions.associationId ' . $attributeConditions . ') > 0', $attributeParams)->queryRow();
                $data[$i]['interviewed'] = isset($row['interviewed']) ? $row['interviewed'] : 0;
                $data[$i]['enrolled'] = isset($row['enrolled']) ? $row['enrolled'] : 0;
                $data[$i]['started'] = isset($row['started']) ? $row['started'] : 0;
                $totals['interviewed'] += $data[$i]['interviewed'];
                $totals['enrolled'] += $data[$i]['enrolled'];
                $totals['started'] += $data[$i]['started'];
                if (array_sum($data[$i]) == 0) {
                    unset($data[$i]);
                }
            }
            $data[] = $totals;
            // die(var_dump($data));
            // $sql = 'SELECT COUNT(*) as `count`,assignedTo, stageNumber FROM `x2_actions` WHERE type="workflow" AND workflowId=1 GROUP BY assignedTo, stageNumber';
            $dataProvider = new CArrayDataProvider($data, array('sort' => array(), 'pagination' => array('pageSize' => Yii::app()->params->profile->resultsPerPage)));
        } else {
            $dataProvider = null;
        }
        $this->render('leadPerformance', array('model' => $model, 'workflow' => $workflow, 'dataProvider' => $dataProvider, 'dateRange' => $dateRange));
    }
Esempio n. 21
0
	/**
	 * Updates a particular model.
	 * If update is successful, the browser will be redirected to the 'view' page.
	 * @param integer $id the ID of the model to be updated
	 */
	public function actionUpdate($id) {
		$name = 'Contacts';
		$model = $this->loadModel($id);
		$users=UserChild::getNames();
		$accounts=AccountChild::getNames();
		
		

		if(isset($_POST[$name])) {
                        $temp=$model->attributes;
			$model->attributes=$_POST[$name];
			$attributeLabels = ContactChild::attributeLabels();
			if($model->address == $attributeLabels['address'])
				$model->address = '';
			if($model->city == $attributeLabels['city'])
				$model->city = '';
			if($model->state == $attributeLabels['state'])
				$model->state = '';
			if($model->zipcode == $attributeLabels['zipcode'])
				$model->zipcode = '';
			if($model->country == $attributeLabels['country'])
				$model->country = '';
                        $changes=$this->calculateChanges($temp,$model->attributes);
			$model=$this->updateChangelog($model,$changes);
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('update',array(
			'model'=>$model,
			'users'=>$users,
			'accounts'=>$accounts,
		));
	}
Esempio n. 22
0
		<td class="label" width="25%"><?php echo $attributeLabels['name']; ?></td>
		<td><?php echo $model->name; ?></td>
	</tr>
	<?php if($moduleConfig['descriptionDisplay']=='1'){ ?>
	<tr>
		<td class="label">
			<?php echo $attributeLabels['description']; ?>
		</td>
		<td class="text-field"><div class="spacer"></div>
			<?php echo $this->convertUrls($model->description); ?>
		</td>
	</tr><?php } ?>
	<?php if($moduleConfig['assignedToDisplay']=='1'){ ?>
	<tr>
		<td class="label"><?php echo $attributeLabels['assignedTo']; ?></td>
		<td><?php echo ($model->assignedTo=='Anyone')? $model->assignedTo : UserChild::getUserLinks($model->assignedTo); ?></td>
	</tr><?php } ?>
	<?php if($moduleConfig['displayOne']=='1'){ ?>
	<tr>
		<td class="label"><?php echo $attributeLabels['fieldOne']; ?></td>
		<td><?php echo $model->fieldOne; ?></td>
	</tr><?php }?>
	<?php if($moduleConfig['displayTwo']=='1'){ ?>
	<tr>
		<td class="label"><?php echo $attributeLabels['fieldTwo']; ?></td>
		<td><?php echo $model->fieldTwo; ?></td>
	</tr><?php } ?>
	<?php if($moduleConfig['displayThree']=='1'){ ?>
	<tr>
		<td class="label"><?php echo $attributeLabels['fieldThree']; ?></td>
		<td><?php echo $model->fieldThree; ?></td>
Esempio n. 23
0
	protected function renderContent() {
		$recentItems = UserChild::getRecentItems(Yii::app()->user->getId());
		$this->render('recentItems',array('recentItems'=>$recentItems));
	}
Esempio n. 24
0
	public function actionLogout() {
		$user = UserChild::model()->findByPk(Yii::app()->user->getId());
		$user->lastLogin=time();
		$user->save();
		Yii::app()->user->logout();
		$this->redirect(Yii::app()->homeUrl);
	}
Esempio n. 25
0
	</div>
	<div class="description">
		<?php
		$template="<a href=".$this->createUrl('search/search?term=%23\\2')."> #\\2</a>";
			$info=$data->actionDescription;
			$info=mb_ereg_replace('(^|\s)#(\w\w+)',$template,$info);
		if($data->type=='attachment' && $data->completedBy!='Email')
			echo MediaChild::attachmentActionText($data->actionDescription,true,true);
		else
			echo $this->convertLineBreaks($info,true);	// convert LF and CRLF to <br />
		?>
	</div>
	<div class="footer">
	<?php if(empty($data->type)) {
		if ($data->complete == 'Yes') {
			echo Yii::t('actions','Completed by {name}',array('{name}'=>UserChild::getUserLinks($data->completedBy)));
		} else {
			$userLink = UserChild::getUserLinks($data->assignedTo);
			$userLink = empty($userLink)? Yii::t('actions','Anyone') : $userLink;
			echo Yii::t('actions','Assigned to {name}',array('{name}'=>$userLink));
		}
	} else if ($data->type == 'note') {
		echo UserChild::getUserLinks($data->completedBy);
		echo ' '.ActionChild::formatDate($data->completeDate);
	} else if ($data->type == 'attachment' && $data->completedBy!='Email') {
		echo Yii::t('media','Uploaded by {name}',array('{name}'=>UserChild::getUserLinks($data->completedBy)));
	}
	?>
	</div>

</div>
Esempio n. 26
0
	/**
	 * Lists all models.
	 */
	public function actionIndex() {
		$dataProvider=new CActiveDataProvider('Social',array(
			'criteria'=>array(
				'condition'=>"type='feed' AND (private!=1 OR associationId=".Yii::app()->user->getId()." OR user='******')",
				'order'=>'lastUpdated DESC'
			),
		));
		$users=UserChild::getProfiles();
		$this->render('index',array(
			'dataProvider'=>$dataProvider,
			'users'=>$users,
		));
	}
Esempio n. 27
0
	/**
	 * Updates a particular model.
	 * If update is successful, the browser will be redirected to the 'view' page.
	 * @param integer $id the ID of the model to be updated
	 */
	public function actionUpdate($model, $name) {
		$users=UserChild::getNames();
		$accounts=AccountChild::getNames();
		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST[$name])) {
			$model->attributes=$_POST[$name];
			$model=$this->updateChangelog($model);
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('update',array(
			'model'=>$model,
			'users'=>$users,
			'accounts'=>$accounts,
		));
	}
Esempio n. 28
0
	/**
	 * Updates a particular model.
	 * If update is successful, the browser will be redirected to the 'view' page.
	 * @param integer $id the ID of the model to be updated
	 */
	public function actionUpdate($id) {
		$model=$this->loadModel($id);
		$users=UserChild::getNames();
		$contacts=ContactChild::getAllNames();

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

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

			$arr=$model->associatedContacts;
			$str='';
			foreach($arr as $contact) {
				$str.=' '.$contact;
			}
			$str=substr($str,1);
			$model->associatedContacts=$str;

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

		$this->render('update',array(
			'model'=>$model,
			'users'=>$users,
			'contacts'=>$contacts,
		));
	}