I have finally had luck thanks to Chu in getting this working correctly. Now I am trying to build a simple report. I have a drop down list of available employees to choose from and then you submit the form.
<?php
/**
* DISPATCH REPORT 3.1
*/
require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
$employees_array = array();
$employees_array[] = array('id' => '', 'text' => 'Select Driver');
$employees = $db->Execute('SELECT * FROM ' . DB_PREFIX . 'employees');
while(!$employees->EOF) {
$employees_array[] = array('id' => $employees->fields['employee_id'], 'text' => $employees->fields['employee_first']);
//$employees_array[] = array('id' => $employees->fields['employee_id'], 'text' => $employees->fields['employee_first'] . ' ' . $employees->fields['employee_last']);
$employees->MoveNext();
}
?>
<?php echo zen_draw_form('drivercheckoutform', 'drivercheckout', zen_get_all_get_params(array('page', 'action')) . 'page=' . $_GET['page'] . '&action=submit', 'post'); ?>
<div align="center" id="employeebox"><?php echo zen_draw_pull_down_menu('employee_id', $employees_array);?></div>
<div align="right"><button type="submit">Submit</button></div>
The above code has db_prefix and I haven't successfully been able to change that to TABLE_EMPLOYEES. A little help there would be great.
This brings you to drivercheckout.php
On this page I want to query TABLE_HTA and return all rows that have status 'OTD' and the selected employee 'ID' for the current day. Then I will display the order number(order_id) and total(order_total) for each record. At the bottom of the report I want to have a total for all orders appearing in the chart($total) So far I have this:
<?php
require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
$start_date = date(DATE_FORMAT, mktime(0, 0, 0, date("m"), date("d"), date("Y")));
$end_date = date(DATE_FORMAT, mktime(23, 59, 59, date("m"), date("d"), date("Y")));
$sql = 'SELECT * FROM ' . TABLE_HTA . ' WHERE date >= ' . date("Y-m-d H:i:s", $start_date) . ' AND date < ' . date("Y-m-d H:i:s", $end_date) . ' AND employee_id = ' . $employee_id . ';
$orders = $db->Execute($sql);
$total = 0;
if($orders->RecordCount() > 0) {
while(!$orders->EOF) {
?>
<tr>
<td align="center"><?php echo $orders->fields['order_id'];?></td>
<td align="center"><?php echo $orders->fields['otd_time'];?>
<td align="right"><?php echo $currencies->format($orders->fields['order_total']);?></td>
<?php $total=$total+$orders->fields['order_total'];?>
</tr>
<?php
$orders->MoveNext();
}?>
<tr>
<td></td>
<td></td>
<td><?php echo $total;?></td>
<?php
}
?>
I know my query is wrong. I'm not even positive it is using the employee_id from the submitted form. This will be my first report I create so I'm really just learning this. I have looked at many examples and tried to use as a pattern and this is what I have so far.
Thank you so much for your help in learning this!