PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/ajax/ajax_income_1.php

https://gitlab.com/dev.essetel/sjnuri
PHP | 262 lines | 202 code | 17 blank | 43 comment | 9 complexity | a0604a383d1a22a02573dcd36ecfd54c MD5 | raw file
  1. <?php
  2. include_once('./_common.php');
  3. $mb_seq = $_GET['mb_seq'];
  4. $cartype = $_GET['cartype'];
  5. $options = array();
  6. $slice_mb_seq = substr($mb_seq, -4, 4);
  7. // 카타입으로 2개 인지 3개인지 골라야함 서버나가있네....
  8. // cartype 2 특장차 엑셀 비교 + 차이 금액 노츠출 + 수입금 일계표
  9. // cartype 1 택시 보조금 + 노출
  10. if ($cartype == 2) {
  11. $sql = "SELECT * FROM ( SELECT LEFT(call_date, 10) as call_date,
  12. IFNULL(SUM(drv_distance),0) as drv_distance,
  13. IFNULL(SUM(drv_cash),0) as drv_cash,
  14. IFNULL(SUM(drv_vccash),0) as drv_vccash,
  15. IFNULL(SUM(tollfee1),0) as tollfee1,
  16. IFNULL(SUM(tollfee2),0) as tollfee2,
  17. IFNULL(SUM(tollfee3),0) as tollfee3,
  18. IFNULL(SUM(tollfee4),0 ) as tollfee4,
  19. drvseq ,COUNT(*) AS cnt
  20. FROM drivers_working_info
  21. WHERE drvseq = $mb_seq
  22. AND ownerlevel = 0
  23. AND Month(call_date)=Month(now())
  24. GROUP BY LEFT(call_date, 10)
  25. ) a
  26. LEFT JOIN (
  27. SELECT LEFT(call_date, 10) as call_date_1,
  28. IFNULL(SUM(drv_distance),0) as drv_distance_1,
  29. IFNULL(SUM(drv_cash),0) as drv_cash_1,
  30. IFNULL(SUM(drv_vccash),0) as drv_vccash_1,
  31. IFNULL(SUM(tollfee1),0) as tollfee1_1,
  32. IFNULL(SUM(tollfee2),0) as tollfee2_1,
  33. IFNULL(SUM(tollfee3),0) as tollfee3_1,
  34. IFNULL(SUM(tollfee4),0 ) as tollfee4_1,
  35. drvseq as drvseq_1 , COUNT(*) as cnt_1
  36. FROM drivers_working_info
  37. WHERE drvseq = $mb_seq
  38. AND ownerlevel = 1
  39. AND Month(call_date)=Month(now())
  40. GROUP BY LEFT(call_date, 10)
  41. ) b
  42. ON (a.call_date = b.call_date_1)";
  43. $result = sql_query($sql);
  44. while ($row = sql_fetch_array($result)) {
  45. // 요금차이
  46. $miner_price = $row['drv_cash_1'] - $row['drv_cash'];
  47. if ($miner_price) {
  48. $miner_price = $miner_price;
  49. } else {
  50. $miner_price = 0;
  51. }
  52. $row['drv_distance'] = number_format($row['drv_distance']);
  53. $row['drv_cash'] = number_format($row['drv_cash']);
  54. $row['drv_vccash'] = number_format($row['drv_vccash']);
  55. $row['tollfee1'] = number_format($row['tollfee1']);
  56. $row['tollfee2'] = number_format($row['tollfee2']);
  57. $row['tollfee3'] = number_format($row['tollfee3']);
  58. $row['tollfee4'] = number_format($row['tollfee4']);
  59. $row['cnt'] = number_format($row['cnt']);
  60. $tollfee_a = (int)$row['tollfee1_1'] + (int)$row['tollfee2_1'] + (int)$row['tollfee3_1'] + (int)$row['tollfee4_1'];
  61. $row['drv_distance_1'] = number_format($row['drv_distance_1']);
  62. $row['drv_cash_1'] = number_format($row['drv_cash_1']);
  63. $row['drv_vccash_1'] = number_format($row['drv_vccash_1']);
  64. $row['tollfee1_1'] = number_format($row['tollfee1_1']);
  65. $row['tollfee2_1'] = number_format($row['tollfee2_1']);
  66. $row['tollfee3_1'] = number_format($row['tollfee3_1']);
  67. $row['tollfee4_1'] = number_format($row['tollfee4_1']);
  68. $row['cnt_1'] = number_format($row['cnt_1']);
  69. $row['a_call_date'] = iuf_hex_encode($row['call_date']);
  70. $a_mb_seq = iuf_hex_encode($mb_seq);
  71. $row['a_drv_distance'] = iuf_hex_encode($row['drv_distance']);
  72. $row['a_cnt'] = iuf_hex_encode($row['cnt']);
  73. $row['a_drv_cash'] = iuf_hex_encode($row['drv_cash']);
  74. $row['a_drv_vccash'] = iuf_hex_encode($row['drv_vccash']);
  75. $row['a_cnt_1'] = iuf_hex_encode($row['cnt_1']);
  76. $row['a_drv_cash_1'] = iuf_hex_encode($row['drv_cash_1']);
  77. $row['a_drv_vccash_1'] = iuf_hex_encode($row['drv_vccash_1']);
  78. $a_tollfee_a = iuf_hex_encode($tollfee_a);
  79. $option['data'] = "<tr class='iframe1_1' data-calldate='{$row['call_date']}' data-cartype='{$cartype}'>
  80. <td class='addtd1'>{$row['call_date']}</td>
  81. <td class='addtd2'>{$row['drv_distance']}</td>
  82. <td class='addtd3'>{$row['cnt']}</td>
  83. <td class='addtd4'>{$row['drv_cash']}</td>
  84. <td class='addtd5'>{$row['drv_vccash']}</td>
  85. <td class='addtd6'>{$row['cnt_1']}</td>
  86. <td class='addtd7'>{$row['drv_cash_1']}</td>
  87. <td class='addtd8'>{$row['drv_vccash_1']}</td>
  88. <td class='addtd9'></td>
  89. <td class='addtd10'></td>
  90. <td class='addtd11'>{$miner_price}</td>
  91. <td class='addtd12'>{$row['tollfee1_1']}</td>
  92. <td class='addtd13'>{$row['tollfee2_1']}</td>
  93. <td class='addtd14'>{$row['tollfee3_1']}</td>
  94. <td class='addtd15'>{$row['tollfee4_1']}</td>
  95. <td>
  96. <a href='./income_day_print.php?calldate={$row['a_call_date']}&drvseq={$a_mb_seq}&drv_distance={$row['a_drv_distance']}&cnt={$row['a_cnt']}&drv_cash={$row['a_drv_cash']}&drv_vccash={$row['a_drv_vccash']}&cnt_1={$row['a_cnt_1']}&drv_cash_1={$row['a_drv_cash_1']}&drv_vccash_1={$row['a_drv_vccash_1']}&tollfee_a={$a_tollfee_a}' onclick='return dayprint(this.href);' target='_blank' class='btn btn_02'>일계표</a>
  97. </td>
  98. </tr>";
  99. // 폼으로 넘기려고 작업 하던 내용
  100. // $option['data'] = "<tr class='iframe1_1' data-calldate='{$row['call_date']}' data-cartype='{$cartype}'>
  101. // <td class='addtd1'>{$row['call_date']}</td>
  102. // <td class='addtd2'>{$row['drv_distance']}</td>
  103. // <td class='addtd3'>{$row['cnt']}</td>
  104. // <td class='addtd4'>{$row['drv_cash']}</td>
  105. // <td class='addtd5'>{$row['drv_vccash']}</td>
  106. // <td class='addtd6'>{$row['cnt_1']}</td>
  107. // <td class='addtd7'>{$row['drv_cash_1']}</td>
  108. // <td class='addtd8'>{$row['drv_vccash_1']}</td>
  109. // <td class='addtd9'></td>
  110. // <td class='addtd10'></td>
  111. // <td class='addtd11'>{$miner_price}</td>
  112. // <td class='addtd12'>{$row['tollfee1_1']}</td>
  113. // <td class='addtd13'>{$row['tollfee2_1']}</td>
  114. // <td class='addtd14'>{$row['tollfee3_1']}</td>
  115. // <td class='addtd15'>{$row['tollfee4_1']}</td>
  116. // <td>
  117. // <form id='fincome1' method='post' action='./income_day_print.php'>
  118. // <input type='hidden' name='calldate' value='{$row['a_call_date']}'>
  119. // <input type='hidden' name='drvseq' value='{$a_mb_seq}'>
  120. // <input type='hidden' name='drv_distance' value='{$row['a_drv_distance']}'>
  121. // <input type='hidden' name='cnt' value='{$row['a_cnt']}'>
  122. // <input type='hidden' name='drv_cash' value='{$row['a_drv_cash']}'>
  123. // <input type='hidden' name='drv_vccash' value='{$row['a_drv_vccash']}'>
  124. // <input type='hidden' name='cnt_1' value='{$row['a_cnt_1']}'>
  125. // <input type='hidden' name='drv_cash_1' value='{$row['drv_cash_1']}'>
  126. // <input type='hidden' name='drv_vccash_1' value='{$row['a_drv_vccash_1']}'>
  127. // <input type='hidden' name='tollfee_a' value='{$a_tollfee_a}'>
  128. // <a href='javascript:void(0)' onclick='dayprint();' class='btn btn_02'>일계표</a>
  129. // </from>
  130. // </td>
  131. // </tr>";
  132. // $option['date'] = $row['call_date'];
  133. // array_push($options, preg_replace('/\r\n|\r|\n/','',$option));
  134. array_push($options, $option);
  135. }
  136. } elseif ($cartype == 1) {
  137. $sql = "SELECT * FROM ( SELECT LEFT(call_date, 10) as call_date,
  138. IFNULL(SUM(drv_distance),0) as drv_distance,
  139. IFNULL(SUM(drv_cash),0) as drv_cash,
  140. IFNULL(SUM(drv_vccash),0) as drv_vccash,
  141. IFNULL(SUM(tollfee1),0) as tollfee1,
  142. IFNULL(SUM(tollfee2),0) as tollfee2,
  143. IFNULL(SUM(tollfee3),0) as tollfee3,
  144. IFNULL(SUM(tollfee4),0 ) as tollfee4,
  145. drvseq ,
  146. COUNT(*) AS cnt
  147. FROM drivers_working_info
  148. WHERE drvseq = $mb_seq
  149. AND ownerlevel = 0
  150. AND Month(call_date)=Month(now())
  151. GROUP BY LEFT(call_date, 10)
  152. ) a
  153. left JOIN (
  154. SELECT LEFT(call_date, 10) as call_date_1,
  155. IFNULL(SUM(drv_distance),0) as drv_distance_1,
  156. IFNULL(SUM(drv_cash),0) as drv_cash_1,
  157. IFNULL(SUM(drv_vccash),0) as drv_vccash_1,
  158. IFNULL(SUM(tollfee1),0) as tollfee1_1,
  159. IFNULL(SUM(tollfee2),0) as tollfee2_1,
  160. IFNULL(SUM(tollfee3),0) as tollfee3_1,
  161. IFNULL(SUM(tollfee4),0 ) as tollfee4_1,
  162. drvseq as drvseq_1 ,
  163. COUNT(*) as cnt_1
  164. FROM drivers_working_info
  165. WHERE drvseq = $mb_seq
  166. AND ownerlevel = 1
  167. AND Month(call_date)=Month(now())
  168. GROUP BY LEFT(call_date, 10)
  169. ) b
  170. ON (a.call_date = b.call_date_1)
  171. left JOIN (
  172. SELECT LEFT(recv_time, 10) AS call_date_2,
  173. COUNT(*) AS cnt_2,
  174. IFNULL(SUM(price),0) AS price_2,
  175. drvno
  176. FROM bank_excel
  177. WHERE REPLACE(REPLACE(drvno,'[',''),']','') = {$slice_mb_seq}
  178. AND result = '계좌이체성공'
  179. AND Month(recv_time)=Month(now())
  180. GROUP BY LEFT(recv_time, 10)
  181. ) c
  182. ON (RIGHT(a.drvseq,4) = REPLACE(REPLACE(c.drvno,'[',''),']',''))";
  183. $result = sql_query($sql);
  184. while ($row = sql_fetch_array($result)) {
  185. // 요금차이
  186. $miner_price = $row['drv_cash_1'] - $row['drv_cash'];
  187. if ($miner_price) {
  188. $miner_price = $miner_price;
  189. } else {
  190. $miner_price = 0;
  191. }
  192. $row['drv_distance'] = number_format($row['drv_distance']);
  193. $row['drv_cash'] = number_format($row['drv_cash']);
  194. $row['drv_vccash'] = number_format($row['drv_vccash']);
  195. $row['tollfee1'] = number_format($row['tollfee1']);
  196. $row['tollfee2'] = number_format($row['tollfee2']);
  197. $row['tollfee3'] = number_format($row['tollfee3']);
  198. $row['tollfee4'] = number_format($row['tollfee4']);
  199. $row['cnt'] = number_format($row['cnt']);
  200. $tollfee_a = (int)$row['tollfee1_1'] + (int)$row['tollfee2_1'] + (int)$row['tollfee3_1'] + (int)$row['tollfee4_1'];
  201. $row['drv_distance_1'] = number_format($row['drv_distance_1']);
  202. $row['drv_cash_1'] = number_format($row['drv_cash_1']);
  203. $row['drv_vccash_1'] = number_format($row['drv_vccash_1']);
  204. $row['tollfee1_1'] = number_format($row['tollfee1_1']);
  205. $row['tollfee2_1'] = number_format($row['tollfee2_1']);
  206. $row['tollfee3_1'] = number_format($row['tollfee3_1']);
  207. $row['tollfee4_1'] = number_format($row['tollfee4_1']);
  208. $row['cnt_1'] = number_format($row['cnt_1']);
  209. $row['a_call_date'] = iuf_hex_encode($row['call_date']);
  210. $a_mb_seq = iuf_hex_encode($mb_seq);
  211. $row['a_drv_distance'] = iuf_hex_encode($row['drv_distance']);
  212. $row['a_cnt'] = iuf_hex_encode($row['cnt']);
  213. $row['a_drv_cash'] = iuf_hex_encode($row['drv_cash']);
  214. $row['a_drv_vccash'] = iuf_hex_encode($row['drv_vccash']);
  215. $row['a_cnt_1'] = iuf_hex_encode($row['cnt_1']);
  216. $row['a_drv_cash_1'] = iuf_hex_encode($row['drv_cash_1']);
  217. $row['a_drv_vccash_1'] = iuf_hex_encode($row['drv_vccash_1']);
  218. $a_tollfee_a = iuf_hex_encode($tollfee_a);
  219. $option['data'] = "<tr class='iframe1_1' data-calldate='{$row['call_date']}' data-cartype='{$cartype}'>
  220. <td class='addtd1'>{$row['call_date']}</td>
  221. <td class='addtd2'>{$row['drv_distance']}</td>
  222. <td class='addtd3'>{$row['cnt']}</td>
  223. <td class='addtd4'>{$row['drv_cash']}</td>
  224. <td class='addtd5'>{$row['drv_vccash']}</td>
  225. <td class='addtd6'>{$row['cnt_1']}</td>
  226. <td class='addtd7'>{$row['drv_cash_1']}</td>
  227. <td class='addtd8'>{$row['drv_vccash_1']}</td>
  228. <td class='addtd9'>{$row['cnt_2']}</td>
  229. <td class='addtd10'>{$row['price_2']}</td>
  230. <td class='addtd11'></td>
  231. <td class='addtd12'>{$row['tollfee1_1']}</td>
  232. <td class='addtd13'>{$row['tollfee2_1']}</td>
  233. <td class='addtd14'>{$row['tollfee3_1']}</td>
  234. <td class='addtd15'>{$row['tollfee4_1']}</td>
  235. <td>
  236. <a href='./income_day_print.php?calldate={$row['a_call_date']}&drvseq={$a_mb_seq}&drv_distance={$row['a_drv_distance']}&cnt={$row['a_cnt']}&drv_cash={$row['a_drv_cash']}&drv_vccash={$row['a_drv_vccash']}&cnt_1={$row['a_cnt_1']}&drv_cash_1={$row['a_drv_cash_1']}&drv_vccash_1={$row['a_drv_vccash_1']}&tollfee_a={$a_tollfee_a}' onclick='return dayprint(this.href);' target='_blank' class='btn btn_02'>일계표</a>
  237. </td>
  238. </tr>";
  239. // $option['date'] = $row['call_date'];
  240. // array_push($options, preg_replace('/\r\n|\r|\n/','',$option));
  241. array_push($options, $option);
  242. }
  243. }
  244. // $output = json_encode($options, JSON_UNESCAPED_UNICODE);
  245. print_r($options);