function geraPDF($id) { $passagem = $this->Passagem->findById($id); $tcpdf = new XTCPDF(); $textfont = 'aefurat'; // looks better, finer, and more condensed than 'dejavusans' // $tcpdf->SetAuthor("BuyPass - BuyPass.com.br"); $tcpdf->SetAutoPageBreak(false); // $tcpdf->setHeaderFont(array($textfont,'',40)); // // $tcpdf->xheadercolor = array(150,0,0); // $tcpdf->xheadertext = 'BuyPas'; $tcpdf->xfootertext = 'Copyright © %d BuyPass direitos reservadas.'; $tcpdf->SetFont($textfont, 'B', 16); // add a page (required with recent versions of tcpdf) $tcpdf->AddPage(); $tcpdf->SetTextColor(0, 0, 0); // set text shadow effect $tcpdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal')); $string = '<div class="row"> <h2> Segunda via: Comprovante de compra de passagem </h2> <span>Nome:</span>' . ' ' . h($passagem['Passagem']['cliente']) . '<br>' . '<span>Transação feita (por/no):</span>' . ' ' . h($passagem['Passagem']['funcionario']) . '<br>' . '<span>Trajeto e Data e Horário:</span>' . ' ' . h($passagem['Rota']['trajeto']) . '<br>' . '<span>Valor:</span>' . ' ' . h($passagem['Rota']['valor']) . '.00' . '<br>' . '<span>Tipo de Ônibus:</span>' . ' ' . h($passagem['Veiculo']['tipo']) . '<br>' . '<span>Pontos ganhos:</span>' . ' ' . h($passagem['Rota']['pontos']) . ' </div> '; $html = <<<EOD {$string} EOD; // Print text using writeHTMLCell() $tcpdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); // ... // etc. // see the TCPDF examples echo $tcpdf->Output('BuyPass.pdf', 'D'); $this->redirect(array('action' => 'view', $id)); }
function sp_performance_report_pdf() { $this->layout = "pdf"; $this->layout = "session"; $s_society_id = $this->Session->read('society_id'); $s_user_id = $this->Session->read('user_id'); $date1 = $this->request->query('con'); $date2 = $this->request->query('con2'); $this->loadmodel('help_desk'); $conditions = array('society_id' => $s_society_id, 'help_desk.help_desk_service_provider_id' => array('$ne' => 0)); $result12 = $this->help_desk->find('all', array('conditions' => $conditions)); $this->set('result_help_desk', $result12); App::import('Vendor', 'xtcpdf'); $tcpdf = new XTCPDF(); $textfont = 'freesans'; // looks better, finer, and more condensed than 'dejavusans' $tcpdf->SetAuthor("KBS Homes & Properties at http://kbs-properties.com"); $tcpdf->SetAutoPageBreak(true); //$tcpdf->setHeaderFont(array($textfont,'',40)); $tcpdf->xheadercolor = array(255, 255, 255); $tcpdf->xheadertext = ''; $tcpdf->xfootertext = 'HousingMatters'; $tcpdf->AddPage(); $tcpdf->SetTextColor(0, 0, 0); $tcpdf->SetFont($textfont, 'N', 12); $html = ' <div style="background-color:#EFEFEF; border-top:1px solid #e6e6e6; border-bottom:1px solid #e6e6e6; padding:10px; box-shadow:5px; font-size:16px; color:#006;"> Service Provider Performance Report </div> <br> <table><tr><th><b>Sr No.</b></th> <th><b>Ticket</b></th> <th><b>Service Provider</b></th> <th><b>Assigned Date</b></th> <th><b>Closure Date</b></th> <th><b>Average</b></th></tr>'; $i = 0; foreach ($result12 as $data) { $avg = ''; $assign_date = $data['help_desk']['help_desk_assign_date']; $close_date = @$data['help_desk']['help_desk_close_date']; $help_desk_date = $data['help_desk']['help_desk_date']; $sp_id = $data['help_desk']['help_desk_service_provider_id']; $ticket_id = $data['help_desk']['ticket_id']; $help_desk_date1 = date("d-m-y", strtotime($help_desk_date)); $help_desk_date2 = date("Y-m-d", strtotime($help_desk_date1)); $help_desk_date3 = date("d-m-Y", strtotime($help_desk_date2)); if (!empty($assign_date) && !empty($close_date)) { $newDate = date("d-m-y", strtotime($assign_date)); $newDate1 = date("Y-m-d", strtotime($newDate)); $newDate2 = date("d-m-y", strtotime($close_date)); $newDate3 = date("Y-m-d", strtotime($newDate2)); $datetime1 = date_create($newDate1); $datetime2 = date_create($newDate3); $interval = date_diff($datetime1, $datetime2); $avg = $interval->format('%R%a days'); } $sp = $this->fetch_service_provider_info_via_vendor_id($sp_id); foreach ($sp as $data) { $sp_name = $data['service_provider']['sp_name']; } if (strtotime($date1) <= strtotime($help_desk_date3) && strtotime($date2) >= strtotime($help_desk_date3)) { $i++; $html .= ' <tr> <td>' . $i . '</td> <td>' . $ticket_id . '</td> <td>' . $sp_name . '</td> <td>' . $assign_date . '</td> <td>' . $close_date . '</td> <td>' . $avg . '</td></tr> '; } } $html .= "</table>"; $tcpdf->writeHTML($html); echo $tcpdf->Output('sp_report.pdf', 'D'); }
function payslip_update() { if ($this->request->data) { $this->set('employee_id', $this->request->data['SalaryRecord']['employee_id']); $res = $this->Employee->SalaryRecord->salarySearch($this->request->data['SalaryRecord']['employee_id'], $this->request->data['SalaryRecord']['salary_date']); if ($res['SalaryRecord']['payslip_generated'] != 1) { //debug($this->request->data); $earnings = $this->request->data['SalaryRecord']['basic'] + $this->request->data['SalaryRecord']['da'] + $this->request->data['SalaryRecord']['bonus'] + $this->request->data['SalaryRecord']['medical_allowance'] + $this->request->data['SalaryRecord']['tiffin'] + $this->request->data['SalaryRecord']['house_rent'] + $this->request->data['SalaryRecord']['education'] + $this->request->data['SalaryRecord']['entertainment']; $deductions = $this->request->data['SalaryRecord']['pf'] + $this->request->data['SalaryRecord']['esi'] + $this->request->data['SalaryRecord']['income_tax']; $this->request->data['SalaryRecord']['net_salary'] = $earnings - $deductions; $se = $this->Session->read("Auth"); $this->request->data['SalaryRecord']['user_id'] = $se['User']['id']; $this->request->data['SalaryRecord']['print_copy'] = 1; $this->request->data['SalaryRecord']['payslip_generated'] = 1; //debug($this->request->data['SalaryRecord']);exit(); if ($res['SalaryRecord']['id']) { $this->Employee->SalaryRecord->id = $res['SalaryRecord']['id']; } else { $this->Employee->SalaryRecord->create(); } if ($this->Employee->SalaryRecord->save($this->request->data)) { //update the loan amount if ($this->request->data['SalaryRecord']['loan_amount'] > 0) { $this->request->data['Loan']['loan_amount'] = $this->request->data['SalaryRecord']['loan_amount']; $this->request->data['Loan']['employee_id'] = $this->request->data['SalaryRecord']['employee_id']; $loan_save = $this->Employee->Loan->loanEntryUpdate($this->request->data['Loan']); } $this->set('salary_saved', 1); $name = $this->request->data['SalaryRecord']['fname']; if ($this->request->data['SalaryRecord']['mname'] != null) { $name .= ' ' . $this->request->data['SalaryRecord']['mname']; } $name .= ' ' . $this->request->data['SalaryRecord']['lname']; App::import('Vendor', 'xtcpdf'); $tcpdf = new XTCPDF(); $textfont = 'freesans'; // looks better, finer, and more condensed than 'dejavusans' $tcpdf->SetAuthor("Company Name"); $tcpdf->SetAutoPageBreak(false); $tcpdf->setPrintHeader(false); $tcpdf->setPrintFooter(false); //$tcpdf->setHeaderFont(array($textfont,'',40)); //$tcpdf->xheadercolor = array(0,0,0); //$tcpdf->xheadertext = ''; //$tcpdf->xfootertext = ''; // add a page (required with recent versions of tcpdf) $tcpdf->AddPage(); // Now you position and print your page content // example: $fill = 0; $tcpdf->SetTextColor(0, 0, 0); $tcpdf->SetFont($textfont, 'B', 20); $header_html = '<span>Company Logo</span>'; $header_html2 = '<span>Company Address</span>'; $payslip_date = '<p style="font-size:20px!important">Playslip for the month of ' . $this->request->data['SalaryRecord']['salary_date'] . '</p>'; $emp_name = '<p style="font-size:20px!important">Name : ' . $name . '</p>'; $employee_id = '<p style="font-size:20px!important">Employee Id : emp' . $this->request->data['SalaryRecord']['employee_id'] . '</p>'; $department = '<p style="font-size:20px!important">Department : ' . $this->request->data['SalaryRecord']['department'] . '</p>'; $designation = '<p style="font-size:20px!important">Designation : ' . $this->request->data['SalaryRecord']['designation'] . '</p>'; $employee = $this->Employee->employeeSearch($this->request->data['SalaryRecord']['employee_id']); $expected_earnings = $employee['Employee']['net_salary'] + $employee['Employee']['da'] + $employee['Employee']['bonus'] + $employee['Employee']['medical_allowance'] + $employee['Employee']['tiffin'] + $employee['Employee']['house_rent'] + $employee['Employee']['education'] + $employee['Employee']['entertainment']; $expected_deductions = $employee['Employee']['pf'] + $employee['Employee']['esi'] + $employee['Employee']['income_tax']; $earnings_content = ' <style> table{width:100%;border:none} th{font-size:12px;height:10px;font-size:22px!important;border-bottom:0px solid black} td{font-size:20px!important;width:100%;} .total{border-top:0px solid black} </style> <table> <tr> <th><b>Earnings</b></th> </tr> <tr> <td width="50%"></td> <td width="25%">Full (Rs.)</td> <td width="25%">Actual (Rs.)</td> </tr> <tr> <td width="50%">Basic</td> <td width="25%">' . $employee['Employee']['net_salary'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['basic'] . '</td> </tr> <tr> <td width="50%">DA</td> <td width="25%">' . $employee['Employee']['da'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['da'] . '</td> </tr> <tr> <td width="50%">Bonus</td> <td width="25%">' . $employee['Employee']['bonus'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['bonus'] . '</td> </tr> <tr> <td width="50%">Medical Allowance</td> <td width="25%">' . $employee['Employee']['medical_allowance'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['medical_allowance'] . '</td> </tr> <tr> <td width="50%">Tiffin Allowance</td> <td width="25%">' . $employee['Employee']['tiffin'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['tiffin'] . '</td> </tr> <tr> <td width="50%">House Rent Allowance</td> <td width="25%">' . $employee['Employee']['house_rent'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['house_rent'] . '</td> </tr> <tr> <td width="50%">Education Allowance</td> <td width="25%">' . $employee['Employee']['education'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['education'] . '</td> </tr> <tr> <td width="50%">Entertainment Allowance</td> <td width="25%">' . $employee['Employee']['entertainment'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['entertainment'] . '</td> </tr> <tr> <td width="50%" class="total"><b>Total Earnings (Rs.) :</b></td> <td width="25%" class="total"><b>' . $expected_earnings . '</b></td> <td width="25%" class="total"><b>' . $earnings . '</b></td> </tr> </table>'; $deductions_content = ' <style> table{width:100%;border:none} th{font-size:12px;height:10px;font-size:22px!important;border-bottom:0px solid black} td{font-size:20px!important;width:100%;} .total{border-top:0px solid black} </style> <table> <tr> <th><b>Deductions</b></th> </tr> <tr> <td width="50%"></td> <td width="25%">Full (Rs.)</td> <td width="25%">Actual (Rs.)</td> </tr> <tr> <td width="50%">PF</td> <td width="25%">' . $employee['Employee']['pf'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['pf'] . '</td> </tr> <tr> <td width="50%">ESI</td> <td width="25%">' . $employee['Employee']['esi'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['esi'] . '</td> </tr> <tr> <td width="50%">TDS</td> <td width="25%">' . $employee['Employee']['income_tax'] . '</td> <td width="25%">' . $this->request->data['SalaryRecord']['income_tax'] . '</td> </tr> <tr> <td width="50%">Advance</td> <td width="25%">0</td> <td width="25%">0</td> </tr> <tr> <td width="50%">Loan</td> <td width="25%">0</td> <td width="25%">0</td> </tr> <tr> <td width="50%"></td> <td width="25%"></td> <td width="25%"></td> </tr> <tr> <td width="50%"></td> <td width="25%"></td> <td width="25%"></td> </tr> <tr> <td width="50%"></td> <td width="25%"></td> <td width="25%"></td> </tr> <tr> <td width="50%" class="total"><b>Total Deductions (Rs.) :</b></td> <td width="25%" class="total"><b>' . $expected_deductions . '</b></td> <td width="25%" class="total"><b>' . $deductions . '</b></td> </tr> </table>'; $net_earnings = $earnings - $deductions; $net_salary = '<p style="font-size:20px!important"><b>Net Salary : Rs. ' . $net_earnings . '</b></p>'; $auto_text = '<p style="font-size:22px!important;color:#cccccc">This is a computer-generated salary slip. Does not require a Signature</p>'; $tcpdf->SetFillColor(155, 100, 0); $tcpdf->writeHTMLCell(50, 0, '', 10, $header_html, 0, 1, 0, true, 'L', true); $tcpdf->writeHTMLCell(50, 0, 55, 10, $header_html2, 0, 0, 0, true, 'R', true); $tcpdf->writeHTMLCell(0, 0, '', 35, $payslip_date, 0, 1, 0, true, 'L', true); $tcpdf->writeHTMLCell(80, 5, '', 40, $emp_name, 'LRTB', 1, 0, true, 'C', true); $tcpdf->writeHTMLCell(80, 5, 85, 40, $employee_id, 'RTB', 1, 0, true, 'C', true); $tcpdf->writeHTMLCell(80, 5, '', 45, $department, 'LRB', 1, 0, true, 'C', true); $tcpdf->writeHTMLCell(80, 5, 85, 45, $designation, 'RB', 1, 0, true, 'C', true); $tcpdf->writeHTMLCell(80, '', '', 55, $earnings_content, 'LRTB', 1, 0, true, 'C', true); $tcpdf->writeHTMLCell(80, '', 85, 55, $deductions_content, 'RTB', 1, 0, true, 'C', true); $tcpdf->writeHTMLCell(155, 3, '', '', $net_salary, 'LRTB', 1, 0, true, 'L', true); $tcpdf->writeHTMLCell(155, '', '', 105, $auto_text, '', 1, 0, true, 'L', true); // ... // etc. // see the TCPDF examples $file_name = time() . '.pdf'; echo $tcpdf->Output($file_name, 'F'); //setting view variables before sending email so that if email is not sent generated salry slip will still be viewed $this->set('salaryrecord', $this->request->data['SalaryRecord']); $this->set('employee', $employee); $this->set('earnings', $earnings); $this->set('deductions', $deductions); $this->set('expected_earnings', $expected_earnings); $this->set('net_earnings', $net_earnings); App::uses('CakeEmail', 'Network/Email'); $Email = new CakeEmail(); $Email->to($this->request->data['SalaryRecord']['email']); $Email->bcc($se['User']['email']); $Email->subject('Salary Slip of ' . $name . ' [ emp' . $this->request->data['SalaryRecord']['employee_id'] . ' ] for ' . $this->request->data['SalaryRecord']['salary_date']); $Email->replyTo($se['User']['email']); $Email->from($se['User']['email']); $Email->emailFormat('html'); $Email->viewVars(array('salary_record' => $this->request->data['SalaryRecord'])); $Email->attachments($file_name); $Email->template('salaryslip'); //$Email->send(); App::uses('File', 'Utility'); $file = new File($file_name); $file->delete(); } else { $this->set('salary_saved', 0); } } } }
/** Lager standard tcpdf oppstart Kalles av bpost og faktura **/ function startPdf() { $tcpdf = new XTCPDF(); //$tcpdf->setCreator(PDF_CREATOR); $tcpdf->SetAuthor("Zapatistgruppa i Bergen http://www.zapatista.no"); $tcpdf->setCreator("Zapatistgruppa i Bergen http://www.zapatista.no"); $tcpdf->SetAutoPageBreak(false); //set image scale factor $tcpdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // Now you position and print your page content // example: $tcpdf->SetTextColor(0, 0, 0); $tcpdf->AddPage(); return $tcpdf; }