Exemplo n.º 1
0
        $versions = FormVersions::model()->findAllByAttributes(array('modelName' => ucfirst($_GET['model'])));
        foreach ($versions as $version) {
            $str2 .= "<a href='?model=" . $_GET['model'] . "&version=" . CHtml::encode($version->name) . "'>" . $version->name . "</a> | ";
        }
    }
    $str2 = substr($str2, 0, -3);
    $str2 .= "</h4><br />";
    echo $str2;
}
if ($formUrl == "") {
} elseif ($model instanceof Contacts) {
    $this->renderPartial($formUrl, array('contactModel' => $model, 'users' => User::getNames(), 'editor' => true));
} elseif ($model instanceof Actions) {
    $this->renderPartial($formUrl, array('actionModel' => $model, 'users' => User::getNames(), 'editor' => true));
} else {
    $this->renderPartial($formUrl, array('model' => $model, 'users' => User::getNames(), 'contacts' => Contacts::getAllNames(), 'editor' => true));
}
$fields = Fields::model()->findAllByAttributes(array('modelName' => get_class($model)), array('order' => 'tabOrder'));
if (isset($_GET['version'])) {
    $version = $_GET['version'];
    $version = FormVersions::model()->findByAttributes(array('name' => $version));
    $sizes = json_decode($version->sizes, true);
    $positions = json_decode($version->positions, true);
    $visibilities = json_decode($version->visibility, true);
    $tempArr = array();
    foreach ($fields as $field) {
        if (isset($positions[$field->fieldName])) {
            $field->coordinates = $positions[$field->fieldName];
            $field->size = $sizes[$field->fieldName];
            $field->visible = $visibilities[$field->fieldName];
            $tempArr[] = $field;
Exemplo n.º 2
0
 public function actionAddContact($id)
 {
     $users = User::getNames();
     unset($users['admin']);
     unset($users['']);
     foreach (Groups::model()->findAll() as $group) {
         $users[$group->id] = $group->name;
     }
     $contacts = Contacts::getAllNames();
     unset($contacts['0']);
     $model = $this->loadModel($id);
     $contacts = Sales::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 = $_POST['Sales']['associatedContacts'];
         foreach ($arr as $contactId) {
             $rel = new Relationships();
             $rel->firstType = 'Contacts';
             $rel->firstId = $contactId;
             $rel->secondType = 'Sales';
             $rel->secondId = $model->id;
             $rel->save();
         }
         $model->associatedContacts = Sales::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'));
 }
Exemplo n.º 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)
 {
     $model = $this->loadModel($id);
     $users = User::getNames();
     $contacts = Contacts::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));
 }
 public function actionAddUser($id)
 {
     $users = User::getNames();
     $contacts = Contacts::getAllNames();
     $model = $this->loadModel($id);
     $users = Accounts::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));
 }
Exemplo n.º 5
0
 public function actionAddUser($id)
 {
     $users = User::getNames();
     unset($users['admin']);
     unset($users['']);
     foreach (Groups::model()->findAll() as $group) {
         $users[$group->id] = $group->name;
     }
     $contacts = Contacts::getAllNames();
     $model = $this->loadModel($id);
     $users = Accounts::editUserArray($users, $model);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Accounts'])) {
         $temp = $model->assignedTo;
         $tempArr = $model->attributes;
         $model->attributes = $_POST['Accounts'];
         $arr = $_POST['Accounts']['assignedTo'];
         $model->assignedTo = Accounts::parseUsers($arr);
         if ($temp != "") {
             $temp .= ", " . $model->assignedTo;
         } else {
             $temp = $model->assignedTo;
         }
         $model->assignedTo = $temp;
         $changes = $this->calculateChanges($tempArr, $model->attributes);
         $model = $this->updateChangelog($model, $changes);
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('addUser', array('model' => $model, 'users' => $users, 'contacts' => $contacts, 'action' => 'Add'));
 }