public function run() { $actionParams = Yii::app()->controller->getActionParams(); $address = ''; if(Yii::app()->controller->id=='contacts' // must be a contact && Yii::app()->controller->action->id=='view' // must be viewing it && isset($actionParams['id'])) { // must have an actual ID value $currentRecord = ContactChild::model()->findByPk($actionParams['id']); if(!empty($currentRecord->city)) { if(!empty($currentRecord->address)) $address .= $currentRecord->address . ', '; $address .= $currentRecord->city . ', '; } if(!empty($currentRecord->state)) $address .= $currentRecord->state . ' '; if(!empty($currentRecord->zipcode)) $address .= $currentRecord->zipcode . ' '; if(!empty($currentRecord->country)) $address .= $currentRecord->country; } $this->render('googleMaps', array( 'address'=>$address, )); }
public function run() { $actionParams = Yii::app()->controller->getActionParams(); $twitter = null; if(Yii::app()->controller->id=='contacts' // must be a contact && Yii::app()->controller->action->id=='view' // must be viewing it && isset($actionParams['id'])) { // must have an actual ID value $currentRecord = ContactChild::model()->findByPk($actionParams['id']); if(!empty($currentRecord->twitter)) $twitter = $currentRecord->twitter; } $this->render('twitterFeed', array( 'twitter'=>$twitter, )); }
/** * Returns an array of names of database entries for a given type. * @param String $type The type of record to return * @return Array An array with id=>name of records for the type provided */ protected function parseType($type) { switch($type) { case 'contacts': return ContactChild::getAllNames(); case 'projects': return ProjectChild::getNames(); case 'accounts': return AccountChild::getNames(); case 'cases': return CaseChild::getNames(); case 'sales': return SaleChild::getNames(); default: return array('0'=>'None'); } }
} ); } );"); 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,
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); }
public function actionWhatsNew(){ if(!Yii::app()->user->isGuest){ $user=UserChild::model()->findByPk(Yii::app()->user->getId()); $lastLogin=$user->lastLogin; $contacts=ContactChild::model()->findAll("lastUpdated > $lastLogin"); $actions=ActionChild::model()->findAll("lastUpdated > $lastLogin AND (assignedTo='".Yii::app()->user->getName()."' OR assignedTo='Anyone')"); $sales=SaleChild::model()->findAll("lastUpdated > $lastLogin"); $accounts=AccountChild::model()->findAll("lastUpdated > $lastLogin"); $arr=array_merge($contacts,$actions,$sales,$accounts); //$arr=array_merge($arr,$sales); //$arr=array_merge($arr,$accounts); $records=Record::convert($arr); $dataProvider=new CArrayDataProvider($records,array( 'id'=>'id', 'pagination'=>array( 'pageSize'=>10, ), )); $this->render('whatsNew',array( 'records'=>$records, 'dataProvider'=>$dataProvider, )); } else{ $this->redirect('login'); } }
public function actionSearch(){ $term=$_GET['term']; $contacts=ContactChild::model()->findAllBySql('SELECT * FROM x2_contacts WHERE CONCAT(firstName," ",lastName) LIKE "%'.$term.'%" OR backgroundInfo LIKE "%'.$term.'%" OR email LIKE "%'.$term.'%" OR firstName LIKE "%'.$term.'%" OR lastName LIKE "%'.$term.'%" OR phone LIKE "%'.$term.'%" OR address LIKE "%'.$term.'%"'); $actions=ActionChild::model()->findAllBySql('SELECT * FROM x2_actions WHERE actionDescription LIKE "%'.$term.'%" LIMIT 10000'); $sales=SaleChild::model()->findAllBySql('SELECT * FROM x2_sales WHERE name LIKE "%'.$term.'%" OR description LIKE "%'.$term.'%"'); $accounts=AccountChild::model()->findAllBySql('SELECT * FROM x2_accounts WHERE name LIKE "%'.$term.'%" OR description LIKE "%'.$term.'%" OR tickerSymbol LIKE "%'.$term.'%"'); $projects=ProjectChild::model()->findAll(); $cases=CaseChild::model()->findAll(); $marketing=MarketingChild::model()->findAll(); $names=array(); $descriptions=array(); $notes=array(); $records=array(); $regEx="/$term/i"; foreach($contacts as $contact){ if(preg_match($regEx,$contact->firstName." ".$contact->lastName)>0){ $names[]=$contact; }elseif(preg_match($regEx,$contact->firstName)>0 || preg_match($regEx,$contact->lastName)>0){ $notes[]=$contact; }elseif(preg_match($regEx,$contact->backgroundInfo)>0){ $descriptions[]=$contact; }elseif(preg_match($regEx,$contact->email)>0){ $names[]=$contact; }elseif(preg_match($regEx,$contact->phone)>0){ $names[]=$contact; }elseif(preg_match($regEx,$contact->address)>0){ $names[]=$contact; } } foreach($actions as $action){ if(preg_match($regEx,$action->actionDescription)>0){ $names[]=$action; } } foreach($sales as $sale){ if(preg_match($regEx,$sale->name)>0){ $names[]=$sale; }elseif(preg_match($regEx,$sale->description)>0){ $descriptions[]=$sale; } } foreach($accounts as $account){ if(preg_match($regEx,$account->name)>0){ $names[]=$account; }elseif(preg_match($regEx,$account->tickerSymbol)>0){ $names[]=$account; }elseif(preg_match($regEx,$account->description)>0){ $descriptions[]=$account; }elseif(preg_match($regEx,$account->website)>0){ $names[]=$account; } } foreach($projects as $project){ if(preg_match($regEx,$project->name)>0){ $names[]=$project; }elseif(preg_match($regEx,$project->description)>0){ $descriptions[]=$project; } } foreach($cases as $case){ if(preg_match($regEx,$case->name)>0){ $names[]=$case; }elseif(preg_match($regEx,$case->description)>0){ $descriptions[]=$case; } } foreach($marketing as $item){ if(preg_match($regEx,$item->name)>0){ $names[]=$item; }elseif(preg_match($regEx,$item->description)>0){ $descriptions[]=$item; } } $records=array_merge($names,$descriptions); $records=array_merge($records,$notes); asort($records); $records=Record::convert($records); $dataProvider=new CArrayDataProvider($records,array( 'id'=>'id', 'pagination'=>array( 'pageSize'=>10, ), )); $this->render('search',array( 'records'=>$records, 'dataProvider'=>$dataProvider, 'term'=>$term, )); }
/** * 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 = ContactChild::model()->findByPk((int) $id); if ($model === null) throw new CHttpException(404, 'The requested page does not exist.'); return $model; }
public static function getMailingList($criteria) { $mailingList=array(); $arr=ContactChild::model()->findAll(); foreach($arr as $contact){ $i=preg_match("/$criteria/i",$contact->backgroundInfo); if($i>=1){ $mailingList[]=$contact->email; } } return $mailingList; }
public static function editContactsInverse($arr) { $data=array(); foreach($arr as $id){ if($id!='') $data[]=ContactChild::model()->findByPk($id); } $temp=array(); foreach($data as $item){ $temp[$item->id]=$item->firstName.' '.$item->lastName; } return $temp; }
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; }
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 )); }
public function actionQuickCreate() { $users = UserChild::getNames(); $actionModel=new ActionChild; $contactModel=new ContactChild; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($actionModel); if(isset($_POST['ActionChild']) && isset($_POST['ContactChild'])) { $actionModel->attributes=$_POST['ActionChild']; $actionModel=$this->updateChangelog($actionModel,'Create'); $contactModel->attributes=$_POST['ContactChild']; $contactModel=$this->updateChangelog($contactModel,'Create'); $actionModel->createDate=time(); $contactModel->createDate=time(); $actionModel->visibility = $contactModel->visibility; $actionModel->assignedTo = $contactModel->assignedTo; $actionModel->priority = $contactModel->priority; // reset to blank if it's the default value $attributeLabels = ContactChild::attributeLabels(); if($contactModel->address == $attributeLabels['address']) $contactModel->address = ''; if($contactModel->city == $attributeLabels['city']) $contactModel->city = ''; if($contactModel->state == $attributeLabels['state']) $contactModel->state = ''; if($contactModel->zipcode == $attributeLabels['zipcode']) $contactModel->zipcode = ''; if($contactModel->country == $attributeLabels['country']) $contactModel->country = ''; $dueDate = strtotime($actionModel->dueDate); $actionModel->dueDate = ($dueDate===false)? '' : $dueDate; //date('Y-m-d',$dueDate).' 23:59:59'; // default to being due by 11:59 PM if($_POST['submit']=='comment') { // if user clicked "New Comment" rather than "New Action" $actionModel->createDate = time(); $actionModel->dueDate = time(); $actionModel->completeDate = time(); $actionModel->complete='Yes'; $actionModel->visibility='1'; $actionModel->assignedTo=Yii::app()->user->getName(); $actionModel->completedBy=Yii::app()->user->getName(); $actionModel->type='note'; } if($contactModel->save()) { // $actionModel->dueDate=$actionModel->dueDate; $actionModel->associationId = $contactModel->id; $actionModel->associationType = 'contacts'; $actionModel->associationName = $contactModel->firstName.' '.$contactModel->lastName; if($actionModel->save()) $this->redirect(array('contacts/view','id'=>$contactModel->id)); else $contactModel->delete(); } } $this->render('quickCreate',array( 'actionModel'=>$actionModel, 'contactModel'=>$contactModel, 'users'=>$users, )); }
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' )); }
/** * 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, )); }
$contactIdList = array(); foreach($topContacts as $contact) { $contactIdList[] = $contact->id; echo '<li id="contact' . $contact->id . '">'; $link = '<strong>'.$contact->firstName.' '.$contact->lastName.'</strong><br />'.$contact->phone; echo CHtml::link($link,array('contacts/view','id'=>$contact->id)); echo CHtml::link('[x]','#',array( 'class'=>'delete-link', 'onclick'=>"removeTopContact('".$contact->id."'); return false;" //."','".$viewId."'); return false;" )); echo "</li>\n"; } if(Yii::app()->controller->id=='contacts' // must be a contact && Yii::app()->controller->action->id=='view' // must be viewing it && $viewId != null // must have an actual ID value && !in_array($viewId,$contactIdList)) { // must not already be in Top Contacts $currentRecord = ContactChild::model()->findByPk($viewId); echo '<li>'; echo CHtml::link( Yii::t('app','Add {name}',array('{name}'=>$currentRecord->firstName.' '.$currentRecord->lastName)), '#', array('onclick'=>"addTopContact('".$viewId."'); return false;") //"','".$viewId."'); return false;") ); echo "</li>\n";; } ?> </ul>