Esempio n. 1
0
 /**
  * Render home page
  */
 public function actionIndex()
 {
     $model = new Form();
     $model->status = 'new';
     if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->save()) {
         $model->images = UploadedFile::getInstances($model, 'images');
         if ($model->upload()) {
             return $this->render('success', ['model' => $model]);
         } else {
             return $this->render('fail', ['model' => $model]);
         }
     }
     return $this->render('index', ['model' => $model]);
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
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 getAssessment($year = null)
 {
     if ($year != null) {
         $form = Form::where('nama', '=', 'ka4')->whereRaw('YEAR(`tanggal`) = ?', array($year))->get();
     } else {
         $form = Form::where('nama', '=', 'ka4')->get();
     }
     //only form that dont have form ka3 will be indexed
     $outform = [];
     $c = 0;
     foreach ($form as $fm) {
         $anak = $fm->anak->first();
         $isFormKA4HasBeenCreated = FALSE;
         foreach ($anak->form as $fa) {
             if ($fa->nama == "ka5") {
                 //this form cannot be included...
                 $isFormKA4HasBeenCreated = TRUE;
             }
         }
         if ($isFormKA4HasBeenCreated == FALSE) {
             $outform[$c] = $fm;
             $c++;
         }
     }
     return $outform;
 }
Esempio n. 5
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();
         }
     }
 }
Esempio n. 6
0
 /**
  * Finds the Form model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Form the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Form::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 7
0
 public static function isLKAExist($lka)
 {
     $form = Form::where('no_lka', '=', $lka)->count();
     if ($form > 0) {
         return true;
     } else {
         return false;
     }
 }
 public function isLKAUnique()
 {
     $q = Input::get('query');
     $form = Form::where('no_lka', '=', $q)->get();
     if (count($form) > 0) {
         return Response::json(['status' => false]);
     } else {
         return Response::json(['status' => true]);
     }
 }
Esempio n. 9
0
 /**
  * @inheritdoc
  */
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         // Delete relation with Forms
         Form::updateAll(['theme_id' => null], ['theme_id' => $this->id]);
         return true;
     } else {
         return false;
     }
 }
Esempio n. 10
0
 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);
 }
Esempio n. 11
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]);
     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;
 }
Esempio n. 12
0
 /**
  * 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;
 }
 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);
 }
Esempio n. 14
0
 public static function getDisposisiForm($year)
 {
     $formDisArray = KA5DisposisiHelper::countMyDisposisi($year);
     // var_dump($formDisArray);
     if (is_array($formDisArray) && count($formDisArray) != 0) {
         $form = Form::wherein('id', $formDisArray)->whereRaw('YEAR(`tanggal`) = ?', array($year))->orderBy('no_lka', 'desc')->get();
         // var_dump($form);
         return $form;
     } else {
         return null;
     }
 }
Esempio n. 15
0
 /**
  * @inheritdoc
  * @param int $id
  * @return int|mixed
  * @throws NotFoundHttpException
  */
 public function run($id)
 {
     /** @var Form|HasProperties $form */
     if (null === ($form = Form::findById($id))) {
         throw new NotFoundHttpException();
     }
     $post = Yii::$app->request->post();
     $form->abstractModel->setAttrubutesValues($post);
     /** @var AbstractModel|SpamCheckerBehavior $model */
     $model = $form->getAbstractModel();
     if (Yii::$app->request->isAjax && isset($post['ajax'])) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     /** @var \app\models\Object $object */
     $object = Object::getForClass(Form::className());
     $propGroups = ObjectPropertyGroup::find()->where(['and', 'object_id = :object', 'object_model_id = :id'], [':object' => $object->id, ':id' => $id])->asArray()->all();
     $propIds = ArrayHelper::getColumn($propGroups, 'property_group_id');
     // Spam checking
     $activeSpamChecker = SpamChecker::getActive();
     $data = [];
     $haveSpam = false;
     if ($activeSpamChecker !== null && !empty($activeSpamChecker->api_key)) {
         $data[$activeSpamChecker->name]['class'] = $activeSpamChecker->behavior;
         $data[$activeSpamChecker->name]['value']['key'] = $activeSpamChecker->api_key;
         $properties = Property::getForGroupId($propIds[0]);
         foreach ($properties as $prop) {
             if (!isset($activeSpamChecker->{$prop->interpret_as}) || empty($activeSpamChecker->{$prop->interpret_as})) {
                 continue;
             }
             $data[$activeSpamChecker->name]['value'][$activeSpamChecker->{$prop->interpret_as}] = is_array($post[$form->abstractModel->formName()][$prop->key]) ? implode(' ', $post[$form->abstractModel->formName()][$prop->key]) : $post[$form->abstractModel->formName()][$prop->key];
         }
         $model->attachBehavior('spamChecker', ['class' => SpamCheckerBehavior::className(), 'data' => $data]);
         $haveSpam = $model->isSpam();
     }
     $date = new \DateTime();
     /** @var Submission|HasProperties $submission */
     $submission = new Submission(['form_id' => $form->id, 'date_received' => $date->format('Y-m-d H:i:s'), 'ip' => Yii::$app->request->userIP, 'user_agent' => Yii::$app->request->userAgent, 'spam' => (int) $haveSpam]);
     if (false === Yii::$app->user->isGuest) {
         $submission->processed_by_user_id = Yii::$app->user->identity->getId();
     }
     if (!($form->abstractModel->validate() && $submission->save())) {
         return "0";
     }
     if (isset($post[$form->abstractModel->formName()])) {
         $data = ['AddPropetryGroup' => [$submission->formName() => array_keys($form->getPropertyGroups())], $submission->abstractModel->formName() => $post[$form->abstractModel->formName()]];
         if (isset($_FILES[$form->abstractModel->formName()])) {
             $_FILES[$submission->abstractModel->formName()] = $_FILES[$form->abstractModel->formName()];
         }
         $submission->saveProperties($data);
     }
     return $submission->id;
 }
Esempio n. 16
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;
 }
Esempio n. 17
0
 public function actionDelete()
 {
     self::$request = Yii::$app->request;
     if (self::$request->getIsGet()) {
         $item_id = self::$request->get('id');
         $user = Form::findOne($item_id);
         $result = $user->delete();
         if (self::$request->getIsAjax()) {
             print json_encode($result);
             die;
         }
     }
     $this->redirect(['/form']);
 }
Esempio n. 18
0
 public function run()
 {
     $object = Object::getForClass(\app\models\Form::className());
     $groups = PropertyGroup::getForModel($object->id, $this->formId);
     $view = !empty($this->model->form_view) ? $this->model->form_view : 'form';
     $successView = !empty($this->model->form_success_view) ? $this->model->form_success_view : 'success';
     if (!$this->isModal) {
         echo Html::beginTag('div', ['id' => 'form-info-' . $this->id, 'style' => 'display: none;']);
         echo $this->render($successView);
         echo '</div>';
     }
     echo $this->render($view, ['id' => $this->id, 'model' => $this->model, 'groups' => $groups, 'options' => $this->options]);
     if ($this->isModal) {
         Modal::end();
         Modal::begin(['id' => 'modal-form-info-' . $this->id, 'size' => Modal::SIZE_SMALL, 'header' => $this->statusHeaderName ? $this->statusHeaderName : $this->model->name . ' ' . \Yii::t('app', 'status')]);
         echo $this->render($successView);
         Modal::end();
     }
 }
Esempio n. 19
0
 public function processCode($fullCode)
 {
     $code = $fullCode['code'];
     $original = $fullCode['original'];
     if ($this->isCodeActive($code)) {
         $group = Group::findOne($code->z_p_id)->toArray();
         $bank = Bank::findOne($code->z_b_id)->toArray();
         $form = Form::findOne(['f_klasse' => $bank['klasse'], 'f_p_id' => $group['p_id']]);
         $style = Style::findOne(['s_b_id' => $bank['b_id'], 's_p_id' => $group['p_id']]);
         if (!$style) {
             $style = Settings::getSetting('style');
         } else {
             $style = $style->style;
         }
         $label = Yii::$app->params['default_next_label'];
         $message = Yii::$app->params['default_next_message'];
         if ($this->language != "default") {
             $language = Language::findOne($this->language);
             if ($language != null) {
                 if ($language->label != '') {
                     $label = $language->label;
                 }
                 if ($language->message != '') {
                     $message = $language->message;
                 }
             }
         }
         Yii::$app->session['anketData'] = ['original' => $original, 'code' => $code->toArray(), 'group' => $group, 'bank' => $bank, 'form' => $form->f_id, 'status' => 0, 'lang' => $this->language, 'style' => $style, 'label' => $label, 'message' => $message];
         $meta = Meta::findOne(['m_z_id' => $code->z_id]);
         if (!$meta) {
             $meta = new Meta();
             $meta->m_z_id = $code->z_id;
             $meta->ip = $_SERVER['REMOTE_ADDR'];
             $meta->time_start = time();
         } else {
             $meta->ip = $_SERVER['REMOTE_ADDR'];
         }
         $meta->save();
         return true;
     }
     return false;
 }
Esempio n. 20
0
 public static function getLKAData($year = null)
 {
     $form = Form::where('nama', '=', 'ka1')->orWhere('nama', '=', 'ka2')->get();
     //only form that dont have form ka3 will be indexed
     $outform = [];
     $c = 0;
     foreach ($form as $fm) {
         if ($year != null) {
             $date = date_create($fm->tanggal);
             $yearDB = date_format($date, 'Y');
             if ($year == $yearDB) {
                 $anak = $fm->anak->first();
                 $isFormKA3HasBeenCreated = FALSE;
                 foreach ($anak->form as $fa) {
                     if ($fa->nama == "ka3") {
                         //this form cannot be included...
                         $isFormKA3HasBeenCreated = TRUE;
                     }
                 }
                 if ($isFormKA3HasBeenCreated == FALSE) {
                     $outform[$c] = $fm;
                     $c++;
                 }
             }
         } else {
             $anak = $fm->anak->first();
             $isFormKA3HasBeenCreated = FALSE;
             foreach ($anak->form as $fa) {
                 if ($fa->nama == "ka3") {
                     //this form cannot be included...
                     $isFormKA3HasBeenCreated = TRUE;
                 }
             }
             if ($isFormKA3HasBeenCreated == FALSE) {
                 $outform[$c] = $fm;
                 $c++;
             }
         }
     }
     return $outform;
 }
Esempio n. 21
0
 public function processCode($code)
 {
     if ($this->isCodeActive($code)) {
         $group = Group::findOne($code->z_p_id)->toArray();
         $bank = Bank::findOne($code->z_b_id)->toArray();
         $form = Form::findOne(['f_klasse' => $bank['klasse'], 'f_p_id' => $group['p_id']]);
         Yii::$app->session['anketData'] = ['code' => $code->toArray(), 'group' => $group, 'bank' => $bank, 'form' => $form->f_id, 'status' => 0, 'lang' => $this->language];
         $meta = Meta::findOne(['m_z_id' => $code->z_id]);
         if (!$meta) {
             $meta = new Meta();
             $meta->m_z_id = $code->z_id;
             $meta->ip = $_SERVER['REMOTE_ADDR'];
             $meta->time_start = time();
         } else {
             $meta->ip = $_SERVER['REMOTE_ADDR'];
         }
         $meta->save();
         return true;
     }
     return false;
 }
 public function handleAfterInsert(Event $event)
 {
     $review = $this->owner;
     if (null === ($form = Form::findById(1))) {
         return;
     }
     $submission = new Submission();
     $submission->loadDefaultValues();
     $submission->form_id = $form->id;
     $submission->user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/45.0.2454.101 Chrome/45.0.2454.101 Safari/537.36';
     $submission->date_received = Date("Y-m-d H:i:s");
     $submission->ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1';
     $submission->submission_referrer = 'localhost';
     if (true === $submission->save()) {
         $submission->addPropertyGroup(3, true, true);
         $review->submission_id = $submission->id;
         $review->parent_id = 0;
         $review->root_id = $review->id;
         $review->save(true, ['submission_id', 'root_id', 'parent_id']);
     }
 }
Esempio n. 23
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);
 }
Esempio n. 24
0
 public static function getLKA()
 {
     $pad = 4;
     $rand_max = 9999;
     $yearDb = SettingDAO::getValue("LKA_YEAR");
     $monthDb = SettingDAO::getValue("LKA_MONTH");
     $yearNow = date('Y');
     $part = SettingDAO::getValue('LKA_PART');
     $num = rand(1, $rand_max);
     //random number
     $number = str_pad($num, $pad, "0", STR_PAD_LEFT);
     $year = date('Y');
     if ($yearDb != $yearNow) {
         $num = rand(1, $rand_max);
         //random number
         $number = str_pad($num, $pad, "0", STR_PAD_LEFT);
         $year = $yearNow;
     }
     $year = date('Y');
     $month = RomanHelper::numberToRoman(date('m'));
     $lka = $number . '/' . $part . '/' . $month . '/' . $year;
     $unique = false;
     while ($unique == false) {
         $f = Form::where('no_lka', '=', $lka)->count();
         if ($f == 0) {
             $unique = true;
             //or break looping
         } else {
             $num = rand(1, $rand_max);
             //random number
             $number = str_pad($num, $pad, "0", STR_PAD_LEFT);
             $lka = $number . '/' . $part . '/' . $month . '/' . $year;
             $f = Form::where('no_lka', '=', $lka)->count();
             if ($f == 0) {
                 $unique == true;
             }
         }
     }
     return $lka;
 }
 public function actionForm()
 {
     if (!isset(Yii::$app->session['anketData'])) {
         $this->redirect('/site/index');
     }
     $data = Yii::$app->session['anketData'];
     $form = Form::findOne($data['form']);
     $questions = $form->getQuestions();
     $status = Code::findOne($data['code']['z_id'])->status;
     if (Yii::$app->request->post('q')) {
         $userAnswers = Yii::$app->request->post('q');
         $status = $form->saveAnswers($data['code'], $userAnswers);
         $data['status'] = $status;
         $data['code']['status'] = $status;
     }
     Yii::$app->session['anketData'] = $data;
     if (!($status < $form->getQuestionsCount($questions))) {
         $code = Code::findOne($data['code']['z_id']);
         $code->used = 1;
         $code->save();
         $this->redirect('/site/end');
     }
     return $this->render('form', ['status' => $status, 'percent' => round($status / $form->getQuestionsCount($questions) * 100), 'questions' => $questions, 'anket' => $form, 'bank' => $data['bank']['b_id']]);
 }
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (null === ($form = Form::findById($this->formId)) || null === $this->model || null === $this->model->object) {
         throw new InvalidParamException();
     }
     if ($this->registerCanonical === true) {
         $this->getView()->registerLinkTag(['rel' => 'canonical', 'href' => ObjectRule::canonical($this->additionalParams)], 'canonical');
     }
     $formObject = Object::getForClass(Form::className());
     $groups = PropertyGroup::getForModel($formObject->id, $form->id);
     $models = Review::getForObjectModel($this->model->id, $this->model->object->id, $form->id);
     $review = new Review(['scenario' => 'check']);
     $review->useCaptcha = $this->useCaptcha;
     /** @var $module \app\modules\review\ReviewModule */
     $module = Yii::$app->getModule('review');
     $maxPerPage = $module->maxPerPage;
     $pageSize = $module->pageSize;
     if ($pageSize > $maxPerPage) {
         $pageSize = $maxPerPage;
     }
     $this->additionalParams['review-page'] = Yii::$app->request->get('review-page');
     $this->additionalParams['review-per-page'] = Yii::$app->request->get('review-per-page');
     return $this->render($this->viewFile, ['reviews' => new ArrayDataProvider(['id' => 'review', 'allModels' => $models, 'pagination' => ['pageSize' => $pageSize, 'params' => $this->additionalParams], 'sort' => ['attributes' => ['submission_id'], 'defaultOrder' => ['submission_id' => $this->sort]]]), 'objectModel' => $this->model, 'model' => $form, 'review' => $review, 'groups' => $groups, 'ratingGroupName' => $this->ratingGroupName, 'useCaptcha' => $this->useCaptcha, 'additionalParams' => $this->additionalParams]);
 }
Esempio n. 27
0
 public function search()
 {
     $keyword = Input::get('keyword');
     $filter = Input::get('filter');
     $result = Form::where('nama', '=', 'ka3')->orderBy('tanggal', 'desc');
     if ($keyword != NULL) {
         if ($filter == "kode" || $filter == NULL) {
             $result = $result->where('id', '=', $keyword);
         } else {
             if ($filter == "lka") {
                 $result = $result->where('no_lka', 'LIKE', '%' . $keyword . '%');
             } else {
                 if ($filter == "anak") {
                     $result = $result->whereHas('anak', function ($qa) use($keyword) {
                         $qa->where('anak.nama', 'LIKE', '%' . $keyword . '%');
                     });
                 } else {
                     if ($filter == "jenis") {
                         $result = $result->whereHas('anak', function ($qa) use($keyword) {
                             $qa->whereHas('jeniskasus', function ($qp) use($keyword) {
                                 $qp->where('jenis_kasus.jenis', 'LIKE', '%' . $keyword . '%');
                             });
                         });
                     } else {
                         if ($filter == "tindak") {
                             $result = $result->whereHas('anak', function ($qa) use($keyword) {
                                 $qa->whereHas('tindaklanjut', function ($qp) use($keyword) {
                                     $qp->where('tindak_lanjut.aksi', 'LIKE', '%' . $keyword . '%');
                                 });
                             });
                         }
                     }
                 }
             }
         }
     }
     $data = ['title' => '', 'page_title' => 'Kasus Anak 3 (KA3)', 'panel_title' => 'Search View', 'location' => 'search', 'table' => $result->orderBy('created_at', 'desc')->get()];
     return View::make('formka3.view', $data);
 }
Esempio n. 28
0
 public function getForm()
 {
     return $this->hasOne(Form::className(), ['id' => 'form_id']);
 }
Esempio n. 29
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']);
 }
Esempio n. 30
0
 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;
 }