/**
  * 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);
     $price_tiers = PriceTier::model()->getProfitPriceTierUpdate($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ProfitMargin'])) {
         $model->attributes = $_POST['ProfitMargin'];
         $model->modified_by = Yii::app()->session['employeeid'];
         if ($model->validate()) {
             $transaction = Yii::app()->db->beginTransaction();
             try {
                 if ($model->save()) {
                     ProfitPriceTier::model()->saveProfitPriceTier($model->id, $price_tiers);
                     $transaction->commit();
                     Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, 'Profit Margin : <strong>' . $model->name . '</strong> have been saved successfully!');
                     $this->redirect(array('admin'));
                 }
             } catch (Exception $e) {
                 $transaction->rollback();
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_WARNING, 'Oop something wrong : <strong>' . $e);
             }
         }
     }
     $this->render('update', array('model' => $model, 'price_tiers' => $price_tiers));
 }
$this->widget('zii.widgets.jui.CJuiAutoComplete', array('model' => $model, 'attribute' => 'client_id', 'source' => $this->createUrl('request/suggestClient'), 'htmlOptions' => array('size' => '30'), 'options' => array('showAnim' => 'fold', 'minLength' => '1', 'delay' => 10, 'autoFocus' => false, 'select' => 'js:function(event, ui) {
                            event.preventDefault();
                            $("#SaleItem_client_id").val(ui.item.id);
                            $("#client_form").ajaxSubmit({target: "#register_container", beforeSubmit: salesBeforeSubmit});
                        }')));
?>

          <?php 
echo TbHtml::linkButton(Yii::t('app', 'New'), array('color' => TbHtml::BUTTON_COLOR_INFO, 'size' => TbHtml::BUTTON_SIZE_SMALL, 'icon' => 'glyphicon-plus white', 'url' => $this->createUrl('Client/Create/', array('sale_mode' => 'Y'))));
?>
 
        </p>
       
        <?php 
if (PriceTier::model()->checkExists() != 0) {
    ?>
            <p>
                <?php 
    echo $form->dropDownListControlGroup($model, 'tier_id', PriceTier::model()->getPriceTier(), array('id' => 'price_tier_id', 'options' => array(Yii::app()->shoppingCart->getPriceTier() => array('selected' => true)), 'class' => 'col-xs-10 col-sm-8', 'empty' => 'None', 'labelOptions' => array('label' => Yii::t('app', 'Item Tier'))));
    ?>

            </p>
        <?php 
}
?>
      
<?php 
$this->endWidget();
?>

 public function actionf5pricetier()
 {
     $model = new Item();
     $price_tiers = PriceTier::model()->getListProfitPriceTier($_POST['profit_margin_id'], $_POST['cost_price']);
     $data['model'] = $model;
     $data['price_tiers'] = $price_tiers;
     if (Yii::app()->request->isAjaxRequest) {
         //Yii::app()->clientScript->scriptMap['*.js'] = false;
         $cs = Yii::app()->clientScript;
         $cs->scriptMap = array('jquery.js' => false, 'bootstrap.js' => false, 'jquery.min.js' => false, 'bootstrap.notify.js' => false, 'bootstrap.bootbox.min.js' => false, 'bootstrap.min.js' => false, 'jquery-ui.min.js' => false);
         Yii::app()->clientScript->scriptMap['*.js'] = false;
         Yii::app()->clientScript->scriptMap['jquery-ui.css'] = false;
         Yii::app()->clientScript->scriptMap['box.css'] = false;
         $this->renderPartial('_price_tier_ajax', $data, false, true);
     }
 }
 public function checkExists()
 {
     return PriceTier::model()->count('status=:active_status', array(':active_status' => Yii::app()->params['active_status']));
 }
 /**
  * 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 $id the ID of the model to be loaded
  * @return PriceTier the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = PriceTier::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
        <p class="help-block"><?php 
echo Yii::t('app', 'Fields with');
?>
 <span
                class="required">*</span> <?php 
echo Yii::t('app', 'are required');
?>
</p>

        <?php 
//echo $form->errorSummary($model);
?>

        <?php 
echo $form->dropDownListControlGroup($model, 'price_tier_id', PriceTier::model()->getPriceTier(), array('class' => 'span3', 'empty' => Yii::t('app', 'Select Default Price Tier')));
?>

        <?php 
echo $form->dropDownListControlGroup($model, 'employee_id', Employee::model()->getEmployee(), array('class' => 'span3', 'empty' => Yii::t('app', 'Select Employee Reference'), 'ajax' => array('type' => 'POST', 'dataType' => 'json', 'url' => Yii::app()->createUrl('client/copyClientInfo'), 'success' => "function(data) {\n                            if ( data.status === 'success' ) {\n                                \$('#Client_mobile_no').val(data.mobile_no);\n                                \$('#Client_first_name').val(data.first_name);\n                                \$('#Client_last_name').val(data.last_name);\n                                \$('#Client_address1').val(data.address1);\n                                \$('#Client_address2').val(data.address2);\n                                \$('#Client_notes').val(data.notes);\n                            }\n                        }")));
?>

        <?php 
echo $form->textFieldControlGroup($model, 'mobile_no', array('class' => 'span3', 'maxlength' => 15));
?>

        <?php 
echo $form->textFieldControlGroup($model, 'first_name', array('class' => 'span3', 'maxlength' => 60));
?>

        <?php