/** * 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); }
/** * 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)); }
/** * 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); }
/** * 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'); } }
public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria = new CDbCriteria(); $fields = Fields::model()->findAllByAttributes(array('modelName' => 'Accounts')); foreach ($fields as $field) { $fieldName = $field->fieldName; switch ($field->type) { case 'boolean': $criteria->compare($field->fieldName, $this->compareBoolean($this->{$fieldName}), true); break; case 'link': $criteria->compare($field->fieldName, $this->compareLookup($field, $this->{$fieldName}), true); break; case 'assignment': $criteria->compare($field->fieldName, $this->compareAssignment($this->{$fieldName}), true); break; default: $criteria->compare($field->fieldName, $this->{$fieldName}, true); } } $dataProvider = new SmartDataProvider(get_class($this), array('sort' => array('defaultOrder' => 'name ASC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'criteria' => $criteria)); $arr = $dataProvider->getData(); foreach ($arr as $account) { $account->assignedTo = User::getUserLinks($account->assignedTo); $account->associatedContacts = Contacts::getContactLinks($account->associatedContacts); } $dataProvider->setData($arr); return $dataProvider; }