public function actionComponents($id)
 {
     $model = new GoodsBuild();
     $goods = Goods::model()->findByPk($id);
     //var_dump($goods);
     //break;
     $criteria = new CDbCriteria();
     $criteria->compare('goods_id', $id);
     $dataGb = new CActiveDataProvider('GoodsBuild', array('criteria' => $criteria));
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['GoodsBuild'])) {
         $model->attributes = $_POST['GoodsBuild'];
         $model->goods_id = $id;
         if ($model->save()) {
             $this->redirect(array('components', 'id' => $id));
         }
     }
     $this->render('components', array('model' => $model, 'goods' => $goods, 'dataGb' => $dataGb));
 }
 public function actionAddbuild()
 {
     if (isset($_POST['goods_id'])) {
         $components = GoodsBuild::model()->findAllByAttributes(array('goods_id' => $_POST['goods_id']));
         $type = TransactionType::model()->findByPk(1);
         $arModels = array();
         foreach ($components as $model) {
             $arModels[] = array('component_id' => $model->component_id, 'component_name' => $model->component->component_name, 'warehouse_from' => $model->warehouse->warehouse_from, 'warehouse_to' => $model->warehouse->warehouse_to, 'component_qty' => $model->component_qty, 'type' => $type->type);
         }
         echo CJSON::encode($arModels);
     }
 }
 /**
  * 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 = GoodsBuild::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }