WebsiteBaker Support (2.8.x) > Bakery Shop
Bakery Reports Add-on
jacobi22:
some question: is the report separatet by user btw customers or "only" for a special time like a mouth or a week?
hillschmidt:
so far, only the 'only' option has been realized :mrgreen: meaning selection of all orders within a given month.
The Bakery Shop is not a customer based one but a order based one (see bakery-shop.ch:
--- Quote ---
* No customer registration needed
* For logged in customers Bakery tries to retrieve their address data of a previous order to prepopulat the address fields
--- End quote ---
) so it could become very hard to search all orders for a specific customer. The invoice is ONE field in the order so that you must scan this (and you will fail as soon as a different input or a typo makes a difference in the customer's section within this field ...)
avde:
Hi,
can you please share the file for generating the report?
thx!
hillschmidt:
Didn't work further since the last post ... so the above is still valid - this is the code to realize the rudimental I talked about:
--- Code: ---<?php
/*
Module developed for the Open Source Content Management System WebsiteBaker (http://WebsiteBaker.org)
Copyright (C) 2012, Christoph Marti
LICENCE TERMS:
This module is free software. You can redistribute it and/or modify it
under the terms of the GNU General Public License - version 2 or later,
as published by the Free Software Foundation: http://www.gnu.org/licenses/gpl.html.
DISCLAIMER:
This module is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
// include WB config.php file and admin class
require('../../config.php');
require_once(WB_PATH.'/framework/class.admin.php');
// Check if GET and SESSION vars are set
//if (!isset($_GET['page_id']) OR !isset($_GET['section_id']) OR !isset($_GET['order_id']) OR !is_numeric($_GET['page_id']) OR !is_numeric($_GET['section_id']) OR !is_numeric($_GET['order_id']) OR !isset($_SESSION['USER_ID']) OR !isset($_SESSION['GROUP_ID'])) {
// die($MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS']);
if (!isset($_GET['page_id']) OR !isset($_GET['section_id']) OR !isset($_GET['YYYY']) OR !isset($_GET['MM']) OR !is_numeric($_GET['page_id']) OR !is_numeric($_GET['section_id']) OR !isset($_SESSION['USER_ID']) OR !isset($_SESSION['GROUP_ID'])) {
die($MESSAGE['FRONTEND']['SORRY_NO_VIEWING_PERMISSIONS']);
} else {
$page_id = $_GET['page_id'];
$section_id = $_GET['section_id'];
//$order_id = $_GET['order_id'];
$order_YYYY = $_GET['YYYY'];
$order_MM = $_GET['MM'];
$start_date=$order_YYYY."-".$order_MM."-01";
if ($order_MM=="01" OR $order_MM=="03" OR $order_MM=="05" OR $order_MM=="07" OR $order_MM=="08" OR $order_MM=="10" OR $order_MM=="12")
{
$end_date=$order_YYYY."-".$order_MM."-31";
}
elseif ($order_MM=="02")
{
$end_date=$order_YYYY."-".$order_MM."-28";
}
elseif ($order_MM=="04" OR $order_MM=="06" OR $order_MM=="09" OR $order_MM=="11")
{
$end_date=$order_YYYY."-".$order_MM."-30";
}
}
// Check if user is authenticated to view this page
$admin = new admin('', '', false, false);
if ($admin->get_page_permission($page_id, $action='admin') === false) {
// User allowed to view this page
die($MESSAGE['ADMIN']['INSUFFICIENT_PRIVELLIGES']);
}
//Look for language File
if (LANGUAGE_LOADED) {
require_once(WB_PATH.'/modules/bakery/languages/EN.php');
if (file_exists(WB_PATH.'/modules/bakery/languages/'.LANGUAGE.'.php')) {
require_once(WB_PATH.'/modules/bakery/languages/'.LANGUAGE.'.php');
}
}
// Header
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?php echo $MOD_BAKERY['TXT_ORDER']." ".$TEXT['VIEW_DETAILS']; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php if (defined('DEFAULT_CHARSET')) { echo DEFAULT_CHARSET; } else { echo 'utf-8'; }?>" />
<link href="<?php echo WB_URL; ?>/modules/bakery/backend.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="order">
<table width="540px" align="center" border="0" cellspacing="0" cellpadding="3">
<tr>
<td><span class="mod_bakery_order_b"><?php echo $MOD_BAKERY['TXT_ORDER_ID']."</span>: " ?></td>
<td><span class="mod_bakery_order_b"><?php echo $MOD_BAKERY['TXT_ORDER_DATE']."</span>: " ?></td>
<td><span class="mod_bakery_order_b"><?php echo $MOD_BAKERY['TXT_ADDRESS']."</span>: " ?></td>
<td><span class="mod_bakery_order_b"><?php echo $MOD_BAKERY['TXT_TOTAL']."</span>: " ?></td>
</tr>
<?php
$ORDER_SUM=0;
// Get invoice data string from db customer table
//$query_customer = $database->query("SELECT invoice FROM ".TABLE_PREFIX."mod_bakery_customer WHERE order_id = '$order_id'");
$query_customer = $database->query("SELECT invoice FROM ".TABLE_PREFIX."mod_bakery_customer WHERE order_date >= UNIX_TIMESTAMP('$start_date') AND order_date <= UNIX_TIMESTAMP('$end_date') ORDER BY order_id");
//if ($query_customer->numRows() > 0) {
//while ($query_customer->numRows() > 0) {
$ANZ = $query_customer->numRows();
$i = 1;
while ($i <= $ANZ) {
$customer = $query_customer->fetchRow();
if ($customer['invoice'] != '') {
// Convert string to array
$invoice = stripslashes($customer['invoice']);
$invoice_array = explode("&&&&&", $invoice);
// Vars
$order_id = $invoice_array[0];
#$shop_name = $invoice_array[1];
#$bank_account = $invoice_array[2];
#$cust_name = $invoice_array[3];
#$address = $invoice_array[4];
$cust_address = $invoice_array[5];
$ship_address = $invoice_array[6];
#$cust_email = $invoice_array[7];
$html_item_list = $invoice_array[8];
$order_date = $invoice_array[9];
// If given get customer tax no
$cust_tax_no = isset($invoice_array[15]) ? $invoice_array[15] : '';
$display_tax_no = $cust_tax_no == '' ? 'none' : '';
// Change frontend classes (eg. mod_bakery_anything_f) to backend classes (eg. mod_bakery_anything_b)
$html_item_list = str_replace("_f'", "_b'", $html_item_list);
$ZW_SUM=explode($MOD_BAKERY['TXT_TOTAL'],$html_item_list);
$CALC_ZW=explode(" ",$ZW_SUM[1]);
$CALC_ZW[1]=str_replace(",", ".",$CALC_ZW[1]);
$ORDER_SUM=$ORDER_SUM + strip_tags($CALC_ZW[1]);
// Show order
?>
<tr>
<td><?php echo strip_tags($order_id); ?></td>
<td><?php echo strip_tags($order_date); ?></td>
<?php $cust=explode(" ",$cust_address); ?>
<td valign="top" width="30%"><?php echo strip_tags($cust[0])." ".strip_tags($cust[1]); ?></td>
<td><?php echo strip_tags($ZW_SUM[1]); ?></td>
</tr>
<?php
$i++;
}
//else {
//echo "<p class='mod_bakery_error_b'>".$TEXT['NONE_FOUND']."!</p>";
//echo "<p style='text-align: right;'><input type='button' value='{$TEXT['CLOSE']}' onclick='javascript: window.close();' style='width: 120px; margin-top: 5px;' /></p>";
//}
}
?>
</table>
</div>
<table width="540px" align="center" border="0" cellspacing="0" cellpadding="3">
<tr id="button" valign="top">
<td colspan="3" height="30" align="left" style="padding-left: 12px;"> </td>
<td colspan="3" height="30" align="right" style="padding-right: 12px;"><?php printf("%01.2f",$ORDER_SUM); ?></td>
</tr>
<tr id="button" valign="top">
<td colspan="3" height="30" align="left" style="padding-left: 12px;"> </td>
<td colspan="3" height="30" align="right" style="padding-right: 12px;">
<input type="button" value="<?php echo $TEXT['CLOSE']; ?>" onclick="javascript: window.close();" style="width: 120px; margin-top: 5px;" />
</td>
</tr>
</table>
</body>
--- End code ---
Navigation
[0] Message Index
[*] Previous page
Go to full version