예제 #1
0
 /**
  * Saved Data Rodetail
  * @author ptrnov  <*****@*****.**>
  * @since 1.1
  */
 public function addnewitem_saved()
 {
     if ($this->validate()) {
         $barangNew = new Barang();
         $this->kD_BARANG = Yii::$app->esmcode->kdbarangUmum(0, $this->kD_CORP, $this->kD_TYPE, $this->kD_KATEGORI, $this->uNIT);
         $barangNew->KD_BARANG = $this->kD_BARANG;
         $barangNew->NM_BARANG = $this->nM_BARANG;
         $barangNew->KD_UNIT = $this->uNIT;
         $barangNew->HARGA_SPL = $this->hARGA;
         $barangNew->PARENT = 0;
         $barangNew->KD_CORP = $this->kD_CORP;
         $barangNew->KD_TYPE = $this->kD_TYPE;
         $barangNew->KD_KATEGORI = $this->kD_KATEGORI;
         $barangNew->KD_SUPPLIER = $this->kD_SUPPLIER;
         $barangNew->STATUS = 1;
         $barangNew->CREATED_BY = Yii::$app->user->identity->username;
         $barangNew->CREATED_AT = date('Y-m-d H:i:s');
         $barangNew->UPDATED_BY = Yii::$app->user->identity->username;
         if ($barangNew->validate()) {
             $barangNew->save();
             $rodetail = new Rodetail();
             $rodetail->CREATED_AT = date('Y-m-d H:i:s');
             $rodetail->KD_RO = $this->kD_RO;
             //required
             $rodetail->KD_CORP = $this->kD_CORP;
             //required
             $rodetail->PARENT_ROSO = 0;
             // RO=1 		//required
             $rodetail->KD_BARANG = $this->kD_BARANG;
             $rodetail->NM_BARANG = $this->nM_BARANG;
             $rodetail->UNIT = $this->uNIT;
             $rodetail->RQTY = $this->rQTY;
             $rodetail->SQTY = $this->rQTY;
             $rodetail->NOTE = $this->nOTE;
             $rodetail->HARGA = $this->hARGA;
             $rodetail->STATUS = 0;
             if ($rodetail->save()) {
                 // print_r($rodetail->geterrors());
                 return $rodetail;
             }
         }
     }
     return null;
 }
예제 #2
0
 public function actionSimpan()
 {
     $model = new Barang();
     $model->load(Yii::$app->request->post());
     //$kdDbtr = $model->KD_DISTRIBUTOR;
     $kdType = $model->KD_TYPE;
     $kdKategori = $model->KD_KATEGORI;
     $kdUnit = $model->KD_UNIT;
     $kdPrn = $model->PARENT;
     $kdCorp = $model->KD_CORP;
     $kd = Yii::$app->esmcode->kdbarangProdak($kdPrn, $kdCorp, $kdType, $kdKategori, $kdUnit);
     $model->KD_BARANG = $kd;
     if ($model->validate()) {
         $model->CREATED_BY = Yii::$app->user->identity->username;
         $image = $model->uploadImage();
         if ($model->save()) {
             // upload only if valid uploaded file instance found
             if ($image !== false) {
                 $path = $model->getImageFile();
                 $image->saveAs($path);
             }
         }
     }
     return $this->redirect(['index']);
 }
예제 #3
0
 public function actionSimpanfirst()
 {
     // $cons = \Yii::$app->db_esm;
     $roHeader = new Requestorder();
     //$reqorder = new Roatribute();
     $roDetail = new Rodetail();
     $BARANG = new Barang();
     $profile = Yii::$app->getUserOpt->Profile_user();
     // $corp = Yii::$app->getUserOpt->Profile_user()->EMP_ID;
     // $Corp1 = Employe::find()->where(['KD_CORP'=>$corp])->asArray()->one();
     $corp = Yii::$app->getUserOpt->Profile_user()->emp->EMP_CORP_ID;
     $hsl = \Yii::$app->request->post();
     $radio = $hsl['Rodetail']['NEW'];
     //if($roDetail->load(Yii::$app->request->post()) && $roDetail->validate()){
     if ($roDetail->load(Yii::$app->request->post())) {
         // print_r($radio);
         // die();
         $selectCorp = $corp;
         if ($radio == 2) {
             // rodetail
             $kdBarang = $roDetail->KD_BARANG;
             $nmBarang = Barang::findOne(['KD_BARANG' => $kdBarang]);
             $GneratekodeRo = \Yii::$app->ambilkonci->getRoCode($selectCorp);
             $roDetail->KD_RO = $GneratekodeRo;
             $roDetail->PARENT_ROSO = 0;
             $roDetail->KD_CORP = $selectCorp;
             $roDetail->CREATED_AT = date('Y-m-d H:i:s');
             $roDetail->NM_BARANG = $nmBarang->NM_BARANG;
             $roDetail->KD_BARANG = $kdBarang;
             $roDetail->SQTY = $roDetail->RQTY;
             $roDetail->HARGA = $nmBarang->HARGA_SPL;
             $roDetail->STATUS = 0;
             $roDetail->save();
             // getErrors()
             // print_r($roDetail->getErrors());
             // die();
             // roheader
             $roHeader->PARENT_ROSO = 0;
             // RO=0
             $roHeader->KD_RO = $GneratekodeRo;
             $roHeader->CREATED_AT = date('Y-m-d H:i:s');
             $roHeader->TGL = date('Y-m-d');
             $roHeader->ID_USER = $profile->emp->EMP_ID;
             $roHeader->EMP_NM = $profile->emp->EMP_NM . ' ' . $profile->emp->EMP_NM_BLK;
             $roHeader->KD_CORP = $selectCorp;
             $roHeader->KD_DEP = $profile->emp->DEP_ID;
             //$roHeader->SIG1_SVGBASE64 = $profile->emp->SIGSVGBASE64;
             //$roHeader->SIG1_SVGBASE30 = $profile->emp->SIGSVGBASE30;
             $roHeader->STATUS = 0;
             $roHeader->PARENT_ROSO = 0;
             // RO=0
             $roHeader->KD_RO = $GneratekodeRo;
             $roHeader->CREATED_AT = date('Y-m-d H:i:s');
             $roHeader->TGL = date('Y-m-d');
             $roHeader->ID_USER = $profile->emp->EMP_ID;
             $roHeader->EMP_NM = $profile->emp->EMP_NM . ' ' . $profile->emp->EMP_NM_BLK;
             $roHeader->KD_CORP = $selectCorp;
             $roHeader->KD_DEP = $profile->emp->DEP_ID;
             //$roHeader->SIG1_SVGBASE64 = $profile->emp->SIGSVGBASE64;
             //$roHeader->SIG1_SVGBASE30 = $profile->emp->SIGSVGBASE30;
             $roHeader->STATUS = 0;
             $roHeader->save();
         } else {
             // barang
             $kdcorp = $BARANG->KD_CORP = $roDetail->KD_CORP;
             $kdType = Yii::$app->esmcode->kdTipe();
             $kdUnit = Yii::$app->esmcode->kdUnit();
             $nw1 = Yii::$app->esmcode->kdKategori();
             $kdKategori = $BARANG->KD_KATEGORI = $nw1;
             $kdPrn = 0;
             $kdbrg = Yii::$app->esmcode->kdbarangUmum($kdPrn, $kdcorp, $kdType, $kdKategori, $kdUnit);
             $BARANG->KD_BARANG = $kdbrg;
             $BARANG->NM_BARANG = $roDetail->NM_BARANG;
             $BARANG->HARGA_SPL = $roDetail->HARGA;
             $BARANG->STATUS = 1;
             $BARANG->KD_SUPPLIER = 'SPL.LG.0000';
             $BARANG->KD_KATEGORI = 39;
             $BARANG->KD_UNIT = $roDetail->UNIT;
             $BARANG->KD_TYPE = 30;
             $BARANG->CREATED_BY = Yii::$app->user->identity->username;
             $BARANG->CREATED_AT = date('Y-m-d H:i:s');
             $BARANG->save();
             // rodetail
             $GneratekodeRo = \Yii::$app->ambilkonci->getRoCode($selectCorp);
             $roDetail->KD_RO = $GneratekodeRo;
             $roDetail->PARENT_ROSO = 0;
             $roDetail->KD_CORP = $selectCorp;
             $roDetail->CREATED_AT = date('Y-m-d H:i:s');
             $roDetail->NM_BARANG = $hsl['Rodetail']['NM_BARANG'];
             $roDetail->KD_BARANG = $kdbrg;
             // $roDetail->UNIT = 'none';
             $roDetail->SQTY = $roDetail->RQTY;
             $roDetail->STATUS = 0;
             $roDetail->save();
             //   print_r($BARANG->getErrors());
             // die();
             // roheader
             $roHeader->PARENT_ROSO = 0;
             // RO=0
             $roHeader->KD_RO = $GneratekodeRo;
             $roHeader->CREATED_AT = date('Y-m-d H:i:s');
             $roHeader->TGL = date('Y-m-d');
             $roHeader->ID_USER = $profile->emp->EMP_ID;
             $roHeader->EMP_NM = $profile->emp->EMP_NM . ' ' . $profile->emp->EMP_NM_BLK;
             $roHeader->KD_CORP = $selectCorp;
             $roHeader->KD_DEP = $profile->emp->DEP_ID;
             //$roHeader->SIG1_SVGBASE64 = $profile->emp->SIGSVGBASE64;
             //$roHeader->SIG1_SVGBASE30 = $profile->emp->SIGSVGBASE30;
             $roHeader->STATUS = 0;
             $roHeader->PARENT_ROSO = 0;
             // RO=0
             $roHeader->KD_RO = $GneratekodeRo;
             $roHeader->CREATED_AT = date('Y-m-d H:i:s');
             $roHeader->TGL = date('Y-m-d');
             $roHeader->ID_USER = $profile->emp->EMP_ID;
             $roHeader->EMP_NM = $profile->emp->EMP_NM . ' ' . $profile->emp->EMP_NM_BLK;
             $roHeader->KD_CORP = $selectCorp;
             $roHeader->KD_DEP = $profile->emp->DEP_ID;
             //$roHeader->SIG1_SVGBASE64 = $profile->emp->SIGSVGBASE64;
             //$roHeader->SIG1_SVGBASE30 = $profile->emp->SIGSVGBASE30;
             $roHeader->STATUS = 0;
             $roHeader->save();
             //   print_r($roHeader->getErrors());
             //  die();
         }
         // //$roHeader->SIG1_SVGBASE64 = $profile->emp->SIGSVGBASE64;
         // //$roHeader->SIG1_SVGBASE30 = $profile->emp->SIGSVGBASE30;
         // $roHeader->STATUS = 0;
         // 	$transaction = $cons->beginTransaction();
         // 	try {
         // 		if (!$roDetail->save()) {
         // 				$transaction->rollback();
         // 				return false;
         // 		}
         //
         // 		if (!$roHeader->save()) {
         // 				$transaction->rollback();
         // 				return false;
         // 		}
         // 		$transaction->commit();
         // 	} catch (Exception $ex) {
         // 		//print_r("error");
         // 		$transaction->rollback();
         // 		return false;
         // 	}
         //return $this->redirect(['index','param'=>$getkdro]);
         //return $this->redirect(['index?RequestorderSearch[KD_RO]='.$getkdro]);
         return $this->redirect(['/purchasing/request-order/edit?kd=' . $GneratekodeRo]);
     } else {
         return $this->redirect(['index']);
     }
 }