The followings are the available columns in table 'length_class':
Inheritance: extends CActiveRecord
 public function actionCreate()
 {
     $model = new LengthClass();
     $description = new LengthClassDescription();
     $this->performAjaxValidation(array($model, $description), 'length-class-form');
     if (isset($_POST[$this->modelName])) {
         $model->setAttributes($_POST[$this->modelName]);
         $description->setAttributes($_POST[$this->modelName . 'Description']);
         $suc = Yii::t('info', 'LengthClass was successfully created');
         $err = Yii::t('info', 'Could not update LengthClass');
         $description->length_class_id = 0;
         $description->locale_code = Yii::app()->getLanguage();
         if ($model->validate() && $description->validate()) {
             if ($model->save()) {
                 $description->length_class_id = $model->id;
                 $description->save();
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, $suc);
                 if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                     $this->renderPartial('_view', array('model' => $model, 'description' => $description), false, true);
                     Yii::app()->end();
                 } else {
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             } else {
                 Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, $err);
             }
         } else {
             $description->validate();
         }
     }
     if (Yii::app()->getRequest()->getIsAjaxRequest()) {
         $this->renderPartial('_form', array('model' => $model, 'description' => $description), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'description' => $description));
 }
Esempio n. 2
0
 public function actionUpdate($id)
 {
     $model = new ProductForm();
     if (isset($_POST['ProductForm'])) {
         $model->attributes = $_POST['ProductForm'];
         if ($model->validate()) {
             $model->save();
             $this->redirect(array('index'));
         }
     } else {
         $model->loadDataFromProduct($id);
     }
     $statuses = array(0 => Yii::t('common', 'Disabled'), 1 => Yii::t('common', 'Enabled'));
     $yes_no = array(0 => Yii::t('common', 'No'), 1 => Yii::t('common', 'Yes'));
     $taxClasses = TaxClass::model()->findAll();
     $taxClassesList = array();
     foreach ($taxClasses as $taxClass) {
         $taxClassesList[$taxClass->tax_class_id] = $taxClass->title;
     }
     // TODO: add language
     $stockStatuses = StockStatus::model()->findAll();
     $stockStatusesList = array();
     foreach ($stockStatuses as $stockStatus) {
         $stockStatusesList[$stockStatus->stock_status_id] = $stockStatus->name;
     }
     // TODO: add language
     $weightClasses = WeightClass::model()->findAll();
     $weightClassesList = array();
     foreach ($weightClasses as $weightClass) {
         $weightClassesList[$weightClass->weight_class_id] = $weightClass->description->title;
     }
     // TODO: add language
     $lengthClasses = LengthClass::model()->findAll();
     $lengthClassesList = array();
     foreach ($lengthClasses as $lengthClass) {
         $lengthClassesList[$lengthClass->length_class_id] = $lengthClass->description->title;
     }
     $this->render('update', array('model' => $model, 'statuses' => $statuses, 'taxClasses' => $taxClassesList, 'yes_no' => $yes_no, 'stockStatuses' => $stockStatusesList, 'weightClasses' => $weightClassesList, 'lengthClasses' => $lengthClassesList));
 }
 public function actionIndex()
 {
     $lengthClasses = LengthClass::model()->findAll();
     $this->render('index', array('lengthClasses' => $lengthClasses));
 }