Example #1
0
	public function run() {
		$total = ActionChild::model()->findAllByAttributes(array('assignedTo' => Yii::app()->user->getName()));
		$total = count($total);

		$temp = ActionChild::model()->findAllByAttributes(array('assignedTo' => Yii::app()->user->getName(), 'complete' => '0'));
		$unfinished = count($temp);

		$overdue = 0;
		foreach ($temp as $action) {
			//$action = ActionChild::changeDates($action);
			if ($action->dueDate == 'Overdue') {
				$overdue++;
			}
		}

		$complete = ActionChild::model()->findAllByAttributes(array('assignedTo' => Yii::app()->user->getName(), 'complete' => 'Yes'));
		$complete = count($complete);

		$this->render('actionMenu', array(
			'total' => $total,
			'unfinished' => $unfinished,
			'overdue' => $overdue,
			'complete' => $complete,
		));
	}
Example #2
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>
Example #3
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);

	}
Example #4
0
	public function actionUpload() {
		if(isset($_FILES['upload'])) {
			$model=new Media;
			$temp = CUploadedFile::getInstanceByName('upload');
			$name=$temp->getName();
			$name=str_replace(' ','_',$name);
			$check=Media::model()->findAllByAttributes(array('fileName'=>$name));
			if(count($check)!=0) {
				$count=1;
				$newName=$name;
				$arr=explode('.',$name);
				$name=$arr[0];
				while(count($check)!=0){
					$newName=$name.'('.$count.').'.$temp->getExtensionName();
					$check=Media::model()->findAllByAttributes(array('fileName'=>$newName));
					$count++;
				}
				$name=$newName;
			}
			if($temp->saveAs('uploads/'.$name)) {
				$model->associationId=$_POST['associationId'];
				$model->associationType=$_POST['type'];
				$model->uploadedBy=Yii::app()->user->getName();
				$model->createDate=time();
				$model->fileName=$name;
				if($model->save()){
					
				}
				if($model->associationType=='feed') {
					$soc = new Social;
					$soc->user = Yii::app()->user->getName();
					$soc->data = Yii::t('app','Attached file: ').
					$soc->type = 'feed';
					$soc->timestamp = time();
					$soc->lastUpdated = time();
					$soc->associationId = $model->associationId;
					$soc->data = CHtml::link($model->fileName,array('media/view','id'=>$model->id));
					if($soc->save()) {
						$this->redirect(array('profile/'.$model->associationId));
					} else {
						unlink('uploads/'.$name);
					}
					$this->redirect(array($model->associationType.'/'.$model->associationId));
					
				} else if($model->associationType=='bg' || $model->associationType=='bg-private') {

					$profile=CActiveRecord::model('ProfileChild')->findByPk(Yii::app()->user->getId());
					$profile->backgroundImg = $name;
					$profile->save();
					$this->redirect(array('profile/settings','id'=>Yii::app()->user->getId()));
				} else {
					$note=new ActionChild;
					$note->createDate = time();
					$note->dueDate = time();
					$note->completeDate = time();
					$note->complete='Yes';
					$note->visibility='1';
					$note->completedBy=Yii::app()->user->getName();
					$note->assignedTo='Anyone';
					$note->type='attachment';
					$note->associationId=$_POST['associationId'];
					$note->associationType=$_POST['type'];
					
					$association = $this->getAssociation($note->associationType,$note->associationId);
					if($association != null)
						$note->associationName = $association->name;

					$note->actionDescription = $model->fileName . ':' . $model->id;
					if($note->save()){
					} else {
						unlink('uploads/'.$name);
					}
					$this->redirect(array($model->associationType.'/'.$model->associationId));
				}
			}
		}
	}
Example #5
0
	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,
		));
	}
Example #6
0
	/**
	 * 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=ActionChild::model('ActionChild')->findByPk((int)$id);
		//$dueDate=$model->dueDate;
		//$model=ActionChild::changeDates($model);
		// if($model->associationId!=0) {
			// $model->associationName = $this->parseName(array($model->associationType,$model->associationId));
		// } else
			// $model->associationName = 'None';
		
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
Example #7
0
 * 
 * You can contact X2Engine, Inc. at P.O. Box 66752,
 * Scotts Valley, CA 95067, USA. or at email address contact@X2Engine.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * X2Engine" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by X2Engine".
 ********************************************************************************/

$attributeLabels = ActionChild::attributeLabels();

$template="<a href=".$this->createUrl('search/search?term=%23\\2')."> #\\2</a>";
		$info=$model->actionDescription;
		$info=mb_ereg_replace('(^|\s)#(\w\w+)',$template,$info);
if($model->complete=='Yes')
	$status = Yii::t('actions','FINISHED');
else {
	if($model->dueDate > time())
		$status = Yii::t('actions','INCOMPLETE');
	else
		$status = Yii::t('actions','OVERDUE');
}
if($model->type=='note' || $model->type=='attachment') {
?>
<table class="details">
Example #8
0
	public function getOwnerName() {
		$ownerModel = ActionChild::getOwnerModel($this->ownerType,$this->ownerId);
		if ($ownerModel)
			return $ownerModel->name;	// get name of owner
		else
			return false;
	}