예제 #1
0
	public static function getNames(){
		$arr=AccountChild::model()->findAll();
		$names=array('0'=>'None');
		foreach($arr as $account){
			$names[$account->id]=$account->name;
		}
		return $names;
	}
예제 #2
0
파일: x2base.php 프로젝트: ruchida/X2Engine
	/**
	 * 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,
		));
	}
예제 #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);

	}
예제 #4
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));
		}
	}
예제 #5
0
	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');
		}
	}
예제 #6
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,
		));
	}
예제 #7
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,
		));
	}
예제 #8
0
	public function actionRemoveUser($id) {
		$model=$this->loadModel($id);
		$pieces=explode(', ',$model->assignedTo);
		$pieces=AccountChild::editUsersInverse($pieces);

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

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

			foreach($arr as $id=>$user) {
				unset($pieces[$user]);
			}
			
			$temp=AccountChild::parseUsersTwo($pieces);

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

		$this->render('addUser',array(
			'model'=>$model,
			'users'=>$pieces,
		));
	}
예제 #9
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 = AccountChild::attributeLabels();

Yii::app()->clientScript->registerScript('detailVewFields', "
function toggleField(field){
	$('#'+field.id+' .detail-field').hide();
	$('#'+field.id+' .detail-form').show();
	highlightSave();
}
function highlightSave() {
	$('#save-changes').css('background','yellow');
}
",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScript('stopEdit','
	$(document).ready(function(){
		$("td#description a").click(function(e){
			e.stopPropagation();
예제 #10
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=AccountChild::model()->findByPk((int)$id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}