/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
- <?php
- include_once('./_common.php');
- $mb_seq = $_GET['mb_seq'];
- $cartype = $_GET['cartype'];
- $options = array();
- $slice_mb_seq = substr($mb_seq, -4, 4);
- // 카타입으로 2개 인지 3개인지 골라야함 서버나가있네....
- // cartype 2 특장차 엑셀 비교 + 차이 금액 노츠출 + 수입금 일계표
- // cartype 1 택시 보조금 + 노출
- if ($cartype == 2) {
- $sql = "SELECT * FROM ( SELECT LEFT(call_date, 10) as call_date,
- IFNULL(SUM(drv_distance),0) as drv_distance,
- IFNULL(SUM(drv_cash),0) as drv_cash,
- IFNULL(SUM(drv_vccash),0) as drv_vccash,
- IFNULL(SUM(tollfee1),0) as tollfee1,
- IFNULL(SUM(tollfee2),0) as tollfee2,
- IFNULL(SUM(tollfee3),0) as tollfee3,
- IFNULL(SUM(tollfee4),0 ) as tollfee4,
- drvseq ,COUNT(*) AS cnt
- FROM drivers_working_info
- WHERE drvseq = $mb_seq
- AND ownerlevel = 0
- AND Month(call_date)=Month(now())
- GROUP BY LEFT(call_date, 10)
- ) a
- LEFT JOIN (
- SELECT LEFT(call_date, 10) as call_date_1,
- IFNULL(SUM(drv_distance),0) as drv_distance_1,
- IFNULL(SUM(drv_cash),0) as drv_cash_1,
- IFNULL(SUM(drv_vccash),0) as drv_vccash_1,
- IFNULL(SUM(tollfee1),0) as tollfee1_1,
- IFNULL(SUM(tollfee2),0) as tollfee2_1,
- IFNULL(SUM(tollfee3),0) as tollfee3_1,
- IFNULL(SUM(tollfee4),0 ) as tollfee4_1,
- drvseq as drvseq_1 , COUNT(*) as cnt_1
- FROM drivers_working_info
- WHERE drvseq = $mb_seq
- AND ownerlevel = 1
- AND Month(call_date)=Month(now())
- GROUP BY LEFT(call_date, 10)
- ) b
- ON (a.call_date = b.call_date_1)";
- $result = sql_query($sql);
- while ($row = sql_fetch_array($result)) {
- // 요금차이
- $miner_price = $row['drv_cash_1'] - $row['drv_cash'];
- if ($miner_price) {
- $miner_price = $miner_price;
- } else {
- $miner_price = 0;
- }
- $row['drv_distance'] = number_format($row['drv_distance']);
- $row['drv_cash'] = number_format($row['drv_cash']);
- $row['drv_vccash'] = number_format($row['drv_vccash']);
- $row['tollfee1'] = number_format($row['tollfee1']);
- $row['tollfee2'] = number_format($row['tollfee2']);
- $row['tollfee3'] = number_format($row['tollfee3']);
- $row['tollfee4'] = number_format($row['tollfee4']);
- $row['cnt'] = number_format($row['cnt']);
- $tollfee_a = (int)$row['tollfee1_1'] + (int)$row['tollfee2_1'] + (int)$row['tollfee3_1'] + (int)$row['tollfee4_1'];
- $row['drv_distance_1'] = number_format($row['drv_distance_1']);
- $row['drv_cash_1'] = number_format($row['drv_cash_1']);
- $row['drv_vccash_1'] = number_format($row['drv_vccash_1']);
- $row['tollfee1_1'] = number_format($row['tollfee1_1']);
- $row['tollfee2_1'] = number_format($row['tollfee2_1']);
- $row['tollfee3_1'] = number_format($row['tollfee3_1']);
- $row['tollfee4_1'] = number_format($row['tollfee4_1']);
- $row['cnt_1'] = number_format($row['cnt_1']);
- $row['a_call_date'] = iuf_hex_encode($row['call_date']);
- $a_mb_seq = iuf_hex_encode($mb_seq);
- $row['a_drv_distance'] = iuf_hex_encode($row['drv_distance']);
- $row['a_cnt'] = iuf_hex_encode($row['cnt']);
- $row['a_drv_cash'] = iuf_hex_encode($row['drv_cash']);
- $row['a_drv_vccash'] = iuf_hex_encode($row['drv_vccash']);
- $row['a_cnt_1'] = iuf_hex_encode($row['cnt_1']);
- $row['a_drv_cash_1'] = iuf_hex_encode($row['drv_cash_1']);
- $row['a_drv_vccash_1'] = iuf_hex_encode($row['drv_vccash_1']);
- $a_tollfee_a = iuf_hex_encode($tollfee_a);
- $option['data'] = "<tr class='iframe1_1' data-calldate='{$row['call_date']}' data-cartype='{$cartype}'>
- <td class='addtd1'>{$row['call_date']}</td>
- <td class='addtd2'>{$row['drv_distance']}</td>
- <td class='addtd3'>{$row['cnt']}</td>
- <td class='addtd4'>{$row['drv_cash']}</td>
- <td class='addtd5'>{$row['drv_vccash']}</td>
- <td class='addtd6'>{$row['cnt_1']}</td>
- <td class='addtd7'>{$row['drv_cash_1']}</td>
- <td class='addtd8'>{$row['drv_vccash_1']}</td>
- <td class='addtd9'></td>
- <td class='addtd10'></td>
- <td class='addtd11'>{$miner_price}</td>
- <td class='addtd12'>{$row['tollfee1_1']}</td>
- <td class='addtd13'>{$row['tollfee2_1']}</td>
- <td class='addtd14'>{$row['tollfee3_1']}</td>
- <td class='addtd15'>{$row['tollfee4_1']}</td>
- <td>
- <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>
- </td>
- </tr>";
- // 폼으로 넘기려고 작업 하던 내용
- // $option['data'] = "<tr class='iframe1_1' data-calldate='{$row['call_date']}' data-cartype='{$cartype}'>
- // <td class='addtd1'>{$row['call_date']}</td>
- // <td class='addtd2'>{$row['drv_distance']}</td>
- // <td class='addtd3'>{$row['cnt']}</td>
- // <td class='addtd4'>{$row['drv_cash']}</td>
- // <td class='addtd5'>{$row['drv_vccash']}</td>
- // <td class='addtd6'>{$row['cnt_1']}</td>
- // <td class='addtd7'>{$row['drv_cash_1']}</td>
- // <td class='addtd8'>{$row['drv_vccash_1']}</td>
- // <td class='addtd9'></td>
- // <td class='addtd10'></td>
- // <td class='addtd11'>{$miner_price}</td>
- // <td class='addtd12'>{$row['tollfee1_1']}</td>
- // <td class='addtd13'>{$row['tollfee2_1']}</td>
- // <td class='addtd14'>{$row['tollfee3_1']}</td>
- // <td class='addtd15'>{$row['tollfee4_1']}</td>
- // <td>
- // <form id='fincome1' method='post' action='./income_day_print.php'>
- // <input type='hidden' name='calldate' value='{$row['a_call_date']}'>
- // <input type='hidden' name='drvseq' value='{$a_mb_seq}'>
- // <input type='hidden' name='drv_distance' value='{$row['a_drv_distance']}'>
- // <input type='hidden' name='cnt' value='{$row['a_cnt']}'>
- // <input type='hidden' name='drv_cash' value='{$row['a_drv_cash']}'>
- // <input type='hidden' name='drv_vccash' value='{$row['a_drv_vccash']}'>
- // <input type='hidden' name='cnt_1' value='{$row['a_cnt_1']}'>
- // <input type='hidden' name='drv_cash_1' value='{$row['drv_cash_1']}'>
- // <input type='hidden' name='drv_vccash_1' value='{$row['a_drv_vccash_1']}'>
- // <input type='hidden' name='tollfee_a' value='{$a_tollfee_a}'>
- // <a href='javascript:void(0)' onclick='dayprint();' class='btn btn_02'>일계표</a>
- // </from>
- // </td>
- // </tr>";
- // $option['date'] = $row['call_date'];
- // array_push($options, preg_replace('/\r\n|\r|\n/','',$option));
- array_push($options, $option);
- }
- } elseif ($cartype == 1) {
- $sql = "SELECT * FROM ( SELECT LEFT(call_date, 10) as call_date,
- IFNULL(SUM(drv_distance),0) as drv_distance,
- IFNULL(SUM(drv_cash),0) as drv_cash,
- IFNULL(SUM(drv_vccash),0) as drv_vccash,
- IFNULL(SUM(tollfee1),0) as tollfee1,
- IFNULL(SUM(tollfee2),0) as tollfee2,
- IFNULL(SUM(tollfee3),0) as tollfee3,
- IFNULL(SUM(tollfee4),0 ) as tollfee4,
- drvseq ,
- COUNT(*) AS cnt
- FROM drivers_working_info
- WHERE drvseq = $mb_seq
- AND ownerlevel = 0
- AND Month(call_date)=Month(now())
- GROUP BY LEFT(call_date, 10)
- ) a
- left JOIN (
- SELECT LEFT(call_date, 10) as call_date_1,
- IFNULL(SUM(drv_distance),0) as drv_distance_1,
- IFNULL(SUM(drv_cash),0) as drv_cash_1,
- IFNULL(SUM(drv_vccash),0) as drv_vccash_1,
- IFNULL(SUM(tollfee1),0) as tollfee1_1,
- IFNULL(SUM(tollfee2),0) as tollfee2_1,
- IFNULL(SUM(tollfee3),0) as tollfee3_1,
- IFNULL(SUM(tollfee4),0 ) as tollfee4_1,
- drvseq as drvseq_1 ,
- COUNT(*) as cnt_1
- FROM drivers_working_info
- WHERE drvseq = $mb_seq
- AND ownerlevel = 1
- AND Month(call_date)=Month(now())
- GROUP BY LEFT(call_date, 10)
- ) b
- ON (a.call_date = b.call_date_1)
- left JOIN (
- SELECT LEFT(recv_time, 10) AS call_date_2,
- COUNT(*) AS cnt_2,
- IFNULL(SUM(price),0) AS price_2,
- drvno
- FROM bank_excel
- WHERE REPLACE(REPLACE(drvno,'[',''),']','') = {$slice_mb_seq}
- AND result = '계좌이체성공'
- AND Month(recv_time)=Month(now())
- GROUP BY LEFT(recv_time, 10)
- ) c
- ON (RIGHT(a.drvseq,4) = REPLACE(REPLACE(c.drvno,'[',''),']',''))";
- $result = sql_query($sql);
- while ($row = sql_fetch_array($result)) {
- // 요금차이
- $miner_price = $row['drv_cash_1'] - $row['drv_cash'];
- if ($miner_price) {
- $miner_price = $miner_price;
- } else {
- $miner_price = 0;
- }
- $row['drv_distance'] = number_format($row['drv_distance']);
- $row['drv_cash'] = number_format($row['drv_cash']);
- $row['drv_vccash'] = number_format($row['drv_vccash']);
- $row['tollfee1'] = number_format($row['tollfee1']);
- $row['tollfee2'] = number_format($row['tollfee2']);
- $row['tollfee3'] = number_format($row['tollfee3']);
- $row['tollfee4'] = number_format($row['tollfee4']);
- $row['cnt'] = number_format($row['cnt']);
- $tollfee_a = (int)$row['tollfee1_1'] + (int)$row['tollfee2_1'] + (int)$row['tollfee3_1'] + (int)$row['tollfee4_1'];
- $row['drv_distance_1'] = number_format($row['drv_distance_1']);
- $row['drv_cash_1'] = number_format($row['drv_cash_1']);
- $row['drv_vccash_1'] = number_format($row['drv_vccash_1']);
- $row['tollfee1_1'] = number_format($row['tollfee1_1']);
- $row['tollfee2_1'] = number_format($row['tollfee2_1']);
- $row['tollfee3_1'] = number_format($row['tollfee3_1']);
- $row['tollfee4_1'] = number_format($row['tollfee4_1']);
- $row['cnt_1'] = number_format($row['cnt_1']);
- $row['a_call_date'] = iuf_hex_encode($row['call_date']);
- $a_mb_seq = iuf_hex_encode($mb_seq);
- $row['a_drv_distance'] = iuf_hex_encode($row['drv_distance']);
- $row['a_cnt'] = iuf_hex_encode($row['cnt']);
- $row['a_drv_cash'] = iuf_hex_encode($row['drv_cash']);
- $row['a_drv_vccash'] = iuf_hex_encode($row['drv_vccash']);
- $row['a_cnt_1'] = iuf_hex_encode($row['cnt_1']);
- $row['a_drv_cash_1'] = iuf_hex_encode($row['drv_cash_1']);
- $row['a_drv_vccash_1'] = iuf_hex_encode($row['drv_vccash_1']);
- $a_tollfee_a = iuf_hex_encode($tollfee_a);
- $option['data'] = "<tr class='iframe1_1' data-calldate='{$row['call_date']}' data-cartype='{$cartype}'>
- <td class='addtd1'>{$row['call_date']}</td>
- <td class='addtd2'>{$row['drv_distance']}</td>
- <td class='addtd3'>{$row['cnt']}</td>
- <td class='addtd4'>{$row['drv_cash']}</td>
- <td class='addtd5'>{$row['drv_vccash']}</td>
- <td class='addtd6'>{$row['cnt_1']}</td>
- <td class='addtd7'>{$row['drv_cash_1']}</td>
- <td class='addtd8'>{$row['drv_vccash_1']}</td>
- <td class='addtd9'>{$row['cnt_2']}</td>
- <td class='addtd10'>{$row['price_2']}</td>
- <td class='addtd11'></td>
- <td class='addtd12'>{$row['tollfee1_1']}</td>
- <td class='addtd13'>{$row['tollfee2_1']}</td>
- <td class='addtd14'>{$row['tollfee3_1']}</td>
- <td class='addtd15'>{$row['tollfee4_1']}</td>
- <td>
- <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>
- </td>
- </tr>";
- // $option['date'] = $row['call_date'];
- // array_push($options, preg_replace('/\r\n|\r|\n/','',$option));
- array_push($options, $option);
- }
- }
- // $output = json_encode($options, JSON_UNESCAPED_UNICODE);
- print_r($options);