From 8c3488a610f05b501008b98e3a2bc4e1f0ce5d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Thu, 18 Aug 2016 05:33:42 +0200 Subject: [PATCH] =?UTF-8?q?-=20Affichage=20des=20prix/solde=20de=20compte?= =?UTF-8?q?=20en=20UKF=20(donc=20en=20prennant=20en=20compte=20le=20=20=20?= =?UTF-8?q?statut=20COF)=20-=20Possible=20de=20s=C3=A9lectionner=20des=20i?= =?UTF-8?q?tems=20(charges/retraits/achats)=20dans=20le=20=20=20panier=20e?= =?UTF-8?q?t=20de=20les=20en=20enlever=20en=20pressant=20"Suppr"=20-=20Pos?= =?UTF-8?q?sibilit=C3=A9=20de=20quitter=20la=20fen=C3=AAtre=20de=20charge/?= =?UTF-8?q?retrait=20avec=20Echap=20=20=20(Correction=20effectu=C3=A9e=20d?= =?UTF-8?q?ans=20jconfirm.js=20pour=20=C3=A9viter=20le=20bug=20ou=20"Enter?= =?UTF-8?q?"=20=20=20ajoutait=202=20fois=20la=20charge/retrait)=20-=20Ajou?= =?UTF-8?q?t/Modif=20de=20raccourcis:=20Shift+F2=20reset=20le=20panier,=20?= =?UTF-8?q?F2=20le=20compte=20=20=20s=C3=A9lectionn=C3=A9,=20F3=20ouvre=20?= =?UTF-8?q?la=20fen=C3=AAtre=20de=20charge,=20Shift+F3=20celle=20de=20retr?= =?UTF-8?q?ait=20-=20JS=20:=20Clean=20des=20fonctions=20de=20reset/Renomma?= =?UTF-8?q?ge=20de=20fonctions=20pour=20=C3=AAtre=20=20=20plus=20clair/Un?= =?UTF-8?q?=20peu=20de=20r=C3=A9organisation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kfet/static/kfet/css/jquery-ui.min.css | 6 + kfet/static/kfet/css/kpsul.css | 5 + kfet/static/kfet/js/jquery-confirm.js | 6 +- kfet/static/kfet/js/jquery-ui.min.js | 6 + kfet/templates/kfet/kpsul.html | 251 ++++++++++++++++++------- kfet/views.py | 2 +- 6 files changed, 203 insertions(+), 73 deletions(-) create mode 100644 kfet/static/kfet/css/jquery-ui.min.css create mode 100644 kfet/static/kfet/js/jquery-ui.min.js diff --git a/kfet/static/kfet/css/jquery-ui.min.css b/kfet/static/kfet/css/jquery-ui.min.css new file mode 100644 index 00000000..5e11b92a --- /dev/null +++ b/kfet/static/kfet/css/jquery-ui.min.css @@ -0,0 +1,6 @@ +/*! jQuery UI - v1.12.0 - 2016-08-17 +* http://jqueryui.com +* Includes: selectable.css +* Copyright jQuery Foundation and other contributors; Licensed MIT */ + +.ui-selectable{-ms-touch-action:none;touch-action:none}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black} \ No newline at end of file diff --git a/kfet/static/kfet/css/kpsul.css b/kfet/static/kfet/css/kpsul.css index 21be5417..c3e248b8 100644 --- a/kfet/static/kfet/css/kpsul.css +++ b/kfet/static/kfet/css/kpsul.css @@ -315,3 +315,8 @@ input[type=number]::-webkit-outer-spin-button { padding-right:10px; text-align:right; } + +#basket tr.ui-selected, #basket tr.ui-selecting { + background-color:#C8102E; + color:#FFF; +} diff --git a/kfet/static/kfet/js/jquery-confirm.js b/kfet/static/kfet/js/jquery-confirm.js index 77d708e7..6f645ccd 100644 --- a/kfet/static/kfet/js/jquery-confirm.js +++ b/kfet/static/kfet/js/jquery-confirm.js @@ -438,15 +438,17 @@ var jconfirm, Jconfirm; } else { this.close(); } - } + }/* if ($.inArray(key, this.confirmKeys) !== -1) { + */ /* * Confirm key pressed. */ + /* if (this.$confirmButton) { this.$confirmButton.click(); } - } + }*/ }, setDialogCenter: function () { if (this.$contentPane.css('display') == 'none') { diff --git a/kfet/static/kfet/js/jquery-ui.min.js b/kfet/static/kfet/js/jquery-ui.min.js new file mode 100644 index 00000000..03fffa75 --- /dev/null +++ b/kfet/static/kfet/js/jquery-ui.min.js @@ -0,0 +1,6 @@ +/*! jQuery UI - v1.12.0 - 2016-08-17 +* http://jqueryui.com +* Includes: widget.js, widgets/selectable.js, widgets/mouse.js +* Copyright jQuery Foundation and other contributors; Licensed MIT */ + +(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)})(function(t){t.ui=t.ui||{},t.ui.version="1.12.0";var e=0,i=Array.prototype.slice;t.cleanData=function(e){return function(i){var s,n,o;for(o=0;null!=(n=i[o]);o++)try{s=t._data(n,"events"),s&&s.remove&&t(n).triggerHandler("remove")}catch(a){}e(i)}}(t.cleanData),t.widget=function(e,i,s){var n,o,a,r={},l=e.split(".")[0];e=e.split(".")[1];var h=l+"-"+e;return s||(s=i,i=t.Widget),t.isArray(s)&&(s=t.extend.apply(null,[{}].concat(s))),t.expr[":"][h.toLowerCase()]=function(e){return!!t.data(e,h)},t[l]=t[l]||{},n=t[l][e],o=t[l][e]=function(t,e){return this._createWidget?(arguments.length&&this._createWidget(t,e),void 0):new o(t,e)},t.extend(o,n,{version:s.version,_proto:t.extend({},s),_childConstructors:[]}),a=new i,a.options=t.widget.extend({},a.options),t.each(s,function(e,s){return t.isFunction(s)?(r[e]=function(){function t(){return i.prototype[e].apply(this,arguments)}function n(t){return i.prototype[e].apply(this,t)}return function(){var e,i=this._super,o=this._superApply;return this._super=t,this._superApply=n,e=s.apply(this,arguments),this._super=i,this._superApply=o,e}}(),void 0):(r[e]=s,void 0)}),o.prototype=t.widget.extend(a,{widgetEventPrefix:n?a.widgetEventPrefix||e:e},r,{constructor:o,namespace:l,widgetName:e,widgetFullName:h}),n?(t.each(n._childConstructors,function(e,i){var s=i.prototype;t.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete n._childConstructors):i._childConstructors.push(o),t.widget.bridge(e,o),o},t.widget.extend=function(e){for(var s,n,o=i.call(arguments,1),a=0,r=o.length;r>a;a++)for(s in o[a])n=o[a][s],o[a].hasOwnProperty(s)&&void 0!==n&&(e[s]=t.isPlainObject(n)?t.isPlainObject(e[s])?t.widget.extend({},e[s],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,s){var n=s.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=i.call(arguments,1),l=this;return a?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(l=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(l=i&&i.jquery?l.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new s(o,this))})),l}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{classes:{},disabled:!1,create:null},_createWidget:function(i,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=e++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),i),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var l=s.match(/^([\w:-]*)\s*(.*)$/),h=l[1]+o.eventNamespace,c=l[2];c?n.on(h,c,r):i.on(h,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var s=!1;t(document).on("mouseup",function(){s=!1}),t.widget("ui.mouse",{version:"1.12.0",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!s){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,n=1===e.which,o="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return n&&!o&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),s=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,s=!1,e.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.widget("ui.selectable",t.ui.mouse,{version:"1.12.0",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var e=this;this._addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){e.elementPos=t(e.element[0]).offset(),e.selectees=t(e.options.filter,e.element[0]),e._addClass(e.selectees,"ui-selectee"),e.selectees.each(function(){var i=t(this),s=i.offset(),n={left:s.left-e.elementPos.left,top:s.top-e.elementPos.top};t.data(this,"selectable-item",{element:this,$element:i,left:n.left,top:n.top,right:n.left+i.outerWidth(),bottom:n.top+i.outerHeight(),startselected:!1,selected:i.hasClass("ui-selected"),selecting:i.hasClass("ui-selecting"),unselecting:i.hasClass("ui-unselecting")})})},this.refresh(),this._mouseInit(),this.helper=t("
"),this._addClass(this.helper,"ui-selectable-helper")},_destroy:function(){this.selectees.removeData("selectable-item"),this._mouseDestroy()},_mouseStart:function(e){var i=this,s=this.options;this.opos=[e.pageX,e.pageY],this.elementPos=t(this.element[0]).offset(),this.options.disabled||(this.selectees=t(s.filter,this.element[0]),this._trigger("start",e),t(s.appendTo).append(this.helper),this.helper.css({left:e.pageX,top:e.pageY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=t.data(this,"selectable-item");s.startselected=!0,e.metaKey||e.ctrlKey||(i._removeClass(s.$element,"ui-selected"),s.selected=!1,i._addClass(s.$element,"ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",e,{unselecting:s.element}))}),t(e.target).parents().addBack().each(function(){var s,n=t.data(this,"selectable-item");return n?(s=!e.metaKey&&!e.ctrlKey||!n.$element.hasClass("ui-selected"),i._removeClass(n.$element,s?"ui-unselecting":"ui-selected")._addClass(n.$element,s?"ui-selecting":"ui-unselecting"),n.unselecting=!s,n.selecting=s,n.selected=s,s?i._trigger("selecting",e,{selecting:n.element}):i._trigger("unselecting",e,{unselecting:n.element}),!1):void 0}))},_mouseDrag:function(e){if(this.dragged=!0,!this.options.disabled){var i,s=this,n=this.options,o=this.opos[0],a=this.opos[1],r=e.pageX,l=e.pageY;return o>r&&(i=r,r=o,o=i),a>l&&(i=l,l=a,a=i),this.helper.css({left:o,top:a,width:r-o,height:l-a}),this.selectees.each(function(){var i=t.data(this,"selectable-item"),h=!1,c={};i&&i.element!==s.element[0]&&(c.left=i.left+s.elementPos.left,c.right=i.right+s.elementPos.left,c.top=i.top+s.elementPos.top,c.bottom=i.bottom+s.elementPos.top,"touch"===n.tolerance?h=!(c.left>r||o>c.right||c.top>l||a>c.bottom):"fit"===n.tolerance&&(h=c.left>o&&r>c.right&&c.top>a&&l>c.bottom),h?(i.selected&&(s._removeClass(i.$element,"ui-selected"),i.selected=!1),i.unselecting&&(s._removeClass(i.$element,"ui-unselecting"),i.unselecting=!1),i.selecting||(s._addClass(i.$element,"ui-selecting"),i.selecting=!0,s._trigger("selecting",e,{selecting:i.element}))):(i.selecting&&((e.metaKey||e.ctrlKey)&&i.startselected?(s._removeClass(i.$element,"ui-selecting"),i.selecting=!1,s._addClass(i.$element,"ui-selected"),i.selected=!0):(s._removeClass(i.$element,"ui-selecting"),i.selecting=!1,i.startselected&&(s._addClass(i.$element,"ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",e,{unselecting:i.element}))),i.selected&&(e.metaKey||e.ctrlKey||i.startselected||(s._removeClass(i.$element,"ui-selected"),i.selected=!1,s._addClass(i.$element,"ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",e,{unselecting:i.element})))))}),!1}},_mouseStop:function(e){var i=this;return this.dragged=!1,t(".ui-unselecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");i._removeClass(s.$element,"ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",e,{unselected:s.element})}),t(".ui-selecting",this.element[0]).each(function(){var s=t.data(this,"selectable-item");i._removeClass(s.$element,"ui-selecting")._addClass(s.$element,"ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",e,{selected:s.element})}),this._trigger("stop",e),this.helper.remove(),!1}})}); \ No newline at end of file diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index ef903390..4a7fb3aa 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -2,9 +2,11 @@ {% load staticfiles %} {% block extra_head %} + + {% endblock %} @@ -130,6 +132,14 @@ $(document).ready(function() { } }); + var subvention_cof = 25; + + function amountToUKF(amount, is_cof=false) { + if (is_cof) + return Math.round(amount * (1+subvention_cof/100) * 100) / 10; + return Math.round(amount * 100) / 10; + } + // ----- // Account data management // ----- @@ -142,7 +152,7 @@ $(document).ready(function() { 'pk' : 0, 'name' : '', 'email': '', - 'is_cof' : false, + 'is_cof' : '', 'promo' : '', 'balance': '', 'trigramme' : '', @@ -153,8 +163,15 @@ $(document).ready(function() { // Display data function displayAccountData() { + var balance = account_data['trigramme'] != 'LIQ' ? account_data['balance'] : ''; + if (balance != '') + balance = amountToUKF(account_data['balance'], account_data['is_cof']); for (var elem in account_data) { - $('#account-'+elem).text(account_data[elem]); + if (elem == 'balance') { + $('#account-balance').text(balance); + } else { + $('#account-'+elem).text(account_data[elem]); + } } if (account_data['is_frozen']) { $('#account').attr('data-balance', 'frozen'); @@ -176,6 +193,11 @@ $(document).ready(function() { displayAccountData(); } + function resetAccount() { + resetAccountData(); + triInput.val(''); + } + // Store data function storeAccountData(data) { account_data = $.extend({}, account_data_default, data); @@ -237,7 +259,7 @@ $(document).ready(function() { } // Clear data - function resetCheckoutData() { + function resetCheckout() { checkout_data = checkout_data_default; $('#id_checkout').val(0); checkoutInput.find('option:first').prop('selected', true); @@ -260,7 +282,7 @@ $(document).ready(function() { data : { 'pk': id }, }) .done(function(data) { storeCheckoutData(data) }) - .fail(function() { resetCheckoutData() }); + .fail(function() { resetCheckout() }); } // Event listener @@ -342,6 +364,7 @@ $(document).ready(function() { for (var elem in article) { article_html.find('.'+elem).text(article[elem]) } + article_html.find('.price').text(amountToUKF(article['price'], false)); var category_html = articles_container .find('.category[data-category='+article['category_id']+']'); if (category_html.length == 0) { @@ -372,7 +395,7 @@ $(document).ready(function() { articlesList.push([article['name'],article['id'],article['category_id'],article['price']]); } - function getArticlesData() { + function getArticles() { $.ajax({ dataType: "json", url : "{% url 'kfet.kpsul.articles_data' %}", @@ -385,6 +408,11 @@ $(document).ready(function() { }); } + function resetArticles() { + articles_container.find('tr').remove(); + articlesList = []; + } + // ----- // Article selection // ----- @@ -392,8 +420,8 @@ $(document).ready(function() { var articleSelect = $('#article_autocomplete'); var articleId = $('#article_id'); var articleNb = $('#article_number'); - // 8:Backspace|9:Tab|13:Enter|112-117:F1-6|121:F10|122:F11|123:F12 - var normalKeys = /^(8|9|13|112|113|114|115|116|117|121|122|123)$/; + // 8:Backspace|9:Tab|13:Enter|46:DEL|112-117:F1-6|121:F10|122:F11|123:F12 + var normalKeys = /^(8|9|13|46|112|113|114|115|116|117|121|122|123)$/; var articlesList = []; function deleteNonMatching(array, str) { @@ -487,29 +515,13 @@ $(document).ready(function() { return false; }); - var item_basket_default_html = ''; - var basket_container = $('#basket table'); - var arrowKeys = /^(37|38|39|40)$/; - - function addArticleToBasket(id, nb) { - var i = 0; - while (i 0 && nb <= 24; } articleNb.on('keypress', function(e) { if (e.keyCode == 13 && is_nb_ok(articleNb.val()) && articleId.val() > 0) { - addArticleToBasket(articleId.val(), articleNb.val()); + addPurchase(articleId.val(), articleNb.val()); articleSelect.val(''); articleNb.val(''); articleSelect.focus(); @@ -527,15 +539,112 @@ $(document).ready(function() { return false; }); + + // ----- + // Basket + // ----- + + var item_basket_default_html = ''; + var basket_container = $('#basket table'); + var arrowKeys = /^(37|38|39|40)$/; + + function addPurchase(id, nb) { + var i = 0; + while (i