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;
 }