Пример #1
0
$actionLabel = 'Update';
$attDinamik = [];
/*GRIDVIEW ARRAY FIELD HEAD*/
$headColomnBT = [['ID' => 0, 'ATTR' => ['FIELD' => 'KD_BERITA', 'SIZE' => '10px', 'label' => 'KD_BERITA', 'align' => 'left', 'warna' => '97, 211, 96, 0.3']], ['ID' => 1, 'ATTR' => ['FIELD' => 'JUDUL', 'SIZE' => '10px', 'label' => 'SUBJECT', 'align' => 'left', 'warna' => '97, 211, 96, 0.3']], ['ID' => 2, 'ATTR' => ['FIELD' => 'KD_REF', 'SIZE' => '10px', 'label' => 'Kode Ref', 'align' => 'left', 'warna' => '97, 211, 96, 0.3']], ['ID' => 3, 'ATTR' => ['FIELD' => 'CREATED_ATCREATED_BY', 'SIZE' => '10px', 'label' => 'Tanggal', 'align' => 'left', 'warna' => '97, 211, 96, 0.3']], ['ID' => 4, 'ATTR' => ['FIELD' => 'corpnnm', 'SIZE' => '10px', 'label' => 'CORP', 'align' => 'left', 'warna' => '97, 211, 96, 0.3']], ['ID' => 5, 'ATTR' => ['FIELD' => 'deptnm', 'SIZE' => '10px', 'label' => 'DEPT', 'align' => 'left', 'warna' => '97, 211, 96, 0.3']], ['ID' => 6, 'ATTR' => ['FIELD' => 'STATUS', 'SIZE' => '10px', 'label' => 'Status Berita', 'align' => 'left', 'warna' => '97, 211, 96, 0.3']]];
$gvHeadColomnBT = ArrayHelper::map($headColomnBT, 'ID', 'ATTR');
/*GRIDVIEW ARRAY ACTION*/
$attDinamik[] = ['class' => 'kartik\\grid\\ActionColumn', 'dropdown' => true, 'template' => '{view}', 'dropdownOptions' => ['class' => 'pull-left dropup', 'style' => ['disable' => true]], 'dropdownButton' => ['class' => $actionClass], 'buttons' => ['view' => function ($url, $model, $key) {
    return '<li>' . Html::a('<span class="fa fa-eye fa-dm"></span>' . Yii::t('app', 'View'), ['/widget/berita/detail-berita', 'KD_BERITA' => $model->KD_BERITA], ['id' => 'inbox-berita-id']) . '</li>' . PHP_EOL;
}], 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '10px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(97, 211, 96, 0.3)']], 'contentOptions' => ['style' => ['text-align' => 'center', 'width' => '10px', 'height' => '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) {
            $id = Yii::$app->user->identity->EMP_ID;
            // componen
            $notif = BeritaNotify::find()->where(['KD_BERITA' => $model->KD_BERITA, 'ID_USER' => $id])->one();
            if ($notif->TYPE == 1) {
                return Html::a('<i class="fa fa-check"></i> &nbsp;Unread', '', ['class' => 'btn btn-success btn-xs', 'title' => 'Aktif']);
            } else {
                if ($notif->TYPE == 0) {
                    return Html::a('<i class="fa fa-close"></i> &nbsp;Read', '', ['class' => 'btn btn-danger btn-xs', 'title' => 'Deactive']);
                }
            }
        }, 'hAlign' => 'right', 'vAlign' => 'middle', 'noWrap' => true, 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => $value[$key]['FIELD'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt', 'background-color' => 'rgba(' . $value[$key]['warna'] . ')']], 'contentOptions' => ['style' => ['text-align' => $value[$key]['align'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt']], 'width' => '12px'];
    } else {
        if ($value[$key]['FIELD'] == 'corpnnm') {
            $attDinamik[] = ['attribute' => $value[$key]['FIELD'], 'label' => $value[$key]['label'], 'filterType' => GridView::FILTER_SELECT2, 'filter' => $selectCorp, 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'select kd corp'], 'hAlign' => 'right', 'vAlign' => 'middle', 'noWrap' => true, 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => $value[$key]['FIELD'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt', 'background-color' => 'rgba(' . $value[$key]['warna'] . ')']], 'contentOptions' => ['style' => ['text-align' => $value[$key]['align'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt']], 'width' => '12px'];
        } elseif ($value[$key]['FIELD'] == 'deptnm') {
            $attDinamik[] = ['attribute' => $value[$key]['FIELD'], 'label' => $value[$key]['label'], 'filterType' => GridView::FILTER_SELECT2, 'filter' => $selectdept, 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'select departemen'], 'hAlign' => 'right', 'vAlign' => 'middle', 'noWrap' => true, 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => $value[$key]['FIELD'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt', 'background-color' => 'rgba(' . $value[$key]['warna'] . ')']], 'contentOptions' => ['style' => ['text-align' => $value[$key]['align'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt']], 'width' => '12px'];
        } elseif ($value[$key]['FIELD'] == 'CREATED_ATCREATED_BY') {
            $attDinamik[] = ['attribute' => $value[$key]['FIELD'], 'label' => $value[$key]['label'], 'value' => function ($model) {
Пример #2
0
 /** author :wawan
  * Creates a new Commentberita model.
  * If creation is successful,update bt0001notify type equal 1 and the browser will be redirected to the 'detail-berita' page.
  * @param string $KD_BERITA
  * @return mixed
  */
 public function actionJoinComment($KD_BERITA)
 {
     $model = new Commentberita();
     /* componen user */
     $profile = Yii::$app->getUserOpt->profile_user()->emp;
     $emp_img = $profile->EMP_IMG;
     $emp_img_base64 = $profile->IMG_BASE64;
     /* foto profile */
     if ($emp_img_base64 == '') {
         $emp_img_base64 = "default.jpg";
         $foto_profile = Html::img(Yii::getAlias('@web') . '/upload/hrd/Employee/default.jpg', ['width' => '130', 'height' => '130', 'align' => 'center', 'class' => 'img-thumbnail']);
     } else {
         $emp_img_base64 = $profile->IMG_BASE64;
         $foto_profile = Html::img('data:image/jpg;base64,' . $emp_img_base64, ['width' => '130', 'height' => '130', 'align' => 'center', 'class' => 'img-thumbnail']);
     }
     /* proses save */
     if ($model->load(Yii::$app->request->post())) {
         $model->KD_BERITA = $KD_BERITA;
         $model->EMP_IMG = $emp_img_base64;
         //componen
         $model->ID_USER = Yii::$app->user->identity->EMP_ID;
         $model->CREATED_AT = date('Y-m-d H:i:s');
         $model->CREATED_BY = Yii::$app->user->identity->EMP_ID;
         if ($model->save()) {
             //   $condition = ['and',
             //   ['ID_USER'=>$profile->EMP_ID],
             //   ['KD_BERITA'=> $model->KD_BERITA],
             //   ['TYPE'=> 0],
             // ];
             // $update_image = BeritaImage::updateAll(['CREATED_AT' => $model->CREATED_AT],$condition);
             /* update read or unread  notifikasion */
             $notifupdateread = BeritaNotify::updateAll(['TYPE' => 1], ['KD_BERITA' => $model->KD_BERITA]);
         }
         return $this->redirect(['detail-berita', 'KD_BERITA' => $model->KD_BERITA]);
     } else {
         return $this->renderAjax('commentar', ['model' => $model, 'emp_img' => $emp_img, 'foto_profile' => $foto_profile, 'KD_BERITA' => $KD_BERITA]);
     }
 }