Modified:
trunk/include/sql_queries.php
trunk/modules/customers/manage.js.php
trunk/modules/products/manage.js.php
trunk/modules/products/manage.php
trunk/modules/products/xml.php
trunk/templates/default/products/manage.tpl
Log:
Modified: trunk/include/sql_queries.php
==============================================================================
--- trunk/include/sql_queries.php (original)
+++ trunk/include/sql_queries.php Tue Jul 1 20:51:58 2008
@@ -62,7 +62,9 @@
// Earlier implementation did not return the $sth on error
}
// $sth now has the PDO object or false on error.
+
return $sth;
+
}
// Used for logging all queries
Modified: trunk/modules/customers/manage.js.php
==============================================================================
--- trunk/modules/customers/manage.js.php (original)
+++ trunk/modules/customers/manage.js.php Tue Jul 1 20:51:58 2008
@@ -46,20 +46,19 @@
var ds = new Ext.data.GroupingStore({
// load using HTTP
//url: 'sheldon2.xml',
- url: 'index.php?module=customers&view=xml',
+ url: 'index.php?module=products&view=xml',
// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "Item" tag
record: 'tablerow',
- id: 'CID',
- type_id: 'type_id',
+ id: 'id',
totalRecords: 'total'
}, [
// set up the fields mapping into the xml doc
// The first needs mapping, the others are very basic
'actions',
- {name: 'CID', mapping: 'CID'},
- 'name','customer_total','owing','enabled'
+ {name: 'id', mapping: 'id'},
+ 'description','unit_price','enabled'
]),
// turn on defautl grouping by Aging field
//groupField: 'Aging',
@@ -72,14 +71,14 @@
function renderActions(value, p, record ){
var viewLink = String.format(
- '<!--0 Quick View --><a class="index_table"
href="index.php?module=customers&view=details&id={1}&action=view"> <img
src="images/common/view.png" height="16" border="-5px" padding="-4px"
valign="bottom" /></a>',
+ '<!--0 Quick View --><a class="index_table"
href="index.php?module=productss&view=details&id={1}&action=view"> <img
src="images/common/view.png" height="16" border="-5px" padding="-4px"
valign="bottom" /></a>',
value,
record.id,
record.data.type_id,
record.data.forumid);
var editLink = String.format(
- '<!--1 Edit View --><a class="index_table"
href="index.php?module=customers&view=details&id={1}&action=edit"><img
src="images/common/edit.png" height="16" border="-5px" padding="-4px"
valign="bottom" /><!-- print --></a>',
+ '<!--1 Edit View --><a class="index_table"
href="index.php?module=products&view=details&id={1}&action=edit"><img
src="images/common/edit.png" height="16" border="-5px" padding="-4px"
valign="bottom" /><!-- print --></a>',
value,
record.id,
record.data.type_id,
@@ -94,10 +93,9 @@
var cm = new Ext.grid.ColumnModel([
{header: "Actions", width: 105, dataIndex: 'actions', sortable:false,
renderer: renderActions },
- {header: "ID", width: 50, dataIndex: 'CID'},
- {header: "Name", width: 180, dataIndex: 'name'},
- {header: "Total", width: 115, dataIndex: 'customer_total'},
- {header: "Owing", width: 75, dataIndex: 'owing'},
+ {header: "ID", width: 50, dataIndex: 'id'},
+ {header: "Description", width: 180, dataIndex: 'description'},
+ {header: "Unit Price", width: 115, dataIndex: 'unit_price'},
{header: "Enabled", width: 100, dataIndex: 'enabled'}
]);
cm.defaultSortable = true;
@@ -106,8 +104,8 @@
var grid = new Ext.grid.GridPanel({
ds: ds,
cm: cm,
- title:'Manage Customers',
- renderTo:'manageCustomersGrid',
+ title:'Manage Products',
+ renderTo:'manageGrid',
autoHeight: true,
viewConfig: {
forceFit:true
Modified: trunk/modules/products/manage.js.php
==============================================================================
--- trunk/modules/products/manage.js.php (original)
+++ trunk/modules/products/manage.js.php Tue Jul 1 20:51:58 2008
@@ -10,6 +10,9 @@
{literal}
+var view_tooltip ="{/literal}{$LANG.quick_view_tooltip} {ldelim}1{rdelim}{literal}";
+var edit_tooltip = "{/literal}{$LANG.edit_view_tooltip}
{$invoices.preference.pref_inv_wording} {ldelim}1{rdelim}{literal}";
+
Ext.onReady(function(){
Ext.QuickTips.init();
@@ -72,14 +75,14 @@
function renderActions(value, p, record ){
var viewLink = String.format(
- '<!--0 Quick View --><a class="index_table"
href="index.php?module=customers&view=details&id={1}&action=view"> <img
src="images/common/view.png" height="16" border="-5px" padding="-4px"
valign="bottom" /></a>',
+ '<!--0 Quick View --><a class="index_table" title="'+ +''+
view_tooltip +'"
href="index.php?module=customers&view=details&id={1}&action=view"> <img
src="images/common/view.png" height="16" border="-5px" padding="-4px"
valign="bottom" /></a>',
value,
record.id,
record.data.type_id,
record.data.forumid);
var editLink = String.format(
- '<!--1 Edit View --><a class="index_table"
href="index.php?module=customers&view=details&id={1}&action=edit"><img
src="images/common/edit.png" height="16" border="-5px" padding="-4px"
valign="bottom" /><!-- print --></a>',
+ '<!--1 Edit View --><a class="index_table" title="'+ +''+
edit_tooltip +'"
href="index.php?module=customers&view=details&id={1}&action=edit"><img
src="images/common/edit.png" height="16" border="-5px" padding="-4px"
valign="bottom" /><!-- print --></a>',
value,
record.id,
record.data.type_id,
Modified: trunk/modules/products/manage.php
==============================================================================
--- trunk/modules/products/manage.php (original)
+++ trunk/modules/products/manage.php Tue Jul 1 20:51:58 2008
@@ -3,11 +3,14 @@
//stop the direct browsing to this file - let index.php handle which
files get displayed
checkLogin();
-$products = getProducts();
+//$products = getProducts();
+ $sql = "SELECT count(*) as count FROM ".TB_PREFIX."products";
+ $sth = dbQuery($sql) or die(htmlspecialchars(end($dbh->errorInfo())));
+ $number_of_rows = $sth->fetch(PDO::FETCH_ASSOC);
$pageActive = "products";
$smarty->assign('pageActive', $pageActive);
-$smarty -> assign("products",$products);
+$smarty -> assign("number_of_rows",$number_of_rows);
?>
Modified: trunk/modules/products/xml.php
==============================================================================
--- trunk/modules/products/xml.php (original)
+++ trunk/modules/products/xml.php Tue Jul 1 20:51:58 2008
@@ -5,7 +5,7 @@
$start = (isset($_POST['start'])) ? $_POST['start'] : "0" ;
$dir = (isset($_POST['dir'])) ? $_POST['dir'] : "ASC" ;
-$sort = (isset($_POST['sort'])) ? $_POST['sort'] : "name" ;
+$sort = (isset($_POST['sort'])) ? $_POST['sort'] : "description" ;
$limit = (isset($_POST['limit'])) ? $_POST['limit'] : "25" ;
//SC: Safety checking values that will be directly subbed in
@@ -20,38 +20,24 @@
}
/*Check that the sort field is OK*/
-$validFields = array('CID', 'name', 'customer_total','owing','enabled');
+$validFields = array('id', 'description', 'unit_price','enabled');
if (in_array($sort, $validFields)) {
$sort = $sort;
} else {
- $sort = "CID";
+ $sort = "id";
}
//$sql = "SELECT * FROM ".TB_PREFIX."customers ORDER BY $sort $dir
LIMIT $start, $limit";
$sql = "SELECT
- c.id as CID,
- c.name as name,
- (SELECT (CASE WHEN c.enabled = 0 THEN 'Disabled' ELSE 'Enabled'
END )) AS enabled,
- (
- SELECT
- coalesce(sum(ii.total), 0) AS total
- FROM
- ".TB_PREFIX."invoice_items ii INNER JOIN
- ".TB_PREFIX."invoices iv ON (iv.id = ii.invoice_id)
- WHERE
- iv.customer_id = CID ) as customer_total,
- (
- SELECT
- coalesce(sum(ap.ac_amount), 0) AS amount
- FROM
- ".TB_PREFIX."account_payments ap INNER JOIN
- ".TB_PREFIX."invoices iv ON (iv.id = ap.ac_inv_id)
- WHERE
- iv.customer_id = CID) AS owing
-
+ id,
+ description,
+ unit_price,
+ (SELECT (CASE WHEN enabled = 0 THEN '".$LANG['disabled']."'
ELSE '".$LANG['enabled']."' END )) AS enabled
FROM
- ".TB_PREFIX."customers c
+ ".TB_PREFIX."products
+ WHERE
+ visible = 1
ORDER BY
$sort $dir
LIMIT
@@ -71,7 +57,7 @@
*/
global $dbh;
-$sqlTotal = "SELECT count(id) AS count FROM ".TB_PREFIX."customers";
+$sqlTotal = "SELECT count(id) AS count FROM ".TB_PREFIX."products
WHERE visible =1";
$tth = dbQuery($sqlTotal) or die(end($dbh->errorInfo()));
$resultCount = $tth->fetch();
$count = $resultCount[0];
Modified: trunk/templates/default/products/manage.tpl
==============================================================================
--- trunk/templates/default/products/manage.tpl (original)
+++ trunk/templates/default/products/manage.tpl Tue Jul 1 20:51:58 2008
@@ -16,37 +16,12 @@
* http://www.simpleinvoices.org
*/
*}
-{if $products == null }
+{if $number_of_rows == null }
<p><em>{$LANG.no_products}</em></p>
{else}
+ {include file='../modules/customers/manage.js.php' LANG=$LANG}
+
<h3>{$LANG.manage_products} :: <a href="index.php?module=products&view=add">{$LANG.add_new_product}</a></h3>
<hr />
-<table class="manage" id="live-grid" align="center">
- <colgroup>
- <col style='width:7%;' />
- <col style='width:10%;' />
- <col style='width:53%;' />
- <col style='width:20%;' />
- <col style='width:10%;' />
- </colgroup>
- <thead>
- <tr class="sortHeader">
- <th class="noFilter sortable">{$LANG.actions}</th>
- <th class="index_table sortable">{$LANG.product_id}</th>
- <th class="index_table sortable">{$LANG.product_description}</th>
- <th class="index_table sortable">{$LANG.product_unit_price}</th>
- <th class="noFilter index_table sortable">{$LANG.enabled}</th>
- </tr>
- </thead>
-{foreach from=$products item=product}
- <tr class="index_table">
- <td class="index_table"><a title="{$LANG.view}" class="index_table"
href="index.php?module=products&view=details&id={$product.id}&action=view"><img
src="images/common/view.png" height="16" border="0" align="absmiddle"/></a>
- <a title="{$LANG.edit}" class="index_table"
href="index.php?module=products&view=details&id={$product.id}&action=edit"><img
src="images/common/edit.png" height="16" border="0" align="absmiddle"
/></a> </td>
- <td class="index_table">{$product.id}</td>
- <td class="index_table">{$product.description}</td>
- <td class="index_table">{$product.unit_price}</td>
- <td class="index_table">{$product.enabled}</td>
- </tr>
-{/foreach}
-</table>
+<div id="manageGrid"></div>
{/if}