Advertisement
Guest User

jadwalok

a guest
Sep 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class jadwalokbackup extends CI_Controller {
  5. public function __construct() {
  6. parent::__construct();
  7. $this->load->model('jadwalRO_model');
  8.  
  9. }
  10. private function _render($view,$data = array())
  11. {
  12. $this->load->view('header',$data);
  13. $this->load->view('body_header');
  14. $this->load->view('sidebar');
  15. $this->load->view($view,$data);
  16. $this->load->view('footer');
  17. }
  18.  
  19. public function index()
  20. {
  21. //load library
  22. $uri =& load_class('URI', 'core');
  23. redirect('index.php/jadwalokbackup/jadwalokview', $data);
  24. }
  25.  
  26. public function jadwalokview()
  27. {
  28. $uri =& load_class('URI', 'core');
  29. $this->load->library('session');
  30. $this->_render('jadwalok_view');
  31. }
  32.  
  33. public function getdata()
  34. {
  35. $uri =& load_class('URI', 'core');
  36. $tanggal = $this->input->get('tanggal');
  37. $data = $this->jadwalRO_model->getdata($tanggal);
  38. $ruang = $this->jadwalRO_model->ruangOk();
  39. $text = '';
  40. $res = array();
  41. $time1 = strtotime('00:00');
  42. $time2 = strtotime('10:00');
  43. $difference = round(abs($time2 - $time1) / 3600,2);
  44. // var_dump($difference);die();
  45. // var_dump($data->result());die();
  46. foreach($ruang->result() as $ruang){
  47.  
  48. $text_jadwal = '';
  49. $countTd = 48;
  50. $rowTd = 0;
  51. foreach($data->result() as $datas){
  52. // print_r($data->result());exit();
  53. if($ruang->kode == $datas->kdruang){
  54. // print_r($ruang->kode);exit();
  55. $jamSelesaiTerakhir = $datas->jam_selesai;
  56. $rowTd = $rowTd+1;
  57. $tdkosong = "";
  58. $tdIsi = "";
  59. $difference = 0;
  60.  
  61. if($rowTd == 1){
  62.  
  63. $difference = round(abs(strtotime($datas->jam_mulai) - strtotime('00:00')) / 1800,2);
  64.  
  65. }else{
  66. $difference = round(abs(strtotime($datas->jam_mulai) - strtotime($jamSelesaiTerakhir)) / 1800,2)-2;
  67. }
  68. $jamSelesaiTerakhir = $datas->jam_selesai;
  69. for($a = 0; $a <$difference; $a++){
  70. $tdkosong .= "<td></td>";
  71. }
  72.  
  73. $countTd = $countTd - ($difference + $datas->minutes);
  74. for($a = 0; $a <$datas->minutes; $a++){
  75. $tdIsi .= "<td style='background: #09ff09;'>".$datas->nmDok."</td>";
  76. }
  77.  
  78. // $text_jadwal .= $tdkosong."<td colspan='".$datas->minutes."' style='background: #09ff09;'>".$datas->nmDok."</td>";
  79. $text_jadwal .= $tdkosong.$tdIsi;
  80. }
  81. }
  82. $sisaTd = '';
  83. for($a = 0; $a <$countTd; $a++){
  84. $sisaTd .= "<td></td>";
  85. }
  86. $text .= "<tr><td style='text-align: center;background: #101ee5;color: white;min-width:150px'>".$ruang->ruang."</td>".$text_jadwal.$sisaTd."</tr>";
  87.  
  88. }
  89. echo json_encode($text);
  90. }
  91.  
  92.  
  93.  
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement