public function actionDownload() { parent::actionDownload(); $pdf = new PDF(); $pdf->title = 'Absence Schedule List'; $pdf->AddPage('L'); $pdf->setFont('Arial', 'B', 12); // definisi font $pdf->setFont('Arial', 'B', 8); // menuliskan tabel $header = array('No', 'ID', 'Schedule Name', 'Absence In', 'Absence Out', 'Status', 'Wage Name', 'Currency', 'Insentif'); $model = new Absschedule('searchwstatus'); $dataprovider = $model->searchwstatus(); $dataprovider->pagination = false; $data = $dataprovider->getData(); $cols = $dataprovider->getKeys(); $dataku = array(count($data)); //var_dump($dataku); $w = array(20, 25, 30, 30, 30, 30, 30, 30, 30); $pdf->SetTableHeader(); //Header for ($i = 0; $i < count($header); $i++) { $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C', true); } $pdf->Ln(); $pdf->SetTableData(); //Data $fill = false; foreach ($data as $n => $datas) { $pdf->Cell($w[0], 6, $n, 'LR', 0, 'C', $fill); $pdf->Cell($w[1], 6, $datas['absscheduleid'], 'LR', 0, 'C', $fill); $pdf->Cell($w[2], 6, $datas['absschedulename'], 'LR', 0, 'C', $fill); $pdf->Cell($w[3], 6, $datas['absin'], 'LR', 0, 'C', $fill); $pdf->Cell($w[4], 6, $datas['absout'], 'LR', 0, 'C', $fill); $pdf->Cell($w[5], 6, Absstatus::model()->findByPk($datas['absstatusid'])->shortstat, 'LR', 0, 'C', $fill); $pdf->Cell($w[6], 6, Wagetype::model()->findByPk($datas['wagetypeid'])->wagename, 'LR', 0, 'C', $fill); $pdf->Cell($w[7], 6, Currency::model()->findByPk($datas['currencyid'])->currencyname, 'LR', 0, 'C', $fill); $pdf->Cell($w[8], 6, number_format($datas['insentif']), 'LR', 0, 'C', $fill); $pdf->Ln(); $fill = !$fill; } $pdf->Cell(array_sum($w), 0, '', 'T'); // me-render ke browser $pdf->Output(); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Wagetype::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }