public function actionCreate()
 {
     $model = new bPorder();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['bPorder'])) {
         $model->attributes = $_POST['bPorder'];
         if ($model->validate()) {
             $model->organization_id = sUser::model()->getGroup();
             //default user Group
             $model->periode_date = Yii::app()->settings->get("System", "cCurrentPeriod");
             $model->payment_state_id = 1;
             $model->po_type_id = 2;
             //PO General
             $model->save();
             //Detail...
             $model->budget_id = $_POST['budget_id'];
             $model->description = $_POST['description'];
             $model->qty = $_POST['qty'];
             $model->amount = $_POST['amount'];
             for ($i = 0; $i < sizeof($model->budget_id); ++$i) {
                 $modelDetail = new bPorderDetail();
                 $modelDetail->parent_id = $model->id;
                 $modelDetail->item_id = $model->budget_id[$i];
                 $modelDetail->description = $model->description[$i];
                 $model->qty[$i] != null ? $modelDetail->qty = $model->qty[$i] : ($modelDetail->qty = 1);
                 $model->amount[$i] != null ? $modelDetail->amount = $model->amount[$i] : ($modelDetail->amount = 0);
                 $modelDetail->save();
             }
             //Create System_ref
             $_ref = "PO-" . $model->periode_date . "-" . str_pad($model->id, 5, "0", STR_PAD_LEFT);
             $model->updateByPk((int) $model->id, array('system_ref' => $_ref));
             Yii::app()->user->setFlash("success", "<strong>Great!</strong> PO created succesfully...");
             $this->redirect(array('/bPorderGeneral'));
         }
     }
     $this->render('create', array('model' => $model));
 }