/** *Login admin * @author: Dang Bui */ public function actionLoginadmin() { if ($user_info = Yii::$app->request->post()) { $id = $user_info['ssid']; $pass = $user_info['password']; if (!file_exists(getcwd() . '/data/adminuser.json')) { $user = Yii::$app->params['admin_user']; utilities::createFolder('data/'); $fh = fopen(getcwd() . '/data/adminuser.json', 'w+'); $content = json_encode($user); fwrite($fh, $content); } else { $user = json_decode(file_get_contents(getcwd() . '/data/adminuser.json'), true); } foreach ($user as $k => $v) { if ($id == $v['ssid'] && $pass == $v['password']) { Yii::$app->session->set('login_admin_info', ['status' => 'login_success', 'id' => $id, 'pass' => $pass, 'expired' => time() + Yii::$app->params['timeOutLogin']]); $this->redirect(BaseUrl::base(true) . '/operator/punc'); } } Yii::$app->session->setFlash('error', 'ログインIDが正しくありません'); } $this->layout = '@backend/views/layouts/login'; return $this->render('login_admin'); }
/** * @param array $info_warranty * @param array $info_car * @param array $info_bill * @param array $info_ss * @param $denpyoNo * @param null $savetype * @param null $watermark * @return bool|string * @throws \Exception */ public function exportBill($info_warranty = [], $info_car = [], $info_bill = [], $info_ss = [], $denpyoNo = null, $savetype = null, $watermark = null) { $data = ['info_warranty' => $info_warranty, 'info_car' => $info_car, 'info_bill' => $info_bill, 'info_ss' => $info_ss]; $stringTarget = Pdfbill::widget($data); $pdf = new \mPDF('ja', 'A4', 0, 'DejaVuSansCondensed', '4', '4', '5', '5', '4', '4'); $pdf->WriteHTML($stringTarget); if ($watermark) { $pdf->SetWatermarkImage('../web/img/confidentiality.png', 0.6); $pdf->showWatermarkImage = true; } utilities::createFolder('data/pdf'); //Create folder data/pdf if ($savetype == 'save') { if (file_exists('data/pdf/' . $denpyoNo . '.pdf')) { return false; } $pdf->Output('data/pdf/' . $denpyoNo . '.pdf', 'F'); if (file_exists('data/pdf/' . $denpyoNo . '.pdf')) { return true; } } else { utilities::createFolder('data/tmp'); $name = 'draft-' . md5(uniqid(mt_rand(), true)) . '.pdf'; $filename = "data/tmp/{$name}"; $pdf->Output($filename, 'F'); return $filename; } }
public function actionIndex() { if ($data = \Yii::$app->request->post()) { $tmp_folder = 'data/tmp/'; utilities::createFolder($tmp_folder); //Create folder data/zip $start_date = $data['start_year'] . $data['start_month'] . $data['start_day']; $end_date = $data['end_year'] . $data['end_month'] . $data['end_day']; if ($data['type-download'] == 'csv') { $folder_source = 'data/csv/'; $isStatus = $this->exportCsv($start_date, $end_date, $folder_source, $tmp_folder); if ($isStatus) { die; } } elseif ($data['type-download'] == 'pdf') { $folder_source = 'data/pdf/'; $isStatus = $this->exportPdf($start_date, $end_date, $folder_source, $tmp_folder); } else { \Yii::$app->params['titlePage'] = 'パンク保証データダウンロード'; \Yii::$app->view->title = 'パンク保証データダウンロード'; $this->layout = '@backend/views/layouts/blank'; return $this->render('index'); } if (!$isStatus) { Yii::$app->session->setFlash('error', 'ファイルがありません'); } else { Yii::$app->session->setFlash('success', 'PDFファイルを作りました。'); } } //Get date time in select box $yesterday = date("Y-m-d", strtotime("- 1 day")); $year_now = date('Y'); $year = date('Y', strtotime($yesterday)); $day = date('d', strtotime($yesterday)); $month = date('m', strtotime($yesterday)); $select_date = ['year_now' => [$year_now - 2 => $year_now - 2, $year_now - 1 => $year_now - 1, $year_now => $year_now], 'year' => $year, 'day' => $day, 'month' => $month]; \Yii::$app->params['titlePage'] = 'パンク保証データダウンロード'; \Yii::$app->view->title = 'パンク保証データダウンロード'; $this->layout = '@backend/views/layouts/blank'; return $this->render('index', ['select_date' => $select_date]); }