/** * Creates a new DraftPlan model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new DraftPlan(); if ($model->load(Yii::$app->request->post())) { $hsl = \Yii::$app->request->post(); $tahun = $hsl['DraftPlan']['YEAR']; $geoidf = $hsl['DraftPlan']['GEO_ID']; //print_r($geoidf); //die(); // $model->save(); $check_exist = DraftPlan::find()->where(['GEO_ID' => $geoidf, 'YEAR' => $tahun])->one(); //$check_exist = DraftPlan::find()->where(['GEO_ID'=>$geoidf,'YEAR'=>$tahun])->andWhere('STATUS<>3')->one(); /*get customers*/ //$get_customers = Customers::find()->where(['GEO'=>$geoidf])->all(); $aryCustomers = new ArrayDataProvider(['allModels' => Yii::$app->db_esm->createCommand("SELECT * FROM c0001 WHERE GEO='" . $geoidf . "' AND STATUS<>3 AND\n\t\t\t\t\t\t\t\t\tCUST_KD NOT IN (\n\t\t\t\t\t\t\t\t\t\tSELECT x1.CUST_KD FROM c0001 x1 INNER JOIN c0002scdl_plan x2 on x1.CUST_KD=x2.CUST_KD AND x2.GEO_ID=x1.GEO WHERE x1.GEO='" . $geoidf . "'\n\t\t\t\t\t\t\t\t\t\tAND x1.STATUS<>3\n\t\t\t\t\t\t\t\t\t\tGROUP BY x1.CUST_KD\n\t\t\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\t")->queryAll()]); $get_customers = $aryCustomers->allModels; // print_r($get_customers); // die(); // if(count($check_exist) != 0) // { // /*delete plan*/ // self::DeletePlan($model->GEO_ID); // /*batch insert*/ // foreach ($get_customers as $key => $value) { // # code... // $batch = self::conn_esm()->CreateCommand()->batchInsert('c0002scdl_plan', ['CUST_KD', 'GEO_ID','LAYER_ID','YEAR'], [ // [$value->CUST_KD,$value->GEO,$value->LAYER,$tahun], // ])->execute(); // } // }else{ // /*batch insert*/ // foreach ($get_customers as $key => $value) { // # code... // $batch = self::conn_esm()->CreateCommand()->batchInsert('c0002scdl_plan', ['CUST_KD', 'GEO_ID','LAYER_ID','YEAR'], [ // [$value->CUST_KD,$value->GEO,$value->LAYER,$tahun], // ])->execute(); // } // } // if(count($check_exist) == 0) // { /*batch insert*/ foreach ($get_customers as $key => $value) { # code... // $batch = self::conn_esm()->CreateCommand()->batchInsert('c0002scdl_plan', ['CUST_KD', 'GEO_ID','LAYER_ID','YEAR'], [ // [$value->CUST_KD,$value->GEO,$value->LAYER,$tahun], // ])->execute(); $batch = self::conn_esm()->CreateCommand()->batchInsert('c0002scdl_plan', ['CUST_KD', 'GEO_ID', 'LAYER_ID', 'YEAR'], [[$value['CUST_KD'], $value['GEO'], $value['LAYER'], $tahun]])->execute(); } //} //return $this->redirect(['index']); return $this->redirect(['index?tab=0']); } else { return $this->renderAjax('create', ['model' => $model, 'geo' => $this->get_arygeo()]); } }
/* @var $searchModel lukisongroup\master\models\DraftPlanSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->sideCorp = 'PT.Effembi Sukses Makmur'; /* Title Select Company pada header pasa sidemenu/menu samping kiri */ $this->sideMenu = 'esm_customers'; /* kd_menu untuk list menu pada sidemenu, get from table of database */ $this->title = Yii::t('app', 'ESM - Produk'); /* title pada header page */ $this->params['breadcrumbs'][] = $this->title; ?> <div class="draft-plan-index"> <?php $data_draft = DraftPlan::find()->all(); $dynamick = new DraftPlan(); // /*converting obejct to array*/ $data = ArrayHelper::toArray($data_draft, ['lukisongroup\\master\\models\\DraftPlan' => ['ID' => function ($dynamick) { return $dynamick->IdDinamikScdl; }, 'GEO_ID', 'LAYER_ID', 'DAY_ID', 'DAY_VALUE']]); foreach ($data as $value) { # code... // echo $value['ID']; $dua[] = Jadwal::getArrayDateCust('2016', 'C', '1', '1', '', $value['ID'], '66'); } // print_r($dynamick->IdDinamikScdl); // die(); // print_r($dua); // die(); // $dua= DraftPlan::getDateVal();
public function searchEmpty($params) { $query = DraftPlan::find()->where('STATUS=100'); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 0]]); return $dataProvider; }