Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function generate_wrr(){
- $r = $this->uri->segment(3) == 'r' ? true : false;
- $WRR = $RJO_ID = $Masked_JO_ID = $SPI_DR = $fabric = '';
- if(!$r) {
- $WRR = $this->input->get('id');
- $this->db->where('WRR', $WRR);
- $fabric = $this->db->get('tblfabric_received')->row();
- }
- $ra = array();
- if($fabric) {
- $Masked_WRR = $fabric->Masked_WRR;
- $page_title = 'Edit Received Fabric';
- $this->db->where('fr.WRR', $WRR);
- $this->db->select('fr.*, c.Customer_ID, c.Customer_Code, jo.*');
- $this->db->from('tblfabric_received fr');
- $this->db->join('tblcustomers c', 'fr.Customer_ID = c.Customer_ID','left');
- $this->db->join('tbljob_orders jo', 'fr.WRR = jo.WRR','left');
- $fabric = $this->db->get()->row();
- $fabric->Date_Created = format_date($fabric->Date_Created, 'm/d/Y');
- $fabric->Date_Scheduled = date('m/d/Y', strtotime($fabric->Date_Scheduled));
- $this->db->where('WRR', $WRR);
- $fabric->Variations = $this->db->get('tblfabric_variations')->result();
- if($fabric->RJO_ID) {
- $RJO_ID = $fabric->RJO_ID;
- $this->db->where('JO_ID', $RJO_ID);
- $Masked_JO_ID = $this->db->get('tbljob_orders')->row('Masked_JO_ID');
- $SPI_DR = $fabric->SPI_DR;
- }
- } else {
- $dj = '';
- $error = $WRR && !$r ? 'WRR not found!' : '';
- if($r) {
- $DJ_ID = $this->input->get('id');
- $this->db->where('dj.DJ_ID', $DJ_ID);
- $this->db->from('tbldelivery_jo dj');
- $this->db->join('tbldeliveries d', 'dj.Delivery_ID = d.Delivery_ID', 'left');
- $this->db->join('tbljob_orders jo', 'dj.JO_ID = jo.JO_ID', 'left');
- $this->db->join('tblcolors c', 'jo.Color_ID = c.Color_ID', 'left');
- $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');
- $dj = $this->db->get()->row();
- if($dj) {
- if($dj->Status == 'Pending Returned') {
- $rrs = unserialize($dj->Rolls_Returned);
- $rbs = unserialize($dj->Rolls_Breakdown);
- $ra['Customer_ID'] = $dj->Customer_ID;
- $RJO_ID = $dj->JO_ID;
- $Masked_JO_ID = $dj->Masked_JO_ID;
- $SPI_DR = $dj->Delivery_ID;
- foreach ($rrs as $vid => $rr) {
- $this->db->where('Variation_ID', $vid);
- $sid = $this->db->get('tblfabric_variations')->row('Specification_ID');
- $rolls = $weight = 0;
- foreach ($rr as $i => $r) {
- if($r == 'false') {
- $rolls++;
- $weight += $rbs[$vid][$i]['weight'];
- }
- }
- if($rolls && $weight) {
- $v = new stdClass();
- $v->Specification_ID = $sid;
- $v->Rolls = $rolls;
- $v->Weight = $weight;
- $v->Color = $dj->Color_Description;
- $v->Orientation = $dj->Orientation;
- $v->Dye_Type = 'bj';
- $v->Finishing_ID = 9;
- if($sid == 1) {
- $v->Width = $dj->Finished_Final_Width;
- $v->Density = $dj->Finished_Final_Density;
- } else {
- $v->Width = $dj->Finished_Final_Width_A;
- $v->Density = $dj->Finished_Final_Density_A;
- }
- $v->Stripe_Repeat = $dj->Finished_Final_Stripe_Repeat;
- $ra['v'][] = $v;
- }
- }
- } else {
- $error = 'Returned JO already received!';
- }
- } else {
- $error = 'Returned JO not found!';
- }
- }
- if($error) {
- generate_prompt($error);
- redirect('/fabric/received', 'refresh');
- }
- $page_title = 'Fabric Receiving';
- $year = date('Y');
- $this->db->order_by('WRR DESC');
- $wrr = $this->db->get('tblfabric_received')->num_rows() + 1;
- $Masked_WRR = 'W' . date('y') . '-' . str_pad( $wrr, 5, "0", STR_PAD_LEFT );
- }
- $blend_list = $this->db->get('tblfabric_blends')->result();
- $specification_list = $this->db->get('tblspecifications')->result();
- $finishing_list = $this->db->get('tblfinishing')->result();
- $orientation_list = array(
- 'T' => 'Tube',
- 'O' => 'Open'
- );
- $dye_type_list = array(
- 'colored' => 'COLORED',
- 'white' => 'WHITE/FB',
- 'stripes' => 'STRIPES',
- 'washing' => 'WASHING',
- 'bj' => 'BACK JOB',
- 'no_instruction' => 'NO INSTRUCTION',
- );
- $this->db->where('WRR', $WRR);
- $this->db->where('Chamber_Details !=', '');
- $jo = $this->db->get('tbljob_orders')->row();
- $disable_wrr = $jo ? true : false;
- $data = array(
- 'page' => 'fabric/receiving',
- 'tab_title' => $page_title,
- 'WRR' => $WRR,
- 'Masked_WRR' => $Masked_WRR,
- 'fabric' => $fabric,
- 'blend_list' => $blend_list,
- 'specification_list' => $specification_list,
- 'finishing_list' => $finishing_list,
- 'orientation_list' => $orientation_list,
- 'dye_type_list' => $dye_type_list,
- 'disable_wrr' => $disable_wrr,
- 'ra' => $ra,
- 'RJO_ID' => $RJO_ID,
- 'Masked_JO_ID' => $Masked_JO_ID,
- 'SPI_DR' => $SPI_DR
- );
- $pdf = new PDF_Code128('P','mm','Legal');
- $pdf->SetFont('Times','',10);
- $pdf->AddPage();
- $pdf->SetTextColor(000, 000, 000);
- $pdf->SetXY(180, 20);
- $pdf->Write(0, 'FORM W-1');
- $pdf->SetXY(0,25);
- $pdf->SetFont('Times','B',15);
- $pdf->Cell(210, 2.7,'SAFFRON PHILIPPINES INC.', 0, 0, 'C');
- $pdf->SetXY(0, 30);
- $pdf->Cell(210, 2.7,'WAREHOUSE RECEIVING REPORT', 0, 0, 'C');
- $pdf->SetXY(30, 50);
- $pdf->SetFont('Times','',10);
- $pdf->Write(0, 'Customer:'.$fabric->Customer_Code);
- $pdf->SetXY(30, 55);
- $pdf->Write(0, 'Customer Ref. No:'.$fabric->Customer_DR);
- $pdf->SetXY(30, 60);
- $pdf->Write(0, 'Customer PO No:' . $fabric->PO_Number);
- $pdf->SetXY(30, 65);
- $pdf->Write(0, 'Fabric Specs:'.$fabric->Fabric_Specification);
- $pdf->SetXY(30, 70);
- $pdf->Write(0, 'Accessory: ');
- $pdf->SetXY(130, 50);
- $pdf->SetFont('Times','',10);
- $pdf->Write(0, 'WRR No:'.$Masked_WRR);
- $pdf->SetXY(130, 55);
- $pdf->Write(0, 'Date Prepared:'.$fabric->Date_Created);
- $pdf->SetXY(130, 60);
- $pdf->Write(0, 'Date Received:'.$fabric->Date_Scheduled);
- $pdf->SetXY(130, 65);
- $pdf->Write(0, 'Due Date:');
- $pdf->SetXY(30, 80);
- $pdf->Write(0, 'Color');
- $pdf->SetXY(55, 80);
- $pdf->Write(0, '# of Rolls');
- $pdf->SetXY(75, 80);
- $pdf->Write(0, 'Weight(KGS)');
- $pdf->SetXY(110, 80);
- $pdf->Write(0, 'Total');
- $pdf->SetXY(130, 80);
- $pdf->Write(0, 'Dye Type');
- $pdf->SetXY(160, 80);
- $pdf->Write(0, 'Finishing');
- // variations
- $row_y = 85;
- $rp = 5;
- foreach ($fabric->Variations as $v) {
- $this->db->where('Finishing_ID',$v->Finishing_ID);
- $Finishing_Description = $this->db->get('tblfinishing')->row('Finishing_Description');
- $pdf->SetXY(30, $row_y);
- $pdf->Write(0, $v->Color);
- $pdf->SetXY(55, $row_y);
- $pdf->Write(0, $v->Rolls);
- $pdf->SetXY(75, $row_y);
- $pdf->Write(0, $v->Weight);
- $pdf->SetXY(110, $row_y);
- $pdf->Write(0, $v->Rolls);
- $pdf->SetXY(130, $row_y);
- $pdf->Write(0, $v->Dye_Type);
- $pdf->SetXY(160, $row_y);
- $pdf->Write(0, $Finishing_Description);
- $row_y = $row_y + 5;
- }
- $last_row = $row_y + 5;
- $pdf->SetXY(30, $last_row);
- $pdf->Write(0, 'SPECIAL INSTRUCTIONS/REMARKS');
- $pdf->SetXY(30, $last_row + 5);
- $pdf->Write(0, 'Initial Width (Body): ' .$fabric->Initial_Body_Width);
- $pdf->SetXY(30, $last_row + 10);
- $pdf->Write(0, 'Initial Width (Access): '.$fabric->Initial_Accessory_Width);
- $pdf->SetXY(30, $last_row + 15);
- $pdf->Write(0, 'Initial Density (Body): ' .$fabric->Initial_Body_Density);
- $pdf->SetXY(30, $last_row + 20);
- $pdf->Write(0, 'Initial Density (Access): '.$fabric->Initial_Accessory_Density);
- $pdf->SetXY(30, $last_row + 25);
- $pdf->Write(0, 'Initial Stripe Repeat: '.$fabric->Initial_Stripe_Repeat);
- $pdf->SetXY(130, $last_row + 5);
- $pdf->Write(0, 'Final Width (Body): '.$fabric->Required_Body_Width);
- $pdf->SetXY(130, $last_row + 10);
- $pdf->Write(0, 'Final Width (Access): '.$fabric->Required_Accessory_Width);
- $pdf->SetXY(130, $last_row + 15);
- $pdf->Write(0, 'Final Density (Body): '.$fabric->Required_Body_Density);
- $pdf->SetXY(130, $last_row + 20);
- $pdf->Write(0, 'Final Density (Access): '.$fabric->Required_Accessory_Density);
- $pdf->SetXY(130, $last_row + 25);
- $pdf->Write(0, 'Final Stripe Repeat: '.$fabric->Required_Stripe_Repeat);
- $pdf->SetXY(30, $last_row + 35);
- $pdf->Write(0, 'PREPARED BY: ');
- $pdf->SetXY(130, $last_row + 35);
- $pdf->Write(0, 'SAMPLE RECEIVED BY: ');
- $pdf->SetXY(130, $last_row + 40);
- $pdf->Write(0, 'DATE ');
- $pdf->SetXY(130, $last_row + 45);
- $pdf->Write(0, 'TIME ');
- $pdf->SetXY(130, $last_row + 50);
- $pdf->Write(0, 'TEST PERFORMED BY: ');
- $pdf->SetXY(130, $last_row + 55);
- $pdf->Write(0, 'CONFIRMED BY: ');
- $pdf->Output();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement