public function addProduct()
 {
     $id = Input::get('prod_id_add');
     //dd($id);
     $product = MProduct::create(array('strProdId' => Input::get('prod_id_add'), 'strProdName' => Input::get('prod_name_add'), 'intProdStock' => Input::get('prod_stock_add'), 'strProdDesc' => Input::get('prod_desc_add'), 'strPCategory' => Input::get('prod_sercat_add'), 'strPSupp' => Input::get('prod_supp_add'), 'strPUOM' => Input::get('prod_uom_add'), 'intProdReOLvl' => Input::get('prod_reorderLevel_add'), 'status' => '1'));
     $product->save();
     return Redirect::to('/ProductDetails');
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new MStock();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['MStock'])) {
         $model->attributes = $_POST['MStock'];
         $model->created_date = time();
         $model->created_by = Yii::app()->user->id;
         if ($model->save()) {
             $model->purchase_date = strtotime($model->purchase_date);
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $products = CHtml::listData(MProduct::model()->findAll(), 'id', 'name');
     $kartons = CHtml::listData(MLitreKarton::model()->findAll(), 'id', 'name');
     $this->render('create', array('model' => $model, 'products' => $products, 'kartons' => $kartons));
 }
 /**
  * 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 = MProduct::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }