isLoggedIn()) { header ("location: ../login.php"); exit(); } if(isset($_POST['selected_brand'])) { $selected_brand=$_POST['selected_brand']; $date_range=$_POST['date_range']; $dates=explode(':',$date_range); $date1=$dates[0]; $date2=$dates[1]; } $sales_table=$cfg_tableprefix.'sales'; $sales_items_table=$cfg_tableprefix.'sales_items'; $display_name=$dbf->idToField($cfg_tableprefix.'brands','brand',$selected_brand); $display=new display($dbf->conn,$cfg_theme,$cfg_currency_symbol,$lang); $display->displayTitle("$cfg_company $lang->brandReport"); $tableheaders=array("$lang->saleID","$lang->itemName","$lang->unitPrice","$lang->quantityPurchased","$lang->tax","$lang->itemTotalCost"); $tablefields=array('sale_id','item_id','item_unit_price','quantity_purchased','item_total_tax','item_total_cost'); $result=mysql_query("SELECT * FROM $sales_table WHERE date between \"$date1\" and \"$date2\" ORDER BY id DESC",$dbf->conn); $result2=mysql_query("SELECT * FROM $sales_table WHERE date between \"$date1\" and \"$date2\" ORDER BY id ASC",$dbf->conn); $row=mysql_fetch_assoc($result); $high_id=$row['id']; $row=mysql_fetch_assoc($result2); $low_id=$row['id']; $result3=mysql_query("SELECT * FROM $sales_items_table WHERE sale_id BETWEEN \"$low_id\" and \"$high_id\" ORDER BY id DESC",$dbf->conn); echo "

$lang->listOfSalesFor $display_name
$lang->between $date1 $lang->and $date2

"; echo '
'; if(@mysql_num_rows($result) ==0) { echo "
$lang->noDataInTable $sales_table $lang->table.
"; exit(); } echo "border_style $display->border_color $display->border_width px\" align='center'> header_rowcolor>\n\n"; for($k=0;$k< count($tableheaders);$k++) { echo "\n"; } echo ''."\n\n"; $rowCounter=0; $subtotal=0; $total=0; while($row=mysql_fetch_assoc($result3)) { $brand_of_item=$dbf->idToField($cfg_tableprefix.'items','brand_id',$row['item_id']); if($selected_brand==$brand_of_item) { if($rowCounter%2==0) { echo "\nrowcolor1>\n"; } else { echo "\nrowcolor2>\n"; } $rowCounter++; for($k=0;$kidToField("$cfg_tableprefix".'items',"$field",$row['item_id']); $data=$display->formatData($field,$field_data,$cfg_tableprefix); } else { $data=$display->formatData($field,$row[$field],$cfg_tableprefix); } echo "\n\n"; } @$subtotal+=$row['item_total_cost']-$row['item_total_tax']; @$total+=$row['item_total_cost']; } } echo '
\n$tableheaders[$k]\n
\n$data\n
'."\n"; $subtotal=number_format($subtotal,2,'.', ''); $total=number_format($total,2,'.', ''); $tax=$total-$subtotal; $tax=number_format($tax,2,'.', ''); echo "
"; echo "
$lang->totalWithOutTax: $display->currency_symbol$subtotal
$lang->totalWithTax: $display->currency_symbol$total
$lang->tax: $display->currency_symbol$tax
"; ?>