Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function printrecord() {
- require(dirname(__FILE__) . '/../../tcpdf/tcpdf_import.php');
- $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- //echo 'ayay lmao';
- $user_id = $this->session->userdata('user_id');
- $items = $this->input->post('items');
- $report_rule = $this->input->post('report_rule');
- $report_detail = $this->admin_report_model->report_select_data($report_rule);
- //print_r($report_detail);
- if ($this->session->userdata('site_language') == "english") {
- $report_name = $report_detail[0]['report_name_english'];
- } else {
- $report_name = $report_detail[0]['report_description_french'];
- }
- $pdf->AddPage('L', 'A4');
- $html = '<h1 style="text-align:center;">' . $report_name . '</h1>';
- $html .= '<table>';
- foreach ($items as $firstitem) {
- $html .= '<tr>';
- //$html .= '<tr>';
- $conditions = array('status' => '1', 'id_report' => $report_rule);
- $all_field = $this->admin_report_model->getFields($conditions);
- $all_field = $all_field->result();
- //$pdf->SetFont('dejavusans', '', 14, '', true);
- $cond = array('inventory_id' => $firstitem);
- $res = $this->inventory_model->getProduct(null, $cond);
- $res = $res->result();
- $condsales = array('inventory_id' => $firstitem);
- $sales = $this->inventory_model->get_sales_history(null, $condsales);
- $sales = $sales->result();
- $elements = array();
- $col = 0;
- foreach ($all_field as $field) {
- if ($field->status == 1) {
- if ($col == 6)
- {
- $html .= '</tr><tr>';
- $col = 0;
- }
- $name = $field->field_name;
- $html .= '<td border="1" padding="1px">' . $res[0]->$name . '</td>';
- $col++;
- }
- //array_push($elements, $field->field_name);
- }
- $html .= '</tr>';
- $col = 0;
- $i = 0;
- //echo 'test : ' . dirname(__FILE__) . '/../../uploads/image/' . $res[0]->prof_img;
- /*
- $html .= '<div style="text-align: center;">';
- if (in_array('prof_img', $elements)) {
- $img = dirname(__FILE__) . '/../../uploads/image/' . $res[0]->prof_img;
- $pdf->Image($img, 120, 30, 50, 50);
- }
- if (in_array('prof_img2', $elements)) {
- $img = dirname(__FILE__) . '/../../uploads/image/' . $res[0]->prof_img2;
- $pdf->Image($img, 120, 80, 50, 50);
- }
- if (in_array('prof_img3', $elements)) {
- $img = dirname(__FILE__) . '/../../uploads/image/' . $res[0]->prof_img3;
- $pdf->Image($img, 120, 130, 50, 50);
- }
- */
- /*
- if (in_array('prof_img', $elements)) {
- $html .= '<td border="1" padding="1px"><img src="' . dirname(__FILE__) . '/../../uploads/image/' . $res[0]->prof_img . '" width="100" height="100" /></td>';
- //$html .= '<td></td>';
- // $html .= '</tr>';
- // $html .= '<tr>';
- //$pdf->Image($img, 120, 30, 50, 50);
- }
- if (in_array('title', $elements)) {
- $html .= '<td border="1" padding="1px">' . $res[0]->title . '</td>';
- }
- if (in_array('artist', $elements)) {
- $html .= '<td border="1">Oeuvre de ' . $res[0]->artist . '</td>';
- }
- if (in_array('created_date', $elements)) {
- $html .= '<td border="1">Date de création : ' . $res[0]->created_date;
- if (in_array('place', $elements)) {
- $html .= ' à ' . $res[0]->place . '</td>';
- } else {
- $html .= '</td>';
- }
- } else {
- if (in_array('place', $elements)) {
- $html .= '<td border="1">Lieu de création : ' . $res[0]->place . '</td>';
- }
- }
- if (in_array('object', $elements)) {
- $html .= '<td border="1">Objet confié ' . $res[0]->object . '</td>';
- }
- if (in_array('inventory_value', $elements)) {
- $html .= '<td border="1">Oeuvre de ' . $res[0]->inventory_value . '</td>';
- }
- if (in_array('f_height', $elements) && in_array('f_depth', $elements) && in_array('f_width', $elements) && in_array('f_unit', $elements)) {
- $html .= '<td border="1">Dimensions : ';
- }
- if (in_array('f_height', $elements)) {
- $html .= $res[0]->f_height . 'x';
- }
- if (in_array('f_depth', $elements)) {
- $html .= $res[0]->f_depth . 'x';
- }
- if (in_array('f_width', $elements)) {
- $html .= $res[0]->f_width;
- }
- if (in_array('f_unit', $elements)) {
- $html .= $res[0]->f_unit;
- }
- if (in_array('f_height', $elements) && in_array('f_depth', $elements) && in_array('f_width', $elements) && in_array('f_unit', $elements)) {
- $html .= '</td>';
- }
- if (in_array('edition1', $elements) && in_array('edition2', $elements)) {
- $html .= '<td border="1">Edition n°' . $res[0]->edition1 . ' / ' . $res[0]->edition2 . '</td>';
- }
- if (in_array('signed', $elements)) {
- if ($res[0]->signed == 'Signed')
- $html .= '<td border="1">Signé</td>';
- else
- $html .= '<td border="1">Non signé</td>';
- }
- if (in_array('address', $elements)) {
- $html .= '<td border="1">' . $res[0]->address . '</td>';
- }
- if (in_array('etat', $elements)) {
- $html .= '<td border="1">Etat : ' . $res[0]->etat . '</td>';
- }
- if (in_array('poids', $elements)) {
- $html .= '<td border="1">Poids : ' . $res[0]->poids . '</td>';
- }
- }
- */
- }
- $html .= '</table>';
- $pdf->writeHTML($html, true, false, true, false, '');
- if (in_array('history', $elements))
- {
- $html = '<p style="width:300px;">Historique : ' . $res[0]->history . '</td>';
- }
- //$pdf->writeHTML($html, true, false, true, false, '');
- $pdf->AddPage();
- $pdf->writeHTML("<h2>Détails financier</h2>", true, false, true, false, '');
- if ($sales[0]->purchased_from != "")
- {
- $pdf->Write(10, $sales[0]->purchased_from, '', 0, null, true, 0, false, false, 0, 24);
- }
- if ($sales[0]->address != "")
- {
- $pdf->Write(10, $sales[0]->address, '', 0, null, true, 0, false, false, 0, 24);
- }
- if ($sales[0]->ph_no != "")
- {
- $pdf->Write(10, $sales[0]->ph_no, '', 0, null, true, 0, false, false, 0, 24);
- }
- if ($sales[0]->email != "")
- {
- $pdf->Write(10, $sales[0]->email, '', 0, null, true, 0, false, false, 0, 24);
- }
- if ($sales[0]->website != "")
- {
- $pdf->Write(10, $sales[0]->website, '', 0, null, true, 0, false, false, 0, 24);
- }
- if ($sales[0]->date_purchesed != "")
- {
- $pdf->Write(10, $sales[0]->date_purchesed, '', 0, null, true, 0, false, false, 0, 24);
- }
- $html = '';
- $html .= '<table>';
- if ($sales[0]->cost != "" && $sales[0]->cost_note != "")
- {
- $html .= '<tr><td border="1">' . $sales[0]->cost_note . '</td><td border="1">' . $sales[0]->cost . '€</td></tr>';
- }
- if ($sales[0]->cost1 != "" && $sales[0]->cost1_note != "")
- {
- $html .= '<tr><td border="1">' . $sales[0]->cost1_note . '</td><td border="1">' . $sales[0]->cost1 . '€</td></tr>';
- }
- if ($sales[0]->cost2 != "" && $sales[0]->cost2_note != "")
- {
- $html .= '<tr><td border="1">' . $sales[0]->cost2_note . '</td><td border="1">' . $sales[0]->cost2 . '€</td></tr>';
- }
- if ($sales[0]->cost3 != "" && $sales[0]->cost3_note != "")
- {
- $html .= '<tr><td border="1">' . $sales[0]->cost3_note . '</td><td border="1">' . $sales[0]->cost3 . '€</td></tr>';
- }
- if ($sales[0]->cost4 != "" && $sales[0]->cost4_note != "")
- {
- $html .= '<tr><td border="1">' . $sales[0]->cost4_note . '</td><td border="1">' . $sales[0]->cost4 . '€</td></tr>';
- }
- if ($sales[0]->cost5 != "" && $sales[0]->cost5_note != "")
- {
- $html .= '<tr><td border="1">' . $sales[0]->cost5_note . '</td><td border="1">' . $sales[0]->cost5 . '€</td></tr>';
- }
- if ($sales[0]->cost_total)
- {
- $html .= '<tr><td></td><td border="1">' . $sales[0]->cost_total . '€</td></tr>';
- }
- $html .= '</table>';
- $pdf->writeHTML($html, true, false, true, false, '');
- $pdf->AddPage('P', 'A4');
- $html = '';
- $count_type = $this->admin_letter_model->getCountByType();
- $count_type = $count_type->result();
- for ($i = 0; $i < count($count_type); $i++)
- {
- $isEnd = false;
- $j = 0;
- while (!$isEnd)
- {
- $elt = strtolower($count_type[$i]->type) . $j;
- if (isset($_POST[$elt]))
- {
- if ($this->input->post($elt) != '')
- {
- if ($count_type[$i]->type == 'Receiver' || $count_type[$i]->type == 'Signature') {
- $pdf->Write(0, $this->input->post($elt), '', 0, 'R', true, 0, false, false, 0, 0, array(30,30, 0, 0));
- }
- else {
- $pdf->Write(0, $this->input->post($elt), '', 0, 'L', true, 0, false, false, 0, 0, array(30, 30, 0, 0));
- }
- //$html .= $this->input->post($elt) . '<br />';
- }
- }
- else
- {
- $isEnd = true;
- }
- $j++;
- }
- if ($count_type[$i]->type == 'Receiver' || $count_type[$i]->type == 'Content')
- {
- $pdf->Ln(25);
- }
- }
- $pdf->Output();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement