Commit 8892bfc0 authored by Malcolm Blaney's avatar Malcolm Blaney

When both order and purchase prices are used in Stock module default

to order price. Basic check for an email address in Contact module.
Fixed some typos and formatting in Payment module.
parent ee83fc2e
Pipeline #12056214 passed with stage
in 2 minutes and 7 seconds
......@@ -504,15 +504,17 @@ class Payment extends Base {
}
public function ListRecent($user) {
if ($this->Substitute('payment-list-recent' !== 'true')) return '';
if ($this->Substitute('payment-list-recent') !== 'true') return '';
$data = $this->Data(strtotime('-7 days'), time(), $user, true);
if (count($data) === 0) return '';
if (count($data) === 0) {
return '<p>No payment received in the past week.</p>';
}
$recent = 'Thanks for your payment this week.<br>';
foreach ($data as $payment) {
$recent .= ' <b>$' . $payment['amount'] . '</b> was received on ' .
date('jS F Y', $payment['timestamp']) . '<br>';
date('jS F Y', $payment['date']) . '<br>';
}
return '<p>' . $recent . '</p>';
}
......
This diff is collapsed.
......@@ -26,5 +26,6 @@
if(!this.dobrado.contact){dobrado.contact={};}
(function(){'use strict';$(function(){if($('.contact').length===0){return;}
$('.contact-form .submit').button().click(submit);});function submit(){var content={};var form=$(this).parent();form.find(':input').each(function(){var name=$(this).attr('name');if(name){content[name]=$(this).val();}});$('.contact-form .submit').button('option','disabled',true);$.post('/php/request.php',{request:'contact',mode:'contact',content:JSON.stringify(content),url:location.href,token:dobrado.token},function(response){$('.contact-form .submit').button('option','disabled',false);if(dobrado.checkResponseError(response,'contact')){form.find('.contact-info').show().html('<i>There was an error '+'sending your message.</i>');return;}
$('.contact-form .submit').button().click(submit);});function submit(){var content={};var form=$(this).parent();form.find(':input').each(function(){var name=$(this).attr('name');if(name){content[name]=$(this).val();}});if(!content.email||!/@/.test(content.email)){form.find('.contact-info').show().html('<i>Please provide your email '+'address.</i>');return false;}
$('.contact-form .submit').button('option','disabled',true);$.post('/php/request.php',{request:'contact',mode:'contact',content:JSON.stringify(content),url:location.href,token:dobrado.token},function(response){$('.contact-form .submit').button('option','disabled',false);if(dobrado.checkResponseError(response,'contact')){form.find('.contact-info').show().html('<i>There was an error '+'sending your message.</i>');return;}
form.find(':input').each(function(){if($(this).attr('type')!=='hidden'){$(this).val('');}});form.find('.contact-info').show().html('<i>Thanks your message '+'has been sent.</i>');});return false;}}());
\ No newline at end of file
......@@ -48,6 +48,12 @@ if (!this.dobrado.contact) {
content[name] = $(this).val();
}
});
if (!content.email || !/@/.test(content.email)) {
form.find('.contact-info').show().html('<i>Please provide your email ' +
'address.</i>');
return false;
}
$('.contact-form .submit').button('option', 'disabled', true);
$.post('/php/request.php',
{ request: 'contact', mode: 'contact',
......
......@@ -26,7 +26,7 @@
if(!this.dobrado.payment){dobrado.payment={};}
(function(){'use strict';var payments=[];var grid=null;var currentPayment=null;var allNames=[];var allReferences=[];var allInactive=[];var details={};var importData=[];var currentImport=0;$(function(){if($(".payment").length===0){return;}
$("#payment-settings-form").dialog({show:true,autoOpen:false,width:400,position:{my:"top",at:"top+50",of:window},title:"Edit your payment settings",create:dobrado.fixedDialog});$("#payment-details-form").dialog({show:true,autoOpen:false,width:450,position:{my:"top",at:"top+50",of:window},title:"Edit Bank Details",create:dobrado.fixedDialog});$("#payment-details-form .submit").button().click(editBankDetails);$(".payment .submit").button().click(savePayment);$(".payment .remove").button().click(removePayment);$(".payment .search").button().click(search);$(".payment .back").button().click(showPreviousImport);$(".payment .edit").click(editSettings);$("#payment-settings-form .submit").button().click(saveSettings);$("#payment-username-input").val("");$("#payment-fullname-input").val("");$("#payment-date-input").change(function(){currentPayment=null;clearSearchDates();}).datepicker({dateFormat:dobrado.dateFormat});$("#payment-start-date-input").val("").change(clearDate).datepicker({dateFormat:dobrado.dateFormat});$("#payment-end-date-input").val("").change(clearDate).datepicker({dateFormat:dobrado.dateFormat});$("#payment-reference-input").val("");$("#payment-import-input").change(loadImportData);$(".payment .toggle-search-options").click(function(){clearSearchDates();clearDate();$(".payment .search-options").toggle();});dobrado.log("Loading payments...","info");$.post("/php/request.php",{request:"payment",action:"list",url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"payment list request")){return;}
$("#payment-settings-form").dialog({show:true,autoOpen:false,width:530,position:{my:"top",at:"top+50",of:window},title:"Edit your payment settings",create:dobrado.fixedDialog});$("#payment-details-form").dialog({show:true,autoOpen:false,width:530,position:{my:"top",at:"top+50",of:window},title:"Edit Bank Details",create:dobrado.fixedDialog});$("#payment-details-form .submit").button().click(editBankDetails);$(".payment .submit").button().click(savePayment);$(".payment .remove").button().click(removePayment);$(".payment .search").button().click(search);$(".payment .back").button().click(showPreviousImport);$(".payment .edit").click(editSettings);$("#payment-settings-form .submit").button().click(saveSettings);$("#payment-username-input").val("");$("#payment-fullname-input").val("");$("#payment-date-input").change(function(){currentPayment=null;clearSearchDates();}).datepicker({dateFormat:dobrado.dateFormat});$("#payment-start-date-input").val("").change(clearDate).datepicker({dateFormat:dobrado.dateFormat});$("#payment-end-date-input").val("").change(clearDate).datepicker({dateFormat:dobrado.dateFormat});$("#payment-reference-input").val("");$("#payment-import-input").change(loadImportData);$(".payment .toggle-search-options").click(function(){clearSearchDates();clearDate();$(".payment .search-options").toggle();});dobrado.log("Loading payments...","info");$.post("/php/request.php",{request:"payment",action:"list",url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"payment list request")){return;}
payments=JSON.parse(response);if($(".grid").length!==0){gridSetup();}
loadUserDetails();});});function gridSetup(){var id="#"+$(".grid").attr("id");var columns=[{id:"date",name:"Date",field:"date",width:110,sortable:true,formatter:Slick.Formatters.Timestamp},{id:"name",name:"Username",field:"name",width:120,sortable:true}];if($('.dobrado-mobile').is(':hidden')){columns.push({id:"reference",name:"Reference",field:"reference",width:100,sortable:true});columns.push({id:"comment",name:"Comment",field:"comment",width:250,sortable:true});}
columns.push({id:"amount",name:"Amount",field:"amount",width:80,sortable:true,formatter:Slick.Formatters.Dollar});var options={enableColumnReorder:false,forceFitColumns:true};grid=dobrado.grid.instance(id,payments,columns,options);grid.setSelectionModel(new Slick.RowSelectionModel());grid.onClick.subscribe(function(e,item){showPayment(payments[item.row]);});grid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showPayment(payments[item.rows[0]]);}});grid.onSort.subscribe(function(e,args){payments.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==="amount"){value1=parseFloat(value1);value2=parseFloat(value2);}
......
......@@ -57,14 +57,14 @@ if (!this.dobrado.payment) {
$("#payment-settings-form").dialog({
show: true,
autoOpen: false,
width: 400,
width: 530,
position: { my: "top", at: "top+50", of: window },
title: "Edit your payment settings",
create: dobrado.fixedDialog });
$("#payment-details-form").dialog({
show: true,
autoOpen: false,
width: 450,
width: 530,
position: { my: "top", at: "top+50", of: window },
title: "Edit Bank Details",
create: dobrado.fixedDialog });
......
......@@ -41,8 +41,9 @@ if(localStorage.stockSortColumns){sort=localStorage.stockSortColumns;}
if(localStorage.stockProfile){profile=localStorage.stockProfile;}}
dobrado.log('Downloading...','info');$.post('/php/request.php',{request:'stock',action:'download',columns:columns,sort:sort,profile:profile,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'stock download')){return;}
var data=JSON.parse(response);location.href='/php/private.php?file='+data.filename;});}
function gridSetup(){var availableName='Members';var availableToolTip='Available to Members';if(stock.orderAvailable){availableName='Order';availableToolTip='Available to Order';}
allColumns=[{id:'product',name:'Product',field:'name',width:200,sortable:true,editor:Slick.Editors.Text},{id:'supplier',name:'Supplier',field:'fullname',width:100,sortable:true},{id:'quantity',name:'Quantity',field:'quantity',width:60,sortable:true},{id:'price',name:'Price',field:'price',width:60,sortable:true,formatter:Slick.Formatters.Dollar,editor:Slick.Editors.Float},{id:'wholesale',name:'Wholesale',field:'wholesale',width:60,sortable:true,formatter:Slick.Formatters.Dollar,editor:Slick.Editors.Float},{id:'retail',name:'Retail',field:'retail',width:60,sortable:true,formatter:Slick.Formatters.Dollar,editor:Slick.Editors.Float},{id:'unit',name:'Unit',field:'unit',width:60,sortable:true,formatter:Slick.Formatters.StockUnits,editor:Slick.Editors.StockUnits},{id:'unitPrice',name:'Unit Price',field:'unitPrice',width:60,sortable:true,formatter:Slick.Formatters.Dollar},{id:'size',name:'Pack Size',field:'size',width:60,sortable:true,editor:Slick.Editors.Float},{id:'alternative',name:'Alternative',field:'alternative',width:80,sortable:true,formatter:Slick.Formatters.Checkmark},{id:'category',name:'Category',field:'category',width:90,sortable:true,editor:Slick.Editors.Text},{id:'description',name:'Description',field:'description',width:90,sortable:true,editor:Slick.Editors.LongText},{id:'image',name:'Image',field:'image',width:90,sortable:true,editor:Slick.Editors.Text},{id:'grower',name:'Grower',field:'grower',width:90,sortable:true,editor:Slick.Editors.LongText},{id:'taxable',name:'Taxable',field:'taxable',width:50,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'composite',name:'Composite',field:'composite',width:80,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'track',name:'Track',field:'track',width:40,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'bulk',name:'Bulk',field:'bulk',width:40,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'cart',name:'Cart',field:'cart',width:40,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'available',name:availableName,field:'available',width:50,sortable:true,toolTip:availableToolTip,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'purchaseAvailable',name:'Purchase',field:'purchaseAvailable',width:60,sortable:true,toolTip:'Available to Purchase',formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'supplierAvailable',name:'Available',field:'supplierAvailable',width:60,sortable:true,toolTip:'Available from Supplier',formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'hidden',name:'Hidden',field:'hidden',width:60,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox}];var columns=[];var columnIds=['product','supplier','price','unit','available'];if(dobrado.localStorage){if(localStorage.stockColumns){columnIds=JSON.parse(localStorage.stockColumns);if($.inArray('supplierAvailable',columnIds)!==-1){supplierAvailableColumn=true;}
function gridSetup(){var priceName='Price';var availableName='Members';var availableToolTip='Available to Members';if(stock.orderAvailable){availableName='Order';availableToolTip='Available to Order';}
if(stock.wholesalePercent||stock.retailPercent){priceName='Cost';}
allColumns=[{id:'product',name:'Product',field:'name',width:200,sortable:true,editor:Slick.Editors.Text},{id:'supplier',name:'Supplier',field:'fullname',width:100,sortable:true},{id:'quantity',name:'Quantity',field:'quantity',width:60,sortable:true},{id:'price',name:priceName,field:'price',width:60,sortable:true,formatter:Slick.Formatters.Dollar,editor:Slick.Editors.Float},{id:'wholesale',name:'Wholesale',field:'wholesale',width:60,sortable:true,formatter:Slick.Formatters.Dollar,editor:Slick.Editors.Float},{id:'retail',name:'Retail',field:'retail',width:60,sortable:true,formatter:Slick.Formatters.Dollar,editor:Slick.Editors.Float},{id:'unit',name:'Unit',field:'unit',width:60,sortable:true,formatter:Slick.Formatters.StockUnits,editor:Slick.Editors.StockUnits},{id:'unitPrice',name:'Unit Price',field:'unitPrice',width:60,sortable:true,formatter:Slick.Formatters.Dollar},{id:'size',name:'Pack Size',field:'size',width:60,sortable:true,editor:Slick.Editors.Float},{id:'alternative',name:'Alternative',field:'alternative',width:80,sortable:true,formatter:Slick.Formatters.Checkmark},{id:'category',name:'Category',field:'category',width:90,sortable:true,editor:Slick.Editors.Text},{id:'description',name:'Description',field:'description',width:90,sortable:true,editor:Slick.Editors.LongText},{id:'image',name:'Image',field:'image',width:90,sortable:true,editor:Slick.Editors.Text},{id:'grower',name:'Grower',field:'grower',width:90,sortable:true,editor:Slick.Editors.LongText},{id:'taxable',name:'Taxable',field:'taxable',width:50,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'composite',name:'Composite',field:'composite',width:80,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'track',name:'Track',field:'track',width:40,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'bulk',name:'Bulk',field:'bulk',width:40,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'cart',name:'Cart',field:'cart',width:40,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'available',name:availableName,field:'available',width:50,sortable:true,toolTip:availableToolTip,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'purchaseAvailable',name:'Purchase',field:'purchaseAvailable',width:60,sortable:true,toolTip:'Available to Purchase',formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'supplierAvailable',name:'Available',field:'supplierAvailable',width:60,sortable:true,toolTip:'Available from Supplier',formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox},{id:'hidden',name:'Hidden',field:'hidden',width:60,sortable:true,formatter:Slick.Formatters.Checkmark,editor:Slick.Editors.Checkbox}];var columns=[];var columnIds=['product','supplier','price','unit','available'];if(dobrado.localStorage){if(localStorage.stockColumns){columnIds=JSON.parse(localStorage.stockColumns);if($.inArray('supplierAvailable',columnIds)!==-1){supplierAvailableColumn=true;}
if($.inArray('hidden',columnIds)!==-1){hiddenColumn=true;}}
else{localStorage.stockColumns=JSON.stringify(columnIds);}}
$.each(columnIds,function(i,id){$('#stock-column-'+id).prop('checked',true);$('#stock-column-'+id).checkboxradio('refresh');$.each(allColumns,function(i,item){if(item.id===id){columns.push(item);return false;}});});$('.grid').each(function(index){if(index===0){stockGridId='#'+$(this).attr('id');}
......
......@@ -272,19 +272,23 @@ if (!this.dobrado.stock) {
}
function gridSetup() {
var priceName = 'Price';
var availableName = 'Members';
var availableToolTip = 'Available to Members';
if (stock.orderAvailable) {
availableName = 'Order';
availableToolTip = 'Available to Order';
}
if (stock.wholesalePercent || stock.retailPercent) {
priceName = 'Cost';
}
allColumns = [{ id : 'product', name: 'Product', field: 'name',
width: 200, sortable: true, editor: Slick.Editors.Text },
{ id : 'supplier', name: 'Supplier', field: 'fullname',
width: 100, sortable: true },
{ id : 'quantity', name: 'Quantity', field: 'quantity',
width: 60, sortable: true },
{ id : 'price', name: 'Price', field: 'price', width: 60,
{ id : 'price', name: priceName, field: 'price', width: 60,
sortable: true, formatter: Slick.Formatters.Dollar,
editor: Slick.Editors.Float },
{ id : 'wholesale', name: 'Wholesale', field: 'wholesale',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment