Skip to content

Commit

Permalink
Version 1.4.3
Browse files Browse the repository at this point in the history
- Fixed firefox appcache issue where newly loaded appcache does not take affect.
- Patch to prevent stored items added in previous versions (with undefined cost field) from causing transactions to fail.
- UI fixes for demo buttons.
- Re-enabled various currencies that were causing browser freezing in some older browser versions.
- Allow stock count to become a minus qty.
  • Loading branch information
micwallace committed Apr 11, 2017
1 parent b3c8c36 commit 8b469ab
Show file tree
Hide file tree
Showing 36 changed files with 609 additions and 207 deletions.
2 changes: 1 addition & 1 deletion admin/assets/css/ace.min.css

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions admin/assets/js/csv-import/csv.import.tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $(function() {
// the constructor
_create: function() {
var widget = this;
var html = '<input id="file_input" type="file" name="file" accept="text/csv" />';
var html = '<input id="file_input" type="file" name="file" accept=".csv, text/csv, text/x-csv, text/plain" />';
html += '<label for="column_headers">CSV includes column header</label><br/>';
var cb = $('<br/><input id="column_headers" type="checkbox" '+(this.options.csvHasHeader ? 'checked="checked"' : '')+'/>');
cb.on('click', function(){
Expand Down Expand Up @@ -78,8 +78,6 @@ $(function() {

file_input.ezdz({
validators: {
maxWidth: 600,
maxHeight: 400,
maxSize: 10000000
},
accept: function(file) {
Expand All @@ -93,8 +91,12 @@ $(function() {
});
$(".ezdz-accept div").append(remove_btn);
},
reject: function() {
alert("Only CSV files less than 10mb can be imported.");
reject: function(filname, errors) {
if (errors.maxSize) {
alert("Only CSV files less than 10mb can be imported.");
return;
}
alert("There was an error loading the file: "+JSON.stringify(errors));
}
});

Expand Down
14 changes: 9 additions & 5 deletions admin/assets/wpos/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ function WPOSTransactions() {
$('#transitemid').val(0);
$('#transitemsitemid').val(0);
$('#transitemcost').val("0.00");
$('#transitemunit').data("unit_original", 0.00);
$('#transitemprice').text(WPOS.util.currencyFormat(0.00));
itemdialog.dialog('option', 'title', 'Add Item');
}
Expand All @@ -397,11 +398,13 @@ function WPOSTransactions() {
function setDisabledItemFields() {
if ($('#transitemsitemid').val() != 0) {
$('#transitemname').prop("disabled", true);
$('#transitemtaxid').prop("disabled", true);
$('#transitemtaxid').prop("disabled", (!WPOS.getConfigTable().pos.hasOwnProperty('taxedit') || WPOS.getConfigTable().pos.taxedit=='no'));
var unitfield = $('#transitemunit');
if (unitfield.val() !== "") {
unitfield.prop("disabled", true);
}
var disableedit = (unitfield.val() !== "" && (!WPOS.getConfigTable().pos.hasOwnProperty('priceedit') || WPOS.getConfigTable().pos.priceedit=='blank'));
unitfield.prop("disabled", disableedit);
unitfield = $('#transitemcost');
disableedit = (unitfield.val() !== "" && (!WPOS.getConfigTable().pos.hasOwnProperty('priceedit') || WPOS.getConfigTable().pos.priceedit=='blank'));
unitfield.prop("disabled", disableedit);
} else {
$('#transitemname').prop("disabled", false);
$('#transitemtaxid').prop("disabled", false);
Expand Down Expand Up @@ -555,6 +558,7 @@ function WPOSTransactions() {
var data = {id: curid, sitemid: $("#transitemsitemid").val(), qty: $("#transitemqty").val(), name: $('#transitemname').val(), alt_name: $('#transitemaltname').val(), desc: $('#transitemdesc').val(), cost: $('#transitemcost').val(), unit: $('#transitemunit').val(), taxid: $('#transitemtaxid').val(), tax: JSON.parse($('#transitemtaxval').val()), price: $('#transitempriceval').val()};
if (itemid == 0) {
action = "invoices/items/add";
data.unit_original = $('#transitemunit').data("unit_original");
} else {
action = "invoices/items/edit";
data.itemid = itemid;
Expand Down Expand Up @@ -1050,7 +1054,7 @@ function WPOSTransactions() {
$('#transitemdesc').val(ui.item.description);
$('#transitemqty').val(ui.item.qty);
$('#transitemcost').val(ui.item.cost);
$('#transitemunit').val(ui.item.price);
$('#transitemunit').val(ui.item.price).data("unit_original", ui.item.price);
$('#transitemtaxid').val(ui.item.taxid);
// lock fields
setDisabledItemFields();
Expand Down
83 changes: 63 additions & 20 deletions admin/assets/wpos/wpos.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,10 @@ function WPOSAdmin(){
return configtable;
};

this.setConfigSet = function (key, data) {
configtable[key] = data;
};

this.getTaxTable = function () {
if (configtable == null) {
return false;
Expand Down Expand Up @@ -676,7 +680,6 @@ function WPOSAdmin(){
this.table2CSV = function(el) {

var csvData = [];
var headerArr = [];

//header
var tmpRow = []; // construct header avalible array
Expand All @@ -693,32 +696,72 @@ function WPOSAdmin(){
$(this).find('td').each(function() {
if (!$(this).hasClass('noexport')) tmpRow[tmpRow.length] = formatData($(this).text());
});
row2CSV(tmpRow);
tmpRow = row2CSV(tmpRow);
if (tmpRow!=null)
csvData[csvData.length] = tmpRow;
});

var mydata = csvData.join('\n');
return mydata;
return csvData.join('\n');
};

this.data2CSV = function(headers, fields, data) {

var csvData = [];

function row2CSV(tmpRow) {
var tmp = tmpRow.join(''); // to remove any blank rows
// alert(tmp);
if (tmpRow.length > 0 && tmp != '') {
var mystr = tmpRow.join(",");
csvData[csvData.length] = mystr;
//header
csvData[csvData.length] = row2CSV(headers);

for (var i in data){
if (data.hasOwnProperty(i)) {
var record = data[i];
var tmpRow = [];
for (var x = 0; x < fields.length; x++) {
var key = fields[x];
if (typeof key === 'object'){
tmpRow[tmpRow.length] = formatData(key.func(record[key.key], record));
} else {
if (record.hasOwnProperty(key)) {
tmpRow[tmpRow.length] = formatData(record[key]);
} else {
tmpRow[tmpRow.length] = '';
}
}
}
tmpRow = row2CSV(tmpRow);
if (tmpRow!=null)
csvData[csvData.length] = tmpRow;
}
}
function formatData(input) {
// replace " with “
var regexp = new RegExp(/["]/g);
var output = input.replace(regexp, "“");
//HTML
var regexp = new RegExp(/\<[^\<]+\>/g);
var output = output.replace(regexp, "");
if (output == "") return '';
return '"' + output + '"';
}

return csvData.join('\n');

};

function row2CSV(tmpRow) {
var tmp = tmpRow.join(''); // to remove any blank rows
// alert(tmp);
if (tmpRow.length > 0 && tmp != '') {
return tmpRow.join(",");
}
return null;
}

function formatData(input) {
if (typeof input === 'number')
return input;

if (typeof input === 'object')
input = JSON.stringify(input);
// replace " with “
var regexp = new RegExp(/["]/g);
var output = input.replace(regexp, '""');
//HTML
regexp = new RegExp(/\<[^\<]+\>/g);
output = output.replace(regexp, "");
if (output == "") return '';
return '"' + output + '"';
}

// Load globally accessable objects
this.util = new WPOSUtil();
this.transactions = new WPOSTransactions();
Expand Down
5 changes: 4 additions & 1 deletion admin/content/accountsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ function saveSettings(){
data['xeroenabled'] = $("#xeroenabled").is(":checked")?1:0;
data['name'] = "accounting";
WPOS.sendJsonData("settings/set", JSON.stringify(data));
var result = WPOS.sendJsonData("settings/set", JSON.stringify(data));
if (result !== false){
WPOS.setConfigSet('accounting', result);
}
// hide loader
WPOS.util.hideLoader();
}
Expand Down
33 changes: 28 additions & 5 deletions admin/content/customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<table id="customertable" class="table table-striped table-bordered table-hover dt-responsive" style="width: 100%;">
<thead>
<tr>
<th data-priority="0" class="center noexport">
<th data-priority="0" class="center">
<label>
<input type="checkbox" class="ace" />
<span class="lbl"></span>
Expand Down Expand Up @@ -61,16 +61,18 @@
datatable = $('#customertable').dataTable({
"bProcessing": true,
"aaData": itemarray,
"aaSorting": [[ 1, "asc" ]],
"aLengthMenu": [ 10, 25, 50, 100, 200],
"aoColumns": [
{ mData:null, sDefaultContent:'<div style="text-align: center"><label><input class="ace dt-select-cb" type="checkbox"><span class="lbl"></span></label><div>', "bSortable": false, sClass:"noexport" },
{ mData:null, sDefaultContent:'<div style="text-align: center"><label><input class="ace dt-select-cb" type="checkbox"><span class="lbl"></span></label><div>', bSortable: false },
{ "mData":"id" },
{ "mData":"name" },
{ "mData":"email" },
{ "mData":"phone" },
{ "mData":"mobile" },
{ "mData":"suburb" },
{ "mData":"postcode" },
{ mData:null, sDefaultContent:'<div class="action-buttons"><a class="green" onclick="WPOS.customers.openCustomerDialog($(this).closest(\'tr\').find(\'td\').eq(1).text());"><i class="icon-pencil bigger-130"></i></a><a class="red" onclick="WPOS.customers.deleteCustomer($(this).closest(\'tr\').find(\'td\').eq(1).text())"><i class="icon-trash bigger-130"></i></a></div>', "bSortable": false }
{ mData:null, sDefaultContent:'<div class="action-buttons"><a class="green" onclick="WPOS.customers.openCustomerDialog($(this).closest(\'tr\').find(\'td\').eq(1).text());"><i class="icon-pencil bigger-130"></i></a><a class="red" onclick="WPOS.customers.deleteCustomer($(this).closest(\'tr\').find(\'td\').eq(1).text())"><i class="icon-trash bigger-130"></i></a></div>', bSortable: false }
],
"columns": [
{},
Expand Down Expand Up @@ -137,10 +139,31 @@ function reloadCustomerTable(){
datatable.api().draw(false);
}
function exportCustomers(){
var data = WPOS.table2CSV($("#customertable"));
var filename = "customers-"+WPOS.util.getDateFromTimestamp(new Date());
filename = filename.replace(" ", "");
WPOS.initSave(filename, data);
var customers = WPOS.customers.getCustomers();
var data = {};
var ids = datatable.api().rows('.selected').data().map(function(row){ return row.id }).join(',').split(',');
if (ids && ids.length > 0 && ids[0]!='') {
for (var i = 0; i < ids.length; i++) {
var id = ids[i];
if (customers.hasOwnProperty(id))
data[id] = customers[id];
}
} else {
data = customers;
}
var csv = WPOS.data2CSV(
['ID', 'Name', 'Email', 'Phone', 'Mobile', 'Address', 'Suburb', 'Postcode', 'State', 'Country', 'Notes', 'Contacts'],
['id', 'name', 'email', 'phone', 'mobile', 'address', 'suburb', 'postcode', 'state', 'country', 'notes', 'contacts'],
data
);
WPOS.initSave(filename, csv);
}
</script>
<style type="text/css">
Expand Down
5 changes: 4 additions & 1 deletion admin/content/generalsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,10 @@ function saveSettings(){
data['altlabels'] = altlabels;
data['gcontact'] = $("#gcontact").is(":checked")?1:0;
data['email_tls'] = $("#email_tls").is(":checked");
WPOS.sendJsonData("settings/general/set", JSON.stringify(data));
var result = WPOS.sendJsonData("settings/general/set", JSON.stringify(data));
if (result !== false){
WPOS.setConfigSet('general', result);
}
// hide loader
WPOS.util.hideLoader();
}
Expand Down
Loading

2 comments on commit 8b469ab

@solancer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can I updgrade my previous system?

@micwallace
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull the repo or replace the files (backup first), then go to /installer in the browser.

Please sign in to comment.