VM暫存
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 line
5.6KB

  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Vghtc_report_daily extends CI_Controller {
  4. public function __construct() {
  5. parent::__construct();
  6. $this->load->model('reports/Erpapidb_model','erpapidb');
  7. }
  8. public function index()
  9. {
  10. define('SYNC_API_URL', 'http://61.219.172.11:60123/admins_station.html/');
  11. $port_info = (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 60123) ? '/' . $_SERVER['SERVER_PORT'] : '';
  12. $reload_url = SYNC_API_URL . 'station_setting_query' . $port_info;
  13. $ch = curl_init();
  14. curl_setopt($ch, CURLOPT_URL, $reload_url);
  15. curl_setopt($ch, CURLOPT_HEADER, FALSE);
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  17. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  18. curl_setopt($ch, CURLOPT_POST, TRUE);
  19. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,10);
  20. curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
  21. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array()));
  22. $output = curl_exec($ch);
  23. curl_close($ch);
  24. $station_arr=json_decode($output,true);
  25. $post_data= $this->input->post(NULL, TRUE);
  26. $get_data= $this->input->get(NULL, TRUE);
  27. if($post_data){
  28. $month= isset($post_data['month']) ? $post_data['month']:'';
  29. }
  30. if($get_data){
  31. $month= isset($get_data['month']) ? $get_data['month']:'';
  32. }
  33. $dd=date('d',mktime(0,0,0,($month+1),0,date('Y')));
  34. $sel_in_lane=$this->erpapidb->sel_in_lane();
  35. if($month<10){
  36. $month0="0".$month;
  37. }else{
  38. $month0=$month;
  39. }
  40. for($i=1; $i<=$dd; $i++){
  41. $monthba=0;
  42. $dateba=0;
  43. $hourba=0;
  44. $alltatle=0;
  45. $dateba_lane_0=0;
  46. $dateba_lane_1=0;
  47. $dateba_lane_2=0;
  48. $dateba_lane_3=0;
  49. $dateba_lane_4=0;
  50. $dateba_lane_5=0;
  51. $dateba_lane_6=0;
  52. $dateba_lane_7=0;
  53. $dateba_lane_8=0;
  54. $dateba_lane_9=0;
  55. $dateba_lane_10=0;
  56. $dateba_lane_11=0;
  57. $dateba_lane_12=0;
  58. $dateba_lane_tatol000=0;
  59. if($i<10){
  60. $i0="0".$i;
  61. }else{
  62. $i0=$i;
  63. }
  64. $dateba_lane00[]=array();
  65. $start0=date('Y-'.$month0.'-'.$i0);
  66. for($j=-8; $j<=23-8; $j++){
  67. $stime0=date('H:i:s',($j*3600));
  68. $etime0=date('H:i:s',(($j+1)*3600));
  69. $stime=date('H:i',($j*3600));
  70. $etime=date('H:i',(($j+1)*3600));
  71. $start=date('Y-'.$month.'-'.$i.' '.$stime0);
  72. $end=date('Y-'.$month.'-'.$i.' '.$etime0);
  73. $sel_cario[]=array();
  74. $dateba0=0;
  75. $dateba_lane_tatol=0;
  76. foreach($sel_in_lane as $key => $value){
  77. $in_lane=$value['in_lane'];
  78. $name=$value['name'];
  79. $note=$value['note'];
  80. // if($in_lane==2 or $in_lane==3 or $in_lane==8 or $in_lane==9 or $in_lane==10 or $in_lane==11){
  81. if($in_lane==0){
  82. $sel_cario=$this->erpapidb->sel_cario($in_lane,$start,$end);
  83. }else{
  84. $sel_cario=$this->erpapidb->sel_cario_out($in_lane,$start,$end);
  85. }
  86. $sel_cario_count[$key]=count($sel_cario);
  87. $alltatle=$alltatle+$sel_cario_count[$key];
  88. $dateba0=$dateba0+$sel_cario_count[$key];
  89. $dateba_lane_tatol=$dateba_lane_tatol+$sel_cario_count[$key];
  90. if($in_lane==0){
  91. $dateba_lane_0=$dateba_lane_0+$sel_cario_count[$key];
  92. }elseif($in_lane==1){
  93. $dateba_lane_1=$dateba_lane_1+$sel_cario_count[$key];
  94. }elseif($in_lane==2){
  95. $dateba_lane_2=$dateba_lane_2+$sel_cario_count[$key];
  96. }elseif($in_lane==3){
  97. $dateba_lane_3=$dateba_lane_3+$sel_cario_count[$key];
  98. /* }elseif($in_lane==4){
  99. $dateba_lane_4=$dateba_lane_4+$sel_cario_count[$key];
  100. }elseif($in_lane==5){
  101. $dateba_lane_5=$dateba_lane_5+$sel_cario_count[$key];
  102. }elseif($in_lane==6){
  103. $dateba_lane_6=$dateba_lane_6+$sel_cario_count[$key];
  104. }elseif($in_lane==7){
  105. $dateba_lane_7=$dateba_lane_7+$sel_cario_count[$key];
  106. }elseif($in_lane==8){
  107. $dateba_lane_8=$dateba_lane_8+$sel_cario_count[$key];
  108. }elseif($in_lane==9){
  109. $dateba_lane_9=$dateba_lane_9+$sel_cario_count[$key];
  110. }elseif($in_lane==10){
  111. $dateba_lane_10=$dateba_lane_10+$sel_cario_count[$key];
  112. }elseif($in_lane==11){
  113. $dateba_lane_11=$dateba_lane_11+$sel_cario_count[$key];
  114. }elseif($in_lane==12){
  115. $dateba_lane_12=$dateba_lane_12+$sel_cario_count[$key]; */
  116. }
  117. }
  118. $sel_cario_tatal[$stime]=array(
  119. "stime" => $stime,
  120. "time" => $stime.'~'.$etime,
  121. "dateba0" => $dateba0,
  122. "sel_cario" => $sel_cario_count
  123. );
  124. }
  125. $dateba_lane00=array(
  126. "dateba_lane_0" => $dateba_lane_0,
  127. "dateba_lane_1" => $dateba_lane_1,
  128. "dateba_lane_2" => $dateba_lane_2,
  129. "dateba_lane_3" => $dateba_lane_3,
  130. /* "dateba_lane_4" => $dateba_lane_4,
  131. "dateba_lane_5" => $dateba_lane_5,
  132. "dateba_lane_6" => $dateba_lane_6,
  133. "dateba_lane_8" => $dateba_lane_8,
  134. "dateba_lane_9" => $dateba_lane_9,
  135. "dateba_lane_10" => $dateba_lane_10,
  136. "dateba_lane_11" => $dateba_lane_11,
  137. "dateba_lane_12" => $dateba_lane_12,*/
  138. );
  139. // "sel_cario_tatal" => $sel_cario_tatal
  140. // "dateba" => $alltatle,
  141. // "hourba" => $alltatle/24
  142. $this->front->sel_cario_tatal[$start0]=$sel_cario_tatal;
  143. $this->front->dateba_lane[$start0]=$dateba_lane00;
  144. $this->front->sel_in_lane[$start0]=$sel_in_lane;
  145. $dateba=$dateba+$dateba_lane_tatol;
  146. }
  147. $this->front->dateba=$dateba;
  148. $this->front->hourba=$dateba/24;
  149. $this->front->month=$month;
  150. $this->front->station_arr=$station_arr;
  151. $this->front->dd=$dd;
  152. $data=$this->front;
  153. $this->load->view('reports/vghtc_report_daily',$data);
  154. }
  155. }