Example #1
0
 public static function synchronize($lka)
 {
     $form = Form::where('no_lka', '=', $lka);
     $count = $form->count();
     if ($count > 1) {
         // looping pada tiap data..
         $fm = $form->orderBy('tanggal', 'asc')->get();
         $c = 1;
         foreach ($fm as $ofm) {
             // cek nilai multiple total dan ubah nilai multiple total
             // sesuai dengan jumlah mutilple total
             $upFm = Form::find($ofm->id);
             if ($ofm->multiple_total != $count) {
                 $upFm->multiple_total = $count;
             }
             // ubah nilai multiple sequence
             $upFm->multiple_sequence = $c;
             $c++;
             $upFm->mode = "multiple";
             // ubah data
             $upFm->save();
         }
     } else {
         if ($count == 1) {
             $fm = $form->first();
             $fm->mode = "multiple";
             $fm->multiple_total = 1;
             $fm->multiple_sequence = 1;
             $fm->update();
         }
     }
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Form::find();
     // Important: join the query with our author relation (Ref: User model)
     $query->joinWith(['author']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['GridView.pagination.pageSize']], 'sort' => ['defaultOrder' => ['updated_at' => SORT_DESC]]]);
     // Search forms by User username
     $dataProvider->sort->attributes['author'] = ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC]];
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'schedule' => $this->schedule, 'total_limit' => $this->total_limit, 'ip_limit' => $this->ip_limit, 'save' => $this->save, 'resume' => $this->resume, 'autocomplete' => $this->autocomplete, 'analytics' => $this->analytics, 'honeypot' => $this->honeypot, 'recaptcha' => $this->recaptcha, 'message' => $this->message, 'created_by' => $this->created_at, 'updated_by' => $this->updated_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'language', $this->language])->andFilterWhere(['like', 'message', $this->message])->andFilterWhere(['like', 'user.username', $this->author]);
     // If Not Admin
     if (!empty(Yii::$app->user) && !Yii::$app->user->can("admin")) {
         // Add user filter to query
         $formIds = Yii::$app->user->getAssignedFormIds();
         $formIds = count($formIds) > 0 ? $formIds : 0;
         // Important restriction
         $query->andFilterWhere(['{{%form}}.id' => $formIds]);
     }
     return $dataProvider;
 }
 public static function formDelete($user_from_id, $user_to_id, $form_id)
 {
     $form = Form::find($form_id);
     $action_status = 'delete';
     $title = "Form " . strtoupper($form->nama);
     NotifikasiHelper::formNotifNew($title, $action_status, $user_from_id, $user_to_id, $form_id);
 }
Example #4
0
 public static function delete($id)
 {
     $form = Form::find($id);
     if (!is_null($form->first())) {
         return $form->delete();
     } else {
         return false;
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Form::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['f_id' => $this->f_id, 'f_p_id' => $this->f_p_id]);
     $query->andFilterWhere(['like', 'f_klasse', $this->f_klasse])->andFilterWhere(['like', 'reihenfolge', $this->reihenfolge])->andFilterWhere(['like', 'history', $this->history]);
     return $dataProvider;
 }
 public function add()
 {
     $f = Input::get('form');
     $form = Form::find($f['id']);
     $pen = Input::get('pendamping');
     $anak = Anak::find(Input::get('anak')['id']);
     $pendamping = PendampinganDAO::saveOrUpdate($pen, $anak);
     //
     Session::flash('message', "Data Pendampingan with {$pendamping->id} has been added!");
     return Redirect::to('/dash/formka6/pendampingan/view/' . $anak->id);
 }
 public static function formDelete($form_id)
 {
     $user_from_id = Auth::user()->id;
     $form = Form::find($form_id);
     $fa = $form->anak->first();
     $anak = Anak::find($fa->id);
     $formLKA = $anak->form->first();
     $user = $formLKA->user->first();
     $uf_id = $user_from_id;
     $ut_id = $user->id;
     NotifikasiFormHelper::formDelete($uf_id, $ut_id, $form_id);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Form::find();
     $pageSize = Yii::$app->session->get('pageSize', 50);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['f_id' => $this->f_id, 'f_p_id' => $this->f_p_id]);
     $query->andFilterWhere(['like', 'f_klasse', $this->f_klasse])->andFilterWhere(['like', 'reihenfolge', $this->reihenfolge])->andFilterWhere(['like', 'history', $this->history]);
     return $dataProvider;
 }
Example #9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Form::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'school', $this->school])->andFilterWhere(['like', 'class', $this->class])->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
Example #10
0
 public static function disposisiNotifNew($title, $user_from_id, $user_to_id, $form_id)
 {
     $user_from = User::find($user_from_id);
     $user_to = User::find($user_to_id);
     $form = Form::find($form_id);
     $user_from_level = ucfirst($user_from->level);
     $user_from_name = $user_from->name;
     $form_nama = strtoupper($form->nama);
     $status = 'new';
     $action_status = 'disposisi';
     $desc = "<b>" . $user_from_level . "</b> dengan Nama <b>" . $user_from_name . "</b>" . "<br/>memberikan <b>disposisi</b> kepada anda melalui Form <b>" . $form_nama . "</b>" . " dengan Nomer LKA " . $form->no_lka;
     $action_from = $user_from->id;
     $action_from_json = json_encode($user_from->get());
     $action_to = $user_to->id;
     $action_to_json = json_encode($user_to);
     $form_id = $form->id;
     $form_nama = $form->nama;
     $form_json = json_encode($form);
     $notif = ['status' => $status, 'title' => $title, 'desc' => $desc, 'action_status' => $action_status, 'action_from' => $action_from, 'action_from_json' => $action_from_json, 'action_to' => $action_to, 'action_to_json' => $action_to_json, 'form_id' => $form_id, 'form_nama' => $form_nama, 'form_json' => $form_json];
     NotifikasiDAO::saveOrUpdate($notif);
 }
 public static function getDisposisiKA5($form_id)
 {
     $form = Form::find($form_id);
     //ambil form id
     $fa = $form->anak->first();
     //ambil data anak dari form ini
     $anak = Anak::find($fa->id);
     //ambil data anak berdasarkan id anak pada form ka4
     $formAll = $anak->form;
     //ambil data banyak form dari anak
     $formDis = null;
     foreach ($formAll as $fm) {
         if ($fm->nama == "ka5") {
             //jika form sama dengan form ka3 maka
             $formDis = $fm;
             //simpan data from ka3 ke $formDis
         }
     }
     //ambil data disposisi
     $disposisi = json_decode($formDis->disposisi->first()->kepada);
     return $disposisi;
 }
 /**
  * Updates an existing Account model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->getSession()->setFlash('success', Yii::t('google_analytics', 'The form tracking has been successfully updated.'));
         return $this->redirect(['index']);
     } else {
         // Select id & name of all themes in the system
         $forms = Form::find()->select(['id', 'name'])->orderBy('updated_at DESC')->asArray()->all();
         $forms = ArrayHelper::map($forms, 'id', 'name');
         return $this->render('update', ['model' => $model, 'forms' => $forms]);
     }
 }
 /**
  * Updates an existing Theme model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $themeModel = $this->findModel($id);
     $forms = Form::find()->select(['id', 'name'])->asArray()->all();
     if ($themeModel->load(Yii::$app->request->post()) && $themeModel->save()) {
         Yii::$app->getSession()->setFlash('success', Yii::t('app', 'The theme has been successfully updated.'));
         return $this->redirect(['view', 'id' => $themeModel->id]);
     } else {
         return $this->render('update', ['themeModel' => $themeModel, 'forms' => $forms]);
     }
 }
Example #14
0
 public function delete($id)
 {
     //notifikasi
     NotifikasiFormLKAHelper::deleteNotif($id);
     $fm = Form::find($id);
     $anak = $fm->anak->first();
     $forms = $anak->form;
     //delete semua form yang berkaitan
     foreach ($forms as $form) {
         FormDAO::delete($form->id);
     }
     $pendampingan = $anak->pendampingan;
     if ($pendampingan) {
         foreach ($pendampingan as $pen) {
             PendampinganDAO::delete($pen->id);
         }
     }
     $files = $anak->files;
     if ($files) {
         foreach ($files as $fl) {
             FilesDAO::delete($fl->id);
         }
     }
     $pelapor = $anak->pelapor->first();
     if ($pelapor) {
         $pelapor->delete();
     }
     $keluarga = $anak->keluarga;
     if ($keluarga) {
         $keluarga->delete();
     }
     $fisik = $anak->gambaran_fisik;
     if ($fisik) {
         $fisik->delete();
     }
     $identifikasi = $anak->identifikasi_masalah;
     if ($identifikasi) {
         $identifikasi->delete();
     }
     $psiko = $anak->kondisi_psikososial;
     if ($psiko) {
         $psiko->delete();
     }
     $contact = $anak->contact_person;
     if ($contact) {
         $contact->delete();
     }
     $jenis = $anak->jenis_kasus;
     if ($jenis) {
         foreach ($jenis as $jn) {
             if ($jn->other == "T") {
                 JenisKasusDAO::delete($jn->id);
             }
         }
     }
     //delete data anak
     AnakDAO::delete($anak->id);
     if ($fm) {
         Session::flash('message', "Form with {$id} has been deleted!");
     } else {
         Session::flash('message', "Error, Form with {$id} not found!");
     }
     return Redirect::to('/dash/formka1');
 }
Example #15
0
 public function updateView($id)
 {
     $anak = Anak::find($id);
     $data = ['page_title' => 'Anak', 'panel_title' => 'Form Edit', 'form_url' => '/dash/anak/update', 'form_status' => 'edit', 'location_anak' => LocationHelper::location($anak->desa->id), 'agama_lists' => Agama::lists('nama', 'nama'), 'record' => Form::find($id)];
     return View::make('anak.form', $data);
 }
Example #16
0
<?php

/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
AppAsset::register($this);
$newFormsCount = \app\models\Form::find()->where(['status' => 'new'])->count();
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
    <meta charset="<?php 
echo Yii::$app->charset;
?>
">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php 
echo Html::csrfMetaTags();
?>
    <title><?php 
echo $this->title;
?>
 - <?php 
 public function delete($id, $enc_lka)
 {
     //notifikasi
     NotifikasiFormLKAHelper::deleteNotif($id);
     $fm = Form::find($id);
     $anak = $fm->anak->first();
     $forms = $anak->form;
     //delete semua form yang berkaitan
     foreach ($forms as $form) {
         FormDAO::delete($form->id);
     }
     //delete data anak
     AnakDAO::delete($anak->id);
     $lka = base64_decode($enc_lka);
     //synchornize multiple total and sequence multiview
     FormMultiHelper::synchronize($lka);
     if ($fm) {
         Session::flash('message', "Form with {$id} has been deleted!");
     } else {
         Session::flash('message', "Error, Form with {$id} not found!");
     }
     return Redirect::to('/dash/formka1multi/view/' . $enc_lka);
 }
 /**
  * Update an existing User model. If update is successful, the browser
  * will be redirected to the 'view' page.
  *
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     // set up user and profile
     $user = $this->findModel($id);
     $user->setScenario("admin");
     $profile = $user->profile;
     // load post data and validate
     $post = Yii::$app->request->post();
     if ($user->load($post) && $user->validate() && $profile->load($post) && $profile->validate()) {
         //Save user
         $user->save(false);
         // Save profile
         $profile->setUser($user->id)->save(false);
         // Remove old forms permissions
         FormUser::deleteAll(['user_id' => $user->id]);
         // Save new forms permissions
         $forms = Yii::$app->request->post('forms');
         if (isset($forms) && is_array($forms)) {
             // Set news
             foreach ($forms as $form_id) {
                 $formUser = new FormUser();
                 $formUser->form_id = $form_id;
                 $formUser->user_id = $user->id;
                 $formUser->save();
             }
         }
         Yii::$app->getSession()->setFlash('success', Yii::t('app', 'The user has been successfully updated.'));
         return $this->redirect(['index']);
     }
     // Get all forms
     $forms = Form::find()->select(['id', 'name'])->orderBy('updated_at DESC')->all();
     // Map id => name
     $forms = ArrayHelper::map($forms, 'id', 'name');
     // Get forms of the selected user
     $userForms = FormUser::find()->select(['form_id'])->where(['user_id' => $user->id])->asArray()->all();
     // Get only ids
     $userForms = ArrayHelper::getColumn($userForms, 'form_id');
     // render
     return $this->render('update', ['user' => $user, 'profile' => $profile, 'forms' => $forms, 'userForms' => $userForms]);
 }
Example #19
0
 public function delete($id)
 {
     //notifikasi
     FormKA4DisposisiHelper::deleteNotif($id);
     $fm = Form::find($id);
     $anakId = 64;
     $anak = Anak::find($anakId);
     $forms = $anak->form;
     //delete semua form yang berkaitan
     foreach ($forms as $form) {
         if ($form->nama == "ka4" || $form->nama == "ka5" || $form->nama == "ka6" || $form->nama == "ka7") {
             FormDAO::delete($form->id);
         }
     }
     //delete data pendampingan
     $pendamping = $anak->Pendampingan()->get();
     foreach ($pendamping as $pd) {
         PendampinganDAO::delete($pd->id);
     }
     $gf = $anak->GambaranFisik()->get();
     foreach ($gf as $val) {
         GambaranFisikDAO::delete($val->id);
     }
     $kp = $anak->KondisiPsikososial()->get();
     foreach ($kp as $val) {
         KondisiPsikososialDAO::delete($val->id);
     }
     $im = $anak->IdentifikasiMasalah()->get();
     foreach ($im as $val) {
         IdentifikasiMasalahDAO::delete($val->id);
     }
     $kel = $anak->Keluarga()->get();
     foreach ($kel as $val) {
         KeluargaDAO::delete($val->id);
     }
     if ($fm) {
         Session::flash('message', "Form with {$id} has been deleted!");
     } else {
         Session::flash('message', "Error, Form with {$id} not found!");
     }
     return Redirect::to('/dash/formka4');
 }
Example #20
0
 public function actionRemoveAll()
 {
     $items = Yii::$app->request->post('items', []);
     if (!empty($items)) {
         $items = Form::find()->where(['in', 'id', $items])->all();
         foreach ($items as $item) {
             $item->delete();
         }
     }
     return $this->redirect(['index']);
 }
Example #21
0
 public function delete($id)
 {
     //notifikasi
     FormKA7DisposisiHelper::deleteNotif($id);
     $fm = Form::find($id);
     $anak = $fm->anak->first();
     $forms = $anak->form;
     //delete semua form yang berkaitan
     foreach ($forms as $form) {
         if ($form->nama == "ka7") {
             FormDAO::delete($form->id);
         }
     }
     if ($fm) {
         Session::flash('message', "Form with {$id} has been deleted!");
     } else {
         Session::flash('message', "Error, Form with {$id} not found!");
     }
     return Redirect::to('/dash/formka7');
 }
Example #22
0
 public function delete($id)
 {
     //notifikasi
     NotifikasiDisposisiHelper::formDelete($id);
     $fm = Form::find($id);
     $anak = $fm->anak->first();
     $forms = $anak->form;
     //delete semua form yang berkaitan
     foreach ($forms as $form) {
         if ($form->nama == "ka3" || $form->nama == "ka4" || $form->nama == "ka5" || $form->nama == "ka6" || $form->nama == "ka7") {
             FormDAO::delete($form->id);
         }
     }
     //delete data pendampingan
     $pendamping = $anak->pendampingan;
     foreach ($pendamping as $pd) {
         PendampinganDAO::delete($pd->id);
     }
     if ($fm) {
         Session::flash('message', "Form with {$id} has been deleted!");
     } else {
         Session::flash('message', "Error, Form with {$id} not found!");
     }
     return Redirect::to('/dash/formka3');
 }
Example #23
0
 public function actionIndex()
 {
     $users = Form::find()->all();
     return $this->render('index', ['users' => $users]);
 }