Example #1
0
    function index()
    {
        $this->load->library('Pdf');
        $userdata = $this->session->all_userdata();
        $data['email'] = $userdata['email'];
        $this->load->model('tenants_model');
        $data['tenant_detail'] = $this->tenants_model->get_unit($data['email']);
        $pdf = new Pdf('P', 'mm', 'A4', true, 'UTF-8', false);
        $pdf->SetTitle('Rent Receipt');
        $pdf->SetHeaderMargin(30);
        $pdf->SetTopMargin(20);
        $pdf->setFooterMargin(20);
        $pdf->SetAutoPageBreak(true);
        $pdf->SetAuthor('Rentit Agency');
        $pdf->SetDisplayMode('real', 'default');
        $pdf->AddPage();
        $html = <<<EOD
<table cellspacing="3" cellpadding="6" border="">

 

\t\t  
\t\t  
EOD;
        $pdf->Ln();
        $html .= "<tr><td>";
        $html .= "<b>RENTIT AGENCY<br />RENT RECEIPT</b>";
        $html .= "</td><td>";
        $this->load->helper('date');
        $datestring = "%Y-%m-%d ";
        $date = mdate($datestring);
        $html .= "<b>Date Received: </b> {$date} <br />";
        $html .= "<br /><b>Received From: </b> ";
        $html .= $userdata['email'];
        '<br />';
        $html .= "<br /><br/><b>The sum of: </b> KeS ";
        $html .= $userdata['amount'];
        '<br />';
        $html .= "</td></tr>";
        $html .= "<tr><td colspan=2>";
        $html .= "<b>For Rent at:</b> ";
        $html .= $data['tenant_detail'][0]['block_name'];
        $html .= " house, ";
        $html .= $data['tenant_detail'][0]['unitname'];
        ',';
        $html .= "<br /><br /><b>Rent Period Starting</b>: ";
        $html .= $data['tenant_detail'][0]['occupation_date'];
        ',<br />';
        $html .= "<br /><br /><b>Received by: </b> Rentit Agency";
        $html .= "</td></tr>";
        $html .= "</table>";
        $pdf->writeHTML($html, true, false, false, false, '');
        ob_clean();
        $pdf->Output('Receipt.pdf', 'I');
    }
Example #2
0
 function tiparire($fromDate, $toDate)
 {
     $this->load->model('cerere_model');
     $filtru = array('fromDate' => $fromDate, 'toDate' => $toDate);
     $cereri = $this->cerere_model->getCereriAll($filtru);
     $this->load->library('Pdf');
     $pdf = new Pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->SetTitle('Cereri');
     $pdf->SetTopMargin(5);
     $pdf->setFooterMargin(5);
     $pdf->SetAutoPageBreak(true);
     $pdf->SetAuthor('poartacerului.ro');
     $pdf->SetDisplayMode('real', 'default');
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $output = "<strong>Cereri rugaciune din data {$fromDate} in data {$toDate}</strong>";
     foreach ($cereri as $cerere) {
         $output .= "<br /><br />Nume: " . $cerere['nume'] . ", Localitate: " . $cerere['localitate'] . ", Data: " . $cerere['data'];
         $output .= "<br />Continut: " . $cerere['continut'];
     }
     $pdf->PrintChapter($output, true);
     $pdf->Output('cereri-rugaciune.pdf', 'I');
 }
    public function cetak_kertas_resep()
    {
        $this->load->library('Pdf');
        $pdf = new Pdf('P', 'mm', 'A5', true, 'UTF-8', false);
        // $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetPageOrientation('P');
        $pdf->SetAuthor('Pemerintah Kota Bogor');
        $pdf->SetTitle('Resep Obat');
        $pdf->SetSubject('Resep Obat');
        $pdf->SetKeywords('Resep Obat');
        // $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
        $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
            require_once dirname(__FILE__) . '/lang/eng.php';
            $pdf->setLanguageArray($l);
        }
        $pdf->setFontSubsetting(true);
        $pdf->SetFont('helvetica', '', 11, '', true);
        $pdf->AddPage();
        $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
        $puskesmas = $this->m_rujukan->get_puskesmas_info($this->session->userdata('kd_puskesmas'));
        $kd_trans_pelayanan = $this->uri->segment(3);
        $surat = $this->m_rujukan->get_data_pasien($kd_trans_pelayanan);
        if ($surat['alamat'] == '') {
            $surat['alamat'] = "-";
        }
        if ($surat['umur'] == '') {
            $surat['umur'] = "-";
        }
        if ($surat['jenis_kelamin'] == '') {
            $surat['jenis_kelamin'] = "-";
        }
        if ($surat['idkartu_medical'] == '') {
            $surat['idkartu_medical'] = "-";
        }
        if ($surat['kd_bayar'] == '') {
            $surat['kd_bayar'] = "-";
        }
        if ($surat['no_asuransi'] == '') {
            $surat['no_asuransi'] = "-";
        }
        if ($surat['nm_dokter'] == '') {
            $surat['nm_dokter'] = "_____________________";
        }
        $tgl = date('d-m-Y');
        #echo $this->db->last_query(); exit;
        $html = '<table align="center" border="0" align="left">';
        $html .= '
						<tr>
                        <td width="20%" style="text-align: center;"><img src="' . base_url() . 'assets/img/logo.png" width="80" height="80"/></td>
						
                        <td width="80%" style="text-align: center;"><h4>00/DOK IN PKM - USI/01/PKM/151/2011</h4><br><h3>PEMERINTAH PROPINSI ' . $puskesmas["nm_propinsi"] . '<br>DINAS KESEHATAN KOTA ' . $puskesmas["nm_kota"] . '</h3>
                        <h4>UPTD ' . $puskesmas["nm_puskesmas"] . '<br>' . $puskesmas["alamat"] . '<br>' . $puskesmas["no_telp"] . '</h4>
					    </td>
                    </tr>';
        $html .= '</table>';
        $html .= '<p align="left"><b>Resep Obat</b></p>';
        $html .= '<table align="center" cellpadding="2" cellspacing="0" border="0" width="100%">
    <tr>
        <td width="20%" border="1px" style="text-align: center;">' . $surat["kd_bayar"] . '</td>
        <td width="5%" style="text-align: left;"></td>
        <td width="75%" style="text-align: right;">' . $puskesmas["nm_kota"] . ', ' . $tgl . '</td>
    </tr>
    <tr>
        <td style="text-align: right;" colspan="3">No KK: ' . $surat["idkartu_medical"] . '</td>
    </tr>
	<tr>
        <td style="text-align: right;" colspan="3">No R.M. Pasien: ' . $surat["kd_rekam_medis"] . '</td>
    </tr>
    <tr>
    <td><p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
	<p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
	<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
    <p>&nbsp;</p></td>
  </tr>
    <tr>
        <td style="text-align: right;" colspan="3">Pemeriksa, </td>
    </tr>
	<tr>
    <td><p>&nbsp;</p>
    <p>&nbsp;</p></td>
  </tr>	
	<tr>
        <td style="text-align: right;" colspan="3">' . $surat["nm_dokter"] . '</td>
    </tr>
	<tr>
        <td width="17%" style="text-align: left;">No. Antrian</td>
        <td width="2%" style="text-align: left;">:</td>
        <td width="81%" style="text-align: left;">' . $surat["no_antrian"] . '</td>
    </tr>
    <tr>
        <td width="17%" style="text-align: left;">Nama</td>
        <td width="2%" style="text-align: left;">:</td>
        <td width="81%" style="text-align: left;">' . $surat["nm_lengkap"] . '</td>
    </tr>
    <tr>
        <td style="text-align: left;">Umur</td>
        <td style="text-align: left;">:</td>
        <td style="text-align: left;">' . $surat["umur"] . '</td>
    </tr>
    <tr>
        <td style="text-align: left;">Alamat</td>
        <td style="text-align: left;">:</td>
        <td style="text-align: left;">' . $surat["alamat"] . ', Kel. ' . ucwords(strtolower($surat["nm_kelurahan"])) . ', Kec. ' . ucwords(strtolower($surat["nm_kecamatan"])) . ' , ' . ucwords(strtolower($surat["nm_kota"])) . '</td>
    </tr>
    <tr>
        <td style="text-align: left;">Status Psn</td>
        <td style="text-align: left;">:</td>
        <td style="text-align: left;">' . $surat["cara_bayar"] . ' , No ' . $surat["no_asuransi"] . '</td>
    </tr>
</table>';
        $pdf->SetTitle('Judul');
        $pdf->SetHeaderMargin(30);
        $pdf->SetTopMargin(20);
        $pdf->setFooterMargin(20);
        $pdf->SetAutoPageBreak(true);
        $pdf->SetAuthor('Pengarang');
        $pdf->SetDisplayMode('real', 'default');
        $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
        $pdf->Output('Resep.pdf', 'I');
    }
/**
* Generates statistics
*
* @param int $surveyid The survey id
* @param mixed $allfields
* @param mixed $q2show
* @param mixed $usegraph
* @param string $outputType Optional - Can be xls, html or pdf - Defaults to pdf
* @param string $pdfOutput Sets the target for the PDF output: DD=File download , F=Save file to local disk
* @param string $statlangcode Lamguage for statistics
* @param mixed $browse  Show browse buttons
* @return buffer
*/
function generate_statistics($surveyid, $allfields, $q2show = 'all', $usegraph = 0, $outputType = 'pdf', $pdfOutput = 'I', $statlangcode = null, $browse = true)
{
    global $pdfdefaultfont, $pdffontsize;
    $astatdata = array();
    //astatdata generates data for the output page's javascript so it can rebuild graphs on the fly
    //load surveytranslator helper
    Yii::import('application.helpers.surveytranslator_helper', true);
    $statisticsoutput = "";
    //This string carries all the actual HTML code to print.
    $imagedir = Yii::app()->getConfig("imagedir");
    $tempdir = Yii::app()->getConfig("tempdir");
    $tempurl = Yii::app()->getConfig("tempurl");
    $clang = Yii::app()->lang;
    $pdf = array();
    //Make sure $pdf exists - it will be replaced with an object if a $pdf is actually being created
    // Used for getting coordinates for google maps
    $agmapdata = array();
    //pick the best font file if font setting is 'auto'
    if (is_null($statlangcode)) {
        $statlangcode = getBaseLanguageFromSurveyID($surveyid);
    } else {
        $statlang = new Limesurvey_lang($statlangcode);
    }
    /*
     * this variable is used in the function shortencode() which cuts off a question/answer title
     * after $maxchars and shows the rest as tooltip (in html mode)
     */
    $maxchars = 13;
    //we collect all the html-output within this variable
    $statisticsoutput = '';
    /**
     * $outputType: html || pdf ||
     */
    /**
     * get/set Survey Details
     */
    //no survey ID? -> come and get one
    if (!isset($surveyid)) {
        $surveyid = returnGlobal('sid');
    }
    //Get an array of codes of all available languages in this survey
    $surveylanguagecodes = Survey::model()->findByPk($surveyid)->additionalLanguages;
    $surveylanguagecodes[] = Survey::model()->findByPk($surveyid)->language;
    $fieldmap = createFieldMap($surveyid, "full", false, false, $statlang->getlangcode());
    // Set language for questions and answers to base language of this survey
    $language = $statlangcode;
    if ($q2show == 'all') {
        $summarySql = " SELECT gid, parent_qid, qid, type " . " FROM {{questions}} WHERE parent_qid=0" . " AND sid={$surveyid} ";
        $summaryRs = Yii::app()->db->createCommand($summarySql)->query()->readAll();
        foreach ($summaryRs as $field) {
            $myField = $surveyid . "X" . $field['gid'] . "X" . $field['qid'];
            // Multiple choice get special treatment
            if ($field['type'] == "M") {
                $myField = "M{$myField}";
            }
            if ($field['type'] == "P") {
                $myField = "P{$myField}";
            }
            //numerical input will get special treatment (arihtmetic mean, standard derivation, ...)
            if ($field['type'] == "N") {
                $myField = "N{$myField}";
            }
            if ($field['type'] == "|") {
                $myField = "|{$myField}";
            }
            if ($field['type'] == "Q") {
                $myField = "Q{$myField}";
            }
            // textfields get special treatment
            if ($field['type'] == "S" || $field['type'] == "T" || $field['type'] == "U") {
                $myField = "T{$myField}";
            }
            //statistics for Date questions are not implemented yet.
            if ($field['type'] == "D") {
                $myField = "D{$myField}";
            }
            if ($field['type'] == "F" || $field['type'] == "H") {
                //Get answers. We always use the answer code because the label might be too long elsewise
                $query = "SELECT code, answer FROM {{answers}} WHERE qid='" . $field['qid'] . "' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, answer";
                $result = Yii::app()->db->createCommand($query)->query();
                $counter2 = 0;
                //check all the answers
                foreach ($result->readAll() as $row) {
                    $row = array_values($row);
                    $myField = "{$myField}{$row[0]}";
                }
                //$myField = "{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]";
            }
            if ($q2show == 'all') {
                $summary[] = $myField;
            }
            //$allfields[]=$myField;
        }
    } else {
        // This gets all the 'to be shown questions' from the POST and puts these into an array
        if (!is_array($q2show)) {
            $summary = returnGlobal('summary');
        } else {
            $summary = $q2show;
        }
        //print_r($_POST);
        //if $summary isn't an array we create one
        if (isset($summary) && !is_array($summary)) {
            $summary = explode("+", $summary);
        }
    }
    /**
     * pdf Config
     */
    if ($outputType == 'pdf') {
        //require_once('classes/tcpdf/config/lang/eng.php');
        global $l;
        $l['w_page'] = $statlang->gT("Page", 'unescaped');
        //require_once('classes/tcpdf/mypdf.php');
        Yii::import('application.libraries.admin.pdf', true);
        // create new PDF document
        $pdf = new Pdf();
        $pdf->SetFont($pdfdefaultfont, '', $pdffontsize);
        $surveyInfo = getSurveyInfo($surveyid, $language);
        // set document information
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('LimeSurvey');
        $pdf->SetTitle('Statistic survey ' . $surveyid);
        $pdf->SetSubject($surveyInfo['surveyls_title']);
        $pdf->SetKeywords('LimeSurvey, Statistics, Survey ' . $surveyid . '');
        $pdf->SetDisplayMode('fullpage', 'two');
        // set header and footer fonts
        $pdf->setHeaderFont(array($pdfdefaultfont, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array($pdfdefaultfont, '', PDF_FONT_SIZE_DATA));
        // set default header data
        $pdf->SetHeaderData("statistics.png", 10, $statlang->gT("Quick statistics", 'unescaped'), $statlang->gT("Survey") . " " . $surveyid . " '" . flattenText($surveyInfo['surveyls_title'], false, true, 'UTF-8') . "'");
        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        //set margins
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        //set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        //set image scale factor
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        //set some language-dependent strings
        $pdf->setLanguageArray($l);
    }
    if ($outputType == 'xls') {
        /**
         * Initiate the Spreadsheet_Excel_Writer
         */
        Yii::import('application.libraries.admin.pear.Spreadsheet.Excel.Xlswriter', true);
        if ($pdfOutput == 'F') {
            $sFileName = $tempdir . '/statistic-survey' . $surveyid . '.xls';
            $workbook = new Xlswriter($sFileName);
        } else {
            $workbook = new Xlswriter();
        }
        $workbook->setVersion(8);
        // Inform the module that our data will arrive as UTF-8.
        // Set the temporary directory to avoid PHP error messages due to open_basedir restrictions and calls to tempnam("", ...)
        $workbook->setTempDir($tempdir);
        // Inform the module that our data will arrive as UTF-8.
        // Set the temporary directory to avoid PHP error messages due to open_basedir restrictions and calls to tempnam("", ...)
        if (!empty($tempdir)) {
            $workbook->setTempDir($tempdir);
        }
        if ($pdfOutput != 'F') {
            $workbook->send('statistic-survey' . $surveyid . '.xls');
        }
        // Creating the first worksheet
        $sheet =& $workbook->addWorksheet(utf8_decode('results-survey' . $surveyid));
        $sheet->setInputEncoding('utf-8');
        $sheet->setColumn(0, 20, 20);
        $separator = "~|";
        /**XXX*/
    }
    /**
     * Start generating
     */
    $selects = buildSelects($allfields, $surveyid, $language);
    //count number of answers
    $query = "SELECT count(*) FROM {{survey_{$surveyid}}}";
    //if incompleted answers should be filtert submitdate has to be not null
    if (incompleteAnsFilterState() == "inc") {
        $query .= " WHERE submitdate is null";
    } elseif (incompleteAnsFilterState() == "filter") {
        $query .= " WHERE submitdate is not null";
    }
    $result = Yii::app()->db->createCommand($query)->query();
    //$total = total number of answers
    $row = $result->read();
    $total = reset($row);
    //are there any filters that have to be taken care of?
    if (isset($selects) && $selects) {
        //filter incomplete answers?
        if (incompleteAnsFilterState() == "filter" || incompleteAnsFilterState() == "inc") {
            $query .= " AND ";
        } else {
            $query .= " WHERE ";
        }
        //add filter criteria to SQL
        $query .= implode(" AND ", $selects);
    }
    //get me some data Scotty
    $result = Yii::app()->db->createCommand($query)->query();
    //put all results into $results
    $row = $result->read();
    $results = reset($row);
    if ($total) {
        $percent = sprintf("%01.2f", $results / $total * 100);
    }
    switch ($outputType) {
        case "xls":
            $xlsRow = 0;
            $sheet->write($xlsRow, 0, $statlang->gT("Number of records in this query:", 'unescaped'));
            $sheet->write($xlsRow, 1, $results);
            ++$xlsRow;
            $sheet->write($xlsRow, 0, $statlang->gT("Total records in survey:", 'unescaped'));
            $sheet->write($xlsRow, 1, $total);
            if ($total) {
                ++$xlsRow;
                $sheet->write($xlsRow, 0, $statlang->gT("Percentage of total:", 'unescaped'));
                $sheet->write($xlsRow, 1, $percent . "%");
            }
            break;
        case 'pdf':
            // add summary to pdf
            $array = array();
            //$array[] = array($statlang->gT("Results"),"");
            $array[] = array($statlang->gT("Number of records in this query:", 'unescaped'), $results);
            $array[] = array($statlang->gT("Total records in survey:", 'unescaped'), $total);
            if ($total) {
                $array[] = array($statlang->gT("Percentage of total:", 'unescaped'), $percent . "%");
            }
            $pdf->addPage('P', 'A4');
            $pdf->Bookmark($pdf->delete_html($statlang->gT("Results", 'unescaped')), 0, 0);
            $pdf->titleintopdf($statlang->gT("Results", 'unescaped'), $statlang->gT("Survey", 'unescaped') . " " . $surveyid);
            $pdf->tableintopdf($array);
            $pdf->addPage('P', 'A4');
            break;
        case 'html':
            $statisticsoutput .= "<br />\n<table class='statisticssummary' >\n" . "\t<thead><tr><th colspan='2'>" . $statlang->gT("Results") . "</th></tr></thead>\n" . "\t<tr><th >" . $statlang->gT("Number of records in this query:") . '</th>' . "<td>{$results}</td></tr>\n" . "\t<tr><th>" . $statlang->gT("Total records in survey:") . '</th>' . "<td>{$total}</td></tr>\n";
            //only calculate percentage if $total is set
            if ($total) {
                $percent = sprintf("%01.2f", $results / $total * 100);
                $statisticsoutput .= "\t<tr><th align='right'>" . $statlang->gT("Percentage of total:") . '</th>' . "<td>{$percent}%</td></tr>\n";
            }
            $statisticsoutput .= "</table>\n";
            break;
        default:
            break;
    }
    //put everything from $selects array into a string connected by AND
    //This string ($sql) can then be passed on to other functions so you can
    //browse these results
    if (isset($selects) && $selects) {
        $sql = implode(" AND ", $selects);
    } elseif (!empty($newsql)) {
        $sql = $newsql;
    }
    if (!isset($sql) || !$sql) {
        $sql = "NULL";
    }
    //only continue if we have something to output
    if ($results > 0) {
        if ($outputType == 'html' && $browse === true) {
            //add a buttons to browse results
            $statisticsoutput .= "<form action='" . Yii::app()->getController()->createUrl("admin/responses/index/surveyid/{$surveyid}") . "' method='post' target='_blank'>\n" . "\t\t<p>" . "\t\t\t<input type='submit' value='" . $statlang->gT("Browse") . "'  />\n" . "\t\t\t<input type='hidden' name='sid' value='{$surveyid}' />\n" . "\t\t\t<input type='hidden' name='sql' value=\"{$sql}\" />\n" . "\t\t\t<input type='hidden' name='subaction' value='all' />\n" . "\t\t</p>" . "\t\t</form>\n";
        }
    }
    //end if (results > 0)
    /* Show Summary results
     * The $summary array contains each fieldname that we want to display statistics for
     *
     * */
    if (isset($summary) && $summary) {
        //let's run through the survey
        $runthrough = $summary;
        //START Chop up fieldname and find matching questions
        //loop through all selected questions
        foreach ($runthrough as $rt) {
            //Step 1: Get information about this response field (SGQA) for the summary
            $outputs = buildOutputList($rt, $language, $surveyid, $outputType, $sql, $statlang);
            $statisticsoutput .= $outputs['statisticsoutput'];
            //2. Collect and Display results #######################################################################
            if (isset($outputs['alist']) && $outputs['alist']) {
                $display = displayResults($outputs, $results, $rt, $outputType, $surveyid, $sql, $usegraph, $browse, $pdf, $statlang);
                $statisticsoutput .= $display['statisticsoutput'];
                $astatdata = array_merge($astatdata, $display['astatdata']);
            }
            //end if -> collect and display results
            //Delete Build Outputs data
            unset($outputs);
            unset($display);
        }
        // end foreach -> loop through all questions
        //output
        if ($outputType == 'html') {
            $statisticsoutput .= "<br />&nbsp;\n";
        }
    }
    //end if -> show summary results
    switch ($outputType) {
        case 'xls':
            $workbook->close();
            if ($pdfOutput == 'F') {
                return $sFileName;
            } else {
                return;
            }
            break;
        case 'pdf':
            $pdf->lastPage();
            if ($pdfOutput == 'F') {
                // This is only used by lsrc to send an E-Mail attachment, so it gives back the filename to send and delete afterwards
                $pdf->Output($tempdir . "/" . $statlang->gT('Survey') . '_' . $surveyid . "_" . $surveyInfo['surveyls_title'] . '.pdf', $pdfOutput);
                return $tempdir . "/" . $statlang->gT('Survey') . '_' . $surveyid . "_" . $surveyInfo['surveyls_title'] . '.pdf';
            } else {
                return $pdf->Output($statlang->gT('Survey') . '_' . $surveyid . "_" . $surveyInfo['surveyls_title'] . '.pdf', $pdfOutput);
            }
            break;
        case 'html':
            $statisticsoutput .= "<script type=\"text/javascript\" src=\"http://maps.googleapis.com/maps/api/js?sensor=false\"></script>\n" . "<script type=\"text/javascript\">var site_url='" . Yii::app()->baseUrl . "';var temppath='{$tempurl}';var imgpath='" . Yii::app()->getConfig('adminimageurl') . "';var aGMapData=" . ls_json_encode($agmapdata) . ";var aStatData=" . ls_json_encode($astatdata) . "</script>";
            return $statisticsoutput;
            break;
        default:
            return $statisticsoutput;
            break;
    }
}
    public function cetak_rm()
    {
        $no_rm = $this->uri->segment(3);
        $view_rekam_medis = $this->m_crud->get_list_pasien($no_rm);
        $view_trans_pelayanan = $this->m_crud->get_pasien_rekam_medis($no_rm);
        $this->load->library('Pdf');
        $pdf = new Pdf('P', 'mm', 'F4', true, 'UTF-8', false);
        // $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        $pdf->SetPrintHeader(false);
        $pdf->SetPrintFooter(false);
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetPageOrientation('P');
        $pdf->SetAuthor('Pemerintah Kota Bogor');
        $pdf->SetTitle('Rekam Medis');
        $pdf->SetSubject('Rekam Medis Pasien');
        $pdf->SetKeywords('Medical Record');
        // $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
        //$pdf->setFooterData(array(0,64,0), array(0,64,128));
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
            require_once dirname(__FILE__) . '/lang/eng.php';
            $pdf->setLanguageArray($l);
        }
        $pdf->setFontSubsetting(true);
        $pdf->SetFont('helvetica', '', 9, '', true);
        $pdf->SetTopMargin(10);
        $pdf->AddPage();
        $pdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
        $puskesmas = $this->m_rujukan->get_puskesmas_info($this->session->userdata('kd_puskesmas'));
        #echo $this->session->userdata('kd_puskesmas');
        #echo $this->db->last_query(); exit;
        $html = '<table width="100%" align="center" border="0">';
        $html .= '<tr>
                        <td width="20%" style="text-align: center;"><img src="' . base_url() . 'assets/img/' . $puskesmas["logo"] . '" width="80" height="80"/></td>
                        <td width="80%" align="center"><h2>PEMERINTAH PROPINSI ' . $puskesmas["nm_propinsi"] . '<br>DINAS KESEHATAN KOTA ' . $puskesmas["nm_kota"] . '</h2>
                        <h1>UPTD ' . $puskesmas["nm_puskesmas"] . '</h1>
						<h3>' . $puskesmas["alamat"] . ' Telp. ' . $puskesmas["telp"] . '</h3>
                        </td>
                    </tr>
					<tr>
              <td colspan="" bordercolordark="#0A0A0A" style="text-align: center;">____________________________________________________________________________________________________</td>
              </tr>';
        $html .= '</table><p></p>';
        $html .= '<div id="rekam-medis">
                        	<h4 class="widgettitle nomargin">Rekam Medis Pasien</h4>
                            <div class="widgetcontent bordered">
                            	<div class="row-fluid">
                                	<div class="span6">
                                    	<table class="table table-bordered table-invoice">
                                            <tbody>
                                                <tr>
                                                    <td width="30%">No. Rekam Medis</td>
                                                    <td width="70%">' . $view_rekam_medis['kd_rekam_medis'] . '</td>
                                                </tr>
                                                <tr>
                                                    <td>Nama Pasien</td>
                                                    <td>' . $view_rekam_medis['nm_lengkap'] . '</td>
                                                </tr>
                                                <tr>
                                                    <td>Tempat, Tgl Lahir</td>
                                                    <td>' . $view_rekam_medis['tempat_lahir'] . ' / ' . $this->functions->format_tgl_cetak2($view_rekam_medis['tanggal_lahir']) . '</td>
                                                </tr>';
        $hitung = $this->functions->CalcAge($view_rekam_medis['tanggal_lahir'], date('Y-m-d'));
        //$hitung = $this->functions->dateDifference($view_rekam_medis['tanggal_lahir'], date('Y-m-d'));
        $umurku = $hitung[0] . ' Tahun ' . $hitung[1] . ' Bulan ' . $hitung[2] . ' Hari';
        // echo $umurku;
        $html .= '
                                                <tr>
                                                    <td>Umur</td>
                                                    <td>' . $umurku . '
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Jenis Kelamin</td>
                                                    <td>' . ucwords(strtolower($view_rekam_medis['jenis_kelamin'])) . '</td>
                                                </tr>
                                                <tr>
                                                    <td>Alamat</td>
                                                    <td>' . $view_rekam_medis['alamat'] . '</td>
                                                </tr>
                                                <tr>
                                                    <td>Puskesmas</td>
                                                    <td>' . $view_rekam_medis['nm_puskesmas'] . '</td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>';
        $html .= '
                        </div> <!-- </row-fluid> -->
                        <div class="clearfix"><br/></div>';
        $html .= '
            <h4 class="widgettitle">Kunjungan Pasien</h4>
            <div class="row-fluid">
                <div class="span12">
                    <table class="table table-bordered table-stripped table-hover" border="1">
                        <thead>
                        <tr align="center">
                            <th><b>No.</b></th>
                            <th><b>Tanggal</b></th>
                            <th><b>Puskesmas</b></th>
                            <th><b>Poli</b></th>
                            <th><b>Dokter</b></th>
                            <th><b>Anamnesa</b></th>
                            <th><b>Cat.Fisik</b></th>
                            <th><b>Penyakit</b></th>
                            <th><b>Tindakan</b></th>
                            <th><b>Obat (Dosis) (Jml)</b></th>
                        </tr>
                        </thead>
                        <tbody>';
        if (isset($view_trans_pelayanan) && !empty($view_trans_pelayanan)) {
            $i = 1;
            foreach ($view_trans_pelayanan as $rs) {
                if ($rs['anamnesa'] == '0') {
                    $rs['anamnesa'] = "-";
                }
                if ($rs['catatan_fisik'] == '0') {
                    $rs['catatan_fisik'] = "-";
                }
                if ($rs['tindakan'] == '') {
                    $rs['tindakan'] = "-";
                }
                if ($rs['dokter'] == '') {
                    $rs['dokter'] = "-";
                }
                $html .= '<tr>
                                    <td>' . $i . '</td>
                                    <td>' . $this->functions->convert_date_indo(array("datetime" => $rs['tgl_pelayanan'])) . '</td>
                                    <td>' . $rs['nm_puskesmas'] . '</td> <!-- jenis layanan diganti poli mana -->
                                    <td>' . $rs['unit_layanan'] . '</td>
                                    <td>' . $rs['dokter'] . '</td>
                                    <td>' . $rs['anamnesa'] . '</td>
                                    <td>' . $rs['catatan_fisik'] . '</td>
                                    <td>' . $rs['kd_icd'] . ' - ' . $rs['penyakit'] . '</td>
                                    <td>' . $rs['tindakan'] . '</td>';
                $pecahObat = explode(';', $rs['obat']);
                $pecahDosis = explode(';', $rs['dosis']);
                $pecahJml = explode(';', $rs['jml_obat']);
                $obatku = '';
                for ($z = 0; $z < count($pecahObat); $z++) {
                    $obatku .= $pecahObat[$z] . " (" . $pecahDosis[$z] . ") (" . $pecahJml[$z] . ")";
                    if ($z != count($pecahObat) - 1) {
                        $obatku .= " \n- ";
                    }
                }
                $html .= '


                                    <td>' . $obatku . '</td>

                                </tr>';
                $i++;
            }
        } else {
            $html .= '

                            <tr>
                                <td colspan="11"><center>Tidak ada riwayat kunjungan</center></td>
                            </tr>';
        }
        $html .= '
                        </tbody>
                    </table>
                </div>
            </div>
            </div> <!-- </widgetcontent> -->
            </div>';
        $pdf->SetTitle('Judul');
        $pdf->SetHeaderMargin(30);
        $pdf->SetTopMargin(20);
        $pdf->setFooterMargin(20);
        $pdf->SetAutoPageBreak(true);
        $pdf->SetAuthor('Pengarang');
        $pdf->SetDisplayMode('real', 'default');
        $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
        $pdf->Output('Rekam Medis.pdf', 'I');
    }
Example #6
-1
 public function index()
 {
     $this->load->library('Pdf');
     $pdf = new Pdf('P', 'mm', 'A4', true, 'UTF-8', false);
     $pdf->SetTitle('Pdf Example');
     $pdf->SetHeaderMargin(30);
     $pdf->SetTopMargin(20);
     $pdf->setFooterMargin(20);
     $pdf->SetAutoPageBreak(true);
     $pdf->SetAuthor('Author');
     $pdf->SetDisplayMode('real', 'default');
     $pdf->Write(5, 'CodeIgniter TCPDF Integration');
     $pdf->Output('pdfexample.pdf', 'I');
 }