Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. public function chooseBale($program_id='')
  2. {
  3. $config = array();
  4. $config["base_url"] = base_url() . "ginner/choosebale/".$program_id;
  5. $config["total_rows"] = $this->GinnerModel->get_count();
  6. $config["per_page"] = 10;
  7. $config["uri_segment"] = 2;
  8. $choice = $config["total_rows"] / $config["per_page"];
  9. $config["num_links"] = round($choice);
  10. $this->pagination->initialize($config);
  11. $page = ($this->uri->segment(4))? $this->uri->segment(4) : 0;
  12. $data["links"] = $this->pagination->create_links();
  13.  
  14. $data['pg_title'] = 'Choose Bale';
  15. $data['breadcrumb'] = array('Home' => '', 'Sale'=>'nolink', 'New Process'=>'nolink', 'Choose Bale'=>'nolink');
  16. $data['left_menu'] = "left-menu-ginner.php";
  17. $data['program'] = $this->CommonModel->getTableWhere(PROGRAM, 'id ='.$program_id);
  18. $data['program_id'] = $program_id;
  19. $data['bale_list'] = $this->GinnerModel->baleList($program_id,$config["per_page"], $page);
  20. $this->load->view('common/header', $data);
  21. $this->load->view('ginner/choose-bale');
  22. $this->load->view('common/footer');
  23. }
  24.  
  25. public function baleList($program_id,$per_page,$page) {
  26.  
  27. $this->db->select('gp.id, gp.lot_no, SUM(gb.weight) AS weight, SUM(gb.staple) AS staple, SUM(gb.mic) AS mic, SUM(gb.strength) AS strength, SUM(gb.trash) AS trash, gb.color_grade');
  28. $this->db->from(GIN_BALES . ' gb');
  29. $this->db->join(GIN_PROCESS . ' gp', 'gp.id=gb.process_id');
  30. $this->db->where('gb.sold_status', 0);
  31. $this->db->where('gp.ginner_id', $this->prscr_id);
  32. $this->db->where('gp.program', $program_id);
  33. $this->db->group_by('gp.id');
  34. $this->db->limit($per_page, $page);
  35. $lot_details = $this->db->get()->result();
  36. $lot_details = array_column($lot_details, null, "id");
  37. $prs_id = "'".implode("','", array_keys($lot_details))."'";
  38. $bales_list = array();
  39. $n = 0;
  40. $this->db->select('id,process_id,press_no,weight,staple,mic,strength,trash,color_grade');
  41. $this->db->from(GIN_BALES);
  42. $this->db->where('sold_status', 0);
  43. $this->db->where("process_id IN (".$prs_id.")",NULL, false);
  44. $bales = $this->db->get()->result();
  45. foreach ($bales as $value) {
  46.  
  47. if (array_key_exists($value->process_id,$lot_details))
  48. {
  49.  
  50. $lot_details[$value->process_id]->bales[] = $value;
  51. }
  52.  
  53.  
  54. $lot_details[$n]->bales = $bales;
  55.  
  56. $n++;
  57. }
  58. return $lot_details;
  59. }
  60.  
  61. <p><?php echo $links; ?></p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement