/** * 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'); } }
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' )); }
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 )); }
/** * 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, )); }