Commit b98e8e0c authored by Malcolm Blaney's avatar Malcolm Blaney

Big refactor of the Grid module and other modules that use it:

autoHeight is now used everywhere, so the Grid module no longer
sets the height or offers scrolling options. (The idea being that
the single scrollbar for the page is easier to use.) The Payment
module previously listed all data in the grid, so this now provides
it's own paging to reduce the grid height. The Grid module now also
includes SlickGrid's DataView, which is now heavily used by the
Stock module, which also received a large number of bug fixes and UI
improvements.
parent cee75a7a
Pipeline #17607487 passed with stage
in 1 minute and 6 seconds
......@@ -38,13 +38,7 @@ class Grid extends Base {
}
public function Content($id) {
return '<div class="view"></div>'.
'<div class="controller">'.
'<button class="top">top</button>'.
'<button class="previous">previous</button>'.
'<button class="bottom">bottom</button>'.
'<button class="next">next</button>'.
'</div>';
return '<div class="view"></div>';
}
public function Copy($id, $new_page, $old_owner, $old_id) {
......@@ -74,11 +68,6 @@ class Grid extends Base {
'"",".grid","border","1px solid #aaaaaa"',
'"",".grid","border-radius","2px"',
'"",".grid .view","width","100%"',
'"",".grid .view","height","400px"',
'"",".grid .controller","background-color","#eeeeee"',
'"",".grid .controller button","margin","5px"',
'"",".grid .controller button.bottom","float","right"',
'"",".grid .controller button.next","float","right"',
'"",".slick-header","height","24px"',
'"",".slick-cell.selected","background-color","#f0f0f0"',
'"",".slick-cell > input[type=text]","border","none"',
......
This diff is collapsed.
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -261,7 +261,13 @@ class Payment extends Base {
'</div>' .
'<div id="payment-details-info"></div>' .
'<button class="submit">submit</button>' .
'</form>';
'</form>' .
'<div class="paging hidden">' .
'Displaying transactions: <span class="start">1</span> - ' .
'<span class="end">50</span>' .
'<button class="previous">Previous</button>' .
'<button class="next">Next</button>' .
'</div>';
return $content;
}
......@@ -375,7 +381,12 @@ class Payment extends Base {
'"",".payment a:hover","color","#aaaaaa"',
'"",".payment .submit","float","right"',
'"",".payment .search","float","right"',
'"",".payment .search","margin-right","10px"'];
'"",".payment .search","margin-right","10px"',
'"",".payment .paging","margin-left","20px"',
'"",".payment .start","font-weight","bold"',
'"",".payment .end","font-weight","bold"',
'"",".payment .previous","margin-left","20px"',
'"",".payment .next","margin-left","20px"'];
$this->AddSiteStyle($site_style);
}
......@@ -864,11 +875,14 @@ class Payment extends Base {
private function AllData() {
$data = [];
$organiser = new Organiser($this->user, $this->owner);
$offset = isset($_POST['offset']) ? (int)$_POST['offset'] : 0;
if ($offset < 0) $offset = 0;
$mysqli = connect_db();
$query = 'SELECT payments.user, timestamp, reference, amount, comment ' .
'FROM payments LEFT JOIN users ON payments.user = users.user WHERE ' .
'active = 1 AND ' . $organiser->GroupQuery() . ' ORDER BY timestamp DESC';
'active = 1 AND ' . $organiser->GroupQuery() .
' ORDER BY timestamp DESC LIMIT ' . $offset . ', 50';
if ($result = $mysqli->query($query)) {
while ($payments = $result->fetch_assoc()) {
$amount = (float)$payments['amount'];
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -3,7 +3,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2016 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -27,8 +27,8 @@
if(!this.dobrado.invoice){dobrado.invoice={};}
(function(){'use strict';var users=[];var grid=null;var selectedUser="";var invoiceDate="";var listAllUsers=false;$(function(){if($(".invoice").length===0){return;}
$(".invoice .export-member-history").button({disabled:true}).click(exportMemberHistory);$(".invoice .export-data").button().click(exportData);$("#invoice-list-all").button().click(listAll);dobrado.log("Loading users...","info");$.post("/php/request.php",{request:"invoice",action:"list",url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"invoice list request")){return;}
users=JSON.parse(response);if($(".grid").length!==0){gridSetup();}});});function gridSetup(){var columns=[{id:"name",name:"Username",field:"name",width:120,sortable:true},{id:"purchases",name:"Purchases",field:"purchases",width:80,sortable:true,formatter:Slick.Formatters.Dollar}];if($('.dobrado-mobile').is(':hidden')){columns.push({id:"surcharge",name:"Surcharge",field:"surcharge",width:80,sortable:true,formatter:Slick.Formatters.Dollar});columns.push({id:"sold",name:"Sold",field:"sold",width:80,sortable:true,formatter:Slick.Formatters.Dollar});}
columns.push({id:"balance",name:"Balance",field:"balance",width:80,sortable:true,formatter:Slick.Formatters.Dollar});var options={enableColumnReorder:false,forceFitColumns:true};var id="#"+$(".grid").attr("id");grid=dobrado.grid.instance(id,users.grid,columns,options);grid.setSelectionModel(new Slick.RowSelectionModel());grid.onClick.subscribe(function(e,item){showUser(users.grid[item.row]);});grid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showUser(users.grid[item.rows[0]]);}});grid.onSort.subscribe(function(e,args){users.grid.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=="name"){value1=parseFloat(value1);value2=parseFloat(value2);}
users=JSON.parse(response);if($(".grid").length!==0){gridSetup();}});});function gridSetup(){var columns=[{id:'name',name:'Username',field:'name',width:120,sortable:true},{id:'purchases',name:'Purchases',field:'purchases',width:80,sortable:true,formatter:Slick.Formatters.Dollar}];if($('.dobrado-mobile').is(':hidden')){columns.push({id:'surcharge',name:'Surcharge',field:'surcharge',width:80,sortable:true,formatter:Slick.Formatters.Dollar});columns.push({id:'sold',name:'Sold',field:'sold',width:80,sortable:true,formatter:Slick.Formatters.Dollar});}
columns.push({id:'balance',name:'Balance',field:'balance',width:80,sortable:true,formatter:Slick.Formatters.Dollar});var options={autoHeight:true,forceFitColumns:true};var id='#'+$('.grid').attr('id');grid=dobrado.grid.instance(id,users.grid,columns,options);grid.setSelectionModel(new Slick.RowSelectionModel());grid.onClick.subscribe(function(e,item){showUser(users.grid[item.row]);});grid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showUser(users.grid[item.rows[0]]);}});grid.onSort.subscribe(function(e,args){users.grid.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=='name'){value1=parseFloat(value1);value2=parseFloat(value2);}
if(value1===value2){return 0;}
if(value1>value2){return sign;}
else{return sign* -1;}});grid.invalidate();});}
......@@ -55,4 +55,4 @@ var data=JSON.parse(response);if(data.filename){location.href="/php/private.php?
function listAll(){var action="list";if(listAllUsers){listAllUsers=false;$("#invoice-list-all").button("option","label","list all");dobrado.log("Listing active accounts...","info");}
else{listAllUsers=true;$("#invoice-list-all").button("option","label","list active");dobrado.log("Listing all accounts...","info");action="listAll";}
$.post("/php/request.php",{request:"invoice",action:action,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"invoice listAll")){return;}
users=JSON.parse(response);if(grid){grid.setData(users.grid);grid.updateRowCount();grid.render();grid.setSelectedRows([]);}});}})();
\ No newline at end of file
users=JSON.parse(response);if(grid){grid.setData(users.grid);grid.updateRowCount();grid.render();grid.setSelectedRows([]);}});}}());
\ No newline at end of file
......@@ -2,7 +2,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2016 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -70,25 +70,22 @@ if (!this.dobrado.invoice) {
});
function gridSetup() {
var columns = [{ id : "name", name: "Username", field: "name", width: 120,
var columns = [{ id : 'name', name: 'Username', field: 'name', width: 120,
sortable: true },
{ id : "purchases", name: "Purchases", field: "purchases",
{ id : 'purchases', name: 'Purchases', field: 'purchases',
width: 80, sortable: true,
formatter: Slick.Formatters.Dollar }];
if ($('.dobrado-mobile').is(':hidden')) {
columns.push({ id : "surcharge", name: "Surcharge", field: "surcharge",
columns.push({ id : 'surcharge', name: 'Surcharge', field: 'surcharge',
width: 80, sortable: true,
formatter: Slick.Formatters.Dollar });
columns.push({ id : "sold", name: "Sold", field: "sold", width: 80,
columns.push({ id : 'sold', name: 'Sold', field: 'sold', width: 80,
sortable: true, formatter: Slick.Formatters.Dollar });
}
columns.push({ id : "balance", name: "Balance", field: "balance", width: 80,
columns.push({ id : 'balance', name: 'Balance', field: 'balance', width: 80,
sortable: true, formatter: Slick.Formatters.Dollar });
var options = {
enableColumnReorder: false,
forceFitColumns: true
};
var id = "#" + $(".grid").attr("id");
var options = { autoHeight: true, forceFitColumns: true };
var id = '#' + $('.grid').attr('id');
grid = dobrado.grid.instance(id, users.grid, columns, options);
grid.setSelectionModel(new Slick.RowSelectionModel());
grid.onClick.subscribe(function(e, item) {
......@@ -105,7 +102,7 @@ if (!this.dobrado.invoice) {
var sign = args.sortAsc ? 1 : -1;
var value1 = row1[field];
var value2 = row2[field];
if (field !== "name") {
if (field !== 'name') {
value1 = parseFloat(value1);
value2 = parseFloat(value2);
}
......@@ -302,4 +299,4 @@ if (!this.dobrado.invoice) {
});
}
})();
}());
......@@ -3,7 +3,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -29,16 +29,16 @@ if(!this.dobrado.manager){dobrado.manager={};}
$('#manager-group-select').change(changeGroup);$('.manager-view-all-dialog').dialog({show:true,autoOpen:false,modal:true,width:830,height:520,position:{my:'top',at:'top+50',of:window},title:'Available Products',create:dobrado.fixedDialog,close:function(){if(allProductsGrid){allProductsGrid.gotoCell(0,0);}}});$('.manager .view-all').button().click(viewAll);$('#manager-form .default-action').click(submit);$('#manager-form .submit').button().click(submit);$('#manager-form .search').button().click(search);$('#manager-form .back').button().click(showPreviousImport);$('#manager-form .remove').button().click(remove);$('#manager-form .import-toggle').click(toggleImport);$('#manager-import-file').change(loadImportData);$('#manager-username-input').val('').change(function(){setTimeout(function(){showUser();},10);});$('#manager-username-input').keypress(checkUsernameEnter);$('#manager-product-input').val('').change(function(){setTimeout(function(){showProductFromMenu();},10);});$('#manager-supplier-input').val('').change(function(){setTimeout(function(){showSupplierFromMenu();},10);});$('#manager-price-input').val('');$('#manager-date-input').val('').change(clearSearchDates).datepicker({dateFormat:dobrado.dateFormat});$('#manager-start-date-input').val('').change(clearDate).datepicker({dateFormat:dobrado.dateFormat});$('#manager-end-date-input').val('').change(clearDate).datepicker({dateFormat:dobrado.dateFormat});$('#manager-quantity-input').val('');$('#manager-quantity-input').spinner({min:0,spin:setQuantity,change:setQuantity});$('.manager .toggle-search-options').click(function(){clearSearchDates();clearDate();$('.manager .search-options').toggle();});if($('.grid').length!==0){gridSetup();}
dobrado.log('Loading users...','info');$.post('/php/request.php',{request:'manager',action:'list',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'manager list')){return;}
manager=JSON.parse(response);if(manager.date){$('#manager-date-input').datepicker('setDate',dobrado.formatDate(manager.date));}
$('#manager-username-input').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:manager.users,select:showUser});updateProducts();});});function gridSetup(){$(".grid").each(function(index){if(index===0){managerGridId="#"+$(this).attr("id");}
if(index===1){allProductsGridId="#"+$(this).attr("id");}});var columns=[{id:"date",name:"Date",field:"date",width:110,sortable:true,formatter:Slick.Formatters.Timestamp},{id:"user",name:"Username",field:"user",width:110,sortable:true},{id:"name",name:"Product",field:"name",width:190,sortable:true},{id:"supplier",name:"Supplier",field:"supplier",width:110,sortable:true}];if($('.dobrado-mobile').is(':hidden')){columns.push({id:"quantity",name:"Qty",field:"quantity",width:60,sortable:true});columns.push({id:"price",name:"Price",field:"price",width:80,sortable:true,formatter:Slick.Formatters.Dollar});columns.push({id:"total",name:"Total",field:"total",width:80,sortable:true,formatter:Slick.Formatters.Dollar});}
var options={enableColumnReorder:false,forceFitColumns:true};managerGrid=dobrado.grid.instance(managerGridId,[],columns,options);managerGrid.setSelectionModel(new Slick.RowSelectionModel());managerGrid.onClick.subscribe(function(e,item){showPurchase(item.row);});managerGrid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showPurchase(item.rows[0]);}});managerGrid.onSort.subscribe(function(e,args){purchase.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field==="quantity"||field==="price"||field==="total"){value1=parseFloat(value1);value2=parseFloat(value2);}
$('#manager-username-input').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:manager.users,select:showUser});updateProducts();});});function gridSetup(){$('.grid').each(function(index){if(index===0){managerGridId='#'+$(this).attr('id');}
if(index===1){allProductsGridId='#'+$(this).attr('id');}});var columns=[{id:'date',name:'Date',field:'date',width:110,sortable:true,formatter:Slick.Formatters.Timestamp},{id:'user',name:'Username',field:'user',width:110,sortable:true},{id:'name',name:'Product',field:'name',width:190,sortable:true},{id:'supplier',name:'Supplier',field:'supplier',width:110,sortable:true}];if($('.dobrado-mobile').is(':hidden')){columns.push({id:'quantity',name:'Qty',field:'quantity',width:60,sortable:true});columns.push({id:'price',name:'Price',field:'price',width:80,sortable:true,formatter:Slick.Formatters.Dollar});columns.push({id:'total',name:'Total',field:'total',width:80,sortable:true,formatter:Slick.Formatters.Dollar});}
var options={autoHeight:true,forceFitColumns:true};managerGrid=dobrado.grid.instance(managerGridId,[],columns,options);managerGrid.setSelectionModel(new Slick.RowSelectionModel());managerGrid.onClick.subscribe(function(e,item){showPurchase(item.row);});managerGrid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showPurchase(item.rows[0]);}});managerGrid.onSort.subscribe(function(e,args){purchase.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field==='quantity'||field==='price'||field==='total'){value1=parseFloat(value1);value2=parseFloat(value2);}
if(value1===value2){return 0;}
if(value1>value2){return sign;}
else{return sign* -1;}});managerGrid.invalidate();});if($(".grid").length>=2){var allProductsColumns=[{id:"product",name:"Product",field:"name",width:210,sortable:true},{id:"supplier",name:"Supplier",field:"supplier",width:140,sortable:true},{id:"date",name:"Date",field:"date",width:110,sortable:true,formatter:Slick.Formatters.Timestamp},{id:"quantity",name:"Quantity",field:"quantity",width:100,sortable:true,editor:Slick.Editors.Float},{id:"price",name:"Price",field:"price",width:100,sortable:true,formatter:Slick.Formatters.Units},{id:"total",name:"Total",field:"total",width:80,sortable:true,formatter:Slick.Formatters.Dollar}];var allProductsOptions={editable:true,enableColumnReorder:false,forceFitColumns:true};allProductsGrid=dobrado.grid.instance(allProductsGridId,[],allProductsColumns,allProductsOptions);allProductsGrid.setSelectionModel(new Slick.RowSelectionModel());allProductsGrid.onCellChange.subscribe(updatePurchase);allProductsGrid.onSort.subscribe(function(e,args){allProductsData.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=="name"&&field!=="supplier"){value1=parseFloat(value1);value2=parseFloat(value2);}
else{return sign* -1;}});managerGrid.invalidate();});if($('.grid').length>=2){var allProductsColumns=[{id:'product',name:'Product',field:'name',width:210,sortable:true},{id:'supplier',name:'Supplier',field:'supplier',width:140,sortable:true},{id:'date',name:'Date',field:'date',width:110,sortable:true,formatter:Slick.Formatters.Timestamp},{id:'quantity',name:'Quantity',field:'quantity',width:100,sortable:true,editor:Slick.Editors.Float},{id:'price',name:'Price',field:'price',width:100,sortable:true,formatter:Slick.Formatters.Units},{id:'total',name:'Total',field:'total',width:80,sortable:true,formatter:Slick.Formatters.Dollar}];var allProductsOptions={autoHeight:true,editable:true,forceFitColumns:true};allProductsGrid=dobrado.grid.instance(allProductsGridId,[],allProductsColumns,allProductsOptions);allProductsGrid.setSelectionModel(new Slick.RowSelectionModel());allProductsGrid.onCellChange.subscribe(updatePurchase);allProductsGrid.onSort.subscribe(function(e,args){allProductsData.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=='name'&&field!=='supplier'){value1=parseFloat(value1);value2=parseFloat(value2);}
if(value1===value2){return 0;}
if(value1>value2){return sign;}
else{return sign* -1;}});allProductsGrid.invalidate();});}
$(allProductsGridId).appendTo($(".manager-view-all-dialog"));$('.grid').hide();}
$(allProductsGridId).appendTo($('.manager-view-all-dialog'));$('.grid').hide();}
function checkUsernameEnter(event){if(event.keyCode!==13){return;}
event.preventDefault();showUser();}
function changeGroup(){dobrado.log("Changing group.","info");$.post("/php/request.php",{request:"manager",action:"changeGroup",group:$("#manager-group-select").val(),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"manager changeGroup")){return;}
......
......@@ -2,7 +2,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -150,35 +150,32 @@ if (!this.dobrado.manager) {
function gridSetup() {
// Get the id's for all the grid modules on the page.
$(".grid").each(function(index) {
$('.grid').each(function(index) {
if (index === 0) {
managerGridId = "#" + $(this).attr("id");
managerGridId = '#' + $(this).attr('id');
}
if (index === 1) {
allProductsGridId = "#" + $(this).attr("id");
allProductsGridId = '#' + $(this).attr('id');
}
});
var columns =
[{ id : "date", name: "Date", field: "date", width: 110,
[{ id : 'date', name: 'Date', field: 'date', width: 110,
sortable: true, formatter: Slick.Formatters.Timestamp },
{ id : "user", name: "Username", field: "user", width: 110,
{ id : 'user', name: 'Username', field: 'user', width: 110,
sortable: true },
{ id : "name", name: "Product", field: "name", width: 190,
{ id : 'name', name: 'Product', field: 'name', width: 190,
sortable: true },
{ id : "supplier", name: "Supplier", field: "supplier", width: 110,
{ id : 'supplier', name: 'Supplier', field: 'supplier', width: 110,
sortable: true }];
if ($('.dobrado-mobile').is(':hidden')) {
columns.push({ id : "quantity", name: "Qty", field: "quantity",
columns.push({ id : 'quantity', name: 'Qty', field: 'quantity',
width: 60, sortable: true });
columns.push({ id : "price", name: "Price", field: "price", width: 80,
columns.push({ id : 'price', name: 'Price', field: 'price', width: 80,
sortable: true, formatter: Slick.Formatters.Dollar });
columns.push({ id : "total", name: "Total", field: "total", width: 80,
columns.push({ id : 'total', name: 'Total', field: 'total', width: 80,
sortable: true, formatter: Slick.Formatters.Dollar });
}
var options = {
enableColumnReorder: false,
forceFitColumns: true
};
var options = { autoHeight: true, forceFitColumns: true };
// Create a grid instance with empty rows, which will be populated
// when a search is performed.
managerGrid = dobrado.grid.instance(managerGridId, [], columns, options);
......@@ -197,7 +194,7 @@ if (!this.dobrado.manager) {
var sign = args.sortAsc ? 1 : -1;
var value1 = row1[field];
var value2 = row2[field];
if (field === "quantity" || field === "price" || field === "total") {
if (field === 'quantity' || field === 'price' || field === 'total') {
value1 = parseFloat(value1);
value2 = parseFloat(value2);
}
......@@ -215,25 +212,22 @@ if (!this.dobrado.manager) {
});
// If a second grid module is on the page initialise columns to view
// all products.
if ($(".grid").length >= 2) {
if ($('.grid').length >= 2) {
var allProductsColumns =
[{ id : "product", name: "Product", field: "name", width: 210,
[{ id : 'product', name: 'Product', field: 'name', width: 210,
sortable: true },
{ id : "supplier", name: "Supplier", field: "supplier", width: 140,
{ id : 'supplier', name: 'Supplier', field: 'supplier', width: 140,
sortable: true },
{ id : "date", name: "Date", field: "date", width: 110,
{ id : 'date', name: 'Date', field: 'date', width: 110,
sortable: true, formatter: Slick.Formatters.Timestamp },
{ id : "quantity", name: "Quantity", field: "quantity", width: 100,
{ id : 'quantity', name: 'Quantity', field: 'quantity', width: 100,
sortable: true, editor: Slick.Editors.Float },
{ id : "price", name: "Price", field: "price", width: 100,
{ id : 'price', name: 'Price', field: 'price', width: 100,
sortable: true, formatter: Slick.Formatters.Units },
{ id : "total", name: "Total", field: "total", width: 80,
{ id : 'total', name: 'Total', field: 'total', width: 80,
sortable: true, formatter: Slick.Formatters.Dollar }];
var allProductsOptions = {
editable: true,
enableColumnReorder: false,
forceFitColumns: true
};
var allProductsOptions = { autoHeight: true, editable: true,
forceFitColumns: true };
allProductsGrid = dobrado.grid.instance(allProductsGridId, [],
allProductsColumns,
allProductsOptions);
......@@ -245,7 +239,7 @@ if (!this.dobrado.manager) {
var sign = args.sortAsc ? 1 : -1;
var value1 = row1[field];
var value2 = row2[field];
if (field !== "name" && field !== "supplier") {
if (field !== 'name' && field !== 'supplier') {
value1 = parseFloat(value1);
value2 = parseFloat(value2);
}
......@@ -263,7 +257,7 @@ if (!this.dobrado.manager) {
});
}
// Want the grid module to be part of the dialog, so move it.
$(allProductsGridId).appendTo($(".manager-view-all-dialog"));
$(allProductsGridId).appendTo($('.manager-view-all-dialog'));
// Hide grid modules after column widths have been computed.
$('.grid').hide();
}
......
......@@ -3,7 +3,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -35,7 +35,7 @@ if(localStorage.membersSortColumns){sort=localStorage.membersSortColumns;}}
else{alert('Could not find selected columns.');return;}
dobrado.log('Downloading account data...','info');$.post('/php/request.php',{request:'members',action:'download',columns:columns,sort:sort,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'members download')){return;}
var result=JSON.parse(response);if(result.filename){location.href="/php/private.php?file="+result.filename;}});}
function gridSetup(){var id='#'+$('.grid').attr('id');var columns=[];var columnIds=[];var options={editable:members.canEdit,enableColumnReorder:false,forceFitColumns:true,multiColumnSort:true};allColumns=[{id:'username',name:'Username',field:'username',width:100,sortable:true},{id:'first',name:'First Name',field:'first',width:150,sortable:true,editor:Slick.Editors.Text},{id:'last',name:'Last Name',field:'last',width:150,sortable:true,editor:Slick.Editors.Text},{id:'email',name:'Email',field:'email',width:100,sortable:true,editor:Slick.Editors.Text},{id:'phone',name:'Phone Number',field:'phone',width:100,sortable:true,editor:Slick.Editors.Text},{id:'address',name:'Address',field:'address',width:200,sortable:true,editor:Slick.Editors.LongText},{id:'description',name:members.descriptionLabel,field:'description',width:200,sortable:true,editor:Slick.Editors.LongText},{id:'delivery',name:'Delivery Group',field:'delivery',width:100,sortable:true,editor:Slick.Editors.Text},{id:'notes',name:'Notes',field:'notes',width:200,sortable:true,editor:Slick.Editors.LongText},{id:'supplier',name:'External Supplier',field:'supplier',width:100,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'membership',name:'Membership Due',field:'membership',width:100,sortable:true,formatter:Slick.Formatters.Timestamp,editor:Slick.Editors.Date},{id:'repeat',name:'Membership Repeats',field:'repeat',width:100,sortable:true,editor:Slick.Editors.MembershipEditor},{id:'balance',name:'Balance',field:'balance',width:80,sortable:true,formatter:Slick.Formatters.Dollar},{id:'date',name:'Last Attendance',field:'date',width:80,sortable:true,formatter:Slick.Formatters.Timestamp},{id:'deposit',name:'Paid Deposit',field:'deposit',width:50,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'buyer',name:'Buyer Rates',field:'buyer',width:50,sortable:true,editor:Slick.Editors.BuyerEditor},{id:'active',name:'Active',field:'active',width:40,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'reference',name:'Account Reference',field:'reference',width:100,sortable:true,editor:Slick.Editors.Text},{id:'accountName',name:'Account Name',field:'accountName',width:100,sortable:true,editor:Slick.Editors.Text},{id:'accountNumber',name:'Account Number',field:'accountNumber',width:100,sortable:true,editor:Slick.Editors.Text},{id:'bsb',name:'Account BSB',field:'bsb',width:100,sortable:true,editor:Slick.Editors.Text},{id:'credit',name:'Receive Credit',field:'credit',width:80,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox}];if(dobrado.localStorage){if(localStorage.membersColumns){columnIds=JSON.parse(localStorage.membersColumns);if($.inArray('supplier',columnIds)!==-1){supplierColumn=true;}
function gridSetup(){var id='#'+$('.grid').attr('id');var columns=[];var columnIds=[];var options={autoHeight:true,editable:members.canEdit,forceFitColumns:true,multiColumnSort:true};allColumns=[{id:'username',name:'Username',field:'username',width:100,sortable:true},{id:'first',name:'First Name',field:'first',width:150,sortable:true,editor:Slick.Editors.Text},{id:'last',name:'Last Name',field:'last',width:150,sortable:true,editor:Slick.Editors.Text},{id:'email',name:'Email',field:'email',width:100,sortable:true,editor:Slick.Editors.Text},{id:'phone',name:'Phone Number',field:'phone',width:100,sortable:true,editor:Slick.Editors.Text},{id:'address',name:'Address',field:'address',width:200,sortable:true,editor:Slick.Editors.LongText},{id:'description',name:members.descriptionLabel,field:'description',width:200,sortable:true,editor:Slick.Editors.LongText},{id:'delivery',name:'Delivery Group',field:'delivery',width:100,sortable:true,editor:Slick.Editors.Text},{id:'notes',name:'Notes',field:'notes',width:200,sortable:true,editor:Slick.Editors.LongText},{id:'supplier',name:'External Supplier',field:'supplier',width:100,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'membership',name:'Membership Due',field:'membership',width:100,sortable:true,formatter:Slick.Formatters.Timestamp,editor:Slick.Editors.Date},{id:'repeat',name:'Membership Repeats',field:'repeat',width:100,sortable:true,editor:Slick.Editors.MembershipEditor},{id:'balance',name:'Balance',field:'balance',width:80,sortable:true,formatter:Slick.Formatters.Dollar},{id:'date',name:'Last Attendance',field:'date',width:80,sortable:true,formatter:Slick.Formatters.Timestamp},{id:'deposit',name:'Paid Deposit',field:'deposit',width:50,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'buyer',name:'Buyer Rates',field:'buyer',width:50,sortable:true,editor:Slick.Editors.BuyerEditor},{id:'active',name:'Active',field:'active',width:40,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'reference',name:'Account Reference',field:'reference',width:100,sortable:true,editor:Slick.Editors.Text},{id:'accountName',name:'Account Name',field:'accountName',width:100,sortable:true,editor:Slick.Editors.Text},{id:'accountNumber',name:'Account Number',field:'accountNumber',width:100,sortable:true,editor:Slick.Editors.Text},{id:'bsb',name:'Account BSB',field:'bsb',width:100,sortable:true,editor:Slick.Editors.Text},{id:'credit',name:'Receive Credit',field:'credit',width:80,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox}];if(dobrado.localStorage){if(localStorage.membersColumns){columnIds=JSON.parse(localStorage.membersColumns);if($.inArray('supplier',columnIds)!==-1){supplierColumn=true;}
if($.inArray('active',columnIds)!==-1){activeColumn=true;}}
else{columnIds=['username','first','last','email','phone'];localStorage.membersColumns=JSON.stringify(columnIds);}
$.each(columnIds,function(i,id){$('#members-column-'+id).prop('checked',true);$('#members-column-'+id).checkboxradio('refresh');$.each(allColumns,function(i,item){if(item.id===id){columns.push(item);return false;}});});}
......
......@@ -2,7 +2,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -134,7 +134,7 @@ if (!this.dobrado.members) {
var columns = [];
var columnIds = [];
// Set editable based on permission given from the server.
var options = { editable: members.canEdit, enableColumnReorder: false,
var options = { autoHeight: true, editable: members.canEdit,
forceFitColumns: true, multiColumnSort: true };
allColumns = [{ id: 'username', name: 'Username', field: 'username',
width: 100, sortable: true },
......
This diff is collapsed.
This diff is collapsed.
......@@ -50,22 +50,22 @@ purchase=JSON.parse(response);tomorrow=purchase.date+oneDay;var source=[];$.each
if(dobrado.localStorage){localStorage.purchase=JSON.stringify(purchase);}
if(purchase.unavailable){$('.purchase-unavailable').html(purchase.unavailableText).dialog({classes:{'ui-dialog':'no-close'},show:true,modal:true,closeOnEscape:false,width:400,position:{my:'top',at:'top+50',of:window},title:'Ordering Unavailable',create:dobrado.fixedDialog});}
else{$('.purchase-date-info').html(purchase.dateInfo);if(purchase.countdown){setInterval(dateInfo,60000);}}});}
function gridSetup(){$(".grid").each(function(index){if(index===0){purchaseGridId="#"+$(this).attr("id");}
if(index===1){allAvailableGridId="#"+$(this).attr("id");}
if(index===2){allUserGridId="#"+$(this).attr("id");}});var supplier="supplier";if(purchase&&purchase.showGrower===true){supplier="grower";}
var mobile=$('.dobrado-mobile').is(':visible');var purchaseColumns=[{id:"product",name:"Product",field:"name",width:300,sortable:true}];if(!mobile){purchaseColumns.push({id:"supplier",name:"Supplier",field:supplier,width:200,sortable:true});}
purchaseColumns.push({id:"quantity",name:"Qty",field:"quantity",width:60,sortable:true,editor:Slick.Editors.Float});purchaseColumns.push({id:"price",name:"Price",field:"price",width:120,sortable:true,formatter:Slick.Formatters.Units});if(!mobile){purchaseColumns.push({id:"total",name:"Total",field:"total",width:120,sortable:true,formatter:Slick.Formatters.Dollar});}
var purchaseOptions={editable:true,enableColumnReorder:false,forceFitColumns:true};purchaseGrid=dobrado.grid.instance(purchaseGridId,[],purchaseColumns,purchaseOptions);purchaseGrid.setSelectionModel(new Slick.RowSelectionModel());purchaseGrid.onClick.subscribe(function(e,item){showPurchase(item.row);});purchaseGrid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showPurchase(item.rows[0]);}});purchaseGrid.onCellChange.subscribe(updateAvailablePurchaseData);purchaseGrid.onBeforeEditCell.subscribe(updateOldQuantity);purchaseGrid.onSort.subscribe(function(e,args){var user=$("#purchase-name-input").val();if(user===''||!purchase.data||!purchase.data[user]){return;}
purchase.data[user].sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=="name"&&field!==supplier){value1=parseFloat(value1);value2=parseFloat(value2);}
function gridSetup(){$('.grid').each(function(index){if(index===0){purchaseGridId='#'+$(this).attr('id');}
if(index===1){allAvailableGridId='#'+$(this).attr('id');}
if(index===2){allUserGridId='#'+$(this).attr('id');}});var supplier='supplier';if(purchase&&purchase.showGrower===true){supplier='grower';}
var mobile=$('.dobrado-mobile').is(':visible');var purchaseColumns=[{id:'product',name:'Product',field:'name',width:300,sortable:true}];if(!mobile){purchaseColumns.push({id:'supplier',name:'Supplier',field:supplier,width:200,sortable:true});}
purchaseColumns.push({id:'quantity',name:'Qty',field:'quantity',width:60,sortable:true,editor:Slick.Editors.Float});purchaseColumns.push({id:'price',name:'Price',field:'price',width:120,sortable:true,formatter:Slick.Formatters.Units});if(!mobile){purchaseColumns.push({id:'total',name:'Total',field:'total',width:120,sortable:true,formatter:Slick.Formatters.Dollar});}
var purchaseOptions={autoHeight:true,editable:true,forceFitColumns:true};purchaseGrid=dobrado.grid.instance(purchaseGridId,[],purchaseColumns,purchaseOptions);purchaseGrid.setSelectionModel(new Slick.RowSelectionModel());purchaseGrid.onClick.subscribe(function(e,item){showPurchase(item.row);});purchaseGrid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showPurchase(item.rows[0]);}});purchaseGrid.onCellChange.subscribe(updateAvailablePurchaseData);purchaseGrid.onBeforeEditCell.subscribe(updateOldQuantity);purchaseGrid.onSort.subscribe(function(e,args){var user=$('#purchase-name-input').val();if(user===''||!purchase.data||!purchase.data[user]){return;}
purchase.data[user].sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=='name'&&field!==supplier){value1=parseFloat(value1);value2=parseFloat(value2);}
if(value1===value2){return 0;}
if(value1>value2){return sign;}
else{return sign* -1;}});purchaseGrid.invalidate();});if($(".grid").length>=2){var allAvailableColumns=[{id:"product",name:"Product",field:"name",width:300,sortable:true}];if(!mobile){allAvailableColumns.push({id:"supplier",name:"Supplier",field:supplier,width:200,sortable:true});}
allAvailableColumns.push({id:"quantity",name:"Qty",field:"quantity",width:60,sortable:true,editor:Slick.Editors.Float});allAvailableColumns.push({id:"price",name:"Price",field:"price",width:120,sortable:true,formatter:Slick.Formatters.Units});if(!mobile){allAvailableColumns.push({id:"total",name:"Total",field:"total",width:120,sortable:true,formatter:Slick.Formatters.Dollar});}
var allAvailableOptions={editable:true,enableColumnReorder:false,forceFitColumns:true};allAvailableGrid=dobrado.grid.instance(allAvailableGridId,[],allAvailableColumns,allAvailableOptions);allAvailableGrid.setSelectionModel(new Slick.RowSelectionModel());allAvailableGrid.onClick.subscribe(function(e,item){showAllAvailablePurchase(item.row);});allAvailableGrid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showAllAvailablePurchase(item.rows[0]);}});allAvailableGrid.onCellChange.subscribe(updateAvailablePurchaseData);allAvailableGrid.onBeforeEditCell.subscribe(updateOldQuantity);allAvailableGrid.onSort.subscribe(function(e,args){allAvailableData.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=="name"&&field!==supplier){value1=parseFloat(value1);value2=parseFloat(value2);}
else{return sign* -1;}});purchaseGrid.invalidate();});if($('.grid').length>=2){var allAvailableColumns=[{id:'product',name:'Product',field:'name',width:300,sortable:true}];if(!mobile){allAvailableColumns.push({id:'supplier',name:'Supplier',field:supplier,width:200,sortable:true});}
allAvailableColumns.push({id:'quantity',name:'Qty',field:'quantity',width:60,sortable:true,editor:Slick.Editors.Float});allAvailableColumns.push({id:'price',name:'Price',field:'price',width:120,sortable:true,formatter:Slick.Formatters.Units});if(!mobile){allAvailableColumns.push({id:'total',name:'Total',field:'total',width:120,sortable:true,formatter:Slick.Formatters.Dollar});}
var allAvailableOptions={autoHeight:true,editable:true,forceFitColumns:true};allAvailableGrid=dobrado.grid.instance(allAvailableGridId,[],allAvailableColumns,allAvailableOptions);allAvailableGrid.setSelectionModel(new Slick.RowSelectionModel());allAvailableGrid.onClick.subscribe(function(e,item){showAllAvailablePurchase(item.row);});allAvailableGrid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showAllAvailablePurchase(item.rows[0]);}});allAvailableGrid.onCellChange.subscribe(updateAvailablePurchaseData);allAvailableGrid.onBeforeEditCell.subscribe(updateOldQuantity);allAvailableGrid.onSort.subscribe(function(e,args){allAvailableData.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=='name'&&field!==supplier){value1=parseFloat(value1);value2=parseFloat(value2);}
if(value1===value2){return 0;}
if(value1>value2){return sign;}
else{return sign* -1;}});allAvailableGrid.invalidate();});}
if($(".grid").length===3){var allUserColumns=[{id:"user",name:"Username",field:"user",width:400,sortable:true},{id:"quantity",name:"Qty",field:"quantity",width:60,sortable:true,editor:Slick.Editors.Float},{id:"price",name:"Price",field:"price",width:120,sortable:true,formatter:Slick.Formatters.Units},{id:"total",name:"Total",field:"total",width:120,sortable:true,formatter:Slick.Formatters.Dollar}];var allUserOptions={editable:true,enableColumnReorder:false,forceFitColumns:true};allUserGrid=dobrado.grid.instance(allUserGridId,[],allUserColumns,allUserOptions);allUserGrid.setSelectionModel(new Slick.RowSelectionModel());allUserGrid.onCellChange.subscribe(updateUserPurchaseData);allUserGrid.onBeforeEditCell.subscribe(updateOldQuantity);allUserGrid.onSort.subscribe(function(e,args){allUserData.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=="user"){value1=parseFloat(value1);value2=parseFloat(value2);}
if($('.grid').length===3){var allUserColumns=[{id:'user',name:'Username',field:'user',width:400,sortable:true},{id:'quantity',name:'Qty',field:'quantity',width:60,sortable:true,editor:Slick.Editors.Float},{id:'price',name:'Price',field:'price',width:120,sortable:true,formatter:Slick.Formatters.Units},{id:'total',name:'Total',field:'total',width:120,sortable:true,formatter:Slick.Formatters.Dollar}];var allUserOptions={autoHeight:true,editable:true,forceFitColumns:true};allUserGrid=dobrado.grid.instance(allUserGridId,[],allUserColumns,allUserOptions);allUserGrid.setSelectionModel(new Slick.RowSelectionModel());allUserGrid.onCellChange.subscribe(updateUserPurchaseData);allUserGrid.onBeforeEditCell.subscribe(updateOldQuantity);allUserGrid.onSort.subscribe(function(e,args){allUserData.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field!=='user'){value1=parseFloat(value1);value2=parseFloat(value2);}
if(value1===value2){return 0;}
if(value1>value2){return sign;}
else{return sign* -1;}});allUserGrid.invalidate();});}
......
......@@ -345,46 +345,43 @@ if (!this.dobrado.purchase) {
function gridSetup() {
// Get the id's for all the grid modules on the page.
$(".grid").each(function(index) {
$('.grid').each(function(index) {
if (index === 0) {
purchaseGridId = "#" + $(this).attr("id");
purchaseGridId = '#' + $(this).attr('id');
}
if (index === 1) {
allAvailableGridId = "#" + $(this).attr("id");
allAvailableGridId = '#' + $(this).attr('id');
}
if (index === 2) {
allUserGridId = "#" + $(this).attr("id");
allUserGridId = '#' + $(this).attr('id');
}
});
// Configure grids to show either the supplier name or grower info in the
// supplier column.
var supplier = "supplier";
var supplier = 'supplier';
if (purchase && purchase.showGrower === true) {
supplier = "grower";
supplier = 'grower';
}
var mobile = $('.dobrado-mobile').is(':visible');
var purchaseColumns = [{ id : "product", name: "Product", field: "name",
var purchaseColumns = [{ id : 'product', name: 'Product', field: 'name',
width: 300, sortable: true }];
if (!mobile) {
purchaseColumns.push({ id : "supplier", name: "Supplier", field: supplier,
purchaseColumns.push({ id : 'supplier', name: 'Supplier', field: supplier,
width: 200, sortable: true });
}
purchaseColumns.push({ id : "quantity", name: "Qty", field: "quantity",
purchaseColumns.push({ id : 'quantity', name: 'Qty', field: 'quantity',
width: 60, sortable: true,
editor: Slick.Editors.Float });
purchaseColumns.push({ id : "price", name: "Price", field: "price",
purchaseColumns.push({ id : 'price', name: 'Price', field: 'price',
width: 120, sortable: true,
formatter: Slick.Formatters.Units });
if (!mobile) {
purchaseColumns.push({ id : "total", name: "Total", field: "total",
purchaseColumns.push({ id : 'total', name: 'Total', field: 'total',
width: 120, sortable: true,
formatter: Slick.Formatters.Dollar });
}
var purchaseOptions = {
editable: true,
enableColumnReorder: false,
forceFitColumns: true
};
var purchaseOptions = { autoHeight: true, editable: true,
forceFitColumns: true };
// Create a grid instance with empty rows, which will be populated
// when a user is selected to assign purchases to.
purchaseGrid = dobrado.grid.instance(purchaseGridId, [], purchaseColumns,
......@@ -401,7 +398,7 @@ if (!this.dobrado.purchase) {
purchaseGrid.onCellChange.subscribe(updateAvailablePurchaseData);
purchaseGrid.onBeforeEditCell.subscribe(updateOldQuantity);
purchaseGrid.onSort.subscribe(function (e, args) {
var user = $("#purchase-name-input").val();
var user = $('#purchase-name-input').val();
if (user === '' || !purchase.data || !purchase.data[user]) {
return;
}
......@@ -411,7 +408,7 @@ if (!this.dobrado.purchase) {
var sign = args.sortAsc ? 1 : -1;
var value1 = row1[field];
var value2 = row2[field];
if (field !== "name" && field !== supplier) {
if (field !== 'name' && field !== supplier) {
value1 = parseFloat(value1);
value2 = parseFloat(value2);
}
......@@ -430,30 +427,27 @@ if (!this.dobrado.purchase) {
// If a second grid module is on the page initialise columns to view
// all available products.
if ($(".grid").length >= 2) {
var allAvailableColumns = [{ id : "product", name: "Product",
field: "name", width: 300, sortable: true }];
if ($('.grid').length >= 2) {
var allAvailableColumns = [{ id : 'product', name: 'Product',
field: 'name', width: 300, sortable: true }];
if (!mobile) {
allAvailableColumns.push({ id : "supplier", name: "Supplier",
allAvailableColumns.push({ id : 'supplier', name: 'Supplier',