public function actionJsoncalendar_add()
 {
     if (Yii::$app->request->isAjax) {
         $request = Yii::$app->request;
         $model = new Scheduleheader();
         $profile = Yii::$app->getUserOpt->Profile_user();
         $usercreate = $profile->username;
         $end = $request->post('tgl2');
         $start = $request->post('tgl1');
         $scdl_group = $request->post('scdl_group');
         $user_id = $request->post('user_id');
         $note = $request->post('note');
         $model->TGL1 = $start;
         $model->TGL2 = $end;
         $model->CREATE_BY = $usercreate;
         $model->CREATE_AT = date("Y-m-d H:i:s");
         $model->NOTE = $note;
         $model->SCDL_GROUP = $scdl_group;
         $model->USER_ID = $user_id;
         $carisdl = ScheduleDetail::find()->where(['TGL' => $model->TGL1, 'SCDL_GROUP' => $scdl_group])->one();
         // print_r($carisdl);
         // die();
         // if exist data customers
         if ($carisdl) {
             echo 2;
         } else {
             if ($model->save()) {
                 // foreach date :author wawan
                 for ($date = strtotime($start); $date < strtotime($end); $date = strtotime("+1 day", $date)) {
                     $tgl = date("Y-m-d", $date);
                     $Customers = Customers::find()->where(['SCDL_GROUP' => $scdl_group])->asArray()->all();
                     foreach ($Customers as $key => $value) {
                         # code...
                         $connection = Yii::$app->db_esm;
                         $connection->createCommand()->batchInsert('c0002scdl_detail', ['TGL', 'CUST_ID', 'SCDL_GROUP', 'USER_ID'], [[$tgl, $value['CUST_KD'], $scdl_group, $user_id]])->execute();
                     }
                 }
             }
         }
     }
     return true;
 }
 /**
  * Creates a new Scheduleheader model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Scheduleheader();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->ID]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }