public function actionCreate($kdpo)
 {
     $searchModel = new RequestorderSearch();
     $dataProviderRo = $searchModel->cariHeaderRO_SendPO(Yii::$app->request->queryParams);
     $searchModel = new SalesorderSearch();
     $dataProviderSo = $searchModel->cariHeaderSO_SendPO(Yii::$app->request->queryParams);
     $poHeader = Purchaseorder::find()->where(['KD_PO' => $kdpo])->one();
     $supplier = $poHeader->suplier;
     $bill = $poHeader->bill;
     $ship = $poHeader->ship;
     $employee = $poHeader->employe;
     $poDetail = Purchasedetail::find()->where(['KD_PO' => $kdpo])->andWhere('STATUS <> 3')->all();
     $poDetailProvider = new ArrayDataProvider(['key' => 'ID', 'allModels' => $poDetail, 'pagination' => ['pageSize' => 20]]);
     /*
      * Edit PO Quantity | Validation max Jumlah RO/SA
      * @author ptrnov <*****@*****.**>
      * @since 1.2
      */
     if (Yii::$app->request->post('hasEditable')) {
         $id = Yii::$app->request->post('editableKey');
         Yii::$app->response->format = Response::FORMAT_JSON;
         $model = Purchasedetail::findOne($id);
         $currentQty = $model->QTY;
         $currentKdPo = $model->KD_PO;
         $currentKdRo = $model->KD_RO;
         $currentKdBrg = $model->KD_BARANG;
         /* $iendPoQtyValidation = new SendPoQtyValidation();
         			$iendPoQtyValidation->findOne($id); */
         $out = Json::encode(['output' => '', 'message' => '']);
         $post = [];
         $posted = current($_POST['Purchasedetail']);
         $post['Purchasedetail'] = $posted;
         /* $posted = current($_POST['SendPoQtyValidation']);			
         			$post['SendPoQtyValidation'] = $posted; */
         if ($model->load($post)) {
             $output = '';
             /*
              * Split PO Plus dan PO Normal 
              * PO Plus=POA.*
              * PO Plus=POB.*
              * @author ptrnov [piter@lukison]
              * @since 1.2
              */
             $kdPo = explode('.', $currentKdPo);
             if ($kdPo[0] != 'POA') {
                 if (isset($posted['QTY'])) {
                     /*
                      * QTY RO-PO VALIDATION
                      * QTY PO tidak boleh lebih dari SQTY Request Order
                      */
                     /*Find SQTY RoDetail*/
                     $roDetail = Rodetail::find()->where(['KD_RO' => $currentKdRo, 'KD_BARANG' => $currentKdBrg])->one();
                     //if(!$roDetail){
                     $roQty = $roDetail->SQTY != 0 ? $roDetail->SQTY : 0;
                     //}else{$roQty=0;}
                     /*Sum QTY PoDetail */
                     $pqtyTaken = "SELECT SUM(QTY) as QTY FROM p0002 WHERE KD_RO='" . $roDetail->KD_RO . "' AND KD_BARANG='" . $roDetail->KD_BARANG . "' GROUP BY KD_BARANG";
                     //$pqtyTaken= 'SELECT SUM(QTY) as QTY FROM p0002 WHERE KD_RO="RO.2015.12.000001" AND KD_BARANG="BRGU.LG.03.06.E07.0001"';
                     $poDetailQtySum = Purchasedetail::findBySql($pqtyTaken)->one();
                     $poQty = $poDetailQtySum->QTY != 0 ? $poDetailQtySum->QTY : 0;
                     /* Calculate SQTY RO - QTY PO + Current QTY | minus current record QTY */
                     $ttlPQTY = $roQty - $poQty + $currentQty;
                     if ($posted['QTY'] <= $ttlPQTY) {
                         $model->save();
                         $output = Yii::$app->formatter->asDecimal($model->QTY, 0);
                     } else {
                         return ['output' => '', 'message' => 'Request Order QTY Limited, Greater than RO QTY ! please insert free Qty, Check Request Order'];
                     }
                 }
                 if (isset($posted['HARGA'])) {
                     $model->save();
                     $output = Yii::$app->formatter->asDecimal($model->HARGA, 2);
                 }
                 if (isset($posted['UNIT'])) {
                     $modelUnit = Unitbarang::find()->where('KD_UNIT="' . $posted['UNIT'] . '"')->one();
                     $model->NM_UNIT = $modelUnit->NM_UNIT;
                     $model->UNIT_QTY = $modelUnit->QTY;
                     $model->UNIT_WIGHT = $modelUnit->WEIGHT;
                     $model->save();
                     $output = $model->UNIT;
                 }
                 /*
                 					if (isset($posted['NOTE'])) {
                 					   // $output =  Yii::$app->formatter->asDecimal($model->EMP_NM, 2);
                 						$output = $model->NOTE;
                 					} */
             } elseif ($kdPo[0] != 'PO') {
                 /* PO Plus=POB.*/
                 if (isset($posted['QTY'])) {
                     $model->save();
                     $output = Yii::$app->formatter->asDecimal($model->QTY, 0);
                 }
                 if (isset($posted['HARGA'])) {
                     $model->save();
                     $output = Yii::$app->formatter->asDecimal($model->HARGA, 2);
                 }
                 if (isset($posted['UNIT'])) {
                     $model->save();
                     $output = $model->UNIT;
                 }
             }
             $out = Json::encode(['output' => $output, 'message' => '']);
         }
         // return ajax json encoded response and exit
         echo $out;
         return;
     }
     return $this->render('create', ['searchModel' => $searchModel, 'dataProviderRo' => $dataProviderRo, 'dataProviderSo' => $dataProviderSo, 'poDetailProvider' => $poDetailProvider, 'poHeader' => $poHeader, 'supplier' => $supplier, 'bill' => $bill, 'ship' => $ship, 'employee' => $employee]);
 }