Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.96 KB | None | 0 0
  1. function printrecord() {
  2.  
  3.  
  4. require(dirname(__FILE__) . '/../../tcpdf/tcpdf_import.php');
  5. $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  6. $pdf->setPrintHeader(false);
  7. $pdf->setPrintFooter(false);
  8. //echo 'ayay lmao';
  9. $user_id = $this->session->userdata('user_id');
  10. $items = $this->input->post('items');
  11. $report_rule = $this->input->post('report_rule');
  12. $report_detail = $this->admin_report_model->report_select_data($report_rule);
  13. //print_r($report_detail);
  14. if ($this->session->userdata('site_language') == "english") {
  15. $report_name = $report_detail[0]['report_name_english'];
  16. } else {
  17. $report_name = $report_detail[0]['report_description_french'];
  18. }
  19. $pdf->AddPage('L', 'A4');
  20. $html = '<h1 style="text-align:center;">' . $report_name . '</h1>';
  21.  
  22. $html .= '<table>';
  23.  
  24. foreach ($items as $firstitem) {
  25.  
  26. $html .= '<tr>';
  27. //$html .= '<tr>';
  28.  
  29. $conditions = array('status' => '1', 'id_report' => $report_rule);
  30. $all_field = $this->admin_report_model->getFields($conditions);
  31. $all_field = $all_field->result();
  32.  
  33. //$pdf->SetFont('dejavusans', '', 14, '', true);
  34. $cond = array('inventory_id' => $firstitem);
  35. $res = $this->inventory_model->getProduct(null, $cond);
  36. $res = $res->result();
  37. $condsales = array('inventory_id' => $firstitem);
  38. $sales = $this->inventory_model->get_sales_history(null, $condsales);
  39. $sales = $sales->result();
  40. $elements = array();
  41. $col = 0;
  42. foreach ($all_field as $field) {
  43. if ($field->status == 1) {
  44. if ($col == 6)
  45. {
  46. $html .= '</tr><tr>';
  47. $col = 0;
  48. }
  49. $name = $field->field_name;
  50. $html .= '<td border="1" padding="1px">' . $res[0]->$name . '</td>';
  51. $col++;
  52. }
  53. //array_push($elements, $field->field_name);
  54. }
  55. $html .= '</tr>';
  56. $col = 0;
  57. $i = 0;
  58. //echo 'test : ' . dirname(__FILE__) . '/../../uploads/image/' . $res[0]->prof_img;
  59. /*
  60. $html .= '<div style="text-align: center;">';
  61. if (in_array('prof_img', $elements)) {
  62. $img = dirname(__FILE__) . '/../../uploads/image/' . $res[0]->prof_img;
  63. $pdf->Image($img, 120, 30, 50, 50);
  64. }
  65. if (in_array('prof_img2', $elements)) {
  66. $img = dirname(__FILE__) . '/../../uploads/image/' . $res[0]->prof_img2;
  67. $pdf->Image($img, 120, 80, 50, 50);
  68. }
  69. if (in_array('prof_img3', $elements)) {
  70. $img = dirname(__FILE__) . '/../../uploads/image/' . $res[0]->prof_img3;
  71. $pdf->Image($img, 120, 130, 50, 50);
  72. }
  73. */
  74. /*
  75. if (in_array('prof_img', $elements)) {
  76. $html .= '<td border="1" padding="1px"><img src="' . dirname(__FILE__) . '/../../uploads/image/' . $res[0]->prof_img . '" width="100" height="100" /></td>';
  77. //$html .= '<td></td>';
  78. // $html .= '</tr>';
  79. // $html .= '<tr>';
  80. //$pdf->Image($img, 120, 30, 50, 50);
  81. }
  82. if (in_array('title', $elements)) {
  83. $html .= '<td border="1" padding="1px">' . $res[0]->title . '</td>';
  84. }
  85. if (in_array('artist', $elements)) {
  86. $html .= '<td border="1">Oeuvre de ' . $res[0]->artist . '</td>';
  87. }
  88. if (in_array('created_date', $elements)) {
  89. $html .= '<td border="1">Date de création : ' . $res[0]->created_date;
  90. if (in_array('place', $elements)) {
  91. $html .= ' à ' . $res[0]->place . '</td>';
  92. } else {
  93. $html .= '</td>';
  94. }
  95. } else {
  96. if (in_array('place', $elements)) {
  97. $html .= '<td border="1">Lieu de création : ' . $res[0]->place . '</td>';
  98. }
  99. }
  100.  
  101. if (in_array('object', $elements)) {
  102. $html .= '<td border="1">Objet confié ' . $res[0]->object . '</td>';
  103. }
  104. if (in_array('inventory_value', $elements)) {
  105. $html .= '<td border="1">Oeuvre de ' . $res[0]->inventory_value . '</td>';
  106. }
  107. if (in_array('f_height', $elements) && in_array('f_depth', $elements) && in_array('f_width', $elements) && in_array('f_unit', $elements)) {
  108. $html .= '<td border="1">Dimensions : ';
  109. }
  110. if (in_array('f_height', $elements)) {
  111. $html .= $res[0]->f_height . 'x';
  112. }
  113. if (in_array('f_depth', $elements)) {
  114. $html .= $res[0]->f_depth . 'x';
  115. }
  116. if (in_array('f_width', $elements)) {
  117. $html .= $res[0]->f_width;
  118. }
  119. if (in_array('f_unit', $elements)) {
  120. $html .= $res[0]->f_unit;
  121. }
  122. if (in_array('f_height', $elements) && in_array('f_depth', $elements) && in_array('f_width', $elements) && in_array('f_unit', $elements)) {
  123. $html .= '</td>';
  124. }
  125. if (in_array('edition1', $elements) && in_array('edition2', $elements)) {
  126. $html .= '<td border="1">Edition n°' . $res[0]->edition1 . ' / ' . $res[0]->edition2 . '</td>';
  127. }
  128. if (in_array('signed', $elements)) {
  129. if ($res[0]->signed == 'Signed')
  130. $html .= '<td border="1">Signé</td>';
  131. else
  132. $html .= '<td border="1">Non signé</td>';
  133. }
  134. if (in_array('address', $elements)) {
  135. $html .= '<td border="1">' . $res[0]->address . '</td>';
  136. }
  137. if (in_array('etat', $elements)) {
  138. $html .= '<td border="1">Etat : ' . $res[0]->etat . '</td>';
  139. }
  140. if (in_array('poids', $elements)) {
  141. $html .= '<td border="1">Poids : ' . $res[0]->poids . '</td>';
  142. }
  143.  
  144. }
  145. */
  146. }
  147. $html .= '</table>';
  148. $pdf->writeHTML($html, true, false, true, false, '');
  149.  
  150.  
  151.  
  152. if (in_array('history', $elements))
  153. {
  154. $html = '<p style="width:300px;">Historique : ' . $res[0]->history . '</td>';
  155. }
  156. //$pdf->writeHTML($html, true, false, true, false, '');
  157. $pdf->AddPage();
  158.  
  159. $pdf->writeHTML("<h2>Détails financier</h2>", true, false, true, false, '');
  160.  
  161. if ($sales[0]->purchased_from != "")
  162. {
  163. $pdf->Write(10, $sales[0]->purchased_from, '', 0, null, true, 0, false, false, 0, 24);
  164. }
  165. if ($sales[0]->address != "")
  166. {
  167. $pdf->Write(10, $sales[0]->address, '', 0, null, true, 0, false, false, 0, 24);
  168. }
  169. if ($sales[0]->ph_no != "")
  170. {
  171. $pdf->Write(10, $sales[0]->ph_no, '', 0, null, true, 0, false, false, 0, 24);
  172. }
  173. if ($sales[0]->email != "")
  174. {
  175. $pdf->Write(10, $sales[0]->email, '', 0, null, true, 0, false, false, 0, 24);
  176. }
  177. if ($sales[0]->website != "")
  178. {
  179. $pdf->Write(10, $sales[0]->website, '', 0, null, true, 0, false, false, 0, 24);
  180. }
  181. if ($sales[0]->date_purchesed != "")
  182. {
  183. $pdf->Write(10, $sales[0]->date_purchesed, '', 0, null, true, 0, false, false, 0, 24);
  184. }
  185. $html = '';
  186. $html .= '<table>';
  187. if ($sales[0]->cost != "" && $sales[0]->cost_note != "")
  188. {
  189. $html .= '<tr><td border="1">' . $sales[0]->cost_note . '</td><td border="1">' . $sales[0]->cost . '€</td></tr>';
  190. }
  191. if ($sales[0]->cost1 != "" && $sales[0]->cost1_note != "")
  192. {
  193. $html .= '<tr><td border="1">' . $sales[0]->cost1_note . '</td><td border="1">' . $sales[0]->cost1 . '€</td></tr>';
  194. }
  195. if ($sales[0]->cost2 != "" && $sales[0]->cost2_note != "")
  196. {
  197. $html .= '<tr><td border="1">' . $sales[0]->cost2_note . '</td><td border="1">' . $sales[0]->cost2 . '€</td></tr>';
  198. }
  199. if ($sales[0]->cost3 != "" && $sales[0]->cost3_note != "")
  200. {
  201. $html .= '<tr><td border="1">' . $sales[0]->cost3_note . '</td><td border="1">' . $sales[0]->cost3 . '€</td></tr>';
  202. }
  203. if ($sales[0]->cost4 != "" && $sales[0]->cost4_note != "")
  204. {
  205. $html .= '<tr><td border="1">' . $sales[0]->cost4_note . '</td><td border="1">' . $sales[0]->cost4 . '€</td></tr>';
  206. }
  207. if ($sales[0]->cost5 != "" && $sales[0]->cost5_note != "")
  208. {
  209. $html .= '<tr><td border="1">' . $sales[0]->cost5_note . '</td><td border="1">' . $sales[0]->cost5 . '€</td></tr>';
  210. }
  211. if ($sales[0]->cost_total)
  212. {
  213. $html .= '<tr><td></td><td border="1">' . $sales[0]->cost_total . '€</td></tr>';
  214. }
  215. $html .= '</table>';
  216. $pdf->writeHTML($html, true, false, true, false, '');
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223. $pdf->AddPage('P', 'A4');
  224. $html = '';
  225. $count_type = $this->admin_letter_model->getCountByType();
  226. $count_type = $count_type->result();
  227. for ($i = 0; $i < count($count_type); $i++)
  228. {
  229. $isEnd = false;
  230. $j = 0;
  231. while (!$isEnd)
  232. {
  233. $elt = strtolower($count_type[$i]->type) . $j;
  234. if (isset($_POST[$elt]))
  235. {
  236. if ($this->input->post($elt) != '')
  237. {
  238. if ($count_type[$i]->type == 'Receiver' || $count_type[$i]->type == 'Signature') {
  239. $pdf->Write(0, $this->input->post($elt), '', 0, 'R', true, 0, false, false, 0, 0, array(30,30, 0, 0));
  240. }
  241. else {
  242. $pdf->Write(0, $this->input->post($elt), '', 0, 'L', true, 0, false, false, 0, 0, array(30, 30, 0, 0));
  243. }
  244. //$html .= $this->input->post($elt) . '<br />';
  245. }
  246. }
  247. else
  248. {
  249. $isEnd = true;
  250. }
  251. $j++;
  252. }
  253. if ($count_type[$i]->type == 'Receiver' || $count_type[$i]->type == 'Content')
  254. {
  255. $pdf->Ln(25);
  256. }
  257. }
  258. $pdf->Output();
  259.  
  260. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement