Ejemplo n.º 1
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $type = 'sales';
     $model = $this->loadModel($id);
     $model->associatedContacts = Contacts::getContactLinks($model->associatedContacts);
     parent::view($model, $type);
 }
Ejemplo n.º 2
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $model = $this->loadModel($id);
     $model->assignedTo = User::getUserLinks($model->assignedTo);
     $type = 'project';
     parent::view($model, $type);
 }
Ejemplo n.º 3
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $type = 'quotes';
     $model = $this->loadModel($id);
     $model->associatedContacts = Contacts::getContactLinks($model->associatedContacts);
     // find associated products and their quantities
     $quoteProducts = QuoteProduct::model()->findAllByAttributes(array('quoteId' => $model->id));
     $orders = array();
     // array of product-quantity pairs
     $total = 0;
     // total price for the quote
     foreach ($quoteProducts as $qp) {
         $price = $qp->price * $qp->quantity;
         if ($qp->adjustmentType == 'percent') {
             $price += $price * ($qp->adjustment / 100);
             $qp->adjustment = "{$qp->adjustment}%";
         } else {
             $price += $qp->adjustment;
         }
         $orders[] = array('name' => $qp->name, 'id' => $qp->productId, 'unit' => $qp->price, 'quantity' => $qp->quantity, 'adjustment' => $qp->adjustment, 'price' => $price);
         $order = end($orders);
         $total += $order['price'];
     }
     $dataProvider = new CArrayDataProvider($orders, array('keyField' => 'name', 'sort' => array('attributes' => array('name', 'unit', 'quantity', 'adjustment', 'price')), 'pagination' => array('pageSize' => false)));
     parent::view($model, $type, array('dataProvider' => $dataProvider, 'total' => $total));
 }
Ejemplo n.º 4
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $model = $this->loadModel($id);
     $model->assignedTo = User::getUserLinks($model->assignedTo);
     $model->associatedContacts = Contacts::getContactLinks($model->associatedContacts);
     $type = 'case';
     parent::view($model, $type);
 }
Ejemplo n.º 5
0
 public function actionView($id)
 {
     if ($id == 0) {
         $this->redirect(array('index'));
     } else {
         $model = X2Calendar::model()->findByPk($id);
         parent::view($model, 'calendar');
     }
 }
Ejemplo n.º 6
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $model = $this->loadModel($id);
     if (!$this->checkPermissions($model, 'view')) {
         $this->denied();
     }
     // add service case to user's recent item list
     User::addRecentItem('s', $id, Yii::app()->user->getId());
     parent::view($model, 'services');
 }
Ejemplo n.º 7
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $type = 'BugReports';
     $model = $this->loadModel($id);
     if ($this->checkPermissions($model, 'view')) {
         parent::view($model, $type);
     } else {
         $this->redirect('index');
     }
 }
Ejemplo n.º 8
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  * @param null|Opportunity Set by actionConvertLead in the case that conversion fails
  */
 public function actionView($id, $opportunity = null)
 {
     $type = 'x2Leads';
     $model = $this->loadModel($id);
     if ($this->checkPermissions($model, 'view')) {
         // add opportunity to user's recent item list
         User::addRecentItem('l', $id, Yii::app()->user->getId());
         parent::view($model, $type);
     } else {
         $this->redirect('index');
     }
 }
Ejemplo n.º 9
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $type = 'opportunities';
     $model = $this->loadModel($id);
     $model->associatedContacts = Contacts::getContactLinks($model->associatedContacts);
     if ($this->checkPermissions($model, 'view')) {
         // add opportunity to user's recent item list
         User::addRecentItem('o', $id, Yii::app()->user->getId());
         parent::view($model, $type);
     } else {
         $this->redirect('index');
     }
 }
Ejemplo n.º 10
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $type = 'quotes';
     $model = $this->getModel($id);
     if (!$this->checkPermissions($model, 'view')) {
         $this->denied();
     }
     $quoteProducts = $model->lineItems;
     // add quote to user's recent item list
     User::addRecentItem('q', $id, Yii::app()->user->getId());
     $contactNameId = Fields::nameAndId($model->associatedContacts);
     $contactId = $contactNameId[1];
     parent::view($model, $type, array('orders' => $quoteProducts, 'contactId' => $contactId));
 }
Ejemplo n.º 11
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $model = $this->loadModel($id);
     if (!parent::checkPermissions($model, 'view')) {
         $this->denied();
     }
     // add account to user's recent item list
     User::addRecentItem('a', $id, Yii::app()->user->getId());
     if ($model->checkForDuplicates()) {
         $this->redirect($this->createUrl('/site/duplicateCheck', array('moduleName' => 'accounts', 'modelName' => 'Accounts', 'id' => $id, 'ref' => 'view')));
     } else {
         $model->duplicateChecked();
         parent::view($model, 'accounts');
     }
 }
Ejemplo n.º 12
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $type = 'product';
     $model = $this->loadModel($id);
     parent::view($model, $type);
 }
Ejemplo n.º 13
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     // $this->layout = '//layouts/column3';
     $contact = $this->loadModel($id);
     $viewPermissions = $contact->assignedTo == Yii::app()->user->getName() || $contact->visibility == 1 || Yii::app()->user->getName() == 'admin';
     /* x2temp */
     $groups = GroupToUser::model()->findAllByAttributes(array('userId' => Yii::app()->user->getId()));
     $temp = array();
     foreach ($groups as $group) {
         $temp[] = $group->groupId;
     }
     if (array_search($contact->assignedTo, $temp) !== false) {
         $viewPermissions = true;
     }
     if ($contact->visibility == '2') {
         $user = User::model()->findByAttributes(array('username' => $contact->assignedTo));
         $groups = GroupToUser::model()->findAllByAttributes(array('userId' => $user->id));
         $tempOne = array();
         foreach ($groups as $group) {
             $tempOne[] = $group->groupId;
         }
         $userGroups = GroupToUser::model()->findAllByAttributes(array('userId' => Yii::app()->user->getId()));
         $tempTwo = array();
         foreach ($userGroups as $userGroup) {
             $tempTwo[] = $userGroup->groupId;
         }
         if (count(array_intersect($tempOne, $tempTwo)) > 0) {
             $viewPermissions = true;
         }
     }
     if (is_numeric($contact->assignedTo)) {
         $contact->assignedTo = Groups::model()->findByPk($contact->assignedTo)->name;
     }
     /* end x2temp */
     if ($viewPermissions) {
         User::addRecentItem('c', $id, Yii::app()->user->getId());
         ////add contact to user's recent item list
         parent::view($contact, 'contacts');
     } else {
         $this->redirect('index');
     }
 }
Ejemplo n.º 14
0
 /**
  * This is a prototype function designed to re-build a record from the changelog.
  *
  * This method is largely a work in progress though it is functional right
  * now as is, it could just use some refactoring and improvements. On the
  * "View Changelog" page in the Admin tab there's a link on each Contact
  * changelog entry to view the record at that point in the history. Clicking
  * that link brings you here.
  * @param int $id The ID of the Contact to be viewed
  * @param int $timestamp The timestamp to view the Contact at... this should probably be refactored to changelog ID
  */
 public function actionRevisions($id, $timestamp)
 {
     $contact = $this->loadModel($id);
     // Find all the changelog entries associated with this Contact after the given
     // timestamp. Realistically, this would be more accurate if Changelog ID
     // was used instead of the timestamp.
     $changes = X2Model::model('Changelog')->findAll('type="Contacts" AND itemId="' . $contact->id . '" AND timestamp > ' . $timestamp . ' ORDER BY timestamp DESC');
     // Loop through the changes and apply each one retroactively to the Contact record.
     foreach ($changes as $change) {
         $fieldName = $change->fieldName;
         if ($contact->hasAttribute($fieldName) && $fieldName != 'id') {
             $contact->{$fieldName} = $change->oldValue;
         }
     }
     // Set our widget info
     if (isset($this->portlets['TimeZone'])) {
         $this->portlets['TimeZone']['params']['model'] =& $contact;
     }
     if ($this->checkPermissions($contact, 'view')) {
         if (isset($_COOKIE['vcr-list'])) {
             Yii::app()->user->setState('vcr-list', $_COOKIE['vcr-list']);
         }
         User::addRecentItem('c', $id, Yii::app()->user->getId());
         ////add contact to user's recent item list
         // View the Contact with the data modified to this point
         parent::view($contact, 'contacts');
     } else {
         $this->redirect('index');
     }
 }
Ejemplo n.º 15
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $type = 'marketing';
     $model = $this->loadModel($id);
     parent::view($model, $type);
 }
Ejemplo n.º 16
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $type = 'templates';
     $model = $this->loadModel($id);
     parent::view($model, $type);
 }
Ejemplo n.º 17
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $model = $this->loadModel($id);
     $type = 'accounts';
     parent::view($model, $type);
 }