diff --git a/www/web/templates/base.html b/www/web/templates/base.html index 49ba1e93d18dbf587e10ccc6ff9f806b114cd883..c8adbe7ed8078e248d5e5021edbaa7e14e59c011 100644 --- a/www/web/templates/base.html +++ b/www/web/templates/base.html @@ -5,6 +5,7 @@ <link rel="stylesheet" href="/media/css/bootstrap.min.css" /> <script type="text/javascript" src="/media/js/jquery.js" ></script> <script src="/media/js/bootstrap.js"></script> + <script src="/media/js/bootbox.min.js"></script> {% block custom_css %} {% endblock %} diff --git a/www/web/templates/media/js/bootbox.min.js b/www/web/templates/media/js/bootbox.min.js new file mode 100644 index 0000000000000000000000000000000000000000..509f14b15481f66e115d00a23f4ec66b447d6598 --- /dev/null +++ b/www/web/templates/media/js/bootbox.min.js @@ -0,0 +1,6 @@ +/** + * bootbox.js v3.3.0 + * + * http://bootboxjs.com/license.txt + */ +var bootbox=window.bootbox||function(a,b){function c(a,b){return"undefined"==typeof b&&(b=d),"string"==typeof m[b][a]?m[b][a]:b!=e?c(a,e):a}var d="en",e="en",f=!0,g="static",h="javascript:;",i="",j={},k={},l={};l.setLocale=function(a){for(var b in m)if(b==a)return d=a,void 0;throw new Error("Invalid locale: "+a)},l.addLocale=function(a,b){"undefined"==typeof m[a]&&(m[a]={});for(var c in b)m[a][c]=b[c]},l.setIcons=function(a){k=a,("object"!=typeof k||null===k)&&(k={})},l.setBtnClasses=function(a){j=a,("object"!=typeof j||null===j)&&(j={})},l.alert=function(){var a="",b=c("OK"),d=null;switch(arguments.length){case 1:a=arguments[0];break;case 2:a=arguments[0],"function"==typeof arguments[1]?d=arguments[1]:b=arguments[1];break;case 3:a=arguments[0],b=arguments[1],d=arguments[2];break;default:throw new Error("Incorrect number of arguments: expected 1-3")}return l.dialog(a,{label:b,icon:k.OK,"class":j.OK,callback:d},{onEscape:d||!0})},l.confirm=function(){var a="",b=c("CANCEL"),d=c("CONFIRM"),e=null;switch(arguments.length){case 1:a=arguments[0];break;case 2:a=arguments[0],"function"==typeof arguments[1]?e=arguments[1]:b=arguments[1];break;case 3:a=arguments[0],b=arguments[1],"function"==typeof arguments[2]?e=arguments[2]:d=arguments[2];break;case 4:a=arguments[0],b=arguments[1],d=arguments[2],e=arguments[3];break;default:throw new Error("Incorrect number of arguments: expected 1-4")}var f=function(){return"function"==typeof e?e(!1):void 0},g=function(){return"function"==typeof e?e(!0):void 0};return l.dialog(a,[{label:b,icon:k.CANCEL,"class":j.CANCEL,callback:f},{label:d,icon:k.CONFIRM,"class":j.CONFIRM,callback:g}],{onEscape:f})},l.prompt=function(){var a="",d=c("CANCEL"),e=c("CONFIRM"),f=null,g="";switch(arguments.length){case 1:a=arguments[0];break;case 2:a=arguments[0],"function"==typeof arguments[1]?f=arguments[1]:d=arguments[1];break;case 3:a=arguments[0],d=arguments[1],"function"==typeof arguments[2]?f=arguments[2]:e=arguments[2];break;case 4:a=arguments[0],d=arguments[1],e=arguments[2],f=arguments[3];break;case 5:a=arguments[0],d=arguments[1],e=arguments[2],f=arguments[3],g=arguments[4];break;default:throw new Error("Incorrect number of arguments: expected 1-5")}var h=a,i=b("<form></form>");i.append("<input class='input-block-level' autocomplete=off type=text value='"+g+"' />");var m=function(){return"function"==typeof f?f(null):void 0},n=function(){return"function"==typeof f?f(i.find("input[type=text]").val()):void 0},o=l.dialog(i,[{label:d,icon:k.CANCEL,"class":j.CANCEL,callback:m},{label:e,icon:k.CONFIRM,"class":j.CONFIRM,callback:n}],{header:h,show:!1,onEscape:m});return o.on("shown",function(){i.find("input[type=text]").focus(),i.on("submit",function(a){a.preventDefault(),o.find(".btn-primary").click()})}),o.modal("show"),o},l.dialog=function(c,d,e){function j(){var a=null;"function"==typeof e.onEscape&&(a=e.onEscape()),a!==!1&&x.modal("hide")}var k="",l=[];e||(e={}),"undefined"==typeof d?d=[]:"undefined"==typeof d.length&&(d=[d]);for(var m=d.length;m--;){var n=null,o=null,p=null,q="",r=null;if("undefined"==typeof d[m].label&&"undefined"==typeof d[m]["class"]&&"undefined"==typeof d[m].callback){var s=0,t=null;for(var u in d[m])if(t=u,++s>1)break;1==s&&"function"==typeof d[m][u]&&(d[m].label=t,d[m].callback=d[m][u])}"function"==typeof d[m].callback&&(r=d[m].callback),d[m]["class"]?p=d[m]["class"]:m==d.length-1&&d.length<=2&&(p="btn-primary"),d[m].link!==!0&&(p="btn "+p),n=d[m].label?d[m].label:"Option "+(m+1),d[m].icon&&(q="<i class='"+d[m].icon+"'></i> "),o=d[m].href?d[m].href:h,k="<a data-handler='"+m+"' class='"+p+"' href='"+o+"'>"+q+n+"</a>"+k,l[m]=r}var v=["<div class='bootbox modal' tabindex='-1' style='overflow:hidden;'>"];if(e.header){var w="";("undefined"==typeof e.headerCloseButton||e.headerCloseButton)&&(w="<a href='"+h+"' class='close'>×</a>"),v.push("<div class='modal-header'>"+w+"<h3>"+e.header+"</h3></div>")}v.push("<div class='modal-body'></div>"),k&&v.push("<div class='modal-footer'>"+k+"</div>"),v.push("</div>");var x=b(v.join("\n")),y="undefined"==typeof e.animate?f:e.animate;y&&x.addClass("fade");var z="undefined"==typeof e.classes?i:e.classes;return z&&x.addClass(z),x.find(".modal-body").html(c),x.on("keyup.dismiss.modal",function(a){27===a.which&&e.onEscape&&j("escape")}),x.on("click","a.close",function(a){a.preventDefault(),j("close")}),x.on("shown",function(){x.find("a.btn-primary:first").focus()}),x.on("hidden",function(a){a.target===this&&x.remove()}),x.on("click",".modal-footer a",function(a){var c=b(this).data("handler"),e=l[c],f=null;("undefined"==typeof c||"undefined"==typeof d[c].href)&&(a.preventDefault(),"function"==typeof e&&(f=e(a)),f!==!1&&x.modal("hide"))}),b("body").append(x),x.modal({backdrop:"undefined"==typeof e.backdrop?g:e.backdrop,keyboard:!1,show:!1}),x.on("show",function(){b(a).off("focusin.modal")}),("undefined"==typeof e.show||e.show===!0)&&x.modal("show"),x},l.modal=function(){var a,c,d,e={onEscape:null,keyboard:!0,backdrop:g};switch(arguments.length){case 1:a=arguments[0];break;case 2:a=arguments[0],"object"==typeof arguments[1]?d=arguments[1]:c=arguments[1];break;case 3:a=arguments[0],c=arguments[1],d=arguments[2];break;default:throw new Error("Incorrect number of arguments: expected 1-3")}return e.header=c,d="object"==typeof d?b.extend(e,d):e,l.dialog(a,[],d)},l.hideAll=function(){b(".bootbox").modal("hide")},l.animate=function(a){f=a},l.backdrop=function(a){g=a},l.classes=function(a){i=a};var m={br:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Sim"},da:{OK:"OK",CANCEL:"Annuller",CONFIRM:"Accepter"},de:{OK:"OK",CANCEL:"Abbrechen",CONFIRM:"Akzeptieren"},en:{OK:"OK",CANCEL:"Cancel",CONFIRM:"OK"},es:{OK:"OK",CANCEL:"Cancelar",CONFIRM:"Aceptar"},fr:{OK:"OK",CANCEL:"Annuler",CONFIRM:"D'accord"},it:{OK:"OK",CANCEL:"Annulla",CONFIRM:"Conferma"},nl:{OK:"OK",CANCEL:"Annuleren",CONFIRM:"Accepteren"},pl:{OK:"OK",CANCEL:"Anuluj",CONFIRM:"Potwierdź"},ru:{OK:"OK",CANCEL:"Отмена",CONFIRM:"Применить"},zh_CN:{OK:"OK",CANCEL:"å–æ¶ˆ",CONFIRM:"确认"},zh_TW:{OK:"OK",CANCEL:"å–æ¶ˆ",CONFIRM:"確èª"}};return l}(document,window.jQuery);window.bootbox=bootbox; \ No newline at end of file diff --git a/www/web/warpfood/templates/warpfood/view.html b/www/web/warpfood/templates/warpfood/view.html index b53a18916488e7e1f52d8739fb0554c68af35bef..5eaa011c84320e1c0b000ac647fc8f1e330ba298 100644 --- a/www/web/warpfood/templates/warpfood/view.html +++ b/www/web/warpfood/templates/warpfood/view.html @@ -15,14 +15,19 @@ <small>{{ sheet.food_service.phone }}</small><br/><br/> <small>{{ sheet.estimated_order_time | naturaltime }}</small><br/><br/> {% if user.is_authenticated %} - <a href="" class="btn btn-primary">Edit Sheet</a> + <a href="" class="btn {% if sheet.order_time %} disabled {% endif %} btn-primary">{% trans "Edit Sheet" %}</a> {% if not sheet.closed %} - <a href="/pizza/toggle_sheet/{{ sheet.id }}" class="btn btn-danger">Close Sheet</a> + <a href="/pizza/toggle_sheet/{{ sheet.id }}" class="btn btn-danger {% if sheet.order_time %} disabled {% endif %}">{% trans "Close Sheet" %}</a> {% else %} - <a href="/pizza/toggle_sheet/{{ sheet.id }}" class="btn btn-success">Open Sheet</a> + <a href="/pizza/toggle_sheet/{{ sheet.id }}" class="btn btn-success {% if sheet.order_time %} disabled {% endif %}">{% trans "Open Sheet" %}</a> {% endif %} {% if sheet.closed %} - <a href="/pizza/export_sheet/{{ sheet.id }}" class="btn btn-info">Print order</a> + {% if sheet.order_time %} + <a href="/pizza/sheet_ordered/{{ sheet.id }}" class="btn btn-success disabled">{% trans "Ordered" %}</a> + {% else %} + <a href="/pizza/sheet_ordered/{{ sheet.id }}" class="btn btn-danger" id="confirm">{% trans "Confirm ordered" %}</a> + {% endif %} + <!-- <a href="/pizza/export_sheet/{{ sheet.id }}" class="btn btn-info">Print order</a> --> {% endif %} {% endif %} </div> @@ -58,6 +63,11 @@ </div> </div> {% endif %} + {% if sheet.order_time %} + <div class="alert alert-success">{% trans "This sheet was ordered " %}{{sheet.order_time | naturaltime }} by {{ sheet.order_user}}</div> + {% endif %} + + <table class="table table-striped table-hover"> <thead> <tr> @@ -139,7 +149,18 @@ </div> </div> </div> - + + <script> + $('#confirm').click(function (e) { + e.preventDefault(); + bootbox.confirm("{% trans "Are you sure?" %}", function (result) { + if(result) + { + window.location = "/pizza/sheet_ordered/{{ sheet.id }}"; + } + }); + }); + </script> {% endblock %} {% block custom_javascript %} @@ -151,4 +172,5 @@ $('#product_modal').modal('hide') } </script> + {% endblock %} \ No newline at end of file diff --git a/www/web/warpfood/views.py b/www/web/warpfood/views.py index 3507b9e3889fb798a0a3ff56466cda960af21bf9..d8db6482fc8935285ceacb5bcd76487183afe90d 100644 --- a/www/web/warpfood/views.py +++ b/www/web/warpfood/views.py @@ -6,8 +6,9 @@ from warpfood.util import * from warpfood.models import * from reportlab.pdfgen import canvas from django.http import HttpResponse -from reportlab.platypus import SimpleDocTemplate -from reportlab.platypus.tables import Table, TableStyle, colors +#from reportlab.platypus import SimpleDocTemplate +#from reportlab.platypus.tables import Table, TableStyle, colors +from datetime import datetime # # ToDo: Hidden Field Paid default value to false @@ -78,6 +79,16 @@ def toggle_paid(request, order_id=0): order.save() return redirect("/pizza/view/%s" % (order.sheet.id)) +@login_required(login_url='/login/', redirect_field_name=None) +def sheet_ordered(request, sheet_id=0): + if sheet_id != 0: + sheet = FoodSheet.objects.get(id=sheet_id) + sheet.order_time = datetime.now() + sheet.order_user = str(request.user) + sheet.save() + + return redirect("/pizza/view/%s" % (sheet_id)) + """ @login_required(login_url='/login/', redirect_field_name=None) def export_sheet(request, sheet_id=0):