| Server IP : 104.21.21.239 / 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/rpt/ |
Upload File : |
<?php include('mod/_mod_security.php'); ?>
<?php
$having = ' HAVING 1=1 ';
$where = ' WHERE 1=1 ';
$having_contact = " HAVING c.first_name > ' ' ";
$where_contact = ' WHERE 1=1 ';
if ($_GET['cat'] > ' ') :
$having .= " AND h.category = ".$db->quote(trim($_GET['cat']))." ";
$having_contact .= " AND h.category = ".$db->quote(trim($_GET['cat']))." ";
endif;
if ($_GET['status'] > ' ') :
$where .= " AND c.status = ".nz(trim($_GET['status']), '0')." ";
$where_contact .= " AND 1=0 ";
endif;
$sql = "SELECT DISTINCT * FROM ( ".
"SELECT if(c.first_name > '','Concierge','') AS rec_type, h.category, c.title, c.first_name, c.last_name, IF(c.nycahc_member = 1,'Y','') AS nycahc_calc, ".
"IF(c.lcd = 1,'Y','') AS lcd_calc, h.hotel_name, h.concierge_service, h.nbr_of_rooms, ".
"SUM(dist_qty) AS cg_qty, ".
//"SUM(IF(p.city_guide = 1,p.city_guide_qty,0)) AS city_guide_calc, ".
//"SUM(IF(p.promenade = 1,p.promenade_qty,0)) AS promenade_calc, ".
"h.bldg_nbr, h.street, h.city, h.state, h.zip, h.main_phone, c.primary_email AS work_email, c.secondary_email AS personal_email, (CASE c.status WHEN 0 THEN 'Inactive' WHEN 1 THEN 'Active' WHEN 2 THEN 'In transition' END) AS c_status ".
"FROM hotels h LEFT OUTER JOIN concierges c ON (h.hotel_id = c.hotel_id) LEFT OUTER JOIN hotels_products hp ON (h.hotel_id = hp.hotel_id AND hp.product_id = ".APP_DEFAULT_PRODUCT." AND hp.active = 1) ".$where.
"GROUP BY if(c.first_name > '','Concierge',''), h.category, c.title, c.first_name, c.last_name, IF(c.nycahc_member = 1,'Y',''), IF(c.lcd = 1,'Y',''), h.hotel_name, h.concierge_service, ".
"h.nbr_of_rooms, h.bldg_nbr, h.street, h.city, h.state, h.zip, h.main_phone, c.primary_email, c.secondary_email, (CASE c.status WHEN 0 THEN 'Inactive' WHEN 1 THEN 'Active' WHEN 2 THEN 'In transition' END) ".
$having.
"UNION ".
"SELECT if(c.first_name > '','Contact','') AS rec_type, h.category, c.title, c.first_name, c.last_name, '' AS nycahc_calc, ".
"'' AS lcd_calc, h.hotel_name, h.concierge_service, h.nbr_of_rooms, ".
"SUM(dist_qty) AS cg_qty, ".
//"SUM(IF(p.city_guide = 1,p.city_guide_qty,0)) AS city_guide_calc, ".
//"SUM(IF(p.promenade = 1,p.promenade_qty,0)) AS promenade_calc, ".
"h.bldg_nbr, h.street, h.city, h.state, h.zip, h.main_phone, c.email AS work_email, NULL AS personal_email, NULL AS c_status ".
"FROM hotels h LEFT OUTER JOIN contacts c ON (h.hotel_id = c.hotel_id) LEFT OUTER JOIN hotels_products hp ON (h.hotel_id = hp.hotel_id AND hp.product_id = ".APP_DEFAULT_PRODUCT." AND hp.active = 1) ".$where_contact.
"GROUP BY 'Contact', h.category, c.title, c.first_name, c.last_name, '', '', h.hotel_name, h.concierge_service, ".
"h.nbr_of_rooms, h.bldg_nbr, h.street, h.city, h.state, h.zip, h.main_phone, c.email, NULL, NULL ".
$having_contact.
" ) u ORDER BY hotel_name, first_name, last_name ";
$result = $db->query($sql) or die('Database Error!');
/* **** */
//echo " === ".$sql." === ";
//echo ' Records: '.$result->rowCount();
//return;
/* *** */
$margin_left = 0.5;
$margin_right = 0.5;
$margin_top = 1.0;
$margin_bottom = 0.75;
$margin_header = 0.5;
$margin_footer = 0.5;
if ($_GET['fmt'] == 'excel') :
echo '<script>';
echo "window.location.href = 'ajax.php?call=_export_excel&sql=".urlencode(sys_encrypt(sys_compress($sql), $_SESSION['rand_key']))."';";
echo '</script>';
elseif ($_GET['fmt'] == 'pdf') :
$mpdf = new \Mpdf\Mpdf([
'format' => 'Letter-L',
'margin_left' => $margin_left * 25.4,
'margin_right' => $margin_right * 25.4,
'margin_top' => $margin_top * 25.4,
'margin_bottom' => $margin_bottom * 25.4,
'margin_header' => $margin_header * 25.4,
'margin_footer' => $margin_footer * 25.4,
]);
$mpdf->debug = false;
$mpdf->keep_table_proportions = true;
$mpdf->SetProtection(array('copy','print'));
$mpdf->SetTitle("Master Hotel Database - Report");
$mpdf->SetAuthor("Davler Media Group");
$mpdf->SetHTMLHeader('<table width="100%" style="vertical-align: bottom; font-size: 11pt; color: #000000;"><tr>'.
'<td width="100%" style="text-align: left;">Full List</td>'.
'</tr></table><br /><br />');
$mpdf->SetHTMLFooter('<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;"><tr>'.
'<td width="33%"><span style="font-weight: bold; font-style: italic;">{DATE m/j/Y}</span></td>'.
'<td width="33%" align="center" style="font-weight: bold; font-style: italic;">Page {PAGENO} of {nbpg}</td>'.
'<td width="33%" style="text-align: right; ">Davler Media Group</td>'.
'</tr></table>');
$mpdf->SetDisplayMode('fullpage');
$html = '<html><body style="font-family: Arial; font-size: 11pt; line-height: 12pt; ">';
$html .= '<table width="100%" style="vertical-align: top; text-align:left; font-size: 8pt; color: #000000; font-weight: normal; border-collapse:collapse;">';
$html .= '<thead style="font-weight:bold;"><tr>';
$html .= '<td style="border:1px solid #000000;" width="3%" align="center">Type</td>';
$html .= '<td style="border:1px solid #000000;" width="3%" align="center">Cat</td>';
$html .= '<td style="border:1px solid #000000;" width="7%" align="center">Title</td>';
$html .= '<td style="border:1px solid #000000;" width="6%" align="center">First Name</td>';
$html .= '<td style="border:1px solid #000000;" width="6%" align="center">Last Name</td>';
$html .= '<td style="border:1px solid #000000;" width="3%" align="center">NYCAHC</td>';
$html .= '<td style="border:1px solid #000000;" width="3%" align="center">LCD</td>';
$html .= '<td style="border:1px solid #000000;" width="8%" align="center">Hotel Name</td>';
$html .= '<td style="border:1px solid #000000;" width="3%" align="center">Concierge Service</td>';
$html .= '<td style="border:1px solid #000000;" width="3%" align="center"># Rooms</td>';
$html .= '<td style="border:1px solid #000000;" width="3%" align="center">CG</td>';
//$html .= '<td style="border:1px solid #000000;" width="3%" align="center">Prom</td>';
$html .= '<td style="border:1px solid #000000;" width="3%" align="center">BLDG #</td>';
$html .= '<td style="border:1px solid #000000;" width="7%" align="center">Street</td>';
$html .= '<td style="border:1px solid #000000;" width="7%" align="center">City</td>';
$html .= '<td style="border:1px solid #000000;" width="4%" align="center">State</td>';
$html .= '<td style="border:1px solid #000000;" width="4%" align="center">Zip</td>';
$html .= '<td style="border:1px solid #000000;" width="7%" align="center">Main Phone</td>';
$html .= '<td style="border:1px solid #000000;" width="7%" align="center">Work Email</td>';
$html .= '<td style="border:1px solid #000000;" width="7%" align="center">Personal Email</td>';
$html .= '<td style="border:1px solid #000000;" width="3%" align="center">Status</td>';
$html .= '</tr></thead><tbody>';
while($row = $result->fetch(PDO::FETCH_OBJ)) :
$html .= '<tr>';
$html .= '<td>'.$row->rec_type.'</td>';
$html .= '<td align="center">'.$row->category.'</td>';
$html .= '<td>'.$row->title.'</td>';
$html .= '<td>'.$row->first_name.'</td>';
$html .= '<td>'.$row->last_name.'</td>';
$html .= '<td align="center">'.$row->nycahc_calc.'</td>';
$html .= '<td align="center">'.$row->lcd_calc.'</td>';
$html .= '<td>'.$row->hotel_name.'</td>';
$html .= '<td align="left">'.$row->concierge_service.'</td>';
$html .= '<td align="right">'.$row->nbr_of_rooms.'</td>';
$html .= '<td align="center">'.$row->cg_qty.'</td>';
//$html .= '<td align="center">'.$row->city_guide_calc.'</td>';
//$html .= '<td align="center">'.$row->promenade_calc.'</td>';
$html .= '<td>'.$row->bldg_nbr.'</td>';
$html .= '<td>'.$row->street.'</td>';
$html .= '<td>'.$row->city.'</td>';
$html .= '<td>'.$row->state.'</td>';
$html .= '<td>'.$row->zip.'</td>';
$html .= '<td>'.$row->main_phone.'</td>';
$html .= '<td style="white-space:nowrap;">'.$row->work_email.'</td>';
$html .= '<td>'.$row->personal_email.'</td>';
$html .= '<td>'.$row->c_status.'</td>';
$html .= '</tr>';
if (strlen($html) > 99999 ) :
$html = utf8_encode($html);
$mpdf->WriteHTML($html);
$html = '';
set_time_limit(180);
endif;
endwhile;
$html .= '</tbody></table>';
$html .= '</body></html>';
$html = utf8_encode($html);
$mpdf->WriteHTML($html);
$mpdf->Output();
endif;
?>