Esempio n. 1
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'
		));
	}