Пример #1
0
	}
	);
}
);");

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,
Пример #2
0
	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,
		));
	}
Пример #3
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,
		));
	}
Пример #4
0
	public function actionSearch(){
		$attributeLabels = ContactChild::attributeLabels();
		$model=new ContactChild;
		if(isset($_POST['ContactChild'])){
			$model->attributes=$_POST['ContactChild'];
			$firstName=true;
			$lastName=true;
			if($model->firstName == $attributeLabels['firstName'])
				$firstName=false;
			if($model->lastName == $attributeLabels['lastName'])
				$lastName=false;

			if($firstName && $lastName){
				$dataProvider=new CActiveDataProvider('Contacts', array(
					'criteria'=>array(
						'order'=>'lastName ASC',
						'condition'=>"firstName='$model->firstName' AND lastName='$model->lastName'"
				)));
			}else if($firstName && !$lastName){
				$dataProvider=new CActiveDataProvider('Contacts', array(
					'criteria'=>array(
						'order'=>'firstName ASC',
						'condition'=>"firstName='$model->firstName'"
				)));
			}else if(!$firstName && $lastName){
				$dataProvider=new CActiveDataProvider('Contacts', array(
					'criteria'=>array(
						'order'=>'lastName ASC',
						'condition'=>"lastName='$model->lastName'"
				)));
			}else{
				$this->redirect($this->createUrl('site/home'));
			}
			
			$this->render('viewAll',array(
				'dataProvider'=>$dataProvider,
			));
		}else{
			$this->render('search',array(
				'model'=>$model,
			));
		}
	}