Ejemplo n.º 1
0
 /**
  * Lists all Barang models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BarangSearch();
     $dataProvider = $searchModel->searchBarangUmum(Yii::$app->request->queryParams);
     $model = new Barang();
     $querys = Barang::find()->from('dbc002.b0001 AS db1')->leftJoin('dbc002.b1001 AS db2', 'db1.KD_BARANG = db2.KD_TYPE')->where(['NM_TYPE' => 'FDSFDG'])->all();
     /*
     var_dump($querys);
     
     
     	$query= new Query;
     	$query->select('*')
     			->from('dbc002.b0001 AS db1')
     			->leftJoin('dbm000.b1001 AS db2', 'db1.KD_BARANG = db2.KD_TYPE')
     			->where(['db2.NM_TYPE' =>'FDSFDG']);
     	$command = $query->createCommand();
     	$resp = $command->queryAll();
     */
     /*
     	select *
     from dbc002.b0001 AS db1
     LEFT JOIN dbm000.b1001 AS db2
     on db1.KD_BARANG = db2.KD_TYPE
     WHERE db2.NM_TYPE = 'FDSFDG'
     
     $querys = Barang::find()->with('tbesm')->where(['tbesm.NM_TYPE' => 'FDSFDG'])->asArray()->all();
     */
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'querys' => $querys]);
 }
Ejemplo n.º 2
0
 public function actionBarangPrice()
 {
     if (Yii::$app->request->post('hasEditable')) {
         $idx = Yii::$app->request->post('editableKey');
         Yii::$app->response->format = Response::FORMAT_JSON;
         $modelPrice = Barang::findOne($idx);
         $out = Json::encode(['output' => '', 'message' => '']);
         $post = [];
         $posted = current($_POST['Barang']);
         $post['Barang'] = $posted;
         if ($modelPrice->load($post)) {
             $output = '';
             $modelPrice->save();
             /* HARGA PABRIK */
             if (isset($posted['HARGA_PABRIK'])) {
                 $output = Yii::$app->formatter->asDecimal($modelPrice->HARGA_PABRIK, 0);
             }
             /* HARGA LG */
             if (isset($posted['HARGA_LG'])) {
                 $output = Yii::$app->formatter->asDecimal($modelPrice->HARGA_LG, 2);
             }
             /* HARGA SUPPLIER */
             if (isset($posted['HARGA_DIST'])) {
                 $output = $modelPrice->HARGA_DIST;
             }
             /* HARGA SALES LG */
             if (isset($posted['HARGA_SALES'])) {
                 $output = $modelPrice->HARGA_SALES;
             }
             $out = Json::encode(['output' => $output, 'message' => '']);
         }
         // return ajax json encoded response and exit
         echo $out;
         return;
     }
     $searchModel = new BarangSearch();
     $dataProvider = $searchModel->searchBarangALG(Yii::$app->request->queryParams);
     return $this->render('price', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }