/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DraftPlanGroup::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => false]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['SCDL_GROUP' => $this->SCDL_GROUP, 'TGL_START' => $this->TGL_START, 'GEO_ID' => $this->GEO_ID, 'DAY_ID' => $this->DAY_ID, 'DAY_VALUE' => $this->DAY_VALUE, 'STATUS' => $this->STATUS, 'CREATED_AT' => $this->CREATED_AT, 'UPDATED_AT' => $this->UPDATED_AT, 'GROUP_PRN' => $this->geonm, 'DAY_ID' => $this->ganjilGenap, 'DAY_VALUE' => $this->dayNm, 'USER_ID' => $this->useridNm]); $query->andFilterWhere(['like', 'SCL_NM', $this->SCL_NM])->andFilterWhere(['like', 'USER_ID', $this->USER_ID])->andFilterWhere(['like', 'CREATED_BY', $this->CREATED_BY])->andFilterWhere(['like', 'UPDATED_BY', $this->UPDATED_BY]); return $dataProvider; }
use kartik\grid\GridView; use yii\bootstrap\Modal; use crm\mastercrm\models\DraftPlan; use crm\mastercrm\models\DraftPlanGroup; use ptrnov\salesforce\Jadwal; use kartik\widgets\Spinner; $ptr_spiner1 = Spinner::widget(['id' => 'spn-gv-maintain', 'preset' => 'large', 'align' => 'center', 'color' => 'blue', 'hidden' => false]); $actionClass = 'btn btn-info btn-xs'; $actionLabel = 'Update'; $attDinamik = []; /*GRIDVIEW ARRAY FIELD HEAD*/ $headColomn = [['ID' => 0, 'ATTR' => ['FIELD' => 'SCDL_GROUP', 'SIZE' => '10px', 'label' => 'AUTO GROUP', 'align' => 'left', 'warna' => '73, 162, 182, 1', 'grp' => true]], ['ID' => 1, 'ATTR' => ['FIELD' => 'TGL', 'SIZE' => '20px', 'label' => 'DATE', 'align' => 'center', 'warna' => '73, 162, 182, 1', 'grp' => false]], ['ID' => 2, 'ATTR' => ['FIELD' => 'dayofDate', 'SIZE' => '30px', 'label' => 'DAY.NM', 'align' => 'center', 'warna' => '73, 162, 182, 1', 'grp' => false]], ['ID' => 3, 'ATTR' => ['FIELD' => 'weekofDate', 'SIZE' => '20px', 'label' => 'WEEK', 'align' => 'center', 'warna' => '73, 162, 182, 1', 'grp' => false]], ['ID' => 4, 'ATTR' => ['FIELD' => 'custlayernm', 'SIZE' => '10px', 'label' => 'LAYER', 'align' => 'center', 'warna' => '73, 162, 182, 1', 'grp' => false]], ['ID' => 5, 'ATTR' => ['FIELD' => 'CUST_ID', 'SIZE' => '50px', 'label' => 'CUST.ID', 'align' => 'center', 'warna' => '73, 162, 182, 1', 'grp' => false]], ['ID' => 6, 'ATTR' => ['FIELD' => 'custNm', 'SIZE' => '200px', 'label' => 'CUSTOMER', 'align' => 'left', 'warna' => '73, 162, 182, 1', 'group' => true]], ['ID' => 7, 'ATTR' => ['FIELD' => 'SalesNm', 'SIZE' => '20px', 'label' => 'SALES.NM', 'align' => 'left', 'warna' => '73, 162, 182, 1', 'grp' => false]], ['ID' => 8, 'ATTR' => ['FIELD' => 'UseridNm', 'SIZE' => '20px', 'label' => 'USER.ID', 'align' => 'left', 'warna' => '73, 162, 182, 1', 'grp' => false]], ['ID' => 9, 'ATTR' => ['FIELD' => 'STATUS', 'SIZE' => '20px', 'label' => 'Status', 'align' => 'left', 'warna' => '73, 162, 182, 1', 'grp' => false]]]; $gvHeadColomnBT = ArrayHelper::map($headColomn, 'ID', 'ATTR'); $attDinamik[] = ['class' => 'kartik\\grid\\SerialColumn', 'width' => '10px', 'header' => 'No.', 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '10px', 'font-family' => 'verdana, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(73, 162, 182, 1)']], 'contentOptions' => ['style' => ['text-align' => 'center', 'width' => '10px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]]; $attDinamik[] = ['class' => '\\kartik\\grid\\CheckboxColumn', 'width' => '10px', 'checkboxOptions' => function ($model, $key, $index, $column) { $check_user = DraftPlanGroup::find()->where(['SCL_NM' => $model->SCDL_GROUP_NM])->one(); if ($check_user->USER_ID == "") { return ['checked' => '', 'hidden' => true]; } elseif ($model->STATUS == 1) { return ['checked' => '', 'hidden' => true]; } }, 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '10px', 'font-family' => 'verdana, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(73, 162, 182, 1)']], 'contentOptions' => ['style' => ['text-align' => 'center', 'width' => '10px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]]; /*GRIDVIEW ARRAY ROWS*/ foreach ($gvHeadColomnBT as $key => $value[]) { if ($value[$key]['FIELD'] == 'STATUS') { $attDinamik[] = ['attribute' => $value[$key]['FIELD'], 'label' => $value[$key]['label'], 'filterType' => GridView::FILTER_SELECT2, 'filter' => $valStt, 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Pilih'], 'format' => 'raw', 'value' => function ($model) { if ($model->STATUS == 1) { return Html::a('<i class="fa fa-check"></i> Approve', '', ['class' => 'btn btn-success btn-xs', 'title' => 'Approve']); } else { if ($model->STATUS == 0) { return Html::a('<i class="fa fa-close"></i> DRAFT', '', ['class' => 'btn btn-danger btn-xs', 'title' => 'Deactive']);
public function getDraftPlanGroupTbl() { return $this->hasOne(DraftPlanGroup::className(), ['SCDL_GROUP' => 'SCDL_GROUP']); }
public function getCountuser() { $count = DraftPlanGroup::find()->where(['USER_ID' => $this->USER_ID, 'STATUS' => 1])->count(); return $count; }
public function actionApproveAll() { if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; $request = Yii::$app->request; $dataKeySelect = $request->post('keysSelect'); foreach ($dataKeySelect as $key => $value) { $model = DraftPlanDetail::find()->where(['LIKE', 'ID', $value])->one(); $scdl_group_nm = $model->SCDL_GROUP_NM; $cus_id = $model->CUST_ID; $cari_user = DraftPlanGroup::find()->where(['SCL_NM' => $scdl_group_nm])->one(); if ($cari_user->USER_ID != '') { $transaction = DraftPlanDetail::getDb()->beginTransaction(); try { self::conn_esm()->createCommand()->update('c0002scdl_plan_detail', ['STATUS' => 1], 'ID LIKE"' . $value . '" AND STATUS = 0')->execute(); self::conn_esm()->createCommand()->update('c0002scdl_plan_header', ['STATUS' => 1, 'USER_ID' => $cari_user->USER_ID], 'NOTE="' . $scdl_group_nm . '" AND STATUS = 0')->execute(); self::conn_esm()->createCommand()->update('c0002scdl_plan', ['STATUS' => 1], 'CUST_KD="' . $cus_id . '" AND STATUS = 0')->execute(); // ...other DB operations... $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); throw $e; } // self::conn_esm()->createCommand()->update('c0002scdl_plan_detail',['STATUS'=>1,'CUST_ID'=>$cus_id],'ID LIKE"'.$value.'" AND STATUS = 0')->execute(); // self::conn_esm()->createCommand()->update('c0002scdl_plan_header',['STATUS'=>1,'USER_ID'=>$cari_user->USER_ID],'NOTE="'.$scdl_group_nm.'" AND STATUS = 0')->execute(); // self::conn_esm()->createCommand()->update('c0002scdl_plan',['STATUS'=>1],'CUST_KD="'.$model->CUST_ID.'" AND STATUS = 0')->execute(); } } return true; } return $this->redirect(['index?tab=1']); }