Dompdf to Mpdf

This commit is contained in:
gandhimathi 2017-12-01 10:25:46 +05:30
parent b510a6a9ca
commit 1f944561ab
3 changed files with 122 additions and 72 deletions

View File

@ -1,6 +1,8 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
require APPPATH . '/third_party/mpdf/mpdf.php';
/**
* Class : Inward Gate Register Controller (security)
@ -45,33 +47,43 @@ class MRIRcontroller extends BaseController
$this->loadViews("materialinspectionreport", $this->global,$data,NULL);
}
// Mrir pdf
public function MrirDetailsPrintPdf()
{
$MrirNo = $_GET['MRIRNO'];
// echo $MrirNo;
$this->global['pageTitle'] = 'Siddharth : MRIR Pdf ';
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
//print_r($data['CompanyDetails']);
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
$data['MRIRDetails'] = $this->mrir_model->edit_mrir($MrirNo);
//$data['MRIRDetails'] = $this->mrir_model->edit_mrir($MrirNo);
//print_r($data['MRIRDetails']);
$this->load->View("Mrirprintpdf",$data, NULL);
//mpdf
$mpdf=new mPDF('utf-8','A4-P',8, 10,10, 10, 82, 38, 4, 6);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetHTMLHeader($HtmlHeading);
$html = $this->load->view('Mrirprintpdf',$data,true);
$mpdf->SetDisplayMode('fullpage');
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
$mpdf->list_indent_first_level = 1;
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($html);
$mpdf->Output("MrirDetails".$data.'.pdf','I',$php);
// Get output html
$php = $this->output->get_output();
// $php = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
// // Load library
// $this->load->library('dompdf_gen');
// Convert to PDF
$this->dompdf->load_html($php);
$this->dompdf->render();
$data['Attachment'] = FALSE;
$this->dompdf->stream("MrirDetails.pdf",$data,$php);
// // Convert to PDF
// $this->dompdf->load_html($php);
// $this->dompdf->render();
// $data['Attachment'] = FALSE;
// $this->dompdf->stream("MrirDetails.pdf",$data,$php);
}
@ -380,4 +392,6 @@ public function viewmMaterialDistributionList()
}
}
?>
?>

View File

@ -1,6 +1,8 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
require APPPATH . '/third_party/mpdf/mpdf.php';
/**
* Class : Employee (Employee Controller)
@ -60,7 +62,8 @@ function phpAlert($msg) {
$m = substr($payon,0,2);
$y = substr($payon,3);
$month = $monthsoptions[$m]."-".$y;
$excel = $this->input->post('excel');
$excel = $this->input->post('excel');
$HTML = '';
//echo $excel;
// if(empty($excel))
// {
@ -94,7 +97,7 @@ function phpAlert($msg) {
$data['Totalamtwords']=$totamtwords;
$data['PayMonth']=$month;
$filename = 'Bank Report for'.$payon.'pdf' ;
$this->load->View("bankreportprint",$data);
$HTML = $this->load->view("bankreportprint",$data,true);
}
if($this->input->post('PF_Report'))
{
@ -122,7 +125,7 @@ function phpAlert($msg) {
$data['Totalamtwords']=$totamtwords;
if(empty($excel)){
$filename = 'PF Report for'.$payon.'pdf' ;
$this->load->View("pfreportprint",$data);
$HTML = $this->load->view("pfreportprint",$data,true);
// echo "PDF PART 1";
}
else{
@ -256,7 +259,7 @@ function phpAlert($msg) {
if(empty($excel)){
$filename = 'ESI Report for'.$payon.'pdf';
$this->load->View("esireportprint",$data);
$HTML = $this->load->view("esireportprint",$data,true);
// echo "PDF PART 1";
}
else{
@ -351,28 +354,41 @@ function phpAlert($msg) {
if(empty($excel)){
$php = $this->output->get_output();
// $php = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
// $this->load->library('dompdf_gen');
require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF();
$dompdf->set_paper('A4', 'portrait');
$dompdf->load_html($php);
// require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php');
// $dompdf = new DOMPDF();
// $dompdf->set_paper('A4', 'portrait');
// $dompdf->load_html($php);
$dompdf->render();
// $dompdf->render();
// add the header
$canvas = $dompdf->get_canvas();
$font = Font_Metrics::get_font("helvetica", "bold");
// // add the header
// $canvas = $dompdf->get_canvas();
// $font = Font_Metrics::get_font("helvetica", "bold");
// the same call as in my previous example
$canvas->page_text(72, 18,"",
$font, 6, array(0,0,0));
// // the same call as in my previous example
// $canvas->page_text(72, 18,"",
// $font, 6, array(0,0,0));
$dompdf->stream($filename);
// $dompdf->stream($filename);
//echo "PDF PART 2";
$mpdf=new mPDF('utf-8','A4-P',9, 12,12, 10, 82, 38, 4, 6);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetHTMLHeader($HtmlHeading);
//$html = $this->load->view("bankreportprint",$data,true);
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
$mpdf->setFooter("Page {PAGENO} of {nb}");
$mpdf->list_indent_first_level = 1;
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($HTML);
$mpdf->Output("".$filename.'.pdf','I',$php);
}
}
@ -747,7 +763,7 @@ function getEmployee()
*/
public function PrintPdf()
{
$html="";
$All = $this->input->post('All');
if($All == '')
{
@ -769,25 +785,32 @@ function getEmployee()
{
$result = $this->payroll_model->getEmpAll($Payon);
//print_r($result);
//echo "-----------------------------------------";
// print_r($result);
// die();
if($result > 0 )
{
for($i=0;$i <count($result) ;$i++ )
for($i=0; $i<count($result) ;$i++ )
{
$EmpID = $result[$i]['EmpId'];
print_r(
$EmpID );
die();
$Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon,$EmpID);
-
//
$totalsalary =$Data['PayDetails'][0]->LessAdvance;
$totalsalaryinwords = $this->convertNumber(round($totalsalary));
$Data['amtinwords']=$totalsalaryinwords;
// print_r ($Data);
// exit();
//$Data['Count'] = $i;
$this->load->View("payslipgenerateprint", $Data );
$html=$this->load->view("payslipgenerateprint", $Data,true );
// print_r ($Data);
// exit();
}
}
@ -801,45 +824,58 @@ function getEmployee()
$totalsalary =$Data['PayDetails'][0]->LessAdvance;
$totalsalaryinwords = $this->convertNumber(round($totalsalary));
$Data['amtinwords']=$totalsalaryinwords;
$this->load->View("payslipgenerateprint", $Data );
//print_r ($Data);
//exit();
$html=$this->load->view("payslipgenerateprint", $Data,true );
}
$php = $this->output->get_output();
// $php = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
// // Load library
// $this->load->library('dompdf_gen');
if($All != '')
{
$filename = 'Payslip-'.$Payon.'.pdf' ;
}
else
{
$filename = 'Payslip-'.$EmpID . '-' .$Payon.'.pdf' ;
}
// if($All != '')
// {
// $filename = 'Payslip-'.$Payon.'.pdf' ;
// }
// else
// {
// $filename = 'Payslip-'.$EmpID . '-' .$Payon.'.pdf' ;
// }
require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF();
$dompdf->set_paper('A4', 'portrait');
$dompdf->load_html($php);
// require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php');
// $dompdf = new DOMPDF();
// $dompdf->set_paper('A4', 'portrait');
// $dompdf->load_html($php);
$dompdf->render();
// $dompdf->render();
// add the header
$canvas = $dompdf->get_canvas();
$font = Font_Metrics::get_font("helvetica", "bold");
// // add the header
// $canvas = $dompdf->get_canvas();
// $font = Font_Metrics::get_font("helvetica", "bold");
// the same call as in my previous example
$canvas->page_text(72, 18, "Page: {PAGE_NUM} of {PAGE_COUNT}",
$font, 6, array(0,0,0));
// // the same call as in my previous example
// $canvas->page_text(72, 18, "Page: {PAGE_NUM} of {PAGE_COUNT}",
// $font, 6, array(0,0,0));
$dompdf->stream($filename);
}
// $dompdf->stream($filename);
// }
$mpdf=new mPDF('utf-8','A4-P',10, 10,10, 10, 10, 38, 4, 6);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetHTMLHeader($HtmlHeading);
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
$mpdf->setFooter("Page {PAGENO} of {nb}");
$mpdf->list_indent_first_level = 1;
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($html);
$mpdf->Output("".$filename.'.pdf','I',$php);
}
}
}
function updatePayslip()
{

View File

@ -184,9 +184,9 @@ if($RecCount > 0)
<table style="border-collapse: collapse;font-size:15px;" cellpadding="0" cellspacing="0" border="1" width="100%">
<table style="border-collapse: collapse;" cellpadding="0" cellspacing="0" border="1" width="100%">
<tr>
<td colspan="1" style="background:#2c0000;"> <center> <img width="80" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA11JREFUeNrsnT9IHEEYxWfFw8rgpUhlo5URi2gTbIUUSrq1ui4oRLRIY9JIKrGKTQrBgJLuuutEi4CtSSOpPIuATdIEcid2YpN9C3sc8c6bf7uZmX0P7k7ultm7337zzXxvZjGaiaIfQoiqoHTUHk6eniSPUbLQUmUoebojB23dDZGBmQiQAAmQAAmQIkACJEACpAiweA3bbvDV5mb6+iKOxfTc3MDjf15dicbBQfr3591d7wBGM1H0J3l9bNLI84UFsby6mkIzFWACJMCafJ9PJyfSx29vbHQuoqJaxl34zc5O+mVtwIPi5EIcXV52IjnoLvx+by/9wXkIF8aHbq0dgYi4vOB1Q7QV2c4BXM4Z3r+RGBTAR9VqmqhVBoZnIyOdx9taTXqQGJ+YUDqXFwBV4WGU69aXRkNsr69LtyEzHfIKIKJCVl9PT3u+/63P+6bnC64SuWm3jdsYn5xkKcdamCJAAiwjQJcHAC8ATs/OBg1Qy0y4ub6WPhb1cuPwUFycn9/77OPWlvXzeQGw2QPGQ9o/PhZrS0v3IPpooFrpwgChYniidq6fnTnvrBSaA3Uc3A/1uvPuSmEA0f0uFLsyBKcZDjaisvSj8DsFW6pbcHPQpV12WQoBCHhri4taEOGwhJAXjeeBgFebn1eyp0LKi1Ym0rCsXieRqLk06HVetFqJwHmWnRz3yotHzabT9n0hpRxGZ0SjjpGKCEQkxgUtWDlbCyMfIi/qTHMgrDf7srCem5mQDS5YQNKRD2vCuQLMhCVM3bwIiK4PLIUYqrp5EXPFeGWFALO8CEdGddId7NYOHWFQUa1cUO4Fty78/fZW6tFrjx7gqfqAT0PbmWAqVCwq+bDUOxMeyokh6L8B1J1kE2BgIkACJMDyAbSx56/cACV3CoyOjfX9rNSrcrI7E/qVYYCnYhKY3LXkJECVOdx+Us51m6Nwm7HVQyUCf4UGEJuFZPMgIhC+XlYfw21WWQ/GxXJ50q09iBS1MSjYW73ww3SXMVXOobsk4MU80GQZc5DQbl5tOzWRRpS8nJqy1tUAzWZ7ecvKDdfdggWfTV0GbdnA4JB1UdhbHjo0LesAS6YWa2GaCQRIgARIESABEiABUgRIgARYRoAVYtBWBfcL/xb8hwS6av8VYADVjF2M5sTWJAAAAABJRU5ErkJggg=="></center>
<td colspan="1" style="background:#2c0000;" width="15%"> <center> <img width="80" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA11JREFUeNrsnT9IHEEYxWfFw8rgpUhlo5URi2gTbIUUSrq1ui4oRLRIY9JIKrGKTQrBgJLuuutEi4CtSSOpPIuATdIEcid2YpN9C3sc8c6bf7uZmX0P7k7ultm7337zzXxvZjGaiaIfQoiqoHTUHk6eniSPUbLQUmUoebojB23dDZGBmQiQAAmQAAmQIkACJEACpAiweA3bbvDV5mb6+iKOxfTc3MDjf15dicbBQfr3591d7wBGM1H0J3l9bNLI84UFsby6mkIzFWACJMCafJ9PJyfSx29vbHQuoqJaxl34zc5O+mVtwIPi5EIcXV52IjnoLvx+by/9wXkIF8aHbq0dgYi4vOB1Q7QV2c4BXM4Z3r+RGBTAR9VqmqhVBoZnIyOdx9taTXqQGJ+YUDqXFwBV4WGU69aXRkNsr69LtyEzHfIKIKJCVl9PT3u+/63P+6bnC64SuWm3jdsYn5xkKcdamCJAAiwjQJcHAC8ATs/OBg1Qy0y4ub6WPhb1cuPwUFycn9/77OPWlvXzeQGw2QPGQ9o/PhZrS0v3IPpooFrpwgChYniidq6fnTnvrBSaA3Uc3A/1uvPuSmEA0f0uFLsyBKcZDjaisvSj8DsFW6pbcHPQpV12WQoBCHhri4taEOGwhJAXjeeBgFebn1eyp0LKi1Ym0rCsXieRqLk06HVetFqJwHmWnRz3yotHzabT9n0hpRxGZ0SjjpGKCEQkxgUtWDlbCyMfIi/qTHMgrDf7srCem5mQDS5YQNKRD2vCuQLMhCVM3bwIiK4PLIUYqrp5EXPFeGWFALO8CEdGddId7NYOHWFQUa1cUO4Fty78/fZW6tFrjx7gqfqAT0PbmWAqVCwq+bDUOxMeyokh6L8B1J1kE2BgIkACJMDyAbSx56/cACV3CoyOjfX9rNSrcrI7E/qVYYCnYhKY3LXkJECVOdx+Us51m6Nwm7HVQyUCf4UGEJuFZPMgIhC+XlYfw21WWQ/GxXJ50q09iBS1MSjYW73ww3SXMVXOobsk4MU80GQZc5DQbl5tOzWRRpS8nJqy1tUAzWZ7ecvKDdfdggWfTV0GbdnA4JB1UdhbHjo0LesAS6YWa2GaCQRIgARIESABEiABUgRIgARYRoAVYtBWBfcL/xb8hwS6av8VYADVjF2M5sTWJAAAAABJRU5ErkJggg=="></center>
</td>
<td colspan="10">
<center><b>SIDDHARTH INDUSTRIES</b><br/> Survey No: 168/1C3,Pennalur Pet Road,Goonipalyam village, <br/>Uthukottai Taluk,Tiruvallur Dist, Chennai,Tamilnadu,Pin code : 602026. <br/> PaySlip for the Month of <?php echo $PayOn ?></center>
@ -256,7 +256,7 @@ if($RecCount > 0)
</td>
</tr>
</table>
<table style="border-collapse: collapse;border-top:#fff;font-size:15px;" cellpadding="0" cellspacing="0" border="1" width="100%" >
<table style="border-collapse: collapse;border-top:#fff;" cellpadding="0" cellspacing="0" border="1" width="100%" >
<tr><th>Earnings</th><th>Amount <span style="font-family: DejaVu Sans; sans-serif;">&#8377;</span></th><th>Deductions</th><th>Amount <span style="font-family: DejaVu Sans; sans-serif;">&#8377;</span></th></tr>
<tr>
<td width="25%;">&nbsp;Basic Plus DA</td>
@ -309,7 +309,7 @@ if($RecCount > 0)
<tr><th style="text-align: right;" colspan="1">Total Amount In Words &nbsp;</th>
<td style="text-align: right;" colspan="3"><?php if(!empty($amtinwords)){ print_r($amtinwords);} ?></td>
</tr>
<tr><td style="text-align: center;font-size:12px;" colspan="4">This is a computer generated document. This document does not require signature.</td></tr>
<tr><td style="text-align: center;" colspan="4">This is a computer generated document. This document does not require signature.</td></tr>
</tbody>
</table>