Example #1
0
function createPDF(array $data, $name = 'catalog')
{
    $CI =& get_instance();
    $html = '';
    $html .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml">
                <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                </head>
                <body style="padding-bottom: 50px;">
                    <div style=" margin:0 auto; width:760px; color:#666; font-family:Arial, Helvetica, sans-serif">
                        <table border="0" cellpadding="0" cellspacing="0" width="760">
                            <tr>
                                <td width="515" align="left">
                                    <table cellpadding="0" cellspacing="5" width="465" border="0">
					<tr>
                                            <td width="175" valign="bottom"></td>
					</tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td width="660" style="height:8px; border-bottom: yellow;" colspan="2">&nbsp;</td>
                            </tr>
                            <tr>
                                <td height="10" colspan="2"></td>
                            </tr>
                            <tr>
                                <td colspan="2" style="font-size:35px;color:#ff; padding:5px;" bgcolor="#00a0d1">
                                    <table cellspacing="0" cellpadding="0" width="760">
                                        <tr>
                                            <td width="10">&nbsp;</td>
                                            <td width="640">Products</td>
                                            <td width="10">&nbsp;</td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td height="10" colspan="2"></td>
                            </tr>
                            <p style="margin:0px 0; color:#000; font-size:30px;">Products</p>
                            <table cellpadding="2" cellspacing="0" width="100%" style=" background:#fff; font-family:Arial, Helvetica, sans-serif; font-size:20px; color:#666666;">
                            ';
    $count = 0;
    for ($i = 0, $n = count($data); $i < $n; $i++) {
        if (is_array($data[$i]) && count($data[$i])) {
            $bgcolor = !$count % 2 ? 'bgcolor="#E7E7E8"' : '';
            $html .= '<tr $bgcolor>';
            //foreach($data[$i] as $d) {
            for ($j = 0; $j < count($data[$i]); $j++) {
                if (!$count) {
                    $html .= "<th>" . $data[$i][$j] . "</th>";
                } else {
                    $html .= "<td>" . $data[$i][$j] . "</td>";
                }
            }
            $html .= "</tr>";
        }
        $count++;
    }
    $html .= '<tr><td colspan="6" height="10"></td></tr>' . '</table>
                               <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tr>
                                        <td height="10"></td>
                                    </tr>
                                    <tr>
                                        <td width="660" style="height:8px; display:block; border-bottom: yellow;">&nbsp;</td>
                                    </tr>
                                </table>
                            </div>
                        </body>
                    </html>';
    $CI->load->helper('pdf');
    $file = $name . ".pdf";
    echo tcpdf_write($html, $file, tcpdf_options('reports'));
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private", false);
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"{$file}\";");
    header("Content-Transfer-Encoding: binary");
    exit;
}
Example #2
0
 function writePDF($html, $fileName)
 {
     $this->load->helper('pdf');
     return tcpdf_write($html, $fileName, tcpdf_options('reports'));
 }
Example #3
0
 function fetch_report_new($fileName = '', $type = '', $columns = array(), $items = array(), $reciever = array(), $temp_type = '', $user_id)
 {
     $htmlData = '';
     $data['excel'] = $type;
     $data['columns'] = $columns;
     $data['items'] = $items;
     $data['fileName'] = $fileName;
     $testEmail = false;
     if ($type == 'excel') {
         $this->load->view('excelview', $data);
     } elseif ($type == 'pdf') {
         $htmlData = $this->load->view('pdfview_reports', $data, true);
         $this->load->helper('pdf');
         tcpdf_write($htmlData, $fileName);
     } else {
         $htmlData = $this->load->view('pdfview_reports', $data, true);
         if (template_email_send($temp_type, $user_id, '', $reciever, $htmlData)) {
             $testEmail = true;
         } else {
             $testEmail = false;
         }
         if ($testEmail) {
             $this->data->html = "Email successfully sent.";
             $this->data->div_class = "success";
             return "success";
         } else {
             $this->data->html = "Unable to send email.";
             $this->data->div_class = "error";
             return "error";
         }
     }
 }
Example #4
0
 function pdfExport()
 {
     $buffer = $_POST['csvBuffer'];
     $fileName = $_POST['fileName'];
     try {
         $this->load->helper('pdf');
         tcpdf_write($html, $fileName, tcpdf_options('catalog'));
     } catch (Exception $e) {
     }
     exit;
 }