Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

namespace app\controllers; use app\components\FileManagerBehavior; use app\components\Use..

Decoded Output download

<?   namespace app\controllers; use app\components\FileManagerBehavior; use app\components\UserAccessBehavior; use app\models\AccessionBook; use app\models\AccessionBookSearch; use app\models\AccessionField; use app\models\AccessionFieldForm; use app\models\AccessionFieldSearch; use app\models\CropInPegawai; use app\models\CropLocationAge; use app\models\MsCrop; use app\models\MsJabatan; use app\models\MsLocation; use app\models\MsPegawai; use Yii; use app\models\Trials; use app\models\TrialsSearch; use app\models\TrialTarget; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use yii\web\Response; use yii\helpers\Html; use app\models\MsReference; use app\models\TrialAccBookSearch; use app\models\TrialDetail; use app\models\TrialDetailForm; use app\models\TrialDetailSearch; use app\models\VTrialFieldList; use Exception; use kartik\mpdf\Pdf; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use yii\base\Exception as BaseException; use yii\db\Query; use yii\helpers\ArrayHelper; use yii\helpers\Url; use yii\web\ForbiddenHttpException; use yii\web\ServerErrorHttpException; use yii\web\UploadedFile; class TrialsController extends Controller { public function behaviors() { return array("verbs" => array("class" => VerbFilter::className(), "actions" => array("delete" => array("post"), "bulkdelete" => array("post"), "addAccSingle" => array("post"))), "ua" => array("class" => UserAccessBehavior::className()), "fm" => array("class" => FileManagerBehavior::className())); } public function actionIndex() { Url::remember(); $query = Yii::$app->request->queryParams; $pegawai = Yii::$app->user->getIdentity()->pegawai; if ($this->isAsistantManger()) { $query["TrialsSearch"]["crop_id"] = $this->cropList; } else { $query["TrialsSearch"]["pegawai_id"] = $this->pegawaiId; } $searchModel = new TrialsSearch(); $dataProvider = $searchModel->search($query); return $this->render("index", array("searchModel" => $searchModel, "dataProvider" => $dataProvider)); } public function actionView($id) { $request = Yii::$app->request; if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("title" => "Trials #" . $id, "content" => $this->renderAjax("view", array("model" => $this->findModel($id))), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::a("Edit", array("update", "id" => $id), array("class" => "btn btn-primary", "role" => "modal-remote"))); } else { return $this->render("view", array("model" => $this->findModel($id))); } } public function actionCreate() { $request = Yii::$app->request; $model = new Trials(); $model->scenario = "insert"; $modelTrialTarget = MsReference::find()->where(array("cat_id" => Yii::$app->params["catReffList"]["catTrialTarget"]))->with("trialTargets")->all(); $pegawaiList = MsPegawai::find()->alias("mp")->select("mp.id, mp.nama_pegawai")->joinWith("msJabatan mj")->where(array("mj.kode_jabatan" => MsJabatan::KD_BREEDER_RND))->andFilterWhere(array("mp.id" => $this->pegawaiId))->asArray()->all(); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { $model->pegawai_id = Yii::$app->user->getIdentity()->pegawai_id; return array("title" => "Create new Trials", "content" => $this->renderAjax("create", array("model" => $model, "modelTrialTarget" => $modelTrialTarget, "pegawaiList" => $pegawaiList)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } else { if ($model->load($request->post()) && $model->save()) { $trialTargets = $request->post("Trials")["trial_targets"]; $modelTrialTarget = new TrialTarget(); foreach ($trialTargets as $target) { $modelTrialTarget->isNewRecord = true; $modelTrialTarget->id = null; $modelTrialTarget->trial_id = $model->id; $modelTrialTarget->target_reff_id = $target; $modelTrialTarget->save(); } return array("forceReload" => "#crud-datatable-pjax", "title" => "Create new Trials", "content" => "<span class="text-success">Create Trials success</span>", "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::a("Create More", array("create"), array("class" => "btn btn-primary", "role" => "modal-remote"))); } else { $model->no = ''; return array("title" => "Create new Trials", "content" => $this->renderAjax("create", array("model" => $model, "modelTrialTarget" => $modelTrialTarget, "pegawaiList" => $pegawaiList)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } } } else { if ($model->load($request->post()) && $model->save()) { return $this->redirect(array("view", "id" => $model->id)); } else { return $this->render("create", array("model" => $model, "modelTrialTarget" => $modelTrialTarget, "pegawaiList" => $pegawaiList)); } } } public function actionFieldList($trial_id) { $request = Yii::$app->request; $this->findModel($trial_id); $model = $this->findModelRemarkField($trial_id); $pegawaiList = MsPegawai::find()->alias("mp")->select("mp.id, mp.nama_pegawai")->joinWith("msJabatan mj")->where(array("mj.kode_jabatan" => MsJabatan::KD_BREEDER_RND))->andFilterWhere(array("mp.id" => $this->pegawaiId))->asArray()->all(); if ($request->isPost) { $fieldData = $request->post("FieldData"); foreach ($fieldData as $data) { $trialField = new VTrialFieldList(); $trialField->load($data); $trialField->saveField(); } $this->redirect("index"); } else { return $this->render("field-list/create", array("models" => $model, "pegawaiList" => $pegawaiList, "action" => "get")); } } public function actionUpdate($id) { $request = Yii::$app->request; $model = $this->findModel($id); $model->scenario = "update"; $pegawaiList = MsPegawai::find()->alias("mp")->select("mp.id, mp.nama_pegawai")->joinWith("msJabatan mj")->where(array("mj.kode_jabatan" => MsJabatan::KD_BREEDER_RND))->andFilterWhere(array("mp.id" => $this->pegawaiId))->asArray()->all(); foreach ($model->trialTargets as $target) { $model->trial_targets[] = $target->target_reff_id; } if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { return array("title" => "Update Trials #" . $id, "content" => $this->renderAjax("update", array("model" => $model, "pegawaiList" => $pegawaiList)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } else { if ($model->load($request->post()) && $model->save()) { $model->updated_at = date("Y-m-d H:i:s"); $trialTargets = $request->post("Trials")["trial_targets"]; $modelTrialTarget = new TrialTarget(); $modelTrialTarget->deleteAll(array("trial_id" => $id)); foreach ($trialTargets as $target) { $modelTrialTarget->isNewRecord = true; $modelTrialTarget->id = null; $modelTrialTarget->trial_id = $id; $modelTrialTarget->target_reff_id = $target; $modelTrialTarget->save(); } return array("forceReload" => "#crud-datatable-pjax", "title" => "Trials #" . $id, "content" => $this->renderAjax("view", array("model" => $model, "pegawaiList" => $pegawaiList)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::a("Edit", array("update", "id" => $id), array("class" => "btn btn-primary", "role" => "modal-remote"))); } else { return array("title" => "Update Trials #" . $id, "content" => $this->renderAjax("update", array("model" => $model, "pegawaiList" => $pegawaiList)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } } } else { if ($model->load($request->post()) && $model->save()) { return $this->redirect(array("view", "id" => $model->id)); } else { return $this->render("update", array("model" => $model, "pegawaiList" => $pegawaiList)); } } } public function actionDelete($id) { $request = Yii::$app->request; $this->findModel($id)->delete(); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("forceClose" => true, "forceReload" => "#crud-datatable-pjax"); } else { return $this->redirect(array("index")); } } public function actionBulkdelete() { $request = Yii::$app->request; $pks = explode(",", $request->post("pks")); foreach ($pks as $pk) { $model = $this->findModel($pk); $model->delete(); } if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("forceClose" => true, "forceReload" => "#crud-datatable-pjax"); } else { return $this->redirect(array("index")); } } public function actionPrint($id) { $model = $this->findModel($id); $data = Trials::find()->alias("t")->innerJoin(TrialDetail::tableName() . " td", "td.trial_id = t.id")->innerJoin(AccessionBook::tableName() . " ab", "ab.id = td.acc_id")->select(array("ab.id", "ab.no", "ab.parents", "td.seed_db", "td.seed_total"))->where(array("t.id" => $id))->asArray()->all(); $dataSowing = AccessionField::find()->where(array("trial_id" => $id))->groupBy(array("phase_reff_id", "acc_id"))->asArray()->all(); $remarks = AccessionField::find()->select(array("acc_id", "GROUP_CONCAT(CONCAT(field_value_name, ': ', field_value_text), '') as remarks"))->where(array("trial_id" => $id))->groupBy(array("acc_id"))->asArray()->all(); $remarks = ArrayHelper::map($remarks, "acc_id", "remarks"); $dataSowing = ArrayHelper::index($dataSowing, "acc_id", "phase_reff_id"); $title = "Trial No. " . $model->no . " " . $model->title; $content = $this->renderPartial("_printout/showing-list", array("header" => $model, "data" => $data, "dataSowing" => $dataSowing, "remarks" => $remarks)); $header = $this->renderPartial("/_printout/header", array("doc_no" => Trials::PRINTOUT_DOC_NO, "doc_used_at" => Trials::PRINTOUT_USED_AT, "doc_title" => Trials::PRINTOUT_DOC_TITLE, "show_iso" => false)); $pdf = new Pdf(array("mode" => Pdf::MODE_CORE, "format" => Pdf::FORMAT_A4, "orientation" => Pdf::ORIENT_PORTRAIT, "destination" => Pdf::DEST_BROWSER, "marginTop" => 37, "content" => $content, "cssFile" => "@app/web/css/_printout.css", "options" => array("title" => "Krajee Report Title"), "methods" => array("SetFooter" => array("Printed by " . Yii::$app->user->getIdentity()->pegawai->nama_pegawai . " @" . date("D, d M Y  H:i:s") . "||{PAGENO}"), "SetCreator" => Yii::$app->name, "SetAuthor" => Yii::$app->params["companyName"], "SetSubject" => "Trial Sowing List", "SetTitle" => $title), "filename" => $title . ".pdf")); $mpdf = $pdf->getApi(); $mpdf->SetHTMLHeader($header); return $pdf->render(); } public function actionPrintOrder($id) { $header = $this->findModel($id); $data = Yii::$app->db->createCommand("
                    SELECT trial_id, MIN(seed_total) min_seed, MAX(seed_total) max_seed, sum(seed_total) population,\xa                        count(*) total_seed, sum(case when is_compare = 1 then 1 else 0 end) compare_seed\xa                    FROM " . TrialDetail::tableName() . " td
                    WHERE trial_id = {$id}\xa                    GROUP BY trial_id
                ")->queryOne(); $title = "Trial Order from Trial No. " . $header->no . " " . $header->title; $content = $this->renderPartial("_printout/trial-order", array("header" => $header, "data" => (object) $data)); $header = $this->renderPartial("/_printout/header", array("doc_no" => Trials::PRINTOUT_TO_DOC_NO, "doc_used_at" => Trials::PRINTOUT_TO_USED_AT, "doc_title" => Trials::PRINTOUT_TO_DOC_TITLE, "doc_rev" => Trials::PRINTOUT_TO_DOC_REV)); $pdf = new Pdf(array("mode" => Pdf::MODE_CORE, "format" => Pdf::FORMAT_A4, "orientation" => Pdf::ORIENT_PORTRAIT, "destination" => Pdf::DEST_BROWSER, "marginTop" => 37, "content" => $content, "cssFile" => "@app/web/css/_printout.css", "options" => array("title" => "PT. Benih Citra Asia"), "methods" => array("SetFooter" => array("Printed by " . Yii::$app->user->getIdentity()->pegawai->nama_pegawai . " @" . date("D, d M Y  H:i:s") . "||{PAGENO}"), "SetCreator" => Yii::$app->name, "SetAuthor" => Yii::$app->params["companyName"], "SetSubject" => "Trial Order", "SetTitle" => $title), "filename" => $title . ".pdf")); $mpdf = $pdf->getApi(); $mpdf->SetHTMLHeader($header); return $pdf->render(); } public function actionPrintExcel($id) { $this->layout = "main-excel"; $model = $this->findModel($id); $query = Trials::find()->alias("t")->innerJoin(TrialDetail::tableName() . " td", "td.trial_id = t.id")->innerJoin(AccessionBook::tableName() . " ab", "ab.id = td.acc_id")->select(array("ab.id", "ab.no", "ab.full_name", "ab.parents", "td.seed_db", "td.seed_total"))->where(array("t.id" => $id)); $data = $query->asArray()->all(); $title = "Field List from Trial No. " . $model->no . " " . $model->title; $header = $this->renderPartial("/_printout/header", array("doc_no" => Trials::PRINTOUT_FL_DOC_NO, "doc_used_at" => Trials::PRINTOUT_FL_USED_AT, "doc_title" => Trials::PRINTOUT_FL_DOC_TITLE, "doc_rev" => Trials::PRINTOUT_FL_DOC_REV, "is_pdf" => false)); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->getColumnDimension("A")->setWidth(1.25, "cm"); $sheet->getColumnDimension("C")->setWidth(6.25, "cm"); $sheet->getColumnDimension("D")->setWidth(10.0, "cm"); $row = 0; $sRow = $row; $sheet->setCellValue("A" . ++$row, "Nama Breeder"); $sheet->setCellValue("C{$row}", ": {$model->pegawai->nama_pegawai}"); $sheet->mergeCells("A{$row}:B{$row}"); $sheet->mergeCells("C{$row}:D{$row}"); $sheet->setCellValue("A" . ++$row, "Crop"); $sheet->setCellValue("C{$row}", ": {$model->crop->jns_tanaman}"); $sheet->mergeCells("A{$row}:B{$row}"); $sheet->mergeCells("C{$row}:D{$row}"); $sheet->setCellValue("A" . ++$row, "Kode Trial"); $sheet->setCellValue("C{$row}", ": {$model->no}"); $sheet->mergeCells("A{$row}:B{$row}"); $sheet->mergeCells("C{$row}:D{$row}"); $sheet->setCellValue("A" . ++$row, "Judul Trial"); $sheet->setCellValue("C{$row}", ": {$model->title}"); $sheet->mergeCells("A{$row}:B{$row}"); $sheet->mergeCells("C{$row}:D{$row}"); $sheet->setCellValue("A" . ++$row, "Target"); $sheet->setCellValue("C{$row}", ": Selfing / Sibbing / Crossing / OC / Yield Data"); $sheet->mergeCells("A{$row}:B{$row}"); $sheet->mergeCells("C{$row}:D{$row}"); $style = $sheet->getStyle("A{$sRow}:D{$row}"); $borders = $style->getBorders(); $borders->getAllBorders()->setBorderStyle(Border::BORDER_THIN); $row++; $sheet->setCellValue("A" . ++$row, "No"); $sheet->setCellValue("B{$row}", "Acc"); $sheet->setCellValue("C{$row}", "Name"); $sheet->setCellValue("D{$row}", "Remark"); $sRow = $row; foreach ($data as $index => $item) { $sheet->setCellValue("A" . ++$row, $index + 1); $sheet->setCellValue("B{$row}", $item["no"]); $sheet->setCellValue("C{$row}", $item["full_name"] . "
\xa" . $item["parents"]); } $style = $sheet->getStyle("A{$sRow}:D{$row}"); $borders = $style->getBorders(); $style->getAlignment()->setVertical("top"); $style->getAlignment()->setWrapText(true); $borders->getAllBorders()->setBorderStyle(Border::BORDER_THIN); $filePath = Yii::$app->runtimePath . "/php-office/{$model->no}.xlsx"; try { $writer = new Xlsx($spreadsheet); $this->createDir(Yii::$app->runtimePath . "/php-office"); $writer->save($filePath); $content = file_get_contents($filePath); } catch (Exception $e) { die($e->getMessage()); } header("Content-Disposition: attachment; filename=" . $model->no . ".xlsx"); unlink($filePath); die($content); } public function actionPrintFieldList($id, $spacing, $blank = 1) { $model = $this->findModel($id); $query = Trials::find()->alias("t")->innerJoin(TrialDetail::tableName() . " td", "td.trial_id = t.id")->innerJoin(AccessionBook::tableName() . " ab", "ab.id = td.acc_id")->select(array("ab.id", "ab.no", "ab.full_name", "ab.parents", "td.seed_db", "td.seed_total"))->where(array("t.id" => $id)); if (!$blank) { $query->innerJoin(VTrialFieldList::tableName() . " vt", "vt.trial_id = t.id and vt.id = td.acc_id")->addSelect("vt.field_remark"); } $data = $query->asArray()->all(); $title = "Field List from Trial No. " . $model->no . " " . $model->title; $content = $this->renderPartial("_printout/field-list", array("header" => $model, "data" => $data, "spacing" => $spacing)); $header = $this->renderPartial("/_printout/header", array("doc_no" => Trials::PRINTOUT_FL_DOC_NO, "doc_used_at" => Trials::PRINTOUT_FL_USED_AT, "doc_title" => Trials::PRINTOUT_FL_DOC_TITLE, "doc_rev" => Trials::PRINTOUT_FL_DOC_REV)); $pdf = new Pdf(array("mode" => Pdf::MODE_CORE, "format" => Pdf::FORMAT_A4, "orientation" => Pdf::ORIENT_PORTRAIT, "destination" => Pdf::DEST_BROWSER, "marginTop" => 37, "content" => $content, "cssFile" => "@app/web/css/_printout.css", "options" => array("title" => "Krajee Report Title"), "methods" => array("SetFooter" => array("Printed by " . Yii::$app->user->getIdentity()->pegawai->nama_pegawai . " @" . date("D, d M Y  H:i:s") . "||{PAGENO}"), "SetCreator" => Yii::$app->name, "SetAuthor" => Yii::$app->params["companyName"], "SetSubject" => "Trial Field List", "SetTitle" => $title), "filename" => $title . ".pdf")); $mpdf = $pdf->getApi(); $mpdf->SetHTMLHeader($header); return $pdf->render(); } public function actionGetTrialNo($cropId) { $request = Yii::$app->request; if ($request->isAjax && $request->isGet) { Yii::$app->response->format = Response::FORMAT_JSON; $modelTrial = new Trials(); $modelTrial->crop_id = $cropId; return array("trial_no" => $modelTrial->createTrialNo($modelTrial, null)); } else { throw new ForbiddenHttpException("Forbidden Request!"); } } public function actionTrialDetail($id) { Url::remember('', "trials-trial-detail"); $searchModel = new TrialDetailSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $id); $searchModelDetail = new AccessionFieldSearch(array("trial_id" => $id)); $dataProviderDetail = $searchModelDetail->search(Yii::$app->request->queryParams); $model = $this->findModel($id); return $this->render("detail/index", array("model" => $model, "searchModel" => $searchModel, "dataProvider" => $dataProvider, "searchModelDetail" => $searchModelDetail, "dataProviderDetail" => $dataProviderDetail)); } public function actionAddTrialData($id) { $request = Yii::$app->request; $model = new AccessionFieldForm(); $modelTrial = $this->findModel($id); if ($request->isGet) { return $this->render("trial-data/create", array("id" => $id, "model" => $model, "modelTrial" => $modelTrial)); } else { $model->load($request->post()); $srcFile = null; $saveDir = "/accession-field/"; foreach ($model->acc_id as $acc) { $accField = new AccessionField(array("acc_id" => $acc, "source_reff_id" => MsReference::RC_ACC_FIELD_SOURCE_BREEDING_TRIAL, "trial_id" => $id, "crop_id" => $modelTrial->crop_id, "phase_reff_id" => $model->phase_reff_id, "user_date" => $model->user_date)); $fields = explode(";", $model->description); foreach ($fields as $field) { list($value, $param) = array_reverse(explode("=", $field)); $accField->field_value_name = $param; $accField->field_value_text = $value; if (is_null($srcFile)) { $fileName = $srcFile = $this->saveFile("AccessionFieldForm[photo_file]", $saveDir, null, "{$id}-{$acc}"); } else { $fileName = $this->cloneFile("{$saveDir}", $srcFile, "{$id}-{$acc}"); } $accField->photo_file = $fileName; $accField->isNewRecord = true; $accField->id = null; $accField->save(); } } $this->redirect(array("trial-detail", "id" => $id)); } } public function actionAddTrialDataSingle($id) { $request = Yii::$app->request; $model = new AccessionField(); $modelTrial = $this->findModel($id); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { return array("title" => "Tambah Data Trial", "content" => $this->renderAjax("trial-data/create-single", array("model" => $model, "modelTrial" => $modelTrial)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } else { if ($request->isPost) { $fieldLists = $request->post("FieldLists"); $error = false; $transaction = Yii::$app->db->beginTransaction(); $saveDir = "/accession-field/"; try { $modelAccField = array(); foreach ($fieldLists as $index => $field) { $tModel = new AccessionField(); $tModel->load($request->post()); $tModel->source_reff_id = AccessionField::SOURCE_REFF_TRIAL_ID; $tModel->trial_id = $id; $tModel->crop_id = $modelTrial->crop_id; $tModel->field_value_name = $field["field_value_name"]; $tModel->field_value_text = $field["field_value_text"]; if (!$tModel->save(false)) { $error = true; break; } else { $fileName = $this->saveFile("FieldLists[{$index}][field_photo_file]", $saveDir, null, "id_" . $tModel->id); if ($fileName === false) { $error = true; break; } else { $tModel->photo_file = $fileName; $tModel->save(false); $modelAccField[] = $tModel; } } } if ($error) { $transaction->rollBack(); } else { $transaction->commit(); } } catch (Exception $e) { $transaction->rollBack(); Yii::$app->response->format = Response::FORMAT_HTML; throw new ServerErrorHttpException("Terjadi kesalahan dalam memproses data field list", 0, $e); } return array("forceReload" => "#crud-datatable-data-pjax", "title" => "Tambah Data Trial", "content" => "<span class="text-success">Tambah Data Trial Berhasil</span>", "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::a("Create More", array("add-trial-data-single", "id" => $id), array("class" => "btn btn-primary", "role" => "modal-remote"))); } else { return array("title" => "Tambah Data Trial", "content" => $this->renderAjax("trial-data/create-single", array("model" => $model, "modelTrial" => $modelTrial)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } } } else { throw new ForbiddenHttpException("Request type not allowed!"); } } public function actionUpdateAccField($id) { $request = Yii::$app->request; $model = $this->findModelAccField($id); $modelTrial = $model->trial; $model->crop_id = $modelTrial->crop_id; if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { return array("title" => "Update Data Trial", "content" => $this->renderAjax("trial-data/update", array("model" => $model, "modelTrial" => $modelTrial)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } else { if ($request->isPost) { $transaction = Yii::$app->db->beginTransaction(); try { $oriFile = $model->photo_file; $saveDir = "/accession-field/"; if ($model->load($request->post()) && $model->save(false)) { $model->photo_file = $this->saveFile("AccessionField[photo_file]", $saveDir, $oriFile, "id-{$id}"); $model->save(false); $transaction->commit(); return array("forceClose" => true, "forceReload" => "#crud-datatable-data-pjax"); } } catch (Exception $e) { $transaction->rollBack(); Yii::$app->response->format = Response::FORMAT_HTML; throw new ServerErrorHttpException("Terjadi kesalahan dalam mengubah data.", 0, $e); } } else { return array("title" => "Update Data Trial", "content" => $this->renderAjax("trial-data/update", array("model" => $model, "modelTrial" => $modelTrial)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } } } else { throw new ForbiddenHttpException("Request type not allowed!"); } } public function actionUpdateAcc($id) { $request = Yii::$app->request; $model = $this->findModelTrialDetail($id); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { return array("title" => "Update Data #" . $model->acc->no, "content" => $this->renderAjax("detail/acc-list/update", array("id" => $id, "model" => $model)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } else { if ($model->load($request->post()) && $model->save()) { return array("forceClose" => true, "forceReload" => "#crud-datatable-pjax"); } else { return array("title" => "Update Aksesi #" . $model->acc->no, "content" => $this->renderAjax("detail/acc-list/update", array("id" => $id, "model" => $model)), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } } } else { $this->redirect(array("trial-detail", "id" => $id)); } } public function actionAddAcc($id, $cropId) { $request = Yii::$app->request; $params = $request->queryParams; $params["TrialAccBookSearch"]["crop_id"] = $cropId; $params["TrialAccBookSearch"]["trial_id"] = $id; $searchModel = new TrialAccBookSearch(); $dataProvider = $searchModel->search($params); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("title" => "Tambah Aksesi", "content" => $this->renderAjax("acc-book/index", array("id" => $id, "cropId" => $cropId, "searchModel" => $searchModel, "dataProvider" => $dataProvider))); } else { $this->redirect(array("trial-detail", "id" => $id)); } } public function actionUpdateMultiple($id) { $request = Yii::$app->request; $model = $this->findModel($id); $data = $model->trialDetail; if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; $errors = array(); if ($request->isPost) { $data = array(); $dataPost = $request->post("TrialDataAcc"); foreach ($dataPost as $item) { $trialDetail = $this->findModelTrialDetail($item["TrialDetail"]["id"]); $trialDetail->load($item); if (!$trialDetail->save()) { $errors[] = $trialDetail->errors; } $data[] = $trialDetail; } if (!count($errors)) { return array("forceClose" => true, "forceReload" => "#crud-datatable-pjax"); } } return array("title" => "Update Aksesi", "content" => $this->renderAjax("detail/acc-list/update-multiple", array("id" => $id, "data" => $data)), "errors" => $errors, "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal")) . Html::button("Save", array("class" => "btn btn-primary", "type" => "submit"))); } else { throw new ForbiddenHttpException("Request Not Allowed"); } } public function actionAddAccSingle($masterId, $id) { $request = Yii::$app->request; if ($request->isAjax && $request->isPost) { Yii::$app->response->format = Response::FORMAT_JSON; $modelTrialDetail = new TrialDetail(); $modelTrialDetail->scenario = "insert"; $modelTrialDetail->acc_id = $id; $modelTrialDetail->trial_id = $masterId; if ($modelTrialDetail->save()) { return array("forceReload" => "#crud-datatable-pjax", "forceReloadUrl" => Url::previous("trials-trial-detail"), "forceClose" => true); } else { return array("title" => "Tambah Aksesi", "content" => "<span class="text-danger">Tambah Aksesi gagal!</span>", "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal"))); } } else { throw new ForbiddenHttpException("Request Not Allowed"); } } public function actionAddAccMultiple($masterId) { $request = Yii::$app->request; if ($request->isAjax && $request->isPost) { Yii::$app->response->format = Response::FORMAT_JSON; $flag = false; $pks = explode(",", $request->post("pks")); $modelTrialDetail = new TrialDetail(); $modelTrialDetail->trial_id = $masterId; foreach ($pks as $pk) { $modelTrialDetail->isNewRecord = true; $modelTrialDetail->id = null; $modelTrialDetail->acc_id = $pk; if (!($flag = $modelTrialDetail->save())) { break; } } if ($flag) { return array("forceReload" => "#crud-datatable-pjax", "forceReloadUrl" => Url::previous("trials-trial-detail"), "forceClose" => true); } else { return array("title" => "Tambah Aksesi", "content" => "<span class="text-danger">Tambah Aksesi gagal!</span>" . json_encode($modelTrialDetail->errors), "footer" => Html::button("Close", array("class" => "btn btn-default pull-left", "data-dismiss" => "modal"))); } } else { throw new ForbiddenHttpException("Request Not Allowed"); } } public function actionDeleteAcc($id) { $request = Yii::$app->request; $this->findModelTrialDetail($id)->delete(); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("forceClose" => true, "forceReload" => "#crud-datatable-pjax"); } else { return $this->redirect(array("index")); } } public function actionBulkdeleteAcc() { $request = Yii::$app->request; $pks = explode(",", $request->post("pks")); foreach ($pks as $pk) { $model = $this->findModelTrialDetail($pk); $model->delete(); } if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("forceClose" => true, "forceReload" => "#crud-datatable-pjax"); } else { return $this->redirect(array("index")); } } public function actionDeleteAccField($id) { $request = Yii::$app->request; $this->findModelAccField($id)->delete(); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("forceClose" => true, "forceReload" => "#crud-datatable-data-pjax"); } else { return $this->redirect(array("index")); } } public function actionBulkdeleteAccField() { $request = Yii::$app->request; $pks = explode(",", $request->post("pks")); foreach ($pks as $pk) { $model = $this->findModelAccField($pk); $model->delete(); } if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("forceClose" => true, "forceReload" => "#crud-datatable-data-pjax"); } else { return $this->redirect(array("index")); } } public function actionTrialList($q = null) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $out = array("results" => array("id" => '', "text" => '')); $query = Trials::find()->filterWhere(array("like", "concat(no, title)", $q))->select(array("id", "crop_id", "concat(no, ' - ', title) as text"))->orderBy("id desc")->limit(10); if (!is_null($q)) { $data = $query->asArray()->all(); $out["results"] = array_values($data); } else { $data = $query->asArray()->all(); $out["results"] = array_values($data); } return $out; } public function actionGetDetail($id) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $model = Trials::find()->where(array("id" => $id))->one(); $result = ArrayHelper::toArray($model); $result["location_type"] = $model->location->locTypeReff->name; $result["location"] = $model->location->name; $result["crop_age"] = CropLocationAge::find()->where(array("crop_id" => $model["crop_id"], "loc_type_reff_id" => $model->location->locTypeReff->id))->one()->age; $result["crop"] = $model->crop->jns_tanaman; return $result; } protected function findModel($id) { $query = Trials::find()->where(array("id" => $id)); if ($this->isAsistantManger()) { $query->andFilterWhere(array("crop_id" => $this->cropList)); } else { $query->andFilterWhere(array("pegawai_id" => $this->pegawaiId)); } if (($model = $query->one()) !== null) { return $model; } else { throw new NotFoundHttpException("The requested page does not exist."); } } protected function findModelRemarkField($id) { if (count($model = VTrialFieldList::findAll(array("trial_id" => $id))) !== 0) { return $model; } else { throw new NotFoundHttpException("The requested page does not exist."); } } protected function findModelAccField($id) { if (($model = AccessionField::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException("The requested page does not exist."); } } protected function findModelTrialData($id) { $data = TrialDetailForm::find()->alias("tf")->leftJoin(array("af" => AccessionField::find()->select(array("acc_id", "count(*) as field_total"))->where(array("trial_id" => $id))->groupBy("acc_id")), "af.acc_id = tf.acc_id")->where(array("trial_id" => $id))->orderBy("af.field_total desc")->all(); if (count($data)) { return $data; } else { throw new NotFoundHttpException("The requested page does not exist."); } } protected function findModelTrialDetail($id) { if (($model = TrialDetail::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException("The requested page does not existx " . $id); } } } ?>

Did this file decode correctly?

Original Code

 namespace app\controllers; use app\components\FileManagerBehavior; use app\components\UserAccessBehavior; use app\models\AccessionBook; use app\models\AccessionBookSearch; use app\models\AccessionField; use app\models\AccessionFieldForm; use app\models\AccessionFieldSearch; use app\models\CropInPegawai; use app\models\CropLocationAge; use app\models\MsCrop; use app\models\MsJabatan; use app\models\MsLocation; use app\models\MsPegawai; use Yii; use app\models\Trials; use app\models\TrialsSearch; use app\models\TrialTarget; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use yii\web\Response; use yii\helpers\Html; use app\models\MsReference; use app\models\TrialAccBookSearch; use app\models\TrialDetail; use app\models\TrialDetailForm; use app\models\TrialDetailSearch; use app\models\VTrialFieldList; use Exception; use kartik\mpdf\Pdf; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use yii\base\Exception as BaseException; use yii\db\Query; use yii\helpers\ArrayHelper; use yii\helpers\Url; use yii\web\ForbiddenHttpException; use yii\web\ServerErrorHttpException; use yii\web\UploadedFile; class TrialsController extends Controller { public function behaviors() { return array("\x76\x65\x72\142\x73" => array("\143\154\141\x73\163" => VerbFilter::className(), "\x61\143\164\151\157\156\163" => array("\144\145\x6c\145\x74\x65" => array("\x70\x6f\163\164"), "\142\165\154\153\x64\145\154\145\x74\145" => array("\160\x6f\163\x74"), "\141\x64\144\x41\143\143\x53\x69\x6e\x67\x6c\x65" => array("\x70\x6f\163\164"))), "\x75\x61" => array("\x63\x6c\x61\163\x73" => UserAccessBehavior::className()), "\146\155" => array("\143\x6c\141\x73\x73" => FileManagerBehavior::className())); } public function actionIndex() { Url::remember(); $query = Yii::$app->request->queryParams; $pegawai = Yii::$app->user->getIdentity()->pegawai; if ($this->isAsistantManger()) { $query["\124\162\x69\141\x6c\x73\x53\145\141\162\x63\150"]["\143\162\157\x70\137\151\x64"] = $this->cropList; } else { $query["\124\162\151\141\154\163\123\x65\x61\x72\x63\150"]["\x70\x65\x67\x61\167\141\x69\x5f\x69\144"] = $this->pegawaiId; } $searchModel = new TrialsSearch(); $dataProvider = $searchModel->search($query); return $this->render("\151\156\x64\x65\170", array("\163\x65\x61\x72\x63\150\115\x6f\x64\145\154" => $searchModel, "\x64\141\164\x61\120\162\x6f\x76\x69\x64\x65\x72" => $dataProvider)); } public function actionView($id) { $request = Yii::$app->request; if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("\x74\x69\x74\x6c\x65" => "\124\162\x69\141\x6c\163\x20\43" . $id, "\143\157\156\164\145\x6e\x74" => $this->renderAjax("\166\151\x65\167", array("\x6d\157\x64\145\154" => $this->findModel($id))), "\146\157\157\x74\x65\x72" => Html::button("\103\x6c\157\163\145", array("\143\x6c\x61\x73\x73" => "\x62\x74\x6e\40\142\164\156\x2d\144\145\146\x61\165\x6c\164\40\x70\x75\154\x6c\x2d\154\x65\x66\164", "\144\141\x74\141\x2d\144\x69\x73\x6d\x69\163\163" => "\x6d\157\x64\x61\154")) . Html::a("\x45\x64\151\164", array("\x75\x70\144\x61\164\145", "\151\x64" => $id), array("\x63\154\141\163\x73" => "\142\164\x6e\40\x62\164\x6e\x2d\x70\162\x69\x6d\141\162\x79", "\162\157\154\145" => "\155\x6f\x64\141\154\55\162\145\155\157\x74\x65"))); } else { return $this->render("\x76\x69\145\x77", array("\x6d\x6f\x64\145\154" => $this->findModel($id))); } } public function actionCreate() { $request = Yii::$app->request; $model = new Trials(); $model->scenario = "\151\x6e\x73\x65\x72\x74"; $modelTrialTarget = MsReference::find()->where(array("\143\x61\x74\137\x69\144" => Yii::$app->params["\x63\141\164\x52\x65\146\146\114\151\163\x74"]["\143\x61\x74\x54\x72\151\141\x6c\124\141\x72\147\x65\x74"]))->with("\164\x72\x69\x61\154\x54\141\162\x67\145\164\163")->all(); $pegawaiList = MsPegawai::find()->alias("\155\x70")->select("\155\160\x2e\151\x64\x2c\40\x6d\160\56\156\x61\155\x61\x5f\160\x65\147\141\x77\x61\151")->joinWith("\155\163\x4a\x61\142\x61\164\x61\156\40\x6d\152")->where(array("\155\x6a\56\153\157\x64\x65\137\152\x61\x62\x61\164\141\x6e" => MsJabatan::KD_BREEDER_RND))->andFilterWhere(array("\155\x70\56\x69\x64" => $this->pegawaiId))->asArray()->all(); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { $model->pegawai_id = Yii::$app->user->getIdentity()->pegawai_id; return array("\164\x69\x74\x6c\145" => "\x43\162\x65\141\164\145\40\156\145\167\40\124\162\151\x61\154\163", "\143\x6f\x6e\164\x65\156\x74" => $this->renderAjax("\143\x72\x65\141\164\145", array("\x6d\157\144\145\x6c" => $model, "\155\157\x64\x65\x6c\x54\162\x69\141\x6c\124\141\x72\147\145\164" => $modelTrialTarget, "\160\x65\x67\141\167\x61\x69\114\x69\163\x74" => $pegawaiList)), "\x66\x6f\157\x74\145\162" => Html::button("\x43\x6c\x6f\x73\x65", array("\x63\x6c\141\163\163" => "\142\164\x6e\40\x62\x74\x6e\55\144\x65\x66\x61\x75\154\x74\40\160\165\154\154\x2d\x6c\x65\x66\164", "\x64\x61\x74\x61\x2d\x64\x69\x73\155\151\x73\x73" => "\x6d\157\x64\x61\x6c")) . Html::button("\x53\141\166\x65", array("\143\x6c\x61\163\x73" => "\x62\x74\x6e\x20\x62\164\x6e\55\160\162\151\155\x61\162\171", "\x74\x79\x70\x65" => "\x73\x75\x62\x6d\x69\164"))); } else { if ($model->load($request->post()) && $model->save()) { $trialTargets = $request->post("\124\x72\151\x61\154\x73")["\164\x72\151\x61\x6c\x5f\164\x61\x72\147\145\164\x73"]; $modelTrialTarget = new TrialTarget(); foreach ($trialTargets as $target) { $modelTrialTarget->isNewRecord = true; $modelTrialTarget->id = null; $modelTrialTarget->trial_id = $model->id; $modelTrialTarget->target_reff_id = $target; $modelTrialTarget->save(); } return array("\x66\157\162\143\145\122\145\154\157\141\x64" => "\x23\143\162\x75\144\55\144\141\x74\141\x74\141\x62\154\x65\55\160\152\x61\170", "\164\151\164\154\x65" => "\103\162\x65\141\x74\x65\x20\x6e\145\167\x20\x54\162\x69\141\x6c\x73", "\x63\x6f\x6e\164\x65\156\x74" => "\x3c\x73\x70\x61\x6e\x20\x63\x6c\x61\163\x73\75\42\x74\145\x78\x74\x2d\x73\x75\x63\143\145\x73\163\x22\76\103\x72\x65\x61\x74\x65\x20\124\162\151\141\154\163\x20\163\x75\x63\x63\145\x73\163\74\x2f\163\x70\141\156\x3e", "\x66\157\157\x74\x65\x72" => Html::button("\103\154\157\x73\145", array("\143\x6c\141\163\x73" => "\142\x74\x6e\x20\x62\164\x6e\55\x64\x65\146\x61\165\x6c\x74\40\160\x75\154\x6c\x2d\x6c\145\146\x74", "\x64\x61\164\x61\55\x64\151\163\x6d\x69\x73\x73" => "\155\157\144\x61\154")) . Html::a("\x43\x72\x65\x61\164\145\x20\x4d\x6f\162\145", array("\143\x72\145\141\164\x65"), array("\x63\x6c\141\x73\163" => "\x62\x74\156\x20\142\164\x6e\55\x70\x72\151\155\x61\162\x79", "\x72\x6f\154\145" => "\155\157\144\141\x6c\55\x72\x65\x6d\x6f\164\x65"))); } else { $model->no = ''; return array("\164\x69\164\154\x65" => "\x43\162\x65\141\164\145\x20\x6e\x65\167\x20\124\x72\151\141\154\x73", "\143\157\156\x74\145\x6e\164" => $this->renderAjax("\x63\x72\145\141\164\x65", array("\155\157\x64\x65\x6c" => $model, "\155\x6f\144\x65\x6c\x54\162\151\141\154\x54\141\x72\x67\145\164" => $modelTrialTarget, "\160\x65\147\141\x77\141\151\x4c\151\x73\164" => $pegawaiList)), "\x66\x6f\157\x74\x65\x72" => Html::button("\103\x6c\157\x73\x65", array("\x63\x6c\141\x73\x73" => "\142\164\x6e\x20\x62\x74\156\55\144\145\146\141\x75\x6c\164\40\x70\165\x6c\x6c\55\154\x65\x66\164", "\144\x61\x74\x61\x2d\144\x69\163\155\151\x73\x73" => "\x6d\157\144\x61\154")) . Html::button("\x53\x61\166\145", array("\x63\x6c\141\163\163" => "\x62\x74\x6e\x20\x62\164\156\x2d\x70\x72\151\155\x61\x72\171", "\x74\171\x70\145" => "\x73\165\142\155\151\x74"))); } } } else { if ($model->load($request->post()) && $model->save()) { return $this->redirect(array("\x76\151\145\x77", "\151\144" => $model->id)); } else { return $this->render("\143\x72\x65\141\164\x65", array("\x6d\x6f\x64\x65\154" => $model, "\x6d\157\x64\x65\154\124\162\x69\x61\154\x54\x61\x72\147\145\164" => $modelTrialTarget, "\160\x65\147\x61\x77\x61\x69\x4c\x69\x73\164" => $pegawaiList)); } } } public function actionFieldList($trial_id) { $request = Yii::$app->request; $this->findModel($trial_id); $model = $this->findModelRemarkField($trial_id); $pegawaiList = MsPegawai::find()->alias("\155\x70")->select("\x6d\x70\x2e\151\x64\54\x20\x6d\x70\x2e\156\141\x6d\x61\137\160\x65\147\x61\x77\141\x69")->joinWith("\155\163\112\141\x62\x61\164\x61\x6e\x20\x6d\x6a")->where(array("\x6d\x6a\x2e\153\x6f\144\x65\x5f\152\x61\x62\141\x74\141\156" => MsJabatan::KD_BREEDER_RND))->andFilterWhere(array("\155\160\x2e\x69\144" => $this->pegawaiId))->asArray()->all(); if ($request->isPost) { $fieldData = $request->post("\106\151\145\x6c\x64\104\x61\164\141"); foreach ($fieldData as $data) { $trialField = new VTrialFieldList(); $trialField->load($data); $trialField->saveField(); } $this->redirect("\x69\156\x64\x65\x78"); } else { return $this->render("\x66\x69\x65\x6c\x64\x2d\154\151\x73\164\57\x63\162\145\x61\164\x65", array("\x6d\x6f\144\145\x6c\163" => $model, "\160\145\147\141\x77\141\x69\x4c\x69\x73\x74" => $pegawaiList, "\x61\143\164\151\157\x6e" => "\147\145\164")); } } public function actionUpdate($id) { $request = Yii::$app->request; $model = $this->findModel($id); $model->scenario = "\x75\160\144\141\164\145"; $pegawaiList = MsPegawai::find()->alias("\x6d\160")->select("\x6d\160\x2e\x69\x64\54\x20\155\160\x2e\156\x61\155\x61\x5f\x70\x65\147\x61\167\x61\x69")->joinWith("\x6d\x73\x4a\x61\142\141\x74\x61\156\40\155\152")->where(array("\x6d\152\x2e\153\157\144\x65\137\152\x61\142\x61\164\x61\156" => MsJabatan::KD_BREEDER_RND))->andFilterWhere(array("\x6d\x70\56\151\x64" => $this->pegawaiId))->asArray()->all(); foreach ($model->trialTargets as $target) { $model->trial_targets[] = $target->target_reff_id; } if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { return array("\x74\x69\x74\x6c\145" => "\125\160\144\x61\x74\x65\40\124\162\x69\x61\x6c\163\40\43" . $id, "\x63\x6f\x6e\164\145\156\x74" => $this->renderAjax("\x75\x70\x64\x61\164\x65", array("\155\x6f\144\x65\154" => $model, "\160\145\x67\141\x77\141\x69\x4c\x69\163\x74" => $pegawaiList)), "\146\157\157\x74\x65\162" => Html::button("\x43\154\157\x73\x65", array("\143\154\141\163\x73" => "\x62\164\x6e\x20\142\x74\156\x2d\144\145\x66\x61\165\x6c\164\40\x70\165\x6c\x6c\x2d\x6c\x65\x66\164", "\x64\141\x74\x61\55\144\x69\163\x6d\x69\163\163" => "\x6d\x6f\x64\x61\154")) . Html::button("\x53\x61\x76\145", array("\143\x6c\x61\163\163" => "\x62\164\x6e\x20\x62\164\x6e\x2d\160\x72\x69\x6d\x61\162\x79", "\x74\x79\x70\145" => "\163\165\x62\155\x69\164"))); } else { if ($model->load($request->post()) && $model->save()) { $model->updated_at = date("\x59\x2d\x6d\x2d\x64\x20\x48\72\151\x3a\163"); $trialTargets = $request->post("\x54\x72\151\141\x6c\163")["\164\x72\151\x61\154\137\164\x61\162\147\x65\x74\163"]; $modelTrialTarget = new TrialTarget(); $modelTrialTarget->deleteAll(array("\x74\x72\x69\141\x6c\137\x69\144" => $id)); foreach ($trialTargets as $target) { $modelTrialTarget->isNewRecord = true; $modelTrialTarget->id = null; $modelTrialTarget->trial_id = $id; $modelTrialTarget->target_reff_id = $target; $modelTrialTarget->save(); } return array("\146\157\162\x63\x65\122\x65\154\157\141\x64" => "\43\143\x72\165\144\x2d\x64\x61\164\x61\x74\x61\x62\154\x65\x2d\160\x6a\x61\170", "\x74\x69\x74\x6c\x65" => "\x54\x72\151\x61\x6c\x73\40\43" . $id, "\x63\157\156\x74\x65\x6e\x74" => $this->renderAjax("\x76\x69\x65\x77", array("\x6d\157\144\x65\154" => $model, "\x70\145\147\x61\x77\x61\151\x4c\x69\163\x74" => $pegawaiList)), "\146\x6f\157\x74\x65\x72" => Html::button("\x43\x6c\157\x73\x65", array("\x63\x6c\141\x73\163" => "\x62\x74\156\x20\142\164\156\55\x64\x65\146\141\165\x6c\164\40\x70\165\154\x6c\x2d\154\145\x66\164", "\x64\141\x74\141\55\144\x69\163\155\151\163\x73" => "\x6d\x6f\x64\x61\154")) . Html::a("\x45\x64\x69\x74", array("\165\x70\x64\141\x74\x65", "\151\x64" => $id), array("\x63\154\x61\163\163" => "\142\164\x6e\x20\142\164\156\55\x70\x72\151\x6d\141\162\171", "\x72\x6f\154\145" => "\x6d\x6f\x64\x61\154\x2d\x72\x65\x6d\x6f\164\145"))); } else { return array("\164\x69\164\x6c\145" => "\x55\160\144\141\164\145\40\x54\162\x69\141\x6c\x73\40\43" . $id, "\x63\157\156\164\x65\x6e\x74" => $this->renderAjax("\x75\160\x64\x61\164\x65", array("\155\157\144\x65\154" => $model, "\x70\x65\x67\x61\x77\x61\151\x4c\151\163\x74" => $pegawaiList)), "\x66\x6f\x6f\164\x65\x72" => Html::button("\x43\x6c\x6f\163\x65", array("\143\154\x61\163\163" => "\x62\164\x6e\40\142\164\156\55\x64\145\146\141\x75\154\164\40\160\x75\154\x6c\x2d\154\145\146\164", "\x64\x61\164\141\55\x64\x69\x73\x6d\151\163\163" => "\x6d\157\x64\x61\154")) . Html::button("\123\x61\166\x65", array("\x63\154\141\163\163" => "\x62\164\x6e\x20\x62\x74\x6e\55\160\162\x69\155\x61\162\x79", "\x74\171\160\x65" => "\163\x75\142\155\151\x74"))); } } } else { if ($model->load($request->post()) && $model->save()) { return $this->redirect(array("\166\151\145\167", "\x69\144" => $model->id)); } else { return $this->render("\165\x70\144\141\x74\145", array("\x6d\157\144\x65\154" => $model, "\x70\x65\x67\x61\167\141\x69\114\x69\163\164" => $pegawaiList)); } } } public function actionDelete($id) { $request = Yii::$app->request; $this->findModel($id)->delete(); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("\146\157\162\x63\145\x43\154\157\x73\x65" => true, "\146\157\162\x63\x65\x52\x65\x6c\x6f\x61\x64" => "\43\x63\x72\x75\x64\55\144\x61\164\x61\164\141\142\x6c\145\x2d\160\152\x61\x78"); } else { return $this->redirect(array("\x69\x6e\144\x65\x78")); } } public function actionBulkdelete() { $request = Yii::$app->request; $pks = explode("\54", $request->post("\160\153\x73")); foreach ($pks as $pk) { $model = $this->findModel($pk); $model->delete(); } if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("\146\157\x72\x63\145\103\x6c\157\163\145" => true, "\146\x6f\x72\x63\x65\122\145\154\x6f\x61\x64" => "\x23\x63\x72\x75\x64\x2d\144\141\164\141\164\141\x62\154\x65\55\160\152\x61\170"); } else { return $this->redirect(array("\x69\x6e\x64\x65\x78")); } } public function actionPrint($id) { $model = $this->findModel($id); $data = Trials::find()->alias("\x74")->innerJoin(TrialDetail::tableName() . "\x20\x74\144", "\x74\144\x2e\x74\162\x69\141\154\x5f\x69\144\40\x3d\x20\164\56\151\x64")->innerJoin(AccessionBook::tableName() . "\40\x61\142", "\141\x62\56\x69\x64\40\x3d\x20\x74\x64\x2e\141\x63\143\137\x69\x64")->select(array("\x61\142\56\151\x64", "\x61\x62\56\x6e\x6f", "\141\x62\56\x70\141\162\145\156\164\x73", "\x74\144\56\x73\x65\x65\x64\x5f\144\142", "\x74\144\56\x73\145\x65\x64\137\x74\157\x74\141\x6c"))->where(array("\x74\x2e\x69\144" => $id))->asArray()->all(); $dataSowing = AccessionField::find()->where(array("\164\162\151\x61\154\137\x69\144" => $id))->groupBy(array("\160\x68\x61\163\145\x5f\x72\145\146\146\137\151\x64", "\141\x63\x63\137\151\144"))->asArray()->all(); $remarks = AccessionField::find()->select(array("\x61\143\x63\x5f\151\x64", "\x47\x52\117\x55\x50\137\103\117\x4e\x43\101\x54\50\x43\117\x4e\x43\x41\x54\x28\x66\151\145\154\x64\137\166\141\154\165\145\x5f\x6e\x61\x6d\145\54\40\x27\x3a\40\x27\54\x20\146\151\145\x6c\x64\x5f\x76\x61\x6c\x75\x65\137\164\x65\170\x74\51\x2c\x20\x27\x27\x29\x20\141\x73\40\x72\x65\x6d\141\162\x6b\x73"))->where(array("\x74\x72\x69\x61\154\x5f\x69\x64" => $id))->groupBy(array("\141\143\143\x5f\x69\x64"))->asArray()->all(); $remarks = ArrayHelper::map($remarks, "\141\143\143\137\151\x64", "\x72\145\x6d\141\162\153\x73"); $dataSowing = ArrayHelper::index($dataSowing, "\x61\143\143\137\151\144", "\160\x68\141\163\145\x5f\x72\145\146\146\x5f\151\144"); $title = "\124\162\151\x61\154\x20\x4e\x6f\56\x20" . $model->no . "\40" . $model->title; $content = $this->renderPartial("\137\160\x72\151\x6e\164\x6f\x75\x74\x2f\x73\150\x6f\x77\x69\x6e\x67\x2d\x6c\151\x73\164", array("\150\145\x61\144\x65\162" => $model, "\144\x61\164\141" => $data, "\x64\x61\x74\x61\x53\157\167\151\x6e\147" => $dataSowing, "\162\145\155\x61\162\153\x73" => $remarks)); $header = $this->renderPartial("\x2f\137\160\x72\151\156\164\157\x75\x74\x2f\150\145\x61\x64\x65\162", array("\144\x6f\x63\137\156\157" => Trials::PRINTOUT_DOC_NO, "\x64\157\x63\x5f\165\x73\x65\x64\137\141\x74" => Trials::PRINTOUT_USED_AT, "\144\157\143\137\x74\x69\164\154\145" => Trials::PRINTOUT_DOC_TITLE, "\163\150\x6f\x77\x5f\x69\x73\x6f" => false)); $pdf = new Pdf(array("\155\157\144\145" => Pdf::MODE_CORE, "\146\x6f\x72\155\141\x74" => Pdf::FORMAT_A4, "\x6f\x72\x69\x65\156\164\141\x74\x69\157\x6e" => Pdf::ORIENT_PORTRAIT, "\x64\x65\163\164\151\156\141\164\x69\157\156" => Pdf::DEST_BROWSER, "\x6d\x61\162\x67\x69\x6e\124\x6f\160" => 37, "\x63\x6f\x6e\164\145\x6e\x74" => $content, "\x63\x73\x73\x46\151\x6c\145" => "\100\x61\160\x70\57\167\x65\142\57\143\163\x73\x2f\x5f\x70\x72\151\156\x74\x6f\165\x74\56\x63\x73\x73", "\157\x70\x74\x69\x6f\x6e\x73" => array("\x74\x69\164\x6c\x65" => "\113\162\x61\152\145\145\x20\122\145\160\x6f\x72\x74\40\124\151\x74\154\x65"), "\x6d\x65\x74\x68\157\x64\163" => array("\123\x65\x74\106\x6f\x6f\164\x65\162" => array("\x50\162\x69\156\164\145\x64\40\x62\171\x20" . Yii::$app->user->getIdentity()->pegawai->nama_pegawai . "\x20\x40" . date("\x44\54\x20\144\x20\x4d\x20\131\40\40\x48\72\x69\72\163") . "\x7c\174\x7b\120\x41\107\105\116\x4f\175"), "\123\145\164\x43\x72\145\x61\164\x6f\x72" => Yii::$app->name, "\x53\x65\x74\101\x75\164\150\x6f\x72" => Yii::$app->params["\x63\157\155\160\x61\x6e\x79\116\141\x6d\x65"], "\123\x65\x74\x53\165\142\152\x65\x63\x74" => "\x54\162\151\141\x6c\40\123\x6f\167\x69\x6e\147\40\x4c\151\163\x74", "\123\145\164\124\151\164\154\145" => $title), "\x66\151\x6c\145\156\x61\155\x65" => $title . "\56\x70\144\x66")); $mpdf = $pdf->getApi(); $mpdf->SetHTMLHeader($header); return $pdf->render(); } public function actionPrintOrder($id) { $header = $this->findModel($id); $data = Yii::$app->db->createCommand("\12\x20\40\40\40\40\x20\40\x20\x20\40\40\40\40\x20\x20\x20\x20\40\x20\40\x53\105\114\105\103\x54\x20\x74\x72\151\141\x6c\137\x69\144\54\x20\115\x49\x4e\x28\163\x65\x65\144\x5f\164\x6f\164\x61\x6c\51\x20\155\x69\x6e\x5f\x73\x65\145\144\54\x20\115\x41\x58\x28\163\145\145\x64\137\x74\x6f\x74\141\154\51\40\x6d\x61\x78\137\x73\x65\x65\x64\x2c\40\x73\x75\x6d\x28\x73\x65\145\144\137\164\x6f\164\141\154\51\x20\x70\x6f\x70\x75\x6c\x61\164\151\157\x6e\54\xa\40\x20\40\x20\x20\x20\x20\40\40\40\40\40\40\x20\x20\40\40\x20\40\40\x20\40\40\40\x63\157\165\x6e\164\50\x2a\51\x20\x74\x6f\x74\141\154\137\163\x65\145\x64\x2c\x20\163\x75\x6d\50\x63\x61\x73\145\40\x77\150\145\x6e\40\151\x73\x5f\143\157\x6d\x70\x61\x72\145\x20\x3d\40\x31\x20\164\150\x65\x6e\x20\x31\40\145\154\x73\145\x20\60\40\145\156\x64\51\x20\x63\157\155\160\141\x72\x65\137\x73\x65\145\x64\xa\x20\40\40\40\x20\x20\40\40\x20\40\40\40\x20\x20\x20\x20\40\40\x20\x20\x46\x52\117\x4d\x20" . TrialDetail::tableName() . "\x20\164\144\12\x20\x20\40\x20\40\40\x20\40\x20\x20\40\40\40\x20\x20\40\40\x20\40\40\127\110\105\x52\x45\40\x74\162\151\141\x6c\137\x69\144\x20\75\x20{$id}\xa\40\x20\x20\x20\x20\x20\40\x20\x20\x20\40\40\40\40\x20\x20\40\40\40\x20\x47\x52\x4f\125\x50\40\102\131\x20\164\x72\x69\x61\154\x5f\151\x64\12\40\x20\x20\x20\x20\x20\40\x20\40\x20\x20\x20\x20\40\40\40")->queryOne(); $title = "\x54\162\x69\x61\x6c\40\x4f\162\144\145\162\40\146\x72\x6f\x6d\40\124\x72\x69\x61\154\40\116\157\56\40" . $header->no . "\40" . $header->title; $content = $this->renderPartial("\x5f\x70\x72\151\x6e\164\157\165\164\57\164\x72\x69\141\x6c\55\x6f\x72\x64\145\x72", array("\x68\145\141\x64\x65\162" => $header, "\x64\x61\164\141" => (object) $data)); $header = $this->renderPartial("\57\137\160\162\151\x6e\x74\157\x75\x74\x2f\150\145\x61\144\x65\x72", array("\x64\157\x63\137\x6e\x6f" => Trials::PRINTOUT_TO_DOC_NO, "\x64\x6f\143\137\x75\x73\x65\x64\137\141\x74" => Trials::PRINTOUT_TO_USED_AT, "\x64\157\x63\x5f\x74\x69\164\x6c\x65" => Trials::PRINTOUT_TO_DOC_TITLE, "\x64\x6f\143\x5f\162\x65\x76" => Trials::PRINTOUT_TO_DOC_REV)); $pdf = new Pdf(array("\x6d\157\x64\x65" => Pdf::MODE_CORE, "\146\157\162\155\141\x74" => Pdf::FORMAT_A4, "\157\162\151\x65\x6e\164\x61\164\151\157\156" => Pdf::ORIENT_PORTRAIT, "\x64\145\x73\164\151\x6e\x61\164\x69\x6f\156" => Pdf::DEST_BROWSER, "\155\x61\162\x67\x69\156\x54\x6f\160" => 37, "\143\157\x6e\x74\145\156\164" => $content, "\x63\x73\163\106\151\154\x65" => "\100\x61\160\x70\x2f\167\x65\142\x2f\x63\163\163\x2f\137\160\162\x69\x6e\x74\x6f\165\164\x2e\x63\x73\163", "\x6f\160\x74\151\x6f\156\163" => array("\x74\x69\164\154\145" => "\x50\x54\x2e\x20\x42\x65\156\151\150\40\103\151\164\162\x61\40\x41\x73\151\141"), "\155\145\x74\150\x6f\144\x73" => array("\x53\x65\x74\x46\x6f\x6f\x74\x65\162" => array("\120\162\151\x6e\164\145\x64\x20\142\x79\x20" . Yii::$app->user->getIdentity()->pegawai->nama_pegawai . "\x20\x40" . date("\104\x2c\x20\x64\40\x4d\x20\131\x20\40\110\x3a\151\72\x73") . "\174\174\173\x50\x41\107\x45\116\117\x7d"), "\x53\x65\164\103\x72\145\x61\164\x6f\162" => Yii::$app->name, "\x53\x65\164\x41\x75\164\x68\157\162" => Yii::$app->params["\x63\157\155\160\x61\x6e\x79\116\x61\x6d\x65"], "\x53\145\164\x53\x75\142\x6a\145\143\x74" => "\124\x72\x69\x61\x6c\40\x4f\x72\144\145\162", "\123\x65\x74\124\151\164\154\145" => $title), "\x66\151\x6c\x65\156\x61\155\x65" => $title . "\56\160\144\146")); $mpdf = $pdf->getApi(); $mpdf->SetHTMLHeader($header); return $pdf->render(); } public function actionPrintExcel($id) { $this->layout = "\155\141\x69\x6e\x2d\x65\170\x63\x65\x6c"; $model = $this->findModel($id); $query = Trials::find()->alias("\164")->innerJoin(TrialDetail::tableName() . "\x20\x74\x64", "\x74\144\56\164\162\151\x61\x6c\137\x69\144\40\75\x20\164\56\151\144")->innerJoin(AccessionBook::tableName() . "\40\141\142", "\141\x62\56\151\144\x20\x3d\40\x74\x64\x2e\141\x63\143\x5f\151\x64")->select(array("\x61\142\56\151\x64", "\x61\x62\56\x6e\x6f", "\x61\142\56\146\x75\x6c\x6c\137\156\141\x6d\145", "\x61\142\56\160\141\x72\145\x6e\x74\163", "\164\x64\x2e\163\x65\x65\144\x5f\x64\142", "\164\144\56\x73\x65\x65\144\137\x74\157\164\x61\154"))->where(array("\x74\56\151\144" => $id)); $data = $query->asArray()->all(); $title = "\x46\x69\x65\x6c\x64\x20\114\x69\163\x74\x20\146\162\157\x6d\40\124\x72\151\141\154\40\116\x6f\56\40" . $model->no . "\x20" . $model->title; $header = $this->renderPartial("\x2f\x5f\160\162\151\156\164\x6f\165\164\x2f\x68\145\141\x64\x65\162", array("\x64\157\143\137\156\157" => Trials::PRINTOUT_FL_DOC_NO, "\144\x6f\143\x5f\x75\163\145\x64\x5f\x61\164" => Trials::PRINTOUT_FL_USED_AT, "\x64\x6f\x63\137\x74\151\164\x6c\145" => Trials::PRINTOUT_FL_DOC_TITLE, "\144\x6f\143\x5f\x72\145\x76" => Trials::PRINTOUT_FL_DOC_REV, "\x69\x73\x5f\x70\x64\146" => false)); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->getColumnDimension("\101")->setWidth(1.25, "\x63\x6d"); $sheet->getColumnDimension("\103")->setWidth(6.25, "\x63\155"); $sheet->getColumnDimension("\x44")->setWidth(10.0, "\143\155"); $row = 0; $sRow = $row; $sheet->setCellValue("\x41" . ++$row, "\x4e\x61\x6d\141\40\x42\x72\145\145\x64\145\x72"); $sheet->setCellValue("\x43{$row}", "\72\x20{$model->pegawai->nama_pegawai}"); $sheet->mergeCells("\101{$row}\72\102{$row}"); $sheet->mergeCells("\103{$row}\72\x44{$row}"); $sheet->setCellValue("\101" . ++$row, "\103\162\x6f\x70"); $sheet->setCellValue("\103{$row}", "\x3a\40{$model->crop->jns_tanaman}"); $sheet->mergeCells("\101{$row}\72\x42{$row}"); $sheet->mergeCells("\103{$row}\x3a\104{$row}"); $sheet->setCellValue("\101" . ++$row, "\x4b\157\x64\145\40\124\162\151\141\x6c"); $sheet->setCellValue("\x43{$row}", "\72\40{$model->no}"); $sheet->mergeCells("\x41{$row}\x3a\x42{$row}"); $sheet->mergeCells("\103{$row}\x3a\x44{$row}"); $sheet->setCellValue("\x41" . ++$row, "\x4a\165\144\165\154\x20\x54\x72\151\x61\154"); $sheet->setCellValue("\103{$row}", "\72\x20{$model->title}"); $sheet->mergeCells("\x41{$row}\x3a\102{$row}"); $sheet->mergeCells("\103{$row}\72\104{$row}"); $sheet->setCellValue("\x41" . ++$row, "\x54\x61\x72\x67\145\x74"); $sheet->setCellValue("\x43{$row}", "\x3a\40\x53\x65\154\146\151\x6e\x67\40\57\x20\123\151\x62\142\151\156\147\40\x2f\40\103\x72\157\163\x73\x69\x6e\147\x20\x2f\40\x4f\103\x20\x2f\40\x59\x69\145\154\x64\x20\104\141\164\141"); $sheet->mergeCells("\101{$row}\72\x42{$row}"); $sheet->mergeCells("\x43{$row}\72\104{$row}"); $style = $sheet->getStyle("\101{$sRow}\72\104{$row}"); $borders = $style->getBorders(); $borders->getAllBorders()->setBorderStyle(Border::BORDER_THIN); $row++; $sheet->setCellValue("\101" . ++$row, "\x4e\x6f"); $sheet->setCellValue("\x42{$row}", "\101\143\x63"); $sheet->setCellValue("\103{$row}", "\116\x61\x6d\x65"); $sheet->setCellValue("\x44{$row}", "\122\145\155\141\x72\153"); $sRow = $row; foreach ($data as $index => $item) { $sheet->setCellValue("\101" . ++$row, $index + 1); $sheet->setCellValue("\102{$row}", $item["\x6e\x6f"]); $sheet->setCellValue("\x43{$row}", $item["\146\165\154\x6c\x5f\x6e\141\155\145"] . "\15\xa" . $item["\160\141\x72\x65\156\164\x73"]); } $style = $sheet->getStyle("\x41{$sRow}\x3a\x44{$row}"); $borders = $style->getBorders(); $style->getAlignment()->setVertical("\x74\x6f\160"); $style->getAlignment()->setWrapText(true); $borders->getAllBorders()->setBorderStyle(Border::BORDER_THIN); $filePath = Yii::$app->runtimePath . "\57\x70\x68\160\55\x6f\146\x66\151\x63\145\57{$model->no}\x2e\x78\154\x73\170"; try { $writer = new Xlsx($spreadsheet); $this->createDir(Yii::$app->runtimePath . "\57\160\x68\160\55\x6f\146\146\151\143\x65"); $writer->save($filePath); $content = file_get_contents($filePath); } catch (Exception $e) { die($e->getMessage()); } header("\103\x6f\x6e\164\x65\x6e\164\55\104\x69\163\x70\157\163\151\164\x69\157\156\72\x20\x61\164\x74\141\x63\150\155\x65\156\x74\x3b\40\146\x69\x6c\145\x6e\141\155\x65\x3d" . $model->no . "\56\170\154\x73\x78"); unlink($filePath); die($content); } public function actionPrintFieldList($id, $spacing, $blank = 1) { $model = $this->findModel($id); $query = Trials::find()->alias("\164")->innerJoin(TrialDetail::tableName() . "\x20\x74\144", "\x74\144\56\x74\x72\151\x61\x6c\x5f\x69\x64\40\75\40\x74\56\x69\x64")->innerJoin(AccessionBook::tableName() . "\x20\141\142", "\141\x62\56\x69\144\40\x3d\x20\x74\x64\x2e\141\143\143\x5f\x69\x64")->select(array("\x61\x62\x2e\151\144", "\141\x62\x2e\x6e\157", "\141\x62\56\x66\165\154\x6c\137\156\x61\x6d\x65", "\x61\x62\x2e\x70\x61\162\145\156\164\x73", "\x74\x64\56\x73\145\145\144\137\144\142", "\164\x64\56\x73\x65\145\x64\x5f\x74\157\x74\141\x6c"))->where(array("\x74\56\151\144" => $id)); if (!$blank) { $query->innerJoin(VTrialFieldList::tableName() . "\x20\x76\x74", "\x76\x74\56\164\162\151\141\x6c\137\x69\144\40\x3d\x20\164\56\151\x64\40\141\x6e\144\40\166\164\56\x69\x64\40\x3d\x20\x74\x64\56\x61\x63\x63\x5f\x69\144")->addSelect("\x76\x74\x2e\x66\151\x65\154\x64\137\162\145\155\141\162\x6b"); } $data = $query->asArray()->all(); $title = "\x46\151\145\x6c\x64\40\114\151\163\164\40\146\162\x6f\x6d\40\x54\162\151\141\154\x20\x4e\157\56\40" . $model->no . "\x20" . $model->title; $content = $this->renderPartial("\x5f\160\162\x69\156\x74\x6f\165\164\57\x66\151\145\x6c\144\55\154\x69\x73\164", array("\x68\145\x61\144\145\x72" => $model, "\x64\x61\x74\141" => $data, "\163\160\x61\143\151\x6e\147" => $spacing)); $header = $this->renderPartial("\57\137\x70\x72\151\x6e\164\157\165\164\x2f\150\145\141\144\145\162", array("\x64\157\x63\137\x6e\x6f" => Trials::PRINTOUT_FL_DOC_NO, "\x64\x6f\143\137\165\163\145\144\137\x61\x74" => Trials::PRINTOUT_FL_USED_AT, "\x64\x6f\x63\137\x74\151\x74\154\145" => Trials::PRINTOUT_FL_DOC_TITLE, "\x64\157\x63\x5f\x72\145\166" => Trials::PRINTOUT_FL_DOC_REV)); $pdf = new Pdf(array("\x6d\157\144\x65" => Pdf::MODE_CORE, "\x66\x6f\162\155\141\x74" => Pdf::FORMAT_A4, "\157\162\x69\145\156\x74\141\x74\x69\157\156" => Pdf::ORIENT_PORTRAIT, "\x64\145\x73\x74\151\156\141\164\x69\x6f\x6e" => Pdf::DEST_BROWSER, "\x6d\x61\162\x67\x69\156\124\157\x70" => 37, "\x63\157\x6e\164\x65\156\164" => $content, "\x63\x73\163\x46\x69\x6c\x65" => "\100\x61\160\160\x2f\167\x65\142\x2f\143\x73\163\57\x5f\160\162\x69\156\164\157\165\x74\56\x63\x73\x73", "\157\160\164\x69\x6f\x6e\163" => array("\164\151\x74\154\145" => "\113\x72\141\x6a\145\x65\40\x52\145\160\157\162\164\x20\x54\151\x74\154\x65"), "\155\145\164\x68\157\144\x73" => array("\123\x65\x74\x46\x6f\x6f\x74\x65\x72" => array("\120\162\151\156\x74\145\x64\40\x62\171\x20" . Yii::$app->user->getIdentity()->pegawai->nama_pegawai . "\40\x40" . date("\x44\54\x20\x64\40\115\40\131\x20\x20\110\x3a\151\x3a\163") . "\x7c\x7c\173\x50\x41\x47\105\116\x4f\x7d"), "\123\x65\164\103\162\x65\x61\164\x6f\x72" => Yii::$app->name, "\123\x65\164\101\165\x74\x68\157\162" => Yii::$app->params["\x63\x6f\x6d\x70\141\156\171\116\x61\155\145"], "\123\145\x74\123\165\142\x6a\145\143\164" => "\x54\x72\x69\141\154\x20\x46\151\145\x6c\x64\40\x4c\x69\x73\x74", "\x53\145\x74\x54\151\x74\154\x65" => $title), "\146\151\154\x65\156\x61\x6d\x65" => $title . "\56\x70\x64\146")); $mpdf = $pdf->getApi(); $mpdf->SetHTMLHeader($header); return $pdf->render(); } public function actionGetTrialNo($cropId) { $request = Yii::$app->request; if ($request->isAjax && $request->isGet) { Yii::$app->response->format = Response::FORMAT_JSON; $modelTrial = new Trials(); $modelTrial->crop_id = $cropId; return array("\x74\x72\151\x61\x6c\137\x6e\157" => $modelTrial->createTrialNo($modelTrial, null)); } else { throw new ForbiddenHttpException("\x46\157\x72\142\151\x64\144\x65\156\x20\x52\145\x71\x75\145\x73\164\41"); } } public function actionTrialDetail($id) { Url::remember('', "\x74\162\x69\x61\154\163\x2d\164\x72\x69\141\x6c\55\x64\145\164\141\x69\154"); $searchModel = new TrialDetailSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $id); $searchModelDetail = new AccessionFieldSearch(array("\x74\162\151\x61\154\137\x69\144" => $id)); $dataProviderDetail = $searchModelDetail->search(Yii::$app->request->queryParams); $model = $this->findModel($id); return $this->render("\144\145\164\x61\151\154\57\x69\156\144\145\x78", array("\x6d\x6f\x64\x65\x6c" => $model, "\163\x65\x61\x72\143\150\115\x6f\144\145\154" => $searchModel, "\144\141\x74\x61\120\x72\x6f\x76\151\x64\x65\x72" => $dataProvider, "\163\x65\x61\x72\x63\150\115\157\x64\x65\x6c\104\145\x74\141\151\x6c" => $searchModelDetail, "\144\141\164\x61\x50\x72\x6f\166\x69\144\145\162\104\x65\164\141\x69\x6c" => $dataProviderDetail)); } public function actionAddTrialData($id) { $request = Yii::$app->request; $model = new AccessionFieldForm(); $modelTrial = $this->findModel($id); if ($request->isGet) { return $this->render("\x74\162\151\x61\x6c\55\x64\141\x74\x61\57\143\162\x65\141\x74\x65", array("\151\x64" => $id, "\155\157\144\x65\154" => $model, "\155\x6f\x64\145\x6c\x54\162\151\141\154" => $modelTrial)); } else { $model->load($request->post()); $srcFile = null; $saveDir = "\57\x61\x63\143\x65\x73\x73\x69\157\x6e\55\x66\x69\x65\154\144\x2f"; foreach ($model->acc_id as $acc) { $accField = new AccessionField(array("\x61\143\x63\x5f\151\144" => $acc, "\163\157\x75\x72\x63\145\137\162\145\146\146\x5f\151\x64" => MsReference::RC_ACC_FIELD_SOURCE_BREEDING_TRIAL, "\164\162\x69\141\x6c\137\x69\144" => $id, "\x63\x72\157\160\x5f\151\144" => $modelTrial->crop_id, "\160\150\x61\x73\x65\x5f\162\x65\146\146\x5f\x69\144" => $model->phase_reff_id, "\165\163\x65\162\x5f\x64\x61\x74\145" => $model->user_date)); $fields = explode("\73", $model->description); foreach ($fields as $field) { list($value, $param) = array_reverse(explode("\x3d", $field)); $accField->field_value_name = $param; $accField->field_value_text = $value; if (is_null($srcFile)) { $fileName = $srcFile = $this->saveFile("\x41\x63\143\145\163\163\x69\157\x6e\106\151\145\x6c\x64\x46\157\162\155\133\x70\x68\x6f\164\157\x5f\x66\151\154\145\x5d", $saveDir, null, "{$id}\55{$acc}"); } else { $fileName = $this->cloneFile("{$saveDir}", $srcFile, "{$id}\x2d{$acc}"); } $accField->photo_file = $fileName; $accField->isNewRecord = true; $accField->id = null; $accField->save(); } } $this->redirect(array("\x74\x72\x69\141\x6c\x2d\x64\x65\164\x61\151\154", "\151\x64" => $id)); } } public function actionAddTrialDataSingle($id) { $request = Yii::$app->request; $model = new AccessionField(); $modelTrial = $this->findModel($id); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { return array("\164\151\164\154\x65" => "\124\x61\155\142\x61\x68\40\104\x61\164\141\x20\x54\x72\x69\x61\154", "\143\157\x6e\164\145\x6e\164" => $this->renderAjax("\x74\162\151\x61\x6c\55\x64\x61\164\141\57\x63\162\145\x61\x74\145\55\x73\x69\156\147\x6c\x65", array("\155\x6f\x64\x65\154" => $model, "\155\157\144\145\154\x54\162\151\x61\154" => $modelTrial)), "\146\157\157\164\x65\x72" => Html::button("\x43\154\157\163\145", array("\143\154\x61\163\x73" => "\142\164\156\x20\x62\x74\156\x2d\144\145\146\141\x75\x6c\164\40\160\x75\154\154\x2d\154\x65\x66\x74", "\x64\141\164\x61\x2d\x64\x69\x73\155\151\163\x73" => "\155\x6f\x64\141\x6c")) . Html::button("\123\141\166\x65", array("\x63\x6c\141\163\x73" => "\142\x74\x6e\40\x62\164\156\55\160\162\x69\x6d\141\x72\171", "\x74\x79\160\145" => "\x73\x75\142\x6d\151\164"))); } else { if ($request->isPost) { $fieldLists = $request->post("\x46\151\x65\154\144\x4c\151\163\x74\x73"); $error = false; $transaction = Yii::$app->db->beginTransaction(); $saveDir = "\x2f\x61\143\143\145\163\163\x69\x6f\x6e\x2d\x66\x69\145\154\144\x2f"; try { $modelAccField = array(); foreach ($fieldLists as $index => $field) { $tModel = new AccessionField(); $tModel->load($request->post()); $tModel->source_reff_id = AccessionField::SOURCE_REFF_TRIAL_ID; $tModel->trial_id = $id; $tModel->crop_id = $modelTrial->crop_id; $tModel->field_value_name = $field["\x66\151\x65\x6c\x64\137\166\x61\154\x75\145\137\156\x61\155\x65"]; $tModel->field_value_text = $field["\x66\151\145\x6c\x64\137\x76\x61\154\165\x65\137\164\145\170\164"]; if (!$tModel->save(false)) { $error = true; break; } else { $fileName = $this->saveFile("\x46\151\x65\x6c\x64\x4c\151\163\164\x73\133{$index}\x5d\x5b\x66\x69\x65\154\x64\137\x70\150\157\x74\x6f\x5f\146\151\154\x65\135", $saveDir, null, "\x69\144\137" . $tModel->id); if ($fileName === false) { $error = true; break; } else { $tModel->photo_file = $fileName; $tModel->save(false); $modelAccField[] = $tModel; } } } if ($error) { $transaction->rollBack(); } else { $transaction->commit(); } } catch (Exception $e) { $transaction->rollBack(); Yii::$app->response->format = Response::FORMAT_HTML; throw new ServerErrorHttpException("\124\x65\x72\x6a\x61\144\x69\40\x6b\x65\x73\141\x6c\141\x68\x61\x6e\x20\x64\x61\154\141\x6d\40\155\x65\155\x70\162\157\163\145\x73\40\x64\141\164\x61\x20\146\x69\145\154\x64\40\154\x69\163\x74", 0, $e); } return array("\146\x6f\162\x63\145\122\145\154\x6f\141\x64" => "\43\x63\162\165\144\55\x64\x61\164\x61\164\x61\x62\154\x65\55\x64\x61\x74\141\55\160\152\141\170", "\164\x69\164\154\145" => "\124\141\155\x62\x61\x68\x20\104\141\x74\141\x20\124\162\151\x61\x6c", "\x63\157\x6e\164\145\x6e\x74" => "\74\x73\160\141\x6e\40\x63\x6c\x61\163\x73\x3d\x22\x74\x65\x78\164\55\163\x75\143\x63\x65\x73\163\x22\76\124\x61\x6d\x62\141\150\40\104\141\x74\x61\x20\124\x72\151\141\x6c\x20\102\x65\x72\150\141\x73\151\154\74\57\163\x70\141\156\x3e", "\x66\157\157\164\x65\x72" => Html::button("\x43\x6c\157\163\145", array("\x63\154\x61\x73\163" => "\x62\164\156\40\142\164\x6e\55\x64\145\x66\141\165\x6c\164\x20\160\x75\154\x6c\x2d\154\145\x66\164", "\144\141\x74\x61\55\144\151\163\155\x69\163\x73" => "\155\x6f\144\x61\154")) . Html::a("\103\x72\145\141\164\x65\x20\x4d\157\x72\145", array("\141\x64\x64\x2d\x74\162\151\141\x6c\55\144\x61\x74\141\x2d\163\x69\156\x67\154\145", "\151\144" => $id), array("\143\154\141\x73\163" => "\142\164\156\40\142\164\x6e\x2d\x70\162\151\x6d\141\162\171", "\162\157\x6c\145" => "\x6d\157\144\141\x6c\55\162\x65\155\157\x74\145"))); } else { return array("\x74\151\x74\x6c\145" => "\124\x61\155\x62\x61\150\40\104\x61\164\x61\x20\x54\x72\x69\x61\x6c", "\x63\157\x6e\164\x65\x6e\x74" => $this->renderAjax("\x74\162\x69\x61\154\x2d\144\141\x74\x61\x2f\x63\x72\145\141\x74\x65\55\163\151\156\x67\x6c\x65", array("\155\157\144\x65\x6c" => $model, "\x6d\x6f\x64\x65\x6c\x54\162\151\x61\154" => $modelTrial)), "\x66\157\157\164\145\162" => Html::button("\103\x6c\157\163\x65", array("\x63\x6c\141\x73\x73" => "\142\164\156\x20\142\164\x6e\55\x64\145\x66\x61\x75\x6c\164\x20\x70\x75\154\x6c\x2d\x6c\x65\x66\x74", "\144\141\164\x61\x2d\x64\151\x73\x6d\151\163\x73" => "\x6d\x6f\x64\x61\x6c")) . Html::button("\123\141\166\145", array("\143\x6c\141\x73\x73" => "\x62\164\x6e\40\x62\x74\156\x2d\160\x72\151\155\x61\x72\x79", "\x74\171\x70\x65" => "\x73\165\142\155\x69\164"))); } } } else { throw new ForbiddenHttpException("\x52\145\161\x75\x65\163\x74\40\x74\171\x70\x65\40\156\157\164\x20\x61\154\x6c\157\167\145\x64\41"); } } public function actionUpdateAccField($id) { $request = Yii::$app->request; $model = $this->findModelAccField($id); $modelTrial = $model->trial; $model->crop_id = $modelTrial->crop_id; if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { return array("\164\151\x74\x6c\145" => "\x55\x70\x64\141\x74\x65\40\x44\141\x74\141\40\124\x72\x69\141\x6c", "\x63\x6f\x6e\164\x65\x6e\164" => $this->renderAjax("\x74\x72\x69\141\154\x2d\144\141\x74\141\x2f\x75\x70\144\x61\x74\145", array("\x6d\157\x64\x65\154" => $model, "\155\x6f\144\145\154\124\x72\151\141\154" => $modelTrial)), "\x66\x6f\157\164\145\162" => Html::button("\103\x6c\157\163\145", array("\143\x6c\x61\163\x73" => "\142\164\x6e\x20\142\164\x6e\x2d\x64\x65\x66\141\x75\x6c\x74\x20\160\x75\154\154\x2d\x6c\x65\x66\x74", "\x64\x61\x74\141\55\144\151\x73\x6d\x69\163\x73" => "\x6d\157\x64\141\154")) . Html::button("\123\x61\166\145", array("\143\154\141\x73\x73" => "\x62\x74\156\40\142\x74\156\55\160\162\151\155\x61\x72\171", "\164\171\x70\x65" => "\163\165\142\155\151\x74"))); } else { if ($request->isPost) { $transaction = Yii::$app->db->beginTransaction(); try { $oriFile = $model->photo_file; $saveDir = "\x2f\x61\x63\143\145\163\163\151\x6f\156\x2d\146\x69\x65\154\144\57"; if ($model->load($request->post()) && $model->save(false)) { $model->photo_file = $this->saveFile("\x41\143\x63\145\x73\163\151\x6f\156\x46\x69\x65\x6c\144\133\160\x68\x6f\x74\157\x5f\146\x69\x6c\145\x5d", $saveDir, $oriFile, "\151\144\x2d{$id}"); $model->save(false); $transaction->commit(); return array("\146\157\x72\x63\145\103\154\x6f\163\145" => true, "\x66\157\x72\143\145\122\x65\x6c\157\141\144" => "\x23\x63\x72\165\x64\x2d\144\141\164\141\164\141\x62\x6c\x65\55\x64\x61\x74\x61\55\160\152\141\x78"); } } catch (Exception $e) { $transaction->rollBack(); Yii::$app->response->format = Response::FORMAT_HTML; throw new ServerErrorHttpException("\x54\x65\x72\152\141\x64\x69\40\153\x65\163\141\154\x61\x68\141\x6e\x20\x64\x61\154\x61\x6d\x20\155\145\156\x67\x75\x62\x61\150\40\x64\x61\x74\x61\x2e", 0, $e); } } else { return array("\164\x69\x74\x6c\145" => "\125\160\144\141\x74\x65\x20\104\141\164\141\x20\124\162\x69\141\x6c", "\x63\157\156\x74\x65\156\x74" => $this->renderAjax("\x74\162\x69\141\154\x2d\x64\x61\x74\x61\57\165\x70\144\x61\164\x65", array("\x6d\157\144\x65\x6c" => $model, "\155\x6f\144\x65\x6c\x54\162\151\x61\154" => $modelTrial)), "\x66\x6f\157\164\x65\x72" => Html::button("\x43\x6c\157\163\x65", array("\x63\154\x61\x73\x73" => "\x62\x74\x6e\x20\142\x74\x6e\55\144\145\146\141\x75\154\x74\40\160\x75\x6c\154\55\154\145\x66\164", "\144\x61\164\x61\x2d\x64\151\163\x6d\x69\x73\x73" => "\x6d\157\x64\141\x6c")) . Html::button("\123\141\x76\x65", array("\x63\154\x61\x73\x73" => "\x62\x74\156\x20\142\x74\156\x2d\160\162\151\x6d\141\162\171", "\164\171\160\145" => "\163\x75\142\155\151\x74"))); } } } else { throw new ForbiddenHttpException("\x52\145\x71\165\x65\163\164\40\164\171\160\x65\40\x6e\x6f\x74\40\141\x6c\154\157\167\145\x64\x21"); } } public function actionUpdateAcc($id) { $request = Yii::$app->request; $model = $this->findModelTrialDetail($id); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; if ($request->isGet) { return array("\x74\151\x74\154\145" => "\x55\160\144\x61\164\x65\x20\104\x61\x74\x61\40\43" . $model->acc->no, "\x63\x6f\x6e\164\x65\156\x74" => $this->renderAjax("\144\145\x74\x61\151\154\x2f\x61\x63\143\55\x6c\151\x73\164\x2f\165\x70\x64\141\164\145", array("\x69\144" => $id, "\x6d\157\144\x65\x6c" => $model)), "\x66\157\157\x74\145\162" => Html::button("\x43\154\x6f\x73\x65", array("\x63\x6c\141\x73\163" => "\x62\x74\156\x20\x62\164\x6e\55\144\x65\146\x61\165\x6c\164\x20\x70\165\x6c\x6c\x2d\x6c\145\146\x74", "\144\141\164\x61\x2d\x64\151\x73\155\x69\163\x73" => "\155\157\144\141\x6c")) . Html::button("\123\141\166\145", array("\x63\154\x61\x73\163" => "\x62\x74\156\40\142\x74\156\x2d\160\162\151\155\x61\162\x79", "\164\x79\160\145" => "\163\x75\142\x6d\x69\164"))); } else { if ($model->load($request->post()) && $model->save()) { return array("\146\x6f\x72\x63\145\103\x6c\157\x73\145" => true, "\146\157\162\143\x65\122\x65\x6c\157\x61\144" => "\43\143\x72\165\x64\55\144\x61\x74\x61\164\141\x62\154\x65\55\x70\x6a\x61\x78"); } else { return array("\164\x69\x74\154\x65" => "\x55\160\144\x61\x74\145\40\101\153\163\145\x73\x69\40\x23" . $model->acc->no, "\x63\x6f\x6e\x74\145\156\x74" => $this->renderAjax("\x64\145\x74\141\151\154\x2f\x61\x63\143\55\x6c\x69\163\x74\57\x75\x70\x64\x61\164\145", array("\151\144" => $id, "\x6d\157\144\x65\x6c" => $model)), "\x66\157\x6f\x74\x65\162" => Html::button("\x43\x6c\x6f\x73\x65", array("\x63\154\141\163\x73" => "\142\x74\156\40\x62\164\156\x2d\x64\x65\146\x61\x75\x6c\x74\x20\x70\165\x6c\154\x2d\154\145\x66\x74", "\x64\141\164\x61\55\x64\151\163\155\151\x73\x73" => "\155\x6f\x64\141\154")) . Html::button("\x53\x61\166\x65", array("\x63\x6c\141\163\163" => "\142\x74\156\x20\142\x74\156\x2d\160\x72\151\155\x61\x72\171", "\164\171\x70\x65" => "\163\x75\142\155\x69\164"))); } } } else { $this->redirect(array("\164\x72\151\141\154\x2d\x64\145\164\x61\151\154", "\151\144" => $id)); } } public function actionAddAcc($id, $cropId) { $request = Yii::$app->request; $params = $request->queryParams; $params["\x54\x72\x69\141\x6c\x41\143\143\102\x6f\157\153\123\145\141\x72\x63\x68"]["\x63\x72\157\x70\137\x69\144"] = $cropId; $params["\x54\x72\x69\141\x6c\x41\x63\143\102\x6f\157\x6b\x53\x65\x61\x72\143\150"]["\164\162\151\x61\x6c\x5f\151\x64"] = $id; $searchModel = new TrialAccBookSearch(); $dataProvider = $searchModel->search($params); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("\164\x69\164\154\145" => "\124\x61\155\142\x61\150\40\101\x6b\x73\x65\x73\x69", "\143\x6f\x6e\x74\x65\156\164" => $this->renderAjax("\141\x63\x63\x2d\142\x6f\x6f\153\x2f\151\x6e\x64\x65\x78", array("\151\144" => $id, "\143\162\x6f\x70\111\144" => $cropId, "\163\x65\x61\162\x63\x68\x4d\x6f\x64\x65\154" => $searchModel, "\x64\x61\164\x61\120\x72\x6f\x76\151\144\145\x72" => $dataProvider))); } else { $this->redirect(array("\x74\162\151\x61\x6c\55\144\x65\164\141\151\x6c", "\151\x64" => $id)); } } public function actionUpdateMultiple($id) { $request = Yii::$app->request; $model = $this->findModel($id); $data = $model->trialDetail; if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; $errors = array(); if ($request->isPost) { $data = array(); $dataPost = $request->post("\124\162\x69\141\x6c\104\x61\x74\x61\101\143\x63"); foreach ($dataPost as $item) { $trialDetail = $this->findModelTrialDetail($item["\124\x72\151\x61\x6c\x44\145\164\141\151\x6c"]["\151\144"]); $trialDetail->load($item); if (!$trialDetail->save()) { $errors[] = $trialDetail->errors; } $data[] = $trialDetail; } if (!count($errors)) { return array("\146\157\162\143\145\x43\x6c\x6f\x73\x65" => true, "\x66\x6f\x72\x63\x65\122\x65\x6c\157\141\x64" => "\43\143\x72\165\144\55\x64\141\x74\x61\164\x61\x62\x6c\x65\55\160\152\141\170"); } } return array("\x74\151\x74\154\145" => "\x55\x70\x64\141\x74\145\x20\x41\x6b\x73\x65\x73\151", "\x63\x6f\x6e\164\x65\156\x74" => $this->renderAjax("\144\145\x74\x61\x69\x6c\57\141\143\143\x2d\154\151\x73\x74\x2f\x75\160\x64\x61\164\x65\55\x6d\165\154\164\x69\x70\154\145", array("\151\144" => $id, "\x64\141\x74\141" => $data)), "\145\162\x72\157\162\163" => $errors, "\x66\x6f\x6f\x74\x65\x72" => Html::button("\x43\154\x6f\x73\145", array("\143\154\141\163\163" => "\142\x74\x6e\x20\x62\164\x6e\x2d\x64\145\146\x61\x75\154\x74\40\x70\x75\x6c\x6c\55\x6c\145\146\x74", "\x64\141\164\x61\55\x64\151\163\x6d\151\x73\163" => "\x6d\157\x64\x61\x6c")) . Html::button("\x53\141\x76\x65", array("\x63\154\x61\163\163" => "\142\x74\x6e\40\x62\164\156\55\x70\162\151\155\141\x72\x79", "\x74\x79\x70\145" => "\163\x75\x62\155\x69\164"))); } else { throw new ForbiddenHttpException("\x52\145\x71\165\145\163\x74\40\x4e\x6f\164\x20\101\154\x6c\x6f\x77\145\144"); } } public function actionAddAccSingle($masterId, $id) { $request = Yii::$app->request; if ($request->isAjax && $request->isPost) { Yii::$app->response->format = Response::FORMAT_JSON; $modelTrialDetail = new TrialDetail(); $modelTrialDetail->scenario = "\151\156\163\145\x72\x74"; $modelTrialDetail->acc_id = $id; $modelTrialDetail->trial_id = $masterId; if ($modelTrialDetail->save()) { return array("\146\157\x72\143\x65\122\145\154\x6f\141\144" => "\x23\x63\162\x75\x64\x2d\x64\x61\x74\141\164\x61\x62\154\145\x2d\x70\152\141\x78", "\x66\x6f\162\143\x65\122\x65\x6c\x6f\141\144\x55\x72\154" => Url::previous("\x74\x72\x69\141\x6c\163\55\164\162\x69\141\x6c\55\x64\x65\164\141\151\154"), "\146\x6f\x72\x63\145\103\154\x6f\163\145" => true); } else { return array("\x74\x69\164\154\x65" => "\124\141\x6d\142\141\x68\x20\101\153\163\x65\163\151", "\x63\x6f\156\x74\145\156\164" => "\74\x73\160\x61\x6e\x20\143\154\x61\x73\163\75\42\164\145\x78\164\55\144\141\x6e\x67\x65\162\42\76\x54\141\x6d\142\141\150\x20\x41\x6b\163\145\163\151\40\147\141\147\x61\x6c\x21\x3c\x2f\x73\160\141\156\x3e", "\146\x6f\157\x74\145\162" => Html::button("\x43\154\157\x73\x65", array("\143\x6c\141\163\x73" => "\x62\x74\156\40\142\x74\x6e\x2d\x64\x65\146\141\165\154\x74\x20\160\x75\x6c\x6c\55\x6c\145\146\x74", "\x64\x61\x74\x61\55\x64\151\x73\x6d\x69\x73\163" => "\155\x6f\x64\x61\x6c"))); } } else { throw new ForbiddenHttpException("\x52\x65\x71\x75\x65\163\x74\x20\116\x6f\x74\40\x41\x6c\x6c\x6f\x77\145\x64"); } } public function actionAddAccMultiple($masterId) { $request = Yii::$app->request; if ($request->isAjax && $request->isPost) { Yii::$app->response->format = Response::FORMAT_JSON; $flag = false; $pks = explode("\54", $request->post("\x70\x6b\x73")); $modelTrialDetail = new TrialDetail(); $modelTrialDetail->trial_id = $masterId; foreach ($pks as $pk) { $modelTrialDetail->isNewRecord = true; $modelTrialDetail->id = null; $modelTrialDetail->acc_id = $pk; if (!($flag = $modelTrialDetail->save())) { break; } } if ($flag) { return array("\x66\157\x72\x63\x65\122\x65\154\157\141\144" => "\x23\x63\x72\x75\144\x2d\x64\x61\164\141\164\141\x62\154\x65\x2d\160\x6a\141\170", "\x66\x6f\x72\143\x65\x52\x65\x6c\x6f\x61\x64\x55\x72\x6c" => Url::previous("\164\x72\x69\x61\x6c\x73\x2d\x74\162\151\x61\x6c\55\x64\145\164\x61\151\x6c"), "\x66\157\x72\x63\x65\x43\x6c\x6f\x73\x65" => true); } else { return array("\164\x69\x74\154\145" => "\x54\141\x6d\x62\141\x68\x20\x41\153\163\x65\x73\151", "\x63\157\156\x74\x65\156\164" => "\74\x73\x70\141\156\40\143\154\x61\163\x73\x3d\42\x74\145\x78\164\55\x64\x61\156\x67\x65\x72\x22\x3e\x54\141\x6d\x62\x61\150\40\x41\x6b\x73\x65\163\x69\x20\147\141\x67\x61\x6c\41\x3c\57\163\x70\x61\x6e\x3e" . json_encode($modelTrialDetail->errors), "\x66\x6f\x6f\x74\x65\162" => Html::button("\103\154\x6f\x73\145", array("\143\154\x61\x73\x73" => "\142\164\156\x20\x62\x74\x6e\55\x64\145\146\x61\x75\154\x74\40\160\165\x6c\x6c\x2d\154\x65\146\164", "\x64\141\164\141\x2d\x64\x69\163\155\x69\x73\163" => "\x6d\x6f\x64\x61\x6c"))); } } else { throw new ForbiddenHttpException("\x52\145\x71\x75\145\163\x74\40\116\157\164\x20\101\x6c\x6c\157\167\x65\x64"); } } public function actionDeleteAcc($id) { $request = Yii::$app->request; $this->findModelTrialDetail($id)->delete(); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("\146\x6f\162\143\x65\103\x6c\x6f\x73\x65" => true, "\x66\157\x72\x63\145\122\x65\x6c\x6f\x61\x64" => "\x23\143\x72\x75\144\55\144\x61\x74\141\x74\x61\x62\154\145\55\160\x6a\141\x78"); } else { return $this->redirect(array("\x69\156\x64\x65\x78")); } } public function actionBulkdeleteAcc() { $request = Yii::$app->request; $pks = explode("\54", $request->post("\160\153\x73")); foreach ($pks as $pk) { $model = $this->findModelTrialDetail($pk); $model->delete(); } if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("\146\x6f\x72\x63\145\103\154\157\x73\145" => true, "\x66\x6f\x72\x63\145\x52\x65\154\x6f\141\144" => "\x23\x63\x72\165\144\x2d\144\141\164\x61\x74\x61\142\x6c\x65\55\x70\152\x61\170"); } else { return $this->redirect(array("\x69\156\x64\145\x78")); } } public function actionDeleteAccField($id) { $request = Yii::$app->request; $this->findModelAccField($id)->delete(); if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("\146\157\x72\x63\x65\x43\x6c\157\163\x65" => true, "\146\157\x72\x63\x65\122\x65\x6c\x6f\x61\x64" => "\43\x63\162\165\x64\x2d\144\x61\164\x61\164\x61\142\x6c\x65\x2d\x64\x61\164\141\55\160\x6a\x61\170"); } else { return $this->redirect(array("\x69\x6e\x64\145\170")); } } public function actionBulkdeleteAccField() { $request = Yii::$app->request; $pks = explode("\54", $request->post("\x70\x6b\x73")); foreach ($pks as $pk) { $model = $this->findModelAccField($pk); $model->delete(); } if ($request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return array("\146\157\x72\143\x65\x43\154\x6f\x73\x65" => true, "\146\157\x72\143\145\122\145\x6c\157\x61\x64" => "\x23\143\x72\x75\x64\x2d\x64\141\164\x61\164\141\142\154\145\55\144\141\164\x61\55\x70\x6a\x61\170"); } else { return $this->redirect(array("\151\156\144\x65\x78")); } } public function actionTrialList($q = null) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $out = array("\x72\x65\163\165\x6c\164\x73" => array("\151\144" => '', "\164\x65\170\x74" => '')); $query = Trials::find()->filterWhere(array("\x6c\x69\x6b\x65", "\x63\157\x6e\x63\141\164\x28\156\157\x2c\40\164\x69\x74\154\x65\x29", $q))->select(array("\151\x64", "\x63\162\157\x70\x5f\151\x64", "\143\x6f\156\x63\141\164\50\156\x6f\x2c\x20\x27\x20\55\40\x27\54\40\164\x69\164\154\x65\x29\40\141\x73\40\x74\x65\x78\164"))->orderBy("\x69\x64\40\144\145\163\143")->limit(10); if (!is_null($q)) { $data = $query->asArray()->all(); $out["\162\x65\163\165\154\x74\x73"] = array_values($data); } else { $data = $query->asArray()->all(); $out["\x72\145\163\x75\154\x74\x73"] = array_values($data); } return $out; } public function actionGetDetail($id) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $model = Trials::find()->where(array("\x69\x64" => $id))->one(); $result = ArrayHelper::toArray($model); $result["\x6c\157\143\x61\x74\x69\157\x6e\137\164\x79\x70\x65"] = $model->location->locTypeReff->name; $result["\154\x6f\x63\x61\164\x69\x6f\x6e"] = $model->location->name; $result["\143\162\x6f\x70\x5f\x61\147\145"] = CropLocationAge::find()->where(array("\x63\162\x6f\160\137\151\x64" => $model["\x63\x72\157\160\137\151\x64"], "\x6c\157\143\137\x74\171\160\x65\x5f\162\x65\146\146\137\151\x64" => $model->location->locTypeReff->id))->one()->age; $result["\143\x72\157\160"] = $model->crop->jns_tanaman; return $result; } protected function findModel($id) { $query = Trials::find()->where(array("\x69\144" => $id)); if ($this->isAsistantManger()) { $query->andFilterWhere(array("\143\162\x6f\x70\137\x69\144" => $this->cropList)); } else { $query->andFilterWhere(array("\x70\x65\147\141\167\141\x69\137\151\x64" => $this->pegawaiId)); } if (($model = $query->one()) !== null) { return $model; } else { throw new NotFoundHttpException("\124\x68\x65\40\162\x65\x71\x75\x65\x73\x74\x65\x64\40\x70\141\x67\145\x20\x64\157\145\163\x20\156\157\x74\40\x65\x78\x69\x73\164\56"); } } protected function findModelRemarkField($id) { if (count($model = VTrialFieldList::findAll(array("\x74\x72\151\141\x6c\137\151\x64" => $id))) !== 0) { return $model; } else { throw new NotFoundHttpException("\124\150\x65\40\162\145\x71\x75\x65\163\x74\x65\144\40\x70\x61\x67\145\40\144\157\145\x73\40\156\x6f\164\x20\145\170\x69\163\x74\56"); } } protected function findModelAccField($id) { if (($model = AccessionField::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException("\124\x68\145\x20\x72\x65\161\x75\x65\163\x74\145\x64\40\x70\x61\147\145\x20\x64\157\x65\x73\x20\156\x6f\x74\40\x65\x78\151\x73\164\x2e"); } } protected function findModelTrialData($id) { $data = TrialDetailForm::find()->alias("\x74\x66")->leftJoin(array("\141\146" => AccessionField::find()->select(array("\141\x63\143\x5f\151\144", "\143\x6f\165\156\x74\x28\52\51\x20\141\163\40\146\151\x65\x6c\144\137\x74\x6f\164\x61\154"))->where(array("\x74\x72\151\x61\x6c\137\x69\144" => $id))->groupBy("\141\x63\x63\x5f\151\144")), "\x61\146\x2e\x61\x63\143\137\x69\144\40\x3d\40\164\x66\56\141\x63\143\x5f\x69\144")->where(array("\x74\162\151\141\154\137\151\x64" => $id))->orderBy("\x61\146\x2e\x66\x69\145\x6c\144\137\164\157\x74\x61\154\40\144\x65\163\143")->all(); if (count($data)) { return $data; } else { throw new NotFoundHttpException("\x54\150\x65\x20\162\145\161\165\145\x73\164\x65\x64\x20\160\x61\147\145\x20\x64\157\x65\163\40\156\157\164\40\x65\170\151\x73\x74\x2e"); } } protected function findModelTrialDetail($id) { if (($model = TrialDetail::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException("\x54\150\x65\x20\162\145\x71\165\x65\163\164\x65\144\x20\x70\x61\x67\145\x20\x64\157\x65\163\40\156\x6f\164\x20\145\x78\151\x73\x74\x78\x20" . $id); } } }

Function Calls

None

Variables

None

Stats

MD5 03bbd1de841a7447a20300b5d0c52480
Eval Count 0
Decode Time 79 ms