/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = CatalogElementsDiscount::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
?> <?php echo $form->textFieldRow($model, 'values', array('class' => 'span5', 'maxlength' => 10)); ?> <?php echo $form->dropDownListRow($model, "type", CatalogElementsDiscount::model()->getType(), array('class' => 'span5')); ?> <?php echo $form->dropDownListRow($model, "user_role_id", CatalogElementsDiscount::model()->getUserRole(), array('class' => 'span5')); ?> <?php echo $form->dropDownListRow($model, 'status', CatalogElementsDiscount::model()->getStatuslist(), array('class' => 'span5')); ?> <?php /* echo $form->DatePickerRow($model, 'created_at', array( 'options'=>array( 'autoclose' => true, //'showAnim'=>'fold', 'type' => 'Component', 'format'=>'yyyy-mm-dd', ), 'htmlOptions'=>array( //'value'=> strlen($model->created_at) > 0 ? Yii::app()->dateFormatter->format('yyyy-MM-dd', $model->created_at) : '', //'class'=>'span2' ), ));; */
/** * Расчитывает цену товара УЖЕ со скидками, если они предоставлены * $element_id - ID товара * $count - количество товаров заказное пользователем (нужно для получения данных о скидках) */ public function returnPrice($element_id, $count) { $return_price = CatalogElements::model()->findByPk((int) $element_id)->price; $price = $return_price; //Расчитываем цену 1единицы товара (с учетом скидок) foreach (CatalogElementsDiscount::model()->findAll('element_id = ' . (int) $element_id . ' AND status = 1') as $data_discount) { $price = $price - CatalogElementsDiscount::model()->returnDiscount($return_price, $count, $data_discount); } $return_price = $price; return $return_price; }
?> <BR>Товар: <a href="/admin/catalog/catalog/updateproduct?id=<?php echo (int) $model->element_id; ?> " target="_blank"><?php echo CatalogElements::model()->findByPk((int) $model->element_id)->name; ?> </a> <?php } ?> </legend> <?php $assetsDir = Yii::app()->basePath; $labels = CatalogElementsDiscount::model()->attributeLabels(); $this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'catalog-elements-discount-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array("id", array('header' => $labels["element_id"], 'name' => "element_id", 'type' => 'raw', 'value' => function ($data) { return !empty($data->element) ? CHtml::link($data->element->name, '/admin/catalog/catalog/updateproduct?id=' . $data->element_id) : '-'; }, 'filter' => ''), "count", "values", array('header' => $labels["type"], 'name' => "type", 'value' => 'CatalogElementsDiscount::model()->getType($data->type)'), array('header' => $labels["user_role_id"], 'name' => "user_role_id", 'value' => '$data->user_role_id==0?"Все":CatalogElementsDiscount::model()->getUserRole($data->user_role_id)'), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) { return ' <a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '"> <div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div> </a> '; }, 'filter' => ''), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update} {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap'))))); ?> <div class="buttons"> <a class="btn btn-primary" style="margin-top:14px; float:left; margin-left:15px" href="/admin/<?php echo Yii::app()->controller->module->id;