Commit 777a8777 authored by Malcolm Blaney's avatar Malcolm Blaney

Initial commit of changes introducing buying group invitations so

that members can order from multiple groups at once.
parent 57dde7f6
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -25,10 +25,12 @@
// for the JavaScript code in this page.
if(!this.dobrado.groupwizard){dobrado.groupwizard={};}
(function(){'use strict';var section=0;var total=0;$(function(){total=$(".groupwizard > div").length-1;$(".groupwizard").dialog({position:{my:"top",at:"top+50",of:"body"},title:"Group Settings Wizard",width:700,height:450,close:function(){$(".groupwizard").remove();}});$(".groupwizard .previous").button({disabled:true}).click(previous);$(".groupwizard .next").button().click(next);$(".groupwizard-purchase-other-order").click(dobrado.account.option);$(".groupwizard-purchase-volunteer").click(dobrado.account.option);$(".groupwizard-invoice-notifications").click(dobrado.account.option);$(".account").on("dialogopen",showGroup);$(".account").on("dialogfocus",showGroup);$("#groupwizard-pre-order-open-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$("#groupwizard-pre-order-final-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$("#groupwizard-co-op-day-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$("#groupwizard-invoice-day-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$("#groupwizard-invoice-remove-orders-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$("#groupwizard-invoice-send-orders-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$(".groupwizard :input").change(save);if($("#groupwizard-pre-order").is(":checked")){$(".groupwizard-pre-order-settings").show();}
(function(){'use strict';var section=0;var total=0;$(function(){total=$(".groupwizard-content > div").length-1;$(".groupwizard").dialog({position:{my:"top",at:"top+50",of:"body"},title:"Group Settings Wizard",width:700,height:450,close:function(){$(".groupwizard").remove();}});init();});function init(){$(".groupwizard .previous").button({disabled:true}).click(previous);$(".groupwizard .next").button().click(next);$("#groupwizard-new-group").button().click(function(){$(".groupwizard-new-group-info").show();$(".groupwizard-existing-group-info").hide();});$("#groupwizard-existing-group").button().click(function(){if($("#groupwizard-existing-group-select").length===0){next();}
else{$(".groupwizard-existing-group-info").show();$(".groupwizard-new-group-info").hide();}});$("#groupwizard-create-group").button().click(createGroup);$("#groupwizard-existing-group-select").change(changeGroup);$(".groupwizard-purchase-other-order").click(dobrado.account.option);$(".groupwizard-purchase-volunteer").click(dobrado.account.option);$(".groupwizard-invoice-notifications").click(dobrado.account.option);$(".groupwizard-invite").click(dobrado.account.option);$(".account").on("dialogopen",showGroup);$(".account").on("dialogfocus",showGroup);$("#groupwizard-pre-order-open-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$("#groupwizard-pre-order-final-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$("#groupwizard-co-op-day-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$("#groupwizard-invoice-day-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$("#groupwizard-invoice-remove-orders-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$("#groupwizard-invoice-send-orders-input").datepicker({dateFormat:dobrado.dateFormat,minDate:0});$(".groupwizard :input").change(save);if($("#groupwizard-pre-order").is(":checked")){$(".groupwizard-pre-order-settings").show();}
if($("#groupwizard-surcharge").is(":checked")){$(".groupwizard-payment-settings").show();}
if($("#groupwizard-stock-order-available").is(":checked")){$("#groupwizard-stock-order-update").parent().show();}
switchInput("pre-order-open");switchInput("pre-order-final");switchInput("co-op-day");switchInput("invoice-day");switchInput("invoice-remove-orders");switchInput("invoice-send-orders");});function previous(){$(".groupwizard-"+section).hide();section--;$(".groupwizard-"+section).show();if(section===0){$(".groupwizard .previous").button("option","disabled",true);}
switchInput("pre-order-open");switchInput("pre-order-final");switchInput("co-op-day");switchInput("invoice-day");switchInput("invoice-remove-orders");switchInput("invoice-send-orders");}
function previous(){$(".groupwizard-"+section).hide();section--;$(".groupwizard-"+section).show();if(section===0){$(".groupwizard .previous").button("option","disabled",true);}
else{$(".groupwizard .previous").button("option","disabled",false);}
$(".groupwizard .next").button("option","disabled",false);}
function next(){$(".groupwizard-"+section).hide();section++;$(".groupwizard-"+section).show();if(section===total){$(".groupwizard .next").button("option","disabled",true);}
......@@ -46,15 +48,21 @@ if(label==="co-op-day-date"){$("#groupwizard-co-op-day-input").val("").parent().
if(label==="invoice-day-date"){$("#groupwizard-invoice-day-input").val("").parent().toggle();$("#groupwizard-invoice-day-select").val("").parent().toggle();return;}
if(label==="invoice-send-orders-date"){$("#groupwizard-invoice-send-orders-input").val("").parent().toggle();$("#groupwizard-invoice-send-orders-select").val("").parent().toggle();return;}
if(label==="invoice-remove-orders-date"){$("#groupwizard-invoice-remove-orders-input").val("").parent().toggle();$("#groupwizard-invoice-remove-orders-select").val("").parent().toggle();return;}
if(label==="new-group-input"){return;}
if($(this).is(":checkbox")){value=$(this).is(":checked")?"true":"false";}
else{value=$(this).val();}
dobrado.log("Saving setting.","info");$.post("/php/request.php",{request:"groupwizard",label:label,value:value,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"save wizard setting")){return false;}
dobrado.log("Saving setting.","info");$.post("/php/request.php",{request:"groupwizard",action:"saveSetting",label:label,value:value,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"groupwizard saveSetting")){return false;}
if(label==="pre-order"){$(".groupwizard-pre-order-settings").toggle();}
if(label==="surcharge"){$(".groupwizard-payment-settings").toggle();}
if(label==="stock-order-available"){$("#groupwizard-stock-order-update").parent().toggle();}});}
function switchInput(label){label="#groupwizard-"+label;if($(label+"-input").val()!==""){$(label+"-date").prop("checked",true);$(label+"-input").parent().show();$(label+"-select").parent().hide();}}
function showGroup(){$("#account-tabs").tabs("option","active",1);if(section===1){$("#group-input").val("admin/purchase-other-order");}
else if(section===2){$("#group-input").val("admin/purchase-volunteer");}
else if(section===4){var group=$("#groupwizard-current-group").val();if(group){$("#group-input").val("admin/invoice-notifications-"+group);}
function showGroup(){$("#account-tabs").tabs("option","active",1);if(section===1){$("#group-input").val("admin/invite-notifications");}
if(section===2){$("#group-input").val("admin/purchase-other-order");}
else if(section===3){$("#group-input").val("admin/purchase-volunteer");}
else if(section===5){var group=$("#groupwizard-current-group").val();if(group){$("#group-input").val("admin/invoice-notifications-"+group);}
else{$("#group-input").val("admin/invoice-notifications");}}
$("#account-groups .show-members").click();}})();
\ No newline at end of file
$("#account-groups .show-members").click();}
function createGroup(){dobrado.log("Creating new group.","info");$.post("/php/request.php",{request:"groupwizard",action:"createGroup",group:$("#groupwizard-new-group-input").val(),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"groupwizard createGroup")){return false;}
var groupwizard=JSON.parse(response);$(".groupwizard-content").html(groupwizard.content);init();next();});}
function changeGroup(){var group=$(this).val();if(group==="")return;dobrado.log("Changing group.","info");$.post("/php/request.php",{request:"groupwizard",action:"changeGroup",group:group,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"groupwizard changeGroup")){return false;}
var groupwizard=JSON.parse(response);$(".groupwizard-content").html(groupwizard.content);init();next();});}})();
\ No newline at end of file
This diff is collapsed.
// @source: /js/source/dobrado.invite.js
//
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2015 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
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program 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 Affero General Public License for more details.
//
// As additional permission under GNU AGPL version 3 section 7, you
// may distribute non-source (e.g., minimized or compacted) forms of
// that code without the copy of the GNU GPL normally required by
// section 4, provided you include this license notice and a URL
// through which recipients can access the Corresponding Source.
//
// @licend The above is the entire license notice
// for the JavaScript code in this page.
if(!this.dobrado.invite){dobrado.invite={};}
(function(){'use strict';$(function(){if($('.invite').length===0){return;}
$('#invite-add').button().click(add);$('.invite-remove').button({icons:{primary:'ui-icon-closethick'},text:false}).click(remove);$('#invite-accept').button().click(accept);$('#invite-decline').button().click(decline);});function add(){dobrado.log('Inviting group.','info');$.post('/php/request.php',{request:'invite',action:'invite',group:$('#invite-select').val(),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'invite add')){return;}});}
function remove(){dobrado.log('Removing invite.','info');var group=$(this).siblings('.invite-remove-group');$.post('/php/request.php',{request:'invite',action:'remove',group:group.html(),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'invite remove')){return;}
group.parent().remove();});}
function accept(){dobrado.log('Accepting invite.','info');$.post('/php/request.php',{request:'invite',action:'accepted',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'invite accept')){return;}});}
function decline(){dobrado.log('Declining invite.','info');$.post('/php/request.php',{request:'invite',action:'declined',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'invite decline')){return;}});}})();
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -158,4 +158,4 @@ if(row.length===14){if(!headerFound){if(row[0]==="name"&&row[1]==="user"&&row[2]
return true;}
var quantity=row[2];quantity=parseFloat(quantity);if(isNaN(quantity)){quantity=0;}
var size=parseFloat(row[4]);var orderAvailable=parseInt(row[9],10);var purchaseAvailable=parseInt(row[10],10);var supplierAvailable=parseInt(row[11],10);var taxable=parseInt(row[12],10);importData.push({product:row[0],supplier:row[1],quantity:quantity,unit:row[3],size:size,price:row[5],wholesale:row[6],retail:row[7],category:row[8],orderAvailable:orderAvailable,purchaseAvailable:purchaseAvailable,supplierAvailable:supplierAvailable,taxable:taxable,grower:row[13]});}});return headerFound;}
dobrado.stock.addUser=function(user){$("#stock-user-input").val(user);stock.users.push(user);updateNames();};})();
\ No newline at end of file
dobrado.stock.addUser=function(user){$("#stock-user-input").val(user);stock.users.push(user);updateNames();$.post("/php/request.php",{request:"stock",action:"updateGroup",supplier:user,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"stock updateGroup")){return;}});};})();
\ No newline at end of file
......@@ -1371,6 +1371,18 @@ if (!this.dobrado.stock) {
$("#stock-user-input").val(user);
stock.users.push(user);
updateNames();
// The stock page can be used to create supplier accounts for other
// buying groups, so check if this new supplier has the right group.
$.post("/php/request.php", { request: "stock",
action: "updateGroup",
supplier: user,
url: location.href,
token: dobrado.token },
function(response) {
if (dobrado.checkResponseError(response, "stock updateGroup")) {
return;
}
});
};
})();
......@@ -3,7 +3,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2014 Malcolm Blaney
// Copyright (C) 2015 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
......@@ -26,13 +26,9 @@
if(!this.dobrado.summary){dobrado.summary={};}
(function(){'use strict';var purchaseGrid=null;var purchaseGridId="";var paymentGrid=null;var paymentGridId="";var oneWeekAgo=new Date().getTime()-(86400000*7);$(function(){if($(".summary").length===0){return;}
$(".view-previous a").click(function(){$("#summary-form").toggle();});$("#summary-start-input").val(dobrado.formatDate(oneWeekAgo)).datepicker({dateFormat:dobrado.dateFormat});$("#summary-end-input").val(dobrado.formatDate()).datepicker({dateFormat:dobrado.dateFormat});$("#summary-form .submit").button().click(view);$(".grid").each(function(index){if(index===0){purchaseGridId="#"+$(this).attr("id");}
if(index===1){paymentGridId="#"+$(this).attr("id");}});if($(".grid").length!==0){$(".grid").hide();var columns=[{id:"product",name:"Product",field:"name",width:230},{id:"supplier",name:"Supplier",field:"supplier",width:100},{id:"date",name:"Date",field:"date",width:110,formatter:Slick.Formatters.Timestamp},{id:"quantity",name:"Quantity",field:"quantity",width:90},{id:"price",name:"Price",field:"price",width:80,formatter:Slick.Formatters.Dollar},{id:"total",name:"Total",field:"total",width:80,formatter:Slick.Formatters.Dollar}];var options={enableColumnReorder:false,forceFitColumns:true};purchaseGrid=dobrado.grid.instance(purchaseGridId,[],columns,options);if($(".grid").length===2){columns=[{id:"date",name:"Date",field:"date",width:110,formatter:Slick.Formatters.Timestamp},{id:"comment",name:"Comment",field:"comment",width:300},{id:"amount",name:"Amount",field:"amount",width:80,formatter:Slick.Formatters.Dollar}];paymentGrid=dobrado.grid.instance(paymentGridId,[],columns,options);}}
dobrado.log("Loading summary...","info");$.post("/php/request.php",{request:"summary",action:"default",url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"summary list request")){return;}
var summary=JSON.parse(response);if(summary.data.length===0){$(".summary .total").html("No recent purchases.");return;}
if(purchaseGrid){purchaseGrid.setData(summary.data);purchaseGrid.updateRowCount();purchaseGrid.render();$(purchaseGridId).show();var total=0;$.each(summary.data,function(i,item){total+=parseFloat(item.total);});var surcharge="";if(summary.surcharge!==0){surcharge=" (plus surcharge: $"+summary.surcharge.toFixed(2)+")";}
$(".summary .total").html("Total purchases in the last week: $"+
total.toFixed(2)+surcharge);}});});function view(){dobrado.log("Updating view...","info");$(".grid").hide();$(".summary .total").html("");var select=$("#summary-view-select").val();var start=parseInt($.datepicker.formatDate("@",$("#summary-start-input").datepicker("getDate")),10);var end=parseInt($.datepicker.formatDate("@",$("#summary-end-input").datepicker("getDate")),10);$.post("/php/request.php",{request:"summary",action:"view",select:select,start:start,end:end,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"summary view request")){return;}
$("#summary-available-orders").change(showOrder);$(".view-previous a").click(function(){$("#summary-form").toggle();});$("#summary-start-input").val(dobrado.formatDate(oneWeekAgo)).datepicker({dateFormat:dobrado.dateFormat});$("#summary-end-input").val(dobrado.formatDate()).datepicker({dateFormat:dobrado.dateFormat});$("#summary-form .submit").button().click(view);$(".grid").each(function(index){if(index===0){purchaseGridId="#"+$(this).attr("id");}
if(index===1){paymentGridId="#"+$(this).attr("id");}});if($(".grid").length!==0){$(".grid").hide();var columns=[{id:"product",name:"Product",field:"name",width:230},{id:"supplier",name:"Supplier",field:"supplier",width:100},{id:"date",name:"Date",field:"date",width:110,formatter:Slick.Formatters.Timestamp},{id:"quantity",name:"Quantity",field:"quantity",width:90},{id:"price",name:"Price",field:"price",width:80,formatter:Slick.Formatters.Dollar},{id:"total",name:"Total",field:"total",width:80,formatter:Slick.Formatters.Dollar}];var options={enableColumnReorder:false,forceFitColumns:true};purchaseGrid=dobrado.grid.instance(purchaseGridId,[],columns,options);if($(".grid").length===2){columns=[{id:"date",name:"Date",field:"date",width:110,formatter:Slick.Formatters.Timestamp},{id:"comment",name:"Comment",field:"comment",width:300},{id:"amount",name:"Amount",field:"amount",width:80,formatter:Slick.Formatters.Dollar}];paymentGrid=dobrado.grid.instance(paymentGridId,[],columns,options);}}});function showOrder(){var group=$(this).val();$(".summary-order").hide();$(".summary-group-"+group).show();$.post("/php/request.php",{request:"summary",action:"change",group:group,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"summary change")){return;}});}
function view(){dobrado.log("Updating view...","info");$(".grid").hide();$(".summary .total").html("");var select=$("#summary-view-select").val();var start=parseInt($.datepicker.formatDate("@",$("#summary-start-input").datepicker("getDate")),10);var end=parseInt($.datepicker.formatDate("@",$("#summary-end-input").datepicker("getDate")),10);$.post("/php/request.php",{request:"summary",action:"view",select:select,start:start,end:end,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"summary view")){return;}
var summary=JSON.parse(response);var total=0;if(summary.data.length===0){$(".summary .total").html("No data for the dates given.");return;}
var startText=$("#summary-start-input").val();var endText=$("#summary-end-input").val();if(select==="purchase"&&purchaseGrid){purchaseGrid.setData(summary.data);purchaseGrid.updateRowCount();purchaseGrid.render();$(purchaseGridId).show();$.each(summary.data,function(i,item){total+=parseFloat(item.total);});var surcharge="";if(summary.surcharge!==0){surcharge=" (plus surcharge: $"+summary.surcharge.toFixed(2)+")";}
$(".summary .total").html("Total purchases for "+startText+" to "+endText+": $"+
......
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) 2014 Malcolm Blaney
// Copyright (C) 2015 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
......@@ -25,4 +25,4 @@
// for the JavaScript code in this page.
if(!this.dobrado.skeleton){dobrado.skeleton={};}
(function(){'use strict';$(function(){if($(".skeleton").length===0){return;}});})();
\ No newline at end of file
(function(){'use strict';$(function(){if($('.skeleton').length===0){return;}});})();
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -180,7 +180,9 @@ class Notification extends Base {
'At !timestamp"',
'"notification-comment","","<b>!author</b> commented '.
'on <a href=\"!permalink\">!description</a><br>'.
'At !timestamp"');
'At !timestamp"',
'"notification-invite","","<b>!author</b> has invited '.
'your group to join <b>!description</b>"');
$this->AddTemplate($template);
$site_style = array('"",".notifications","display","none"',
......
This diff is collapsed.
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