public function actionCreate($kdpo)
 {
     $searchModel = new RequestorderSearch();
     $dataProvider = $searchModel->caripo(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' => 'KD_PO', 'allModels' => $poDetail, 'pagination' => ['pageSize' => 20]]);
     return $this->render('create', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'poDetailProvider' => $poDetailProvider, 'poHeader' => $poHeader, 'supplier' => $supplier, 'bill' => $bill, 'ship' => $ship, 'employee' => $employee]);
 }
Пример #2
0
 /**
  * Index 
  * @author ptrnov  <*****@*****.**>
  * @since 1.1
  */
 public function actionIndex()
 {
     //Check componen generate kode RO
     //print_r(\Yii::$app->ambilkonci->getRoCode());
     //function getPermission(){
     //return Yii::$app->getUserOpt->Modul_akses(1);
     //}
     //$getPermission=Yii::$app->getUserOpt->Modul_akses(1);
     $searchModel = new RequestorderSearch();
     /*  if (isset($_GET['param'])){
     			  $dataProvider = $searchModel->searchChildRo(Yii::$app->request->queryParams,$_GET['param']);
     		}else{
     			$dataProvider = $searchModel->searchChildRo(Yii::$app->request->queryParams);
     		}  */
     //$searchModel->KD_RO ='2015.12.04.RO.0070';
     $dataProvider = $searchModel->searchRo(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 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]);
 }
Пример #4
0
 /**
  * Index
  * @author ptrnov  <*****@*****.**>
  * @since 1.1
  */
 public function actionIndex()
 {
     //Check componen generate kode RO
     //print_r(\Yii::$app->ambilkonci->getRoCode());
     //function getPermission(){
     //return Yii::$app->getUserOpt->Modul_akses(1);
     //}
     //$getPermission=Yii::$app->getUserOpt->Modul_akses(1);
     $searchModel = new RequestorderSearch();
     /*  if (isset($_GET['param'])){
     			  $dataProvider = $searchModel->searchChildRo(Yii::$app->request->queryParams,$_GET['param']);
     		}else{
     			$dataProvider = $searchModel->searchChildRo(Yii::$app->request->queryParams);
     		}  */
     //$searchModel->KD_RO ='2015.12.04.RO.0070';
     $dataProvider = $searchModel->searchRo(Yii::$app->request->queryParams);
     $dataProviderInbox = $searchModel->searchRoInbox(Yii::$app->request->queryParams);
     $dataProviderOutbox = $searchModel->searchRoOutbox(Yii::$app->request->queryParams);
     $profile = Yii::$app->getUserOpt->Profile_user();
     // data for search index RO//
     $AryCorp = ArrayHelper::map(Corp::find()->all(), 'CORP_ID', 'CORP_NM');
     $Combo_Dept = ArrayHelper::map(Dept::find()->orderBy('SORT')->asArray()->all(), 'DEP_NM', 'DEP_NM');
     // ** //
     $datachecked = Requestorder::find()->where("PARENT_ROSO = 0 AND STATUS = 101 AND STATUS <> 3 AND USER_CC='" . $profile->emp->EMP_ID . "'")->count();
     $datacreate = Requestorder::find()->where("PARENT_ROSO = 0 AND STATUS <> 3 AND STATUS = 0 AND ID_USER = '******'")->count();
     $dataapprove = Requestorder::find()->where("PARENT_ROSO = 0 AND STATUS = 102 AND  STATUS <>3 AND KD_DEP='" . $profile->emp->DEP_ID . "' OR STATUS = 5")->count();
     $dataAprrove = new ActiveDataProvider(['query' => Requestorder::find()->where("PARENT_ROSO = 0 AND STATUS = 102 AND STATUS<>3  AND KD_DEP='" . $profile->emp->DEP_ID . "'OR STATUS = 5"), 'pagination' => ['pageSize' => 5]]);
     $dataChecked = new ActiveDataProvider(['query' => Requestorder::find()->where("PARENT_ROSO = 0 AND  STATUS = 101 AND USER_CC='" . $profile->emp->EMP_ID . "'"), 'pagination' => ['pageSize' => 5]]);
     $dataCreate = new ActiveDataProvider(['query' => Requestorder::find()->where("PARENT_ROSO = 0 AND STATUS <> 3 AND STATUS = 0 AND ID_USER = '******'"), 'pagination' => ['pageSize' => 5]]);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'dataProviderInbox' => $dataProviderInbox, 'dataProviderOutbox' => $dataProviderOutbox, 'datachecked' => $datachecked, 'datacreate' => $datacreate, 'dataCreate' => $dataCreate, 'dataapprove' => $dataapprove, 'dataAprrove' => $dataAprrove, 'dataChecked' => $dataChecked, 'Combo_Dept' => $Combo_Dept, 'AryCorp' => $AryCorp]);
 }