| Server IP : 172.67.201.108 / Your IP : 216.73.216.11 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/hotel-prod/public_html/mod/ |
Upload File : |
<?php
//ini_set('display_errors',1);
//error_reporting(E_ALL & ~E_NOTICE);
?>
<?php include('_mod_security.php'); ?>
<?php
//header('Content-Type: application/json');
//var_dump($_GET);
$sql = '';
switch ($_GET['func']):
case 'grid' :
require_once('classes/lcs_db_grid.php');
$dbg = new lcs_db_grid;
$dbg->start_header_section();
$dbg->start_header();
$dbg->add_column(array('label' => 'Delivered', 'dbcol'=>'d.create_date', 'sortable' => true, 'searchable' => false, 'width' => '75px', 'align' => 'center'));
$dbg->add_column(array('label' => 'Seq', 'dbcol' => 'h.sequence_nbr', 'width' => '50px', 'align' => 'right'));
$dbg->add_column(array('label' => 'Hotel Name', 'dbcol' => 'h.hotel_name', 'width' => '210px'));
$dbg->add_column(array('label' => 'Bldg', 'dbcol' => 'h.bldg_nbr', 'width' => '60px'));
$dbg->add_column(array('label' => 'Street', 'dbcol' => 'h.street', 'width' => '120px'));
$dbg->add_column(array('label' => 'Drop Location', 'dbcol' => 'hp.drop_location', 'width' => '220px'));
$dbg->add_column(array('label' => 'Zip', 'dbcol' => 'h.zip', 'width' => '65px'));
$dbg->add_column(array('label' => 'City', 'dbcol' => 'h.city', 'width' => '100px'));
$dbg->add_column(array('label' => 'State', 'dbcol' => 'h.state', 'width' => '60px'));
$dbg->add_column(array('label' => 'Dist Qty', 'dbcol' => 'hp.dist_qty', 'width' => '60px', 'align' => 'right'));
$dbg->add_column(array('label' => 'Last Qty', 'dbcol' => 'dd.qty', 'width' => '60px', 'align' => 'right'));
$dbg->end_header();
$dbg->end_header_section();
$sql = "SELECT DISTINCT h.zip, h.city, h.street, h.bldg_nbr, h.hotel_id, h.state, h.hotel_name, d.delivery_id, d.create_date, dd.qty, h.sequence_nbr, hp.product_id, hp.drop_location, hp.dist_qty FROM routes r INNER JOIN hotels h ON (h.route_id = r.route_id AND h.status = 1) ".
"INNER JOIN hotels_products hp ON (h.hotel_id = hp.hotel_id AND hp.product_id = ".APP_DEFAULT_PRODUCT." AND hp.active = 1) ".
"LEFT OUTER JOIN deliveries dd ON (h.hotel_id = dd.hotel_id AND dd.create_date = (SELECT MAX(create_date) FROM deliveries WHERE hotel_id = h.hotel_id AND product_id = hp.product_id AND drop_location = hp.drop_location)) ".
"LEFT OUTER JOIN deliveries d ON (h.hotel_id = d.hotel_id AND d.product_id = hp.product_id AND d.drop_location = hp.drop_location AND d.create_date >= now() - INTERVAL 3 DAY) ".
"WHERE ".$dbg->search_spec()." ".$_GET['parm1']." ".$_GET['parm2']." ".$_GET['parm3']." "." AND h.status = 1 ".
"ORDER BY ".$dbg->sort_spec();
//error_log($sql);
//echo ' === '.$sql.' === ';
$xls_sql = $sql;
$xls_sql_encoded = xls_sql_encrypt($xls_sql);
$result = $db->query($sql) or die('Database Error!');
$dbg->start_data_section();
$total_delivered_qty = 0;
$total_dist_qty = 0;
if ($result->rowCount() > 0) :
while ($row = $result->fetch(PDO::FETCH_OBJ)) :
$dbg->start_row();
if (!empty($row->create_date)) :
$dbg->add_cell('<img src="img/check_icon.gif" style="border:none;" />');
$total_delivered_qty += $row->qty;
else :
$dbg->add_cell('<a href="index.php?IX=delivery_form&ref='.urlencode('my_route_locations&id='.nz($_GET['parm1'], '0').'&search='.trim($_GET['search_str'])).'&hotel_id='.$row->hotel_id.'&product_id='.$row->product_id.'&drop_location='.urlencode($row->drop_location).'" >Deliver <img src="img/arrow_right.gif" style="border:none; vertical-align:middle;" /></a>');
endif;
$dbg->add_cell($row->sequence_nbr);
$dbg->add_cell('<a href="index.php?IX='.$_GET['ix_form'].'&id='.$row->hotel_id.'" >'.$row->hotel_name.'</a>');
$dbg->add_cell($row->bldg_nbr);
$dbg->add_cell($row->street);
$dbg->add_cell($row->drop_location);
$dbg->add_cell($row->zip);
$dbg->add_cell($row->city);
$dbg->add_cell($row->state);
$dbg->add_cell(number_format($row->dist_qty, 0, '.', ','));
$dbg->add_cell(number_format($row->qty, 0, '.', ','));
$dbg->end_row();
$total_dist_qty += $row->dist_qty;
endwhile;
else :
$dbg->start_row();
$dbg->add_cell('No records found');
$dbg->end_row();
endif;
$dbg->end_data_section();
echo json_encode(array('row_count' => $result->rowCount(), 'html' => $dbg->get_html(), 'xls_sql' => $xls_sql_encoded, 'extra_data'=> 'Dist qty: '.number_format($total_dist_qty, 0, '.', ',').' / Delivered: '.number_format($total_delivered_qty, 0, '.', ',')));
return;
break;
endswitch;
?>