/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Employees::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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, 'sex' => $this->sex, 'birthdate' => $this->birthdate, 'tumbon' => $this->tumbon, 'ampur' => $this->ampur, 'chw' => $this->chw, 'department_id' => $this->department_id, 'comein' => $this->comein, 'status' => $this->status]); $query->andFilterWhere(['like', 'cid', $this->cid])->andFilterWhere(['like', 'pname', $this->pname])->andFilterWhere(['like', 'fname', $this->fname])->andFilterWhere(['like', 'lname', $this->lname])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'education', $this->education])->andFilterWhere(['like', 'ability', $this->ability])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'avatar', $this->avatar]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Employees::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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->where('employee_status=\'Y\''); $query->andFilterWhere(['employee_id' => $this->employee_id]); $query->orFilterWhere(['like', 'employee_title', $this->employee_name]); $query->orFilterWhere(['like', 'employee_code', $this->employee_name]); $query->orFilterWhere(['like', 'employee_name', $this->employee_name]); $query->andFilterWhere(['like', 'employee_status', $this->employee_status]); return $dataProvider; }
/** * Updates an existing Transactions model. * If update is successful, the browser will be redirected to the 'view' page. * @param string $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post())) { $data = Yii::$app->request->post(); $_tanggal = explode("/", $data["Transactions"]["trans_date"]); $transaction_date = $_tanggal[2] . '-' . $_tanggal[1] . '-' . $_tanggal[0]; $transaction_id = $id; // HEADER if (sizeof($data["item"]["code"]) > 0) { $transaction_id = $this->_saveHeader('update', $id, $transaction_date, $data["Transactions"]["trans_employee"], array_sum($data["item"]["price"])); $this->_deleteDetail($id); for ($i = 0; $i < sizeof($data["item"]["code"]); $i++) { $transactions = $this->_saveDetail($id, $data["item"]["code"][$i], $data["item"]["qty"][$i], $data["item"]["price"][$i]); } } Yii::$app->session->setFlash('success', 'Transaksi berhasil disimpan'); return $this->redirect(['index']); } else { $employee = Employees::find()->one(); $q = \Yii::$app->db; $rowsDetail = $q->createCommand("SELECT * FROM vtransdetail_init WHERE trans_id='" . $id . "'")->queryAll(); return $this->render('update', ['transid' => $model->trans_id, 'model' => $model, 'rows' => $rowsDetail]); } }
<table class="table" style="font-size:15pt; "> <thead> <tr> <td>#</td> <td><strong>คำนำหน้า</strong></td> <td><strong>ชื่อ</strong></td> <td><strong>สกุล</strong></td> <td><strong>ฝ่าย/แผนก</strong></td> </tr> </thead> <tbody> <?php $no = 1; ?> <?php foreach (Employees::find()->where(['id' => $model->id])->all() as $row) { ?> <tr> <td><?php echo $no++; ?> </td> <td style="text-align:left"><?php echo $row->pname; ?> </td> <td style="text-align:left"><?php echo $row->fname; ?> </td>
public function actionReport($id) { // get your HTML raw content without any layouts or scripts $model = Employees::find()->where(['id' => $id])->one(); $content = $this->renderPartial('_reportView', ['model' => $model]); // setup kartik\mpdf\Pdf component $pdf = new Pdf(['mode' => Pdf::MODE_CORE, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Krajee Report Title'], 'methods' => ['SetFooter' => ['{PAGENO}']]]); // return the pdf output as per the destination setting return $pdf->render(); }
/* @var $this yii\web\View */ /* @var $model app\models\Transactions */ /* @var $form yii\widgets\ActiveForm */ $form = ActiveForm::begin(['options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => '{label}<div class="col-sm-10">{input}<div class="help-block">{error}</div></div>', 'labelOptions' => ['class' => 'col-sm-2 control-label']]]); ?> <?php $model->trans_id = $transid; ?> <div class="box-body"> <div class="row"> <div class="col-md-6"> <div class="form-group required"> <label class="col-sm-3 control-label required" for="transactions-trans_employee">Nama Karyawan</label> <div class="col-sm-9"> <?php $employees = Employees::find()->all(); ?> <select id="transactions-trans_employee" class="form-control select2" name="Transactions[trans_employee]"> <option value="">Pilih Karyawan</option> <?php foreach ($employees as $e) { ?> <option value="<?php echo $e->employee_id; ?> " <?php echo $e->employee_id == $model->trans_employee ? 'selected="selected"' : ''; ?> > <?php $name = '';