Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.08 KB | None | 0 0
  1. function generate_wrr(){
  2.  
  3. $r = $this->uri->segment(3) == 'r' ? true : false;
  4.  
  5. $WRR = $RJO_ID = $Masked_JO_ID = $SPI_DR = $fabric = '';
  6. if(!$r) {
  7. $WRR = $this->input->get('id');
  8. $this->db->where('WRR', $WRR);
  9. $fabric = $this->db->get('tblfabric_received')->row();
  10. }
  11.  
  12. $ra = array();
  13. if($fabric) {
  14. $Masked_WRR = $fabric->Masked_WRR;
  15. $page_title = 'Edit Received Fabric';
  16.  
  17. $this->db->where('fr.WRR', $WRR);
  18. $this->db->select('fr.*, c.Customer_ID, c.Customer_Code, jo.*');
  19. $this->db->from('tblfabric_received fr');
  20. $this->db->join('tblcustomers c', 'fr.Customer_ID = c.Customer_ID','left');
  21. $this->db->join('tbljob_orders jo', 'fr.WRR = jo.WRR','left');
  22. $fabric = $this->db->get()->row();
  23.  
  24. $fabric->Date_Created = format_date($fabric->Date_Created, 'm/d/Y');
  25. $fabric->Date_Scheduled = date('m/d/Y', strtotime($fabric->Date_Scheduled));
  26.  
  27. $this->db->where('WRR', $WRR);
  28. $fabric->Variations = $this->db->get('tblfabric_variations')->result();
  29.  
  30. if($fabric->RJO_ID) {
  31. $RJO_ID = $fabric->RJO_ID;
  32. $this->db->where('JO_ID', $RJO_ID);
  33. $Masked_JO_ID = $this->db->get('tbljob_orders')->row('Masked_JO_ID');
  34. $SPI_DR = $fabric->SPI_DR;
  35. }
  36. } else {
  37. $dj = '';
  38. $error = $WRR && !$r ? 'WRR not found!' : '';
  39. if($r) {
  40. $DJ_ID = $this->input->get('id');
  41. $this->db->where('dj.DJ_ID', $DJ_ID);
  42. $this->db->from('tbldelivery_jo dj');
  43. $this->db->join('tbldeliveries d', 'dj.Delivery_ID = d.Delivery_ID', 'left');
  44. $this->db->join('tbljob_orders jo', 'dj.JO_ID = jo.JO_ID', 'left');
  45. $this->db->join('tblcolors c', 'jo.Color_ID = c.Color_ID', 'left');
  46. $this->db->select('dj.*, d.Delivery_ID, d.Customer_ID, jo.Masked_JO_ID, jo.Finished_Final_Width, jo.Finished_Final_Width_A, jo.Finished_Final_Density, jo.Finished_Final_Density_A, jo.Finished_Final_Stripe_Repeat, jo.Orientation, c.Color_Description');
  47. $dj = $this->db->get()->row();
  48.  
  49. if($dj) {
  50. if($dj->Status == 'Pending Returned') {
  51. $rrs = unserialize($dj->Rolls_Returned);
  52. $rbs = unserialize($dj->Rolls_Breakdown);
  53.  
  54. $ra['Customer_ID'] = $dj->Customer_ID;
  55. $RJO_ID = $dj->JO_ID;
  56. $Masked_JO_ID = $dj->Masked_JO_ID;
  57. $SPI_DR = $dj->Delivery_ID;
  58.  
  59. foreach ($rrs as $vid => $rr) {
  60. $this->db->where('Variation_ID', $vid);
  61. $sid = $this->db->get('tblfabric_variations')->row('Specification_ID');
  62. $rolls = $weight = 0;
  63. foreach ($rr as $i => $r) {
  64. if($r == 'false') {
  65. $rolls++;
  66. $weight += $rbs[$vid][$i]['weight'];
  67. }
  68. }
  69.  
  70. if($rolls && $weight) {
  71. $v = new stdClass();
  72. $v->Specification_ID = $sid;
  73. $v->Rolls = $rolls;
  74. $v->Weight = $weight;
  75. $v->Color = $dj->Color_Description;
  76. $v->Orientation = $dj->Orientation;
  77. $v->Dye_Type = 'bj';
  78. $v->Finishing_ID = 9;
  79. if($sid == 1) {
  80. $v->Width = $dj->Finished_Final_Width;
  81. $v->Density = $dj->Finished_Final_Density;
  82. } else {
  83. $v->Width = $dj->Finished_Final_Width_A;
  84. $v->Density = $dj->Finished_Final_Density_A;
  85. }
  86. $v->Stripe_Repeat = $dj->Finished_Final_Stripe_Repeat;
  87. $ra['v'][] = $v;
  88. }
  89. }
  90. } else {
  91. $error = 'Returned JO already received!';
  92. }
  93. } else {
  94. $error = 'Returned JO not found!';
  95. }
  96. }
  97.  
  98. if($error) {
  99. generate_prompt($error);
  100. redirect('/fabric/received', 'refresh');
  101. }
  102.  
  103. $page_title = 'Fabric Receiving';
  104. $year = date('Y');
  105. $this->db->order_by('WRR DESC');
  106. $wrr = $this->db->get('tblfabric_received')->num_rows() + 1;
  107. $Masked_WRR = 'W' . date('y') . '-' . str_pad( $wrr, 5, "0", STR_PAD_LEFT );
  108. }
  109.  
  110.  
  111. $blend_list = $this->db->get('tblfabric_blends')->result();
  112. $specification_list = $this->db->get('tblspecifications')->result();
  113. $finishing_list = $this->db->get('tblfinishing')->result();
  114. $orientation_list = array(
  115. 'T' => 'Tube',
  116. 'O' => 'Open'
  117. );
  118.  
  119. $dye_type_list = array(
  120. 'colored' => 'COLORED',
  121. 'white' => 'WHITE/FB',
  122. 'stripes' => 'STRIPES',
  123. 'washing' => 'WASHING',
  124. 'bj' => 'BACK JOB',
  125. 'no_instruction' => 'NO INSTRUCTION',
  126. );
  127.  
  128. $this->db->where('WRR', $WRR);
  129. $this->db->where('Chamber_Details !=', '');
  130. $jo = $this->db->get('tbljob_orders')->row();
  131. $disable_wrr = $jo ? true : false;
  132.  
  133. $data = array(
  134. 'page' => 'fabric/receiving',
  135. 'tab_title' => $page_title,
  136. 'WRR' => $WRR,
  137. 'Masked_WRR' => $Masked_WRR,
  138. 'fabric' => $fabric,
  139. 'blend_list' => $blend_list,
  140. 'specification_list' => $specification_list,
  141. 'finishing_list' => $finishing_list,
  142. 'orientation_list' => $orientation_list,
  143. 'dye_type_list' => $dye_type_list,
  144. 'disable_wrr' => $disable_wrr,
  145. 'ra' => $ra,
  146. 'RJO_ID' => $RJO_ID,
  147. 'Masked_JO_ID' => $Masked_JO_ID,
  148. 'SPI_DR' => $SPI_DR
  149. );
  150.  
  151.  
  152.  
  153. $pdf = new PDF_Code128('P','mm','Legal');
  154. $pdf->SetFont('Times','',10);
  155.  
  156. $pdf->AddPage();
  157. $pdf->SetTextColor(000, 000, 000);
  158.  
  159. $pdf->SetXY(180, 20);
  160. $pdf->Write(0, 'FORM W-1');
  161.  
  162. $pdf->SetXY(0,25);
  163. $pdf->SetFont('Times','B',15);
  164. $pdf->Cell(210, 2.7,'SAFFRON PHILIPPINES INC.', 0, 0, 'C');
  165.  
  166. $pdf->SetXY(0, 30);
  167. $pdf->Cell(210, 2.7,'WAREHOUSE RECEIVING REPORT', 0, 0, 'C');
  168.  
  169.  
  170. $pdf->SetXY(30, 50);
  171. $pdf->SetFont('Times','',10);
  172. $pdf->Write(0, 'Customer:'.$fabric->Customer_Code);
  173.  
  174. $pdf->SetXY(30, 55);
  175. $pdf->Write(0, 'Customer Ref. No:'.$fabric->Customer_DR);
  176.  
  177. $pdf->SetXY(30, 60);
  178. $pdf->Write(0, 'Customer PO No:' . $fabric->PO_Number);
  179.  
  180. $pdf->SetXY(30, 65);
  181. $pdf->Write(0, 'Fabric Specs:'.$fabric->Fabric_Specification);
  182.  
  183. $pdf->SetXY(30, 70);
  184. $pdf->Write(0, 'Accessory: ');
  185.  
  186. $pdf->SetXY(130, 50);
  187. $pdf->SetFont('Times','',10);
  188. $pdf->Write(0, 'WRR No:'.$Masked_WRR);
  189.  
  190. $pdf->SetXY(130, 55);
  191. $pdf->Write(0, 'Date Prepared:'.$fabric->Date_Created);
  192.  
  193. $pdf->SetXY(130, 60);
  194. $pdf->Write(0, 'Date Received:'.$fabric->Date_Scheduled);
  195.  
  196. $pdf->SetXY(130, 65);
  197. $pdf->Write(0, 'Due Date:');
  198.  
  199.  
  200. $pdf->SetXY(30, 80);
  201. $pdf->Write(0, 'Color');
  202. $pdf->SetXY(55, 80);
  203. $pdf->Write(0, '# of Rolls');
  204. $pdf->SetXY(75, 80);
  205. $pdf->Write(0, 'Weight(KGS)');
  206. $pdf->SetXY(110, 80);
  207. $pdf->Write(0, 'Total');
  208. $pdf->SetXY(130, 80);
  209. $pdf->Write(0, 'Dye Type');
  210. $pdf->SetXY(160, 80);
  211. $pdf->Write(0, 'Finishing');
  212.  
  213. // variations
  214.  
  215. $row_y = 85;
  216. $rp = 5;
  217. foreach ($fabric->Variations as $v) {
  218. $this->db->where('Finishing_ID',$v->Finishing_ID);
  219. $Finishing_Description = $this->db->get('tblfinishing')->row('Finishing_Description');
  220.  
  221. $pdf->SetXY(30, $row_y);
  222. $pdf->Write(0, $v->Color);
  223. $pdf->SetXY(55, $row_y);
  224. $pdf->Write(0, $v->Rolls);
  225. $pdf->SetXY(75, $row_y);
  226. $pdf->Write(0, $v->Weight);
  227. $pdf->SetXY(110, $row_y);
  228. $pdf->Write(0, $v->Rolls);
  229. $pdf->SetXY(130, $row_y);
  230. $pdf->Write(0, $v->Dye_Type);
  231. $pdf->SetXY(160, $row_y);
  232. $pdf->Write(0, $Finishing_Description);
  233. $row_y = $row_y + 5;
  234. }
  235.  
  236. $last_row = $row_y + 5;
  237. $pdf->SetXY(30, $last_row);
  238. $pdf->Write(0, 'SPECIAL INSTRUCTIONS/REMARKS');
  239.  
  240. $pdf->SetXY(30, $last_row + 5);
  241. $pdf->Write(0, 'Initial Width (Body): ' .$fabric->Initial_Body_Width);
  242. $pdf->SetXY(30, $last_row + 10);
  243. $pdf->Write(0, 'Initial Width (Access): '.$fabric->Initial_Accessory_Width);
  244.  
  245. $pdf->SetXY(30, $last_row + 15);
  246. $pdf->Write(0, 'Initial Density (Body): ' .$fabric->Initial_Body_Density);
  247.  
  248. $pdf->SetXY(30, $last_row + 20);
  249. $pdf->Write(0, 'Initial Density (Access): '.$fabric->Initial_Accessory_Density);
  250.  
  251. $pdf->SetXY(30, $last_row + 25);
  252. $pdf->Write(0, 'Initial Stripe Repeat: '.$fabric->Initial_Stripe_Repeat);
  253.  
  254.  
  255. $pdf->SetXY(130, $last_row + 5);
  256. $pdf->Write(0, 'Final Width (Body): '.$fabric->Required_Body_Width);
  257. $pdf->SetXY(130, $last_row + 10);
  258. $pdf->Write(0, 'Final Width (Access): '.$fabric->Required_Accessory_Width);
  259.  
  260. $pdf->SetXY(130, $last_row + 15);
  261. $pdf->Write(0, 'Final Density (Body): '.$fabric->Required_Body_Density);
  262.  
  263. $pdf->SetXY(130, $last_row + 20);
  264. $pdf->Write(0, 'Final Density (Access): '.$fabric->Required_Accessory_Density);
  265.  
  266. $pdf->SetXY(130, $last_row + 25);
  267. $pdf->Write(0, 'Final Stripe Repeat: '.$fabric->Required_Stripe_Repeat);
  268.  
  269. $pdf->SetXY(30, $last_row + 35);
  270. $pdf->Write(0, 'PREPARED BY: ');
  271.  
  272. $pdf->SetXY(130, $last_row + 35);
  273. $pdf->Write(0, 'SAMPLE RECEIVED BY: ');
  274. $pdf->SetXY(130, $last_row + 40);
  275. $pdf->Write(0, 'DATE ');
  276. $pdf->SetXY(130, $last_row + 45);
  277. $pdf->Write(0, 'TIME ');
  278.  
  279. $pdf->SetXY(130, $last_row + 50);
  280. $pdf->Write(0, 'TEST PERFORMED BY: ');
  281. $pdf->SetXY(130, $last_row + 55);
  282. $pdf->Write(0, 'CONFIRMED BY: ');
  283.  
  284. $pdf->Output();
  285.  
  286.  
  287. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement