/** * createPdf * * @param mixed $params params * @param mixed $event event * * @access public * @return void */ function createPDF($params, $event) { App::import('Vendor', 'xtcpdf'); $this->User = ClassRegistry::init('User'); $this->GroupsMembers = ClassRegistry::init('GroupsMembers'); $this->responseModelName = EvaluationResponseBase::$types[$event['Event']['event_template_type_id']]; $this->responseModel = ClassRegistry::init($this->responseModelName); $epdf = new XTCPDF(); // Construct the filename and extension $fileName = !empty($params['file_name']) ? $params['file_name'] . '.pdf' : date('m.d.y') . '.pdf'; $epdf->AddPage(); $courseName = $params['include']['course'] ? ': ' . $event['Course']['course'] : ''; $eventName = $params['include']['eval_event_names'] ? ' - ' . $event['Event']['title'] : ''; $headerText = '<h2>Evaluation Event Detail' . $courseName . $eventName . '</h2>'; $epdf->writeHTML($headerText, true, false, true, false, ''); $pageCount = 0; foreach ($event['GroupEvent'] as $groupEvent) { $grpEventId = $groupEvent['id']; $grpId = $groupEvent['group_id']; // write group/event details $evalDetails = $this->_writeEvalDetails($event, $grpId, $params); $epdf->writeHTML($evalDetails, true, false, true, false, ''); // get incomplete/unenrolled members $submitted = $this->responseModel->findAllByGrpEventId($grpEventId); $members = Set::extract('/GroupsMembers/user_id', $this->GroupsMembers->findAllByGroupId($grpId)); $evaluators = Set::extract('/' . $this->responseModelName . '/evaluator', $submitted); $evaluatees = Set::extract('/' . $this->responseModelName . '/evaluatee', $submitted); $inComplete = array_diff($members, $evaluators); $inComplete = empty($inComplete) ? array() : $this->User->getFullNames($inComplete); $unEnrolled = array_diff(array_unique(array_merge($evaluators, $evaluatees)), $members); $unEnrolled = empty($unEnrolled) ? array() : $this->User->getFullNames($unEnrolled); $title = !empty($inComplete) || !empty($unEnrolled) ? __('Summary', true) : ''; $epdf->writeHTML('<br><h3>' . $title . '</h3>', true, false, true, false, ''); $title = !empty($inComplete) ? __('Members who have not submitted their evaluations', true) : ''; $epdf->writeHTML('<p><b>' . $title . '</b></p>', true, false, true, false, ''); foreach ($inComplete as $name) { $epdf->writeHTML($name, true, false, true, false, ''); } $title = !empty($unEnrolled) ? __('Left the group, but had submitted or were evaluated', true) : ''; $epdf->writeHTML('<p><b>' . $title . '</b></p>', true, false, true, false, ''); foreach ($unEnrolled as $name) { $epdf->writeHTML($name, true, false, true, false, ''); } $header = '<h3>' . __('Evaluation Results', true) . '</h3><br>'; // broke the summary table and details section into two switch blocks // would be more efficient if the user is filtering out sections if ($params['include']['grade_tables']) { switch ($event['Event']['event_template_type_id']) { case 1: $table = $this->_writeScoresTbl($event, $grpEventId, $grpId, $params); break; case 2: $table = $this->_writeRubricResultsTbl($event, $grpEventId, $grpId, $params); break; case 4: $table = $this->_writeMixResultsTbl($event, $grpEventId, $grpId, $params); break; } if (!empty($table)) { $epdf->writeHTML('<br>', true, false, true, false, ''); } $epdf->writeHTML($table, true, false, true, false, ''); } switch ($event['Event']['event_template_type_id']) { case 1: $results = $params['include']['comments'] ? $this->_writeComments($grpEventId) : ''; $header = $params['include']['comments'] ? '<h3>' . __('Comments', true) . '</h3><br>' : ''; break; case 2: $results = $this->_writeRubricEvalResults($event, $grpEventId, $grpId, $params); break; case 4: $results = $this->_writeMixEvalResults($event, $grpEventId, $grpId, $params); break; } $epdf->writeHTML($header, true, false, true, false, ''); $epdf->writeHTML($results, true, false, true, false, ''); $epdf->lastPage(); $epdf->addPage(); $pageCount++; } $epdf->deletePage($epdf->getNumPages()); if (ob_get_contents()) { ob_clean(); } return $epdf->Output($fileName, 'I'); }
function registration_pdf() { $this->layout = "pdf"; $id_pdf = $this->request->query('id_pdf'); $this->loadModel('registration'); $registrations = $this->registration->find('all', array('conditions' => array('id' => $id_pdf))); 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 = 'DreamShapers'; $tcpdf->AddPage(); //$tcpdf->SetTextColor(0, 0, 0); $tcpdf->SetFont($textfont, 'N', 12); $html = '<table> <tr><td style="background-color:#F1F1F1; color:rgba(28, 62, 143, 0.51); padding-left:10%">Personal Information </td></tr> </table>'; foreach ($registrations as $view_data) { $id = $view_data['registration']['id']; $name = $view_data['registration']['name']; $swd_of = $view_data['registration']['swd_of']; $p_address = $view_data['registration']['p_address']; $p_phone = $view_data['registration']['p_phone']; $fax = $view_data['registration']['fax']; $c_address = $view_data['registration']['c_address']; $phone_home = $view_data['registration']['phone_home']; $office = $view_data['registration']['office']; $mobile_no = $view_data['registration']['mobile_no']; $email = $view_data['registration']['email']; $marital_status = $view_data['registration']['marital_status']; $residential_status = $view_data['registration']['residential_status']; $nationality = $view_data['registration']['nationality']; $occupation = $view_data['registration']['occupation']; $tax_ac_no = $view_data['registration']['tax_ac_no']; $guest_type = $view_data['registration']['guest_type']; if ($guest_type == 'life time') { $wing_name = $view_data['registration']['wing_name']; $flat_no = $view_data['registration']['flat_no']; $floor = $view_data['registration']['floor']; } $card_id_no = $view_data['registration']['card_id_no']; $dob = $view_data['registration']['dob']; $date_of_anniversary = $view_data['registration']['date_of_anniversary']; $reg_type = $view_data['registration']['reg_type']; if ($reg_type == 'dependant') { $cardholder = $view_data['registration']['cardholder']; if (!empty($cardholder)) { $cardholder = explode("-", $cardholder); } } } $html .= ' <br> <table style="line-height:5px"> <tr><td><strong>Name :</strong></td><td>' . ucwords($name) . '</td></tr> <tr><td><strong>S/W/D of :</strong></td><td>' . ucwords($swd_of) . '</td></tr> <tr><th><strong>Permanent Adderss :</strong></th><td>' . ucwords($p_address) . '</td></tr> <tr><th><strong>Phone No. :</strong></th><td>' . $p_phone . '</td></tr> <tr><th><strong>Fax :</strong></th><td>' . ucwords($fax) . '</td></tr> <tr><th><strong>Correspondence Adderss :</strong></th><td>' . ucwords($c_address) . '</td></tr> <tr><th><strong>Phone No. (Home) :</strong></th><td>' . ucwords($phone_home) . '</td></tr> <tr><th><strong>Office :</strong></th><td>' . ucwords($office) . '</td></tr> <tr><th><strong>Mobile No. :</strong></th><td>' . ucwords($mobile_no) . '</td></tr> <tr><th><strong>Email :</strong></th><td>' . $email . '</td></tr> <tr><th><strong>Marital Status :</strong></th><td>' . ucwords($marital_status) . '</td></tr> <tr><td><strong>Residential Status :</strong></td><td>' . ucwords($residential_status) . '</td></tr> <tr><td><strong>Nationality :</strong></td><td>' . ucwords($nationality) . '</td></tr> <tr><th><strong>Occupation :</strong></th><td>' . ucwords($occupation) . '</td></tr> <tr><th><strong>Card Id No. :</strong></th><td>' . $card_id_no . '</td></tr> <tr><th><strong>Income Tax Permanent Account No :</strong></th><td>' . $tax_ac_no . '</td></tr> <tr><th><strong>Date Of Birth :</strong></th><td>' . date("d-m-Y", strtotime($dob)) . '</td></tr> <tr><th><strong>Date of Anniversary:</strong></th><td>' . date("d-m-Y", strtotime($date_of_anniversary)) . '</td></tr> <tr><th><strong>Guest Type :</strong></th><td>' . ucwords($guest_type) . '</td></tr> <tr><th><strong>Registration Type :</strong></th><td>' . ucwords($reg_type) . '</td></tr> </table>'; if ($guest_type == 'life time') { $html .= '<table width="100%" style="margin-top:1%;"> <tr><td colspan="10" style="background-color:#F1F1F1; color:rgba(28, 62, 143, 0.51); padding-left:10%">Details of The Flat </td></tr> </table> <table style="line-height:5px"> <tr><th><strong>Wing Name :</strong></th><td>' . ucwords($wing_name) . '</td></tr> <tr><th><strong>Flat No. :</strong></th><td>' . ucwords($flat_no) . '</td></tr> <tr><th><strong>Floor :</strong></th><td>' . ucwords($floor) . '</td></tr> </table>'; } if ($reg_type == 'dependant') { $html .= '<table width="100%" style="margin-top:1%;"> <tr><td colspan="10" style="background-color:#F1F1F1; color:rgba(28, 62, 143, 0.51); padding-left:10%">Name of Cardholder </td> <td colspan="10" style="background-color:#F1F1F1; color:rgba(28, 62, 143, 0.51); ">Relation with Applicant </td></tr> </table><table style="line-height:5px">'; foreach ($cardholder as $data_store) { $data_exp = explode(',', $data_store); $html .= '<tr><td>' . $data_exp[0] . '</td><td>' . $data_exp[1] . '</td></tr>'; } $html .= '</table>'; } $tcpdf->writeHTML($html); ob_clean(); echo $tcpdf->Output('html.pdf', 'D'); return $this->redirect(array('action' => 'registration_view')); }
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'); }
$pdf->SetKeywords($keywords = $formatter->pi['#keywords']); } // load default font $pdf->AddFont($conf['default_unifont']); $pdf->SetFont($conf['default_font']); // set header and footer fonts // $pdf->setHeaderFont(Array($conf['default_unifont'], '', PDF_FONT_SIZE_MAIN)); $pdf->setHeaderFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); //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 some language-dependent strings $pdf->setLanguageArray($l); //set image scale factor //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); # initialize document $pdf->AliasNbPages(); # add a page $pdf->AddPage(); $pdf->Bookmark($formatter->page->name, 0, 0); # $pdf->writeHTML($html, true, 0, false, false); # output $pdf->output(date("Ymd", time()) . '.pdf', 'I'); return; } // vim:et:sts=4: