diff --git a/Gemfile b/Gemfile index 99489d5b..22275707 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -gem 'pg' +# gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' @@ -66,6 +66,8 @@ gem 'kaminari', '~> 1.0.1' # Datatable gem 'filterrific' +gem 'cancancan', '~> 1.10' + # Use Capistrano for deployment # gem 'capistrano-rails', group: :development diff --git a/Gemfile.lock b/Gemfile.lock index e6f683f6..5c0f8a10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,7 +39,7 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) arel (8.0.0) - autoprefixer-rails (7.1.1) + autoprefixer-rails (7.1.1.2) execjs bcrypt (3.1.11) bindex (0.5.0) @@ -50,6 +50,7 @@ GEM railties (>= 3.0) builder (3.2.3) byebug (9.0.6) + cancancan (1.17.0) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -121,7 +122,6 @@ GEM nokogiri (1.8.0) mini_portile2 (~> 2.2.0) pdf-core (0.7.0) - pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -159,8 +159,8 @@ GEM thor (>= 0.18.1, < 2.0) rake (12.0.0) rb-fsevent (0.9.8) - rb-inotify (0.9.8) - ffi (>= 0.5.0) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) redis (3.3.3) rspec-core (3.6.0) rspec-support (~> 3.6.0) @@ -191,7 +191,7 @@ GEM activesupport (>= 3.2.1) shoulda-matchers (3.1.1) activesupport (>= 4.0.0) - sidekiq (5.0.2) + sidekiq (5.0.3) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) rack-protection (>= 1.5.0) @@ -245,6 +245,7 @@ DEPENDENCIES bootstrap (~> 4.0.0.alpha3) bootstrap-datepicker-rails byebug + cancancan (~> 1.10) coffee-rails (~> 4.2) cups (~> 0.0.7) database_cleaner @@ -259,7 +260,6 @@ DEPENDENCIES kaminari (~> 1.0.1) listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) - pg prawn prawn-table puma (~> 3.0) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 202d4387..63c871d9 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -25,6 +25,12 @@ $(document).on("focus", "[data-behaviour~='datepicker']", function(e){ $('.dropdown-toggle').dropdown(); }); +function export_to(path) +{ + var form_params = $("#frm_report").serialize(); + window.location = path+"?"+ form_params; +} + /* * ToDo Move to here from pages * diff --git a/app/assets/javascripts/jquery-confirm.js b/app/assets/javascripts/jquery-confirm.js new file mode 100644 index 00000000..43d8889b --- /dev/null +++ b/app/assets/javascripts/jquery-confirm.js @@ -0,0 +1,10 @@ +/*! + * jquery-confirm v3.2.3 (http://craftpip.github.io/jquery-confirm/) + * Author: Boniface Pereira + * Website: www.craftpip.com + * Contact: hey@craftpip.com + * + * Copyright 2013-2017 jquery-confirm + * Licensed under MIT (https://github.com/craftpip/jquery-confirm/blob/master/LICENSE) + */ +if(typeof jQuery==="undefined"){throw new Error("jquery-confirm requires jQuery");}var jconfirm,Jconfirm;(function($,window){$.fn.confirm=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false};}$(this).each(function(){var $this=$(this);$this.on("click",function(e){e.preventDefault();var jcOption=$.extend({},options);if($this.attr("data-title")){jcOption.title=$this.attr("data-title");}if($this.attr("data-content")){jcOption.content=$this.attr("data-content");}if(typeof jcOption.buttons=="undefined"){jcOption.buttons={};}jcOption["$target"]=$this;if($this.attr("href")&&Object.keys(jcOption.buttons).length==0){var buttons=$.extend(true,{},jconfirm.pluginDefaults.defaultButtons,(jconfirm.defaults||{}).defaultButtons||{});var firstBtn=Object.keys(buttons)[0];jcOption.buttons=buttons;jcOption.buttons[firstBtn].action=function(){location.href=$this.attr("href");};}jcOption.closeIcon=false;$.confirm(jcOption);});});return $(this);};$.confirm=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false};}if(typeof options.buttons!="object"){options.buttons={};}if(Object.keys(options.buttons).length==0){var buttons=$.extend(true,{},jconfirm.pluginDefaults.defaultButtons,(jconfirm.defaults||{}).defaultButtons||{});options.buttons=buttons;}return jconfirm(options);};$.alert=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false};}if(typeof options.buttons!="object"){options.buttons={};}if(Object.keys(options.buttons).length==0){var buttons=$.extend(true,{},jconfirm.pluginDefaults.defaultButtons,(jconfirm.defaults||{}).defaultButtons||{});var firstBtn=Object.keys(buttons)[0];options.buttons[firstBtn]=buttons[firstBtn];}return jconfirm(options);};$.dialog=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false,closeIcon:function(){}};}options.buttons={};if(typeof options.closeIcon=="undefined"){options.closeIcon=function(){};}options.confirmKeys=[13];return jconfirm(options);};jconfirm=function(options){if(typeof options==="undefined"){options={};}var pluginOptions=$.extend(true,{},jconfirm.pluginDefaults);if(jconfirm.defaults){pluginOptions=$.extend(true,pluginOptions,jconfirm.defaults);}pluginOptions=$.extend(true,{},pluginOptions,options);var instance=new Jconfirm(pluginOptions);jconfirm.instances.push(instance);return instance;};Jconfirm=function(options){$.extend(this,options);this._init();};Jconfirm.prototype={_init:function(){var that=this;if(!jconfirm.instances.length){jconfirm.lastFocused=$("body").find(":focus");}this._id=Math.round(Math.random()*99999);if(!this.lazyOpen){setTimeout(function(){that.open();},0);}},_buildHTML:function(){var that=this;this._parseAnimation(this.animation,"o");this._parseAnimation(this.closeAnimation,"c");this._parseBgDismissAnimation(this.backgroundDismissAnimation);this._parseColumnClass(this.columnClass);this._parseTheme(this.theme);this._parseType(this.type);var template=$(this.template);template.find(".jconfirm-box").addClass(this.animationParsed).addClass(this.backgroundDismissAnimationParsed).addClass(this.typeParsed);if(this.typeAnimated){template.find(".jconfirm-box").addClass("jconfirm-type-animated");}if(this.useBootstrap){template.find(".jc-bs3-row").addClass(this.bootstrapClasses.row);template.find(".jc-bs3-row").addClass("justify-content-md-center justify-content-sm-center justify-content-xs-center justify-content-lg-center");template.find(".jconfirm-box-container").addClass(this.columnClassParsed);if(this.containerFluid){template.find(".jc-bs3-container").addClass(this.bootstrapClasses.containerFluid);}else{template.find(".jc-bs3-container").addClass(this.bootstrapClasses.container);}}else{template.find(".jconfirm-box").css("width",this.boxWidth);}if(this.titleClass){template.find(".jconfirm-title-c").addClass(this.titleClass);}template.addClass(this.themeParsed);var ariaLabel="jconfirm-box"+this._id;template.find(".jconfirm-box").attr("aria-labelledby",ariaLabel).attr("tabindex",-1);template.find(".jconfirm-content").attr("id",ariaLabel);if(this.bgOpacity!=null){template.find(".jconfirm-bg").css("opacity",this.bgOpacity);}if(this.rtl){template.addClass("jconfirm-rtl");}this.$el=template.appendTo(this.container);this.$jconfirmBoxContainer=this.$el.find(".jconfirm-box-container");this.$jconfirmBox=this.$body=this.$el.find(".jconfirm-box");this.$jconfirmBg=this.$el.find(".jconfirm-bg");this.$title=this.$el.find(".jconfirm-title");this.$titleContainer=this.$el.find(".jconfirm-title-c");this.$content=this.$el.find("div.jconfirm-content");this.$contentPane=this.$el.find(".jconfirm-content-pane");this.$icon=this.$el.find(".jconfirm-icon-c");this.$closeIcon=this.$el.find(".jconfirm-closeIcon");this.$btnc=this.$el.find(".jconfirm-buttons");this.$scrollPane=this.$el.find(".jconfirm-scrollpane");this._contentReady=$.Deferred();this._modalReady=$.Deferred();this.setTitle();this.setIcon();this._setButtons();this._parseContent();this.initDraggable();if(this.isAjax){this.showLoading(false);}$.when(this._contentReady,this._modalReady).then(function(){if(that.isAjaxLoading){setTimeout(function(){that.isAjaxLoading=false;that.setContent();that.setTitle();that.setIcon();setTimeout(function(){that.hideLoading(false);},100);if(typeof that.onContentReady=="function"){that.onContentReady();}},50);}else{that.setContent();that.setTitle();that.setIcon();if(typeof that.onContentReady=="function"){that.onContentReady();}}if(that.autoClose){that._startCountDown();}});that._contentHash=this._hash(that.$content.html());that._contentHeight=this.$content.height();this._watchContent();this.setDialogCenter();if(this.animation=="none"){this.animationSpeed=1;this.animationBounce=1;}this.$body.css(this._getCSS(this.animationSpeed,this.animationBounce));this.$contentPane.css(this._getCSS(this.animationSpeed,1));this.$jconfirmBg.css(this._getCSS(this.animationSpeed,1));},_typePrefix:"jconfirm-type-",typeParsed:"",_parseType:function(type){this.typeParsed=this._typePrefix+type;},setType:function(type){var oldClass=this.typeParsed;this._parseType(type);this.$jconfirmBox.removeClass(oldClass).addClass(this.typeParsed);},themeParsed:"",_themePrefix:"jconfirm-",setTheme:function(theme){var previous=this.theme;this.theme=theme||this.theme;this._parseTheme(this.theme);if(previous){this.$el.removeClass(previous);}this.$el.addClass(this.themeParsed);this.theme=theme;},_parseTheme:function(theme){var that=this;theme=theme.split(",");$.each(theme,function(k,a){if(a.indexOf(that._themePrefix)==-1){theme[k]=that._themePrefix+$.trim(a);}});this.themeParsed=theme.join(" ").toLowerCase();},backgroundDismissAnimationParsed:"",_bgDismissPrefix:"jconfirm-hilight-",_parseBgDismissAnimation:function(bgDismissAnimation){var animation=bgDismissAnimation.split(",");var that=this;$.each(animation,function(k,a){if(a.indexOf(that._bgDismissPrefix)==-1){animation[k]=that._bgDismissPrefix+$.trim(a);}});this.backgroundDismissAnimationParsed=animation.join(" ").toLowerCase();},animationParsed:"",closeAnimationParsed:"",_animationPrefix:"jconfirm-animation-",setAnimation:function(animation){this.animation=animation||this.animation;this._parseAnimation(this.animation,"o");},_parseAnimation:function(animation,which){which=which||"o";var animations=animation.split(",");var that=this;$.each(animations,function(k,a){if(a.indexOf(that._animationPrefix)==-1){animations[k]=that._animationPrefix+$.trim(a);}});var a_string=animations.join(" ").toLowerCase();if(which=="o"){this.animationParsed=a_string;}else{this.closeAnimationParsed=a_string;}return a_string;},setCloseAnimation:function(closeAnimation){this.closeAnimation=closeAnimation||this.closeAnimation;this._parseAnimation(this.closeAnimation,"c");},setAnimationSpeed:function(speed){this.animationSpeed=speed||this.animationSpeed;},columnClassParsed:"",setColumnClass:function(colClass){if(!this.useBootstrap){console.warn("cannot set columnClass, useBootstrap is set to false");return;}this.columnClass=colClass||this.columnClass;this._parseColumnClass(this.columnClass);this.$jconfirmBoxContainer.addClass(this.columnClassParsed);},setBoxWidth:function(){if(this.useBootstrap){console.warn("cannot set boxWidth, useBootstrap is set to true");return;}this.$jconfirmBox.css("width",this.boxWidth);},_parseColumnClass:function(colClass){colClass=colClass.toLowerCase();var p;switch(colClass){case"xl":case"xlarge":p="col-md-12";break;case"l":case"large":p="col-md-8 col-md-offset-2";break;case"m":case"medium":p="col-md-6 col-md-offset-3";break;case"s":case"small":p="col-md-4 col-md-offset-4";break;case"xs":case"xsmall":p="col-md-2 col-md-offset-5";break;default:p=colClass;}this.columnClassParsed=p;},initDraggable:function(){var that=this;var $t=this.$titleContainer;this.resetDrag();if(this.draggable){$t.addClass("jconfirm-hand");$t.on("mousedown",function(e){that.mouseX=e.clientX;that.mouseY=e.clientY;that.isDrag=true;});$(window).on("mousemove."+this._id,function(e){if(that.isDrag){that.movingX=e.clientX-that.mouseX+that.initialX;that.movingY=e.clientY-that.mouseY+that.initialY;that.setDrag();}});$(window).on("mouseup."+this._id,function(){if(that.isDrag){that.isDrag=false;that.initialX=that.movingX;that.initialY=that.movingY;}});}},resetDrag:function(){this.isDrag=false;this.initialX=0;this.initialY=0;this.movingX=0;this.movingY=0;this.movingXCurrent=0;this.movingYCurrent=0;this.mouseX=0;this.mouseY=0;this.$jconfirmBoxContainer.css("transform","translate("+0+"px, "+0+"px)");},setDrag:function(){if(!this.draggable){return;}this.alignMiddle=false;this._boxWidth=this.$jconfirmBox.outerWidth();var ww=$(window).width();var that=this;if(that.movingX%2==0||that.movingY%2==0){var tb=that._boxTopMargin-that.dragWindowGap;if(tb+that.movingY<0){that.movingY=-tb;}else{that.movingYCurrent=that.movingY;}var lb=(ww/2)-that._boxWidth/2;var rb=(ww/2)+(that._boxWidth/2)-that._boxWidth;rb-=that.dragWindowGap;lb-=that.dragWindowGap;if(lb+that.movingX<0){that.movingX=-lb;}else{if(rb-that.movingX<0){that.movingX=rb;}else{that.movingXCurrent=that.movingX;}}that.$jconfirmBoxContainer.css("transform","translate("+that.movingX+"px, "+that.movingY+"px)");}},_hash:function(a){var string=a.toString();var h=0;if(string.length==0){return h;}for(var i=0;i').html(that.buttons[key].text).addClass(that.buttons[key].btnClass).prop("disabled",that.buttons[key].isDisabled).css("display",that.buttons[key].isHidden?"none":"").click(function(e){e.preventDefault();var res=that.buttons[key].action.apply(that);that.onAction(key);that._stopCountDown();if(typeof res==="undefined"||res){that.close();}});that.buttons[key].el=button_element;that.buttons[key].setText=function(text){button_element.html(text);};that.buttons[key].addClass=function(className){button_element.addClass(className);};that.buttons[key].removeClass=function(className){button_element.removeClass(className);};that.buttons[key].disable=function(){that.buttons[key].isDisabled=true;button_element.prop("disabled",true);};that.buttons[key].enable=function(){that.buttons[key].isDisabled=false;button_element.prop("disabled",false);};that.buttons[key].show=function(){that.buttons[key].isHidden=false;button_element.css("display","");that.setDialogCenter();};that.buttons[key].hide=function(){that.buttons[key].isHidden=true;button_element.css("display","none");that.setDialogCenter();};that["$_"+key]=that["$$"+key]=button_element;that.$btnc.append(button_element);});if(total_buttons===0){this.$btnc.hide();}if(this.closeIcon===null&&total_buttons===0){this.closeIcon=true;}if(this.closeIcon){if(this.closeIconClass){var closeHtml='';this.$closeIcon.html(closeHtml);}this.$closeIcon.click(function(e){e.preventDefault();var buttonName=false;var shouldClose=false;var str;if(typeof that.closeIcon=="function"){str=that.closeIcon();}else{str=that.closeIcon;}if(typeof str=="string"&&typeof that.buttons[str]!="undefined"){buttonName=str;shouldClose=false;}else{if(typeof str=="undefined"||!!(str)==true){shouldClose=true;}else{shouldClose=false;}}if(buttonName){var btnResponse=that.buttons[buttonName].action.apply(that);shouldClose=(typeof btnResponse=="undefined")||!!(btnResponse);}if(shouldClose){that.close();}});this.$closeIcon.show();}else{this.$closeIcon.hide();}},setTitle:function(string,force){force=force||false;if(typeof string!=="undefined"){if(typeof string=="string"){this.title=string;}else{if(typeof string=="function"){if(typeof string.promise=="function"){console.error("Promise was returned from title function, this is not supported.");}var response=string();if(typeof response=="string"){this.title=response;}else{this.title=false;}}else{this.title=false;}}}if(this.isAjaxLoading&&!force){return;}this.$title.html(this.title||"");},setIcon:function(iconClass,force){force=force||false;if(typeof iconClass!=="undefined"){if(typeof iconClass=="string"){this.icon=iconClass;}else{if(typeof iconClass==="function"){var response=iconClass();if(typeof response=="string"){this.icon=response;}else{this.icon=false;}}else{this.icon=false;}}}if(this.isAjaxLoading&&!force){return;}this.$icon.html(this.icon?'':"");},setContentPrepend:function(string,force){this.contentParsed=string+this.contentParsed;if(this.isAjaxLoading&&!force){return;}this.$content.prepend(string);},setContentAppend:function(string,force){this.contentParsed=this.contentParsed+string;if(this.isAjaxLoading&&!force){return;}this.$content.append(string);},setContent:function(string,force){force=force||false;var that=this;this.contentParsed=(typeof string=="undefined")?this.contentParsed:string;if(this.isAjaxLoading&&!force){return;}this.$content.html(this.contentParsed);this.setDialogCenter();setTimeout(function(){that.$body.find("input[autofocus]:visible:first").focus();},100);},loadingSpinner:false,showLoading:function(disableButtons){this.loadingSpinner=true;this.$jconfirmBox.addClass("loading");if(disableButtons){this.$btnc.find("button").prop("disabled",true);}this.setDialogCenter();},hideLoading:function(enableButtons){this.loadingSpinner=false;this.$jconfirmBox.removeClass("loading");if(enableButtons){this.$btnc.find("button").prop("disabled",false);}this.setDialogCenter();},ajaxResponse:false,contentParsed:"",isAjax:false,isAjaxLoading:false,_parseContent:function(){var that=this;var e=" ";if(typeof this.content=="function"){var res=this.content.apply(this);if(typeof res=="string"){this.content=res;}else{if(typeof res=="object"&&typeof res.always=="function"){this.isAjax=true;this.isAjaxLoading=true;res.always(function(data,status,xhr){that.ajaxResponse={data:data,status:status,xhr:xhr};that._contentReady.resolve(data,status,xhr);if(typeof that.contentLoaded=="function"){that.contentLoaded(data,status,xhr);}});this.content=e;}else{this.content=e;}}}if(typeof this.content=="string"&&this.content.substr(0,4).toLowerCase()==="url:"){this.isAjax=true;this.isAjaxLoading=true;var u=this.content.substring(4,this.content.length);$.get(u).done(function(html){that.contentParsed=html;}).always(function(data,status,xhr){that.ajaxResponse={data:data,status:status,xhr:xhr};that._contentReady.resolve(data,status,xhr);if(typeof that.contentLoaded=="function"){that.contentLoaded(data,status,xhr);}});}if(!this.content){this.content=e;}if(!this.isAjax){this.contentParsed=this.content;this.setContent(this.contentParsed);that._contentReady.resolve();}},_stopCountDown:function(){clearInterval(this.autoCloseInterval);if(this.$cd){this.$cd.remove();}},_startCountDown:function(){var that=this;var opt=this.autoClose.split("|");if(opt.length!==2){console.error("Invalid option for autoClose. example 'close|10000'");return false;}var button_key=opt[0];var time=parseInt(opt[1]);if(typeof this.buttons[button_key]==="undefined"){console.error("Invalid button key '"+button_key+"' for autoClose");return false;}var seconds=Math.ceil(time/1000);this.$cd=$(' ('+seconds+")").appendTo(this["$_"+button_key]);this.autoCloseInterval=setInterval(function(){that.$cd.html(" ("+(seconds-=1)+") ");if(seconds<=0){that["$$"+button_key].trigger("click");that._stopCountDown();}},1000);},_getKey:function(key){switch(key){case 192:return"tilde";case 13:return"enter";case 16:return"shift";case 9:return"tab";case 20:return"capslock";case 17:return"ctrl";case 91:return"win";case 18:return"alt";case 27:return"esc";case 32:return"space";}var initial=String.fromCharCode(key);if(/^[A-z0-9]+$/.test(initial)){return initial.toLowerCase();}else{return false;}},reactOnKey:function(e){var that=this;var a=$(".jconfirm");if(a.eq(a.length-1)[0]!==this.$el[0]){return false;}var key=e.which;if(this.$content.find(":input").is(":focus")&&/13|32/.test(key)){return false;}var keyChar=this._getKey(key);if(keyChar==="esc"&&this.escapeKey){if(this.escapeKey===true){this.$scrollPane.trigger("click");}else{if(typeof this.escapeKey==="string"||typeof this.escapeKey==="function"){var buttonKey;if(typeof this.escapeKey==="function"){buttonKey=this.escapeKey();}else{buttonKey=this.escapeKey;}if(buttonKey){if(typeof this.buttons[buttonKey]==="undefined"){console.warn("Invalid escapeKey, no buttons found with key "+buttonKey);}else{this["$_"+buttonKey].trigger("click");}}}}}$.each(this.buttons,function(key,button){if(button.keys.indexOf(keyChar)!=-1){that["$_"+key].trigger("click");}});},_boxTopMargin:0,_boxBottomMargin:0,_boxWidth:0,setDialogCenter:function(){var contentHeight;var paneHeight;var style;contentHeight=0;paneHeight=0;if(this.$contentPane.css("display")!="none"){contentHeight=this.$content.outerHeight()||0;paneHeight=this.$contentPane.height()||0;}var children=this.$content.children();if(children.length!=0){var marginTopChild=parseInt(children.eq(0).css("margin-top"));if(marginTopChild){contentHeight+=marginTopChild;}}if(paneHeight==0){paneHeight=contentHeight;}var windowHeight=$(window).height();var boxHeight;boxHeight=(this.$body.outerHeight()-paneHeight)+contentHeight;var topMargin=(windowHeight-boxHeight)/2;if(boxHeight>(windowHeight-(this.offsetTop+this.offsetBottom))||!this.alignMiddle){style={"margin-top":this.offsetTop,"margin-bottom":this.offsetBottom};this._boxTopMargin=this.offsetTop;this._boxBottomMargin=this.offsetBottom;$("body").addClass("jconfirm-no-scroll-"+this._id);}else{style={"margin-top":topMargin,"margin-bottom":this.offsetBottom};this._boxTopMargin=topMargin;this._boxBottomMargin=this.offsetBottom;$("body").removeClass("jconfirm-no-scroll-"+this._id);}this.$contentPane.css({height:contentHeight}).scrollTop(0);this.$body.css(style);this.setDrag();},_unwatchContent:function(){clearInterval(this._timer);},close:function(){var that=this;if(typeof this.onClose==="function"){this.onClose();}this._unwatchContent();clearInterval(this.imageLoadInterval);$(window).unbind("resize."+this._id);$(window).unbind("keyup."+this._id);$(window).unbind("jcKeyDown."+this._id);if(this.draggable){$(window).unbind("mousemove."+this._id);$(window).unbind("mouseup."+this._id);this.$titleContainer.unbind("mousedown");}$("body").removeClass("jconfirm-no-scroll-"+this._id);this.$body.addClass(this.closeAnimationParsed);this.$jconfirmBg.addClass("jconfirm-bg-h");var closeTimer=(this.closeAnimation=="none")?1:this.animationSpeed;that.$el.removeClass(that.loadedClass);setTimeout(function(){that.$el.remove();var l=jconfirm.instances;var i=jconfirm.instances.length-1;for(i;i>=0;i--){if(jconfirm.instances[i]._id==that._id){jconfirm.instances.splice(i,1);}}if(!jconfirm.instances.length){if(that.scrollToPreviousElement&&jconfirm.lastFocused&&jconfirm.lastFocused.length&&$.contains(document,jconfirm.lastFocused[0])){var $lf=jconfirm.lastFocused;if(that.scrollToPreviousElementAnimate){var st=$(window).scrollTop();var ot=jconfirm.lastFocused.offset().top;var wh=$(window).height();if(!(ot>st&&ot<(st+wh))){var scrollTo=(ot-Math.round((wh/3)));$("html, body").animate({scrollTop:scrollTo},that.animationSpeed,"swing",function(){$lf.focus();});}else{$lf.focus();}}else{$lf.focus();}jconfirm.lastFocused=false;}}if(typeof that.onDestroy=="function"){that.onDestroy();}},closeTimer*0.4);return true;},open:function(){if(this.isOpen()){return false;}this._buildHTML();this._bindEvents();this._open();return true;},_open:function(){var that=this;if(typeof that.onOpenBefore=="function"){that.onOpenBefore();}this.$body.removeClass(this.animationParsed);this.$jconfirmBg.removeClass("jconfirm-bg-h");this.$body.focus();setTimeout(function(){that.$body.css(that._getCSS(that.animationSpeed,1));that.$body.css({"transition-property":that.$body.css("transition-property")+", margin"});that._modalReady.resolve();if(typeof that.onOpen==="function"){that.onOpen();}that.$el.addClass(that.loadedClass);},this.animationSpeed);},loadedClass:"jconfirm-open",isClosed:function(){return !this.$el||this.$el.css("display")==="";},isOpen:function(){return !this.isClosed();},toggle:function(){if(!this.isOpen()){this.open();}else{this.close();}}};jconfirm.instances=[];jconfirm.lastFocused=false;jconfirm.pluginDefaults={template:'
',title:"Hello",titleClass:"",type:"default",typeAnimated:true,draggable:false,alignMiddle:true,content:"Are you sure to continue?",buttons:{},defaultButtons:{ok:{action:function(){}},close:{action:function(){}}},contentLoaded:function(){},icon:"",lazyOpen:false,bgOpacity:null,theme:"light",animation:"zoom",closeAnimation:"scale",animationSpeed:400,animationBounce:1.2,escapeKey:true,rtl:false,container:"body",containerFluid:false,backgroundDismiss:false,backgroundDismissAnimation:"shake",autoClose:false,closeIcon:null,closeIconClass:false,watchInterval:100,columnClass:"col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1",boxWidth:"50%",scrollToPreviousElement:true,scrollToPreviousElementAnimate:true,useBootstrap:true,offsetTop:50,offsetBottom:50,dragWindowGap:15,bootstrapClasses:{container:"container",containerFluid:"container-fluid",row:"row"},onContentReady:function(){},onOpenBefore:function(){},onOpen:function(){},onClose:function(){},onDestroy:function(){},onAction:function(){}};var keyDown=false;$(window).on("keydown",function(e){if(!keyDown){var $target=$(e.target);var pass=false;if($target.closest(".jconfirm-box").length){pass=true;}if(pass){$(window).trigger("jcKeyDown");}keyDown=true;}});$(window).on("keyup",function(e){keyDown=false;});})(jQuery,window); \ No newline at end of file diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index d4071432..7acdb485 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -1,15 +1,3 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. JavaScript code in this file should be added after the last require_* statement. -// -// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details -// about supported directives. -// //= require jquery //= require tether //= require bootstrap @@ -49,7 +37,7 @@ $(document).ready(function(){ control_button(order_status); var customer_id=$(this).find(".customer-id").text(); - show_customer_details(customer_id); + //show_customer_details(customer_id); $("#re-print").val(unique_id); @@ -304,49 +292,9 @@ $(document).ready(function(){ $(this).addClass('selected-item'); }); + // $(".orders").on('click', function(){ + // var dining_id = $(this).attr("data-id"); + // window.location.href = '/origami/' + dining_id; + // }) + }); - -/* Button Control by Status */ -function control_button(order_status){ - if(order_status=="billed"){ - $("#customer").prop('disabled', false); - $("#request_bills").prop('disabled', true); - $("#discount").prop('disabled', false); - $("#pay-bill").prop('disabled', false); - $("#re-print").prop('disabled', true); - } - else if(order_status=="new") { - $("#customer").prop('disabled', false); - $("#request_bills").prop('disabled', false); - $("#discount").prop('disabled', true); - $("#pay-bill").prop('disabled', true); - $("#re-print").prop('disabled', true); - }else if(order_status=="completed"){ - $("#re-print").prop('disabled', false); - } - else { - $("#customer").prop('disabled', true); - $("#request_bills").prop('disabled', true); - $("#discount").prop('disabled', true); - $("#pay-bill").prop('disabled', true); - $("#re-print").prop('disabled', true); - } - -} - -/* For Receipt - Update Balance */ -function update_balance(){ - var discount_type = $('#discount-type').val(); - var discount_amount = $('#discount-amount').val(); - var sub_total = $('#order-sub-total').text(); - var tax = $('#order-Tax').text(); - - // For Percentage Discount - if(discount_type == 1){ - discount_amount=(sub_total*discount_amount)/100; - } - - var total = (parseFloat(sub_total) + parseFloat(tax)) - discount_amount; - $('#order-discount').text(discount_amount); - $('#order-grand-total').text(total); -} diff --git a/app/assets/javascripts/origami_bk.js b/app/assets/javascripts/origami_bk.js new file mode 100644 index 00000000..d4071432 --- /dev/null +++ b/app/assets/javascripts/origami_bk.js @@ -0,0 +1,352 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require tether +//= require bootstrap +//= require jquery_ujs +//= require turbolinks +//= require cable +//= require jquery-ui +//= require bootstrap-datepicker + +$(document).ready(function(){ + // auto refresh every 60 seconds + // setTimeout(function(){ + // window.location.reload(1); + // }, 60000); + + // For selected order return + var order_status = ""; + order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim(); + + // Enable/Disable Button + control_button(order_status); + + $(".orders").on('click', function(){ + $("#order-sub-total").text(''); + // $("#order-food").text(''); + // $("#order-beverage").text(''); + $("#order-discount").text(''); + $("#order-Tax").text(''); + $("#order-grand-total").text(''); + + var zone_name=$(this).find(".orders-table").text(); + var receipt_no=$(this).find(".orders-receipt-no").text(); + var unique_id = $(this).find(".orders-id").text(); + var order_status=$(this).find(".orders-order-status").text().trim(); + + // Enable/Disable Button + control_button(order_status); + + var customer_id=$(this).find(".customer-id").text(); + show_customer_details(customer_id); + + $("#re-print").val(unique_id); + + var cashier=""; + var receipt_date=""; + var sub_total=0.0; + var discount_amount=0; + var tax_amount=0; + var grand_total_amount=0; + + $("#order-title").text("ORDER DETAILS - " + zone_name); + // clear order items + $("#order-items-table").children("tbody").empty(); + + // AJAX call for order + $.ajax({ + type: "POST", + url: "/origami/" + unique_id, + data: { 'booking_id' : unique_id }, + success:function(result){ + for (i = 0; i < result.length; i++) { + var data = JSON.stringify(result[i]); + var parse_data = JSON.parse(data); + var show_date = ""; + + // Receipt Header + receipt_no = result[i].receipt_no; + cashier = result[i].cashier_name; + if(result[i].receipt_date != null){ + receipt_date = new Date(result[i].receipt_date); + show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes() + } + + //Receipt Charges + sub_total += parseFloat(parse_data.price); + + discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount; + tax_amount = parse_data.tax_amount; + grand_total_amount = parse_data.grand_total_amount; + + // Ordered Items + var order_items_rows = "" + + "" + parse_data.item_name + "" + + "" + parse_data.qty + "" + + "" + parse_data.price + "" + + ""; + + $("#order-items-table").children("tbody").append(order_items_rows); + } + + // Cashier Info + $("#receipt_no").text(receipt_no); + $("#cashier").text(cashier == null ? "" : cashier); + $("#receipt_date").text(show_date); + + // Payment Info + $("#order-sub-total").text(sub_total); + // $("#order-food").text(''); + // $("#order-beverage").text(''); + $("#order-discount").text(discount_amount); + $("#order-Tax").text(tax_amount); + $("#order-grand-total").text(grand_total_amount); + } + }); + // End AJAX Call + + $('.orders').removeClass('selected-item'); + $(this).addClass('selected-item'); + }); + + // Bill Request + $('#request_bills').click(function() { + var order_id=$(".selected-item").find(".orders-id").text().substr(0,16); + if(order_id!=""){ + window.location.href = '/origami/' + order_id + '/request_bills' + } + else { + alert("Please select an order!"); + } + return false; + }); + + // Discount for Payment + $('#discount').click(function() { + var order_id=$(".selected-item").find(".orders-id").text().substr(0,16); + + if(order_id!=""){ + window.location.href = '/origami/' + order_id + '/discount' + } + else { + alert("Please select an order!"); + } + + return false; + }); + + // Pay Discount for Payment + $("#pay-discount").on('click', function(e){ + e.preventDefault(); + var sale_id = $('#sale-id').text(); + var sale_item_id = $('.selected-item').attr('id').substr(0,16); + var sub_total = $('#order-sub-total').text(); + var grand_total = $('#order-grand-total').text(); + var discount_type = $('#discount-type').val(); + var discount_value = $('#discount-amount').val(); + var discount_amount = discount_value; + var ajax_url = "/origami/" + sale_id + "/discount"; + + if(sale_item_id != null){ + ajax_url = "/origami/" + sale_item_id + "/discount"; + sub_total = $("#"+sale_item_id).children().find("#item-total-price").text(); + } + + // For Percentage Discount + if(discount_type == 1){ + discount_amount=(sub_total*discount_value)/100; + } + + var params = {'sale_id': sale_id, 'sale_item_id': sale_item_id, 'grand_total' : grand_total, 'discount_type':discount_type, 'discount_value':discount_value, 'discount_amount':discount_amount}; + $.ajax({ + type: "POST", + url: ajax_url, + data: params, + success:function(result){ } + }); + }); + + + // Payment for Bill + $('#pay-bill').click(function() { + var sale_id=$(".selected-item").find(".orders-id").text().substr(0,16); + if(sale_id!=""){ + window.location.href = '/origami/sale/'+ sale_id + "/payment" + } + else { + alert("Please select an order!"); + } + + return false; + }); + + $('#customer').click(function() { + var sale = $(".selected-item").find(".orders-id").text().substr(0,16); + if (sale.substring(0, 3)=="SAL") { + var sale_id = sale + }else{ + var sale_id = $(".selected-item").find(".order-cid").text(); + } + window.location.href = '/origami/'+ sale_id + "/customers" + + return false; + }); + + $('#re-print').click(function() { + var sale_id = $(".selected-item").find(".orders-id").text().substr(0,16); + + window.location.href = '/origami/'+ sale_id + "/reprint" + + return false; + }); + + function show_customer_details(customer_id){ + + if(window.location.pathname.substring(0, 12) == "/origami/SAL"){ + var url = customer_id+"/get_customer/" + }else{ + var url = "origami/"+customer_id+"/get_customer/" + } + + $('.customer_detail').removeClass('hide'); + + //Start Ajax + $.ajax({ + type: "GET", + url: url, + data: {}, + dataType: "json", + success: function(data) { + $("#customer_name").text(data["customer"].name); + if (data["response_data"]["data"].length) { + $.each(data["response_data"]["data"], function (i) { + if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ + var balance = data["response_data"]["data"][i]["balance"]; + if (data["response_data"]["status"]==true) { + $('.rebate_amount').removeClass('hide'); + row = + '' + data["response_data"]["data"][i]["accountable_type"] +'' + +'' + balance + ''; + + $(".rebate_amount").html(row); + } + + } + }); + }else{ + $('.rebate_amount').addClass('hide'); + } + } + }); + //End Ajax + } + + /* For Receipt - Calculate discount or tax */ + $('.cashier_number').on('click', function(event){ + if(event.handled !== true) { + var original_value=0; + original_value = $('#discount-amount').val(); + + var input_type = $(this).attr("data-type"); + + switch (input_type) { + case 'num': + var input_value = $(this).attr("data-value"); + if (original_value == "0.0"){ + $('#discount-amount').val(input_value); + update_balance(); + } + else{ + $('#discount-amount').val(original_value + '' + input_value); + update_balance(); + } + break; + + case 'add': + var input_value = $(this).attr("data-value"); + amount = parseInt(input_value); + $('#discount-amount').val(amount); + $('#discount-type').val(1); + update_balance(); + break; + + case 'del' : + var discount_text=$('#discount-amount').val(); + $('#discount-amount').val(discount_text.substr(0,discount_text.length-1)); + update_balance(); + break; + + case 'clr': + $('#discount-amount').val("0.0"); + update_balance(); + break; + } + + event.handled = true; + } else { + return false; + } + }); + + $('.discount-item-row').on('click',function(){ + $('.discount-item-row').removeClass('selected-item'); + $(this).addClass('selected-item'); + }); + +}); + +/* Button Control by Status */ +function control_button(order_status){ + if(order_status=="billed"){ + $("#customer").prop('disabled', false); + $("#request_bills").prop('disabled', true); + $("#discount").prop('disabled', false); + $("#pay-bill").prop('disabled', false); + $("#re-print").prop('disabled', true); + } + else if(order_status=="new") { + $("#customer").prop('disabled', false); + $("#request_bills").prop('disabled', false); + $("#discount").prop('disabled', true); + $("#pay-bill").prop('disabled', true); + $("#re-print").prop('disabled', true); + }else if(order_status=="completed"){ + $("#re-print").prop('disabled', false); + } + else { + $("#customer").prop('disabled', true); + $("#request_bills").prop('disabled', true); + $("#discount").prop('disabled', true); + $("#pay-bill").prop('disabled', true); + $("#re-print").prop('disabled', true); + } + +} + +/* For Receipt - Update Balance */ +function update_balance(){ + var discount_type = $('#discount-type').val(); + var discount_amount = $('#discount-amount').val(); + var sub_total = $('#order-sub-total').text(); + var tax = $('#order-Tax').text(); + + // For Percentage Discount + if(discount_type == 1){ + discount_amount=(sub_total*discount_amount)/100; + } + + var total = (parseFloat(sub_total) + parseFloat(tax)) - discount_amount; + $('#order-discount').text(discount_amount); + $('#order-grand-total').text(total); +} diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss index 8ddc1605..9ab3730c 100644 --- a/app/assets/stylesheets/CRM.scss +++ b/app/assets/stylesheets/CRM.scss @@ -23,3 +23,17 @@ .assign .text-muted{ color: #fff !important; } +.red{ + color: #fff !important; + background-color: red; +} +.green{ + color: #fff !important; + background-color: green; +} +.required abbr{ + color: red !important; +} +.jconfirm-box-container{ + margin-left:-40px !important +} \ No newline at end of file diff --git a/app/assets/stylesheets/jquery-confirm.scss b/app/assets/stylesheets/jquery-confirm.scss new file mode 100644 index 00000000..3c16dc8d --- /dev/null +++ b/app/assets/stylesheets/jquery-confirm.scss @@ -0,0 +1,10 @@ +/*! + * jquery-confirm v3.2.3 (http://craftpip.github.io/jquery-confirm/) + * Author: boniface pereira + * Website: www.craftpip.com + * Contact: hey@craftpip.com + * + * Copyright 2013-2017 jquery-confirm + * Licensed under MIT (https://github.com/craftpip/jquery-confirm/blob/master/LICENSE) + */@-webkit-keyframes + jconfirm-spin{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes jconfirm-spin{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}body[class*=jconfirm-no-scroll-]{overflow:hidden!important}.jconfirm{position:fixed;top:0;left:0;right:0;bottom:0;z-index:99999999;font-family:inherit;overflow:hidden}.jconfirm .jconfirm-bg{position:fixed;top:0;left:0;right:0;bottom:0;-webkit-transition:opacity .4s;transition:opacity .4s}.jconfirm .jconfirm-bg.jconfirm-bg-h{opacity:0!important}.jconfirm .jconfirm-scrollpane{position:fixed;top:0;left:0;right:0;bottom:0;overflow-y:auto;-webkit-perspective:500px;perspective:500px;-webkit-perspective-origin:center;perspective-origin:center}.jconfirm .jconfirm-box{background:white;border-radius:4px;position:relative;outline:0;padding:15px 15px 0;overflow:hidden;margin-left:auto;margin-right:auto}@-webkit-keyframes type-blue{1%,100%{border-color:#3498db}50%{border-color:#5faee3}}@keyframes type-blue{1%,100%{border-color:#3498db}50%{border-color:#5faee3}}@-webkit-keyframes type-green{1%,100%{border-color:#2ecc71}50%{border-color:#54d98c}}@keyframes type-green{1%,100%{border-color:#2ecc71}50%{border-color:#54d98c}}@-webkit-keyframes type-red{1%,100%{border-color:#e74c3c}50%{border-color:#ed7669}}@keyframes type-red{1%,100%{border-color:#e74c3c}50%{border-color:#ed7669}}@-webkit-keyframes type-orange{1%,100%{border-color:#f1c40f}50%{border-color:#f4d03f}}@keyframes type-orange{1%,100%{border-color:#f1c40f}50%{border-color:#f4d03f}}@-webkit-keyframes type-purple{1%,100%{border-color:#9b59b6}50%{border-color:#b07cc6}}@keyframes type-purple{1%,100%{border-color:#9b59b6}50%{border-color:#b07cc6}}@-webkit-keyframes type-dark{1%,100%{border-color:#34495e}50%{border-color:#46627f}}@keyframes type-dark{1%,100%{border-color:#34495e}50%{border-color:#46627f}}.jconfirm .jconfirm-box.jconfirm-type-animated{-webkit-animation-duration:2s;animation-duration:2s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite}.jconfirm .jconfirm-box.jconfirm-type-blue{border-top:solid 7px #3498db;-webkit-animation-name:type-blue;animation-name:type-blue}.jconfirm .jconfirm-box.jconfirm-type-green{border-top:solid 7px #2ecc71;-webkit-animation-name:type-green;animation-name:type-green}.jconfirm .jconfirm-box.jconfirm-type-red{border-top:solid 7px #e74c3c;-webkit-animation-name:type-red;animation-name:type-red}.jconfirm .jconfirm-box.jconfirm-type-orange{border-top:solid 7px #f1c40f;-webkit-animation-name:type-orange;animation-name:type-orange}.jconfirm .jconfirm-box.jconfirm-type-purple{border-top:solid 7px #9b59b6;-webkit-animation-name:type-purple;animation-name:type-purple}.jconfirm .jconfirm-box.jconfirm-type-dark{border-top:solid 7px #34495e;-webkit-animation-name:type-dark;animation-name:type-dark}.jconfirm .jconfirm-box.loading{height:120px}.jconfirm .jconfirm-box.loading:before{content:'';position:absolute;left:0;background:white;right:0;top:0;bottom:0;border-radius:10px;z-index:1}.jconfirm .jconfirm-box.loading:after{opacity:.6;content:'';height:30px;width:30px;border:solid 3px transparent;position:absolute;left:50%;margin-left:-15px;border-radius:50%;-webkit-animation:jconfirm-spin 1s infinite linear;animation:jconfirm-spin 1s infinite linear;border-bottom-color:dodgerblue;top:50%;margin-top:-15px;z-index:2}.jconfirm .jconfirm-box div.jconfirm-closeIcon{height:20px;width:20px;position:absolute;top:5px;right:5px;cursor:pointer;opacity:.6;text-align:center;-webkit-transition:opacity .3s ease-in;transition:opacity .3s ease-in;font-size:27px!important;line-height:14px!important;display:none}.jconfirm .jconfirm-box div.jconfirm-closeIcon:empty{display:none}.jconfirm .jconfirm-box div.jconfirm-closeIcon .fa{font-size:16px}.jconfirm .jconfirm-box div.jconfirm-closeIcon .glyphicon{font-size:16px}.jconfirm .jconfirm-box div.jconfirm-closeIcon .zmdi{font-size:16px}.jconfirm .jconfirm-box div.jconfirm-closeIcon:hover{opacity:1}.jconfirm .jconfirm-box div.jconfirm-title-c{display:block;font-size:22px;line-height:20px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.jconfirm .jconfirm-box div.jconfirm-title-c.jconfirm-hand{cursor:move}.jconfirm .jconfirm-box div.jconfirm-title-c .jconfirm-icon-c{font-size:inherit;padding-bottom:15px;display:inline-block;vertical-align:middle}.jconfirm .jconfirm-box div.jconfirm-title-c .jconfirm-icon-c i{vertical-align:middle}.jconfirm .jconfirm-box div.jconfirm-title-c .jconfirm-icon-c:empty{display:none}.jconfirm .jconfirm-box div.jconfirm-title-c .jconfirm-title{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;font-size:inherit;font-family:inherit;display:inline-block;vertical-align:middle;padding-bottom:15px}.jconfirm .jconfirm-box div.jconfirm-title-c .jconfirm-title:empty{display:none}.jconfirm .jconfirm-box div.jconfirm-content-pane{margin-bottom:15px;height:auto;-webkit-transition:height .4s ease-in;transition:height .4s ease-in;display:inline-block;width:100%;position:relative;overflow:hidden}.jconfirm .jconfirm-box div.jconfirm-content-pane .jconfirm-content img{max-width:100%;height:auto}.jconfirm .jconfirm-box div.jconfirm-content-pane .jconfirm-content:empty{display:none}.jconfirm .jconfirm-box .jconfirm-buttons{padding-bottom:11px}.jconfirm .jconfirm-box .jconfirm-buttons>button{margin-bottom:4px;margin-left:2px;margin-right:2px}.jconfirm .jconfirm-box .jconfirm-buttons button{display:inline-block;padding:6px 12px;font-size:14px;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;border-radius:4px;min-height:1em;outline:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transition:opacity .1s ease,background-color .1s ease,color .1s ease,box-shadow .1s ease,background .1s ease;transition:opacity .1s ease,background-color .1s ease,color .1s ease,box-shadow .1s ease,background .1s ease;-webkit-tap-highlight-color:transparent;border:0;background-image:none}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-blue{background-color:#3498db;color:#FFF;text-shadow:none;-webkit-transition:background .2s;transition:background .2s}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-blue:hover{background-color:#2980b9;color:#FFF}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-green{background-color:#2ecc71;color:#FFF;text-shadow:none;-webkit-transition:background .2s;transition:background .2s}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-green:hover{background-color:#27ae60;color:#FFF}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-red{background-color:#e74c3c;color:#FFF;text-shadow:none;-webkit-transition:background .2s;transition:background .2s}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-red:hover{background-color:#c0392b;color:#FFF}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-orange{background-color:#f1c40f;color:#FFF;text-shadow:none;-webkit-transition:background .2s;transition:background .2s}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-orange:hover{background-color:#f39c12;color:#FFF}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-default{background-color:#ecf0f1;color:#000;text-shadow:none;-webkit-transition:background .2s;transition:background .2s}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-default:hover{background-color:#bdc3c7;color:#000}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-purple{background-color:#9b59b6;color:#FFF;text-shadow:none;-webkit-transition:background .2s;transition:background .2s}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-purple:hover{background-color:#8e44ad;color:#FFF}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-dark{background-color:#34495e;color:#FFF;text-shadow:none;-webkit-transition:background .2s;transition:background .2s}.jconfirm .jconfirm-box .jconfirm-buttons button.btn-dark:hover{background-color:#2c3e50;color:#FFF}.jconfirm .jconfirm-box.jconfirm-type-red .jconfirm-title-c .jconfirm-icon-c{color:#e74c3c!important}.jconfirm .jconfirm-box.jconfirm-type-blue .jconfirm-title-c .jconfirm-icon-c{color:#3498db!important}.jconfirm .jconfirm-box.jconfirm-type-green .jconfirm-title-c .jconfirm-icon-c{color:#2ecc71!important}.jconfirm .jconfirm-box.jconfirm-type-purple .jconfirm-title-c .jconfirm-icon-c{color:#9b59b6!important}.jconfirm .jconfirm-box.jconfirm-type-orange .jconfirm-title-c .jconfirm-icon-c{color:#f1c40f!important}.jconfirm .jconfirm-box.jconfirm-type-dark .jconfirm-title-c .jconfirm-icon-c{color:#34495e!important}.jconfirm .jconfirm-clear{clear:both}.jconfirm.jconfirm-rtl{direction:rtl}.jconfirm.jconfirm-rtl div.jconfirm-closeIcon{left:5px;right:auto}.jconfirm.jconfirm-white .jconfirm-bg,.jconfirm.jconfirm-light .jconfirm-bg{background-color:#444;opacity:.2}.jconfirm.jconfirm-white .jconfirm-box,.jconfirm.jconfirm-light .jconfirm-box{box-shadow:0 2px 6px rgba(0,0,0,0.2);border-radius:5px}.jconfirm.jconfirm-white .jconfirm-box .jconfirm-title-c .jconfirm-icon-c,.jconfirm.jconfirm-light .jconfirm-box .jconfirm-title-c .jconfirm-icon-c{margin-right:8px;margin-left:0}.jconfirm.jconfirm-white .jconfirm-box .jconfirm-buttons,.jconfirm.jconfirm-light .jconfirm-box .jconfirm-buttons{float:right}.jconfirm.jconfirm-white .jconfirm-box .jconfirm-buttons button,.jconfirm.jconfirm-light .jconfirm-box .jconfirm-buttons button{text-transform:uppercase;font-size:14px;font-weight:bold;text-shadow:none}.jconfirm.jconfirm-white .jconfirm-box .jconfirm-buttons button.btn-default,.jconfirm.jconfirm-light .jconfirm-box .jconfirm-buttons button.btn-default{box-shadow:none;color:#333}.jconfirm.jconfirm-white .jconfirm-box .jconfirm-buttons button.btn-default:hover,.jconfirm.jconfirm-light .jconfirm-box .jconfirm-buttons button.btn-default:hover{background:#ddd}.jconfirm.jconfirm-white.jconfirm-rtl .jconfirm-title-c .jconfirm-icon-c,.jconfirm.jconfirm-light.jconfirm-rtl .jconfirm-title-c .jconfirm-icon-c{margin-left:8px;margin-right:0}.jconfirm.jconfirm-black .jconfirm-bg,.jconfirm.jconfirm-dark .jconfirm-bg{background-color:darkslategray;opacity:.4}.jconfirm.jconfirm-black .jconfirm-box,.jconfirm.jconfirm-dark .jconfirm-box{box-shadow:0 2px 6px rgba(0,0,0,0.2);background:#444;border-radius:5px;color:white}.jconfirm.jconfirm-black .jconfirm-box .jconfirm-title-c .jconfirm-icon-c,.jconfirm.jconfirm-dark .jconfirm-box .jconfirm-title-c .jconfirm-icon-c{margin-right:8px;margin-left:0}.jconfirm.jconfirm-black .jconfirm-box .jconfirm-buttons,.jconfirm.jconfirm-dark .jconfirm-box .jconfirm-buttons{float:right}.jconfirm.jconfirm-black .jconfirm-box .jconfirm-buttons button,.jconfirm.jconfirm-dark .jconfirm-box .jconfirm-buttons button{border:0;background-image:none;text-transform:uppercase;font-size:14px;font-weight:bold;text-shadow:none;-webkit-transition:background .1s;transition:background .1s;color:white}.jconfirm.jconfirm-black .jconfirm-box .jconfirm-buttons button.btn-default,.jconfirm.jconfirm-dark .jconfirm-box .jconfirm-buttons button.btn-default{box-shadow:none;color:#fff;background:0}.jconfirm.jconfirm-black .jconfirm-box .jconfirm-buttons button.btn-default:hover,.jconfirm.jconfirm-dark .jconfirm-box .jconfirm-buttons button.btn-default:hover{background:#666}.jconfirm.jconfirm-black.jconfirm-rtl .jconfirm-title-c .jconfirm-icon-c,.jconfirm.jconfirm-dark.jconfirm-rtl .jconfirm-title-c .jconfirm-icon-c{margin-left:8px;margin-right:0}.jconfirm .jconfirm-box.hilight.jconfirm-hilight-shake{-webkit-animation:shake .82s cubic-bezier(0.36,0.07,0.19,0.97) both;animation:shake .82s cubic-bezier(0.36,0.07,0.19,0.97) both;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.jconfirm .jconfirm-box.hilight.jconfirm-hilight-glow{-webkit-animation:glow .82s cubic-bezier(0.36,0.07,0.19,0.97) both;animation:glow .82s cubic-bezier(0.36,0.07,0.19,0.97) both;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}@-webkit-keyframes shake{10%,90%{-webkit-transform:translate3d(-2px,0,0);transform:translate3d(-2px,0,0)}20%,80%{-webkit-transform:translate3d(4px,0,0);transform:translate3d(4px,0,0)}30%,50%,70%{-webkit-transform:translate3d(-8px,0,0);transform:translate3d(-8px,0,0)}40%,60%{-webkit-transform:translate3d(8px,0,0);transform:translate3d(8px,0,0)}}@keyframes shake{10%,90%{-webkit-transform:translate3d(-2px,0,0);transform:translate3d(-2px,0,0)}20%,80%{-webkit-transform:translate3d(4px,0,0);transform:translate3d(4px,0,0)}30%,50%,70%{-webkit-transform:translate3d(-8px,0,0);transform:translate3d(-8px,0,0)}40%,60%{-webkit-transform:translate3d(8px,0,0);transform:translate3d(8px,0,0)}}@-webkit-keyframes glow{0%,100%{box-shadow:0 0 3px red}50%{box-shadow:0 0 30px red}}@keyframes glow{0%,100%{box-shadow:0 0 3px red}50%{box-shadow:0 0 30px red}}.jconfirm{-webkit-perspective:400px;perspective:400px}.jconfirm .jconfirm-box{opacity:1;-webkit-transition-property:all;transition-property:all}.jconfirm .jconfirm-box.jconfirm-animation-top,.jconfirm .jconfirm-box.jconfirm-animation-left,.jconfirm .jconfirm-box.jconfirm-animation-right,.jconfirm .jconfirm-box.jconfirm-animation-bottom,.jconfirm .jconfirm-box.jconfirm-animation-opacity,.jconfirm .jconfirm-box.jconfirm-animation-zoom,.jconfirm .jconfirm-box.jconfirm-animation-scale,.jconfirm .jconfirm-box.jconfirm-animation-none,.jconfirm .jconfirm-box.jconfirm-animation-rotate,.jconfirm .jconfirm-box.jconfirm-animation-rotatex,.jconfirm .jconfirm-box.jconfirm-animation-rotatey,.jconfirm .jconfirm-box.jconfirm-animation-scaley,.jconfirm .jconfirm-box.jconfirm-animation-scalex{opacity:0}.jconfirm .jconfirm-box.jconfirm-animation-rotate{-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.jconfirm .jconfirm-box.jconfirm-animation-rotatex{-webkit-transform:rotateX(90deg);transform:rotateX(90deg);-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center}.jconfirm .jconfirm-box.jconfirm-animation-rotatexr{-webkit-transform:rotateX(-90deg);transform:rotateX(-90deg);-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center}.jconfirm .jconfirm-box.jconfirm-animation-rotatey{-webkit-transform:rotatey(90deg);-ms-transform:rotatey(90deg);transform:rotatey(90deg);-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center}.jconfirm .jconfirm-box.jconfirm-animation-rotateyr{-webkit-transform:rotatey(-90deg);-ms-transform:rotatey(-90deg);transform:rotatey(-90deg);-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center}.jconfirm .jconfirm-box.jconfirm-animation-scaley{-webkit-transform:scaley(1.5);-ms-transform:scaley(1.5);transform:scaley(1.5);-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center}.jconfirm .jconfirm-box.jconfirm-animation-scalex{-webkit-transform:scalex(1.5);-ms-transform:scalex(1.5);transform:scalex(1.5);-webkit-transform-origin:center;-ms-transform-origin:center;transform-origin:center}.jconfirm .jconfirm-box.jconfirm-animation-top{-webkit-transform:translate(0px,-100px);-ms-transform:translate(0px,-100px);transform:translate(0px,-100px)}.jconfirm .jconfirm-box.jconfirm-animation-left{-webkit-transform:translate(-100px,0px);-ms-transform:translate(-100px,0px);transform:translate(-100px,0px)}.jconfirm .jconfirm-box.jconfirm-animation-right{-webkit-transform:translate(100px,0px);-ms-transform:translate(100px,0px);transform:translate(100px,0px)}.jconfirm .jconfirm-box.jconfirm-animation-bottom{-webkit-transform:translate(0px,100px);-ms-transform:translate(0px,100px);transform:translate(0px,100px)}.jconfirm .jconfirm-box.jconfirm-animation-zoom{-webkit-transform:scale(1.2);-ms-transform:scale(1.2);transform:scale(1.2)}.jconfirm .jconfirm-box.jconfirm-animation-scale{-webkit-transform:scale(0.5);-ms-transform:scale(0.5);transform:scale(0.5)}.jconfirm .jconfirm-box.jconfirm-animation-none{visibility:hidden}.jconfirm.jconfirm-supervan .jconfirm-bg{background-color:rgba(54,70,93,0.95)}.jconfirm.jconfirm-supervan .jconfirm-box{background-color:transparent}.jconfirm.jconfirm-supervan .jconfirm-box.jconfirm-type-blue{border:0}.jconfirm.jconfirm-supervan .jconfirm-box.jconfirm-type-green{border:0}.jconfirm.jconfirm-supervan .jconfirm-box.jconfirm-type-red{border:0}.jconfirm.jconfirm-supervan .jconfirm-box.jconfirm-type-orange{border:0}.jconfirm.jconfirm-supervan .jconfirm-box.jconfirm-type-purple{border:0}.jconfirm.jconfirm-supervan .jconfirm-box.jconfirm-type-dark{border:0}.jconfirm.jconfirm-supervan .jconfirm-box div.jconfirm-closeIcon{color:white}.jconfirm.jconfirm-supervan .jconfirm-box div.jconfirm-title-c{text-align:center;color:white;font-size:28px;font-weight:normal}.jconfirm.jconfirm-supervan .jconfirm-box div.jconfirm-title-c>*{padding-bottom:25px}.jconfirm.jconfirm-supervan .jconfirm-box div.jconfirm-title-c .jconfirm-icon-c{margin-right:8px;margin-left:0}.jconfirm.jconfirm-supervan .jconfirm-box div.jconfirm-content-pane{margin-bottom:25px}.jconfirm.jconfirm-supervan .jconfirm-box div.jconfirm-content{text-align:center;color:white}.jconfirm.jconfirm-supervan .jconfirm-box .jconfirm-buttons{text-align:center}.jconfirm.jconfirm-supervan .jconfirm-box .jconfirm-buttons button{font-size:16px;border-radius:2px;background:#303f53;text-shadow:none;border:0;color:white;padding:10px;min-width:100px}.jconfirm.jconfirm-supervan.jconfirm-rtl .jconfirm-box div.jconfirm-title-c .jconfirm-icon-c{margin-left:8px;margin-right:0}.jconfirm.jconfirm-material .jconfirm-bg{background-color:rgba(0,0,0,0.67)}.jconfirm.jconfirm-material .jconfirm-box{background-color:white;box-shadow:0 7px 8px -4px rgba(0,0,0,0.2),0 13px 19px 2px rgba(0,0,0,0.14),0 5px 24px 4px rgba(0,0,0,0.12);padding:30px 25px 10px 25px}.jconfirm.jconfirm-material .jconfirm-box .jconfirm-title-c .jconfirm-icon-c{margin-right:8px;margin-left:0}.jconfirm.jconfirm-material .jconfirm-box div.jconfirm-closeIcon{color:rgba(0,0,0,0.87)}.jconfirm.jconfirm-material .jconfirm-box div.jconfirm-title-c{color:rgba(0,0,0,0.87);font-size:22px;font-weight:bold}.jconfirm.jconfirm-material .jconfirm-box div.jconfirm-content{color:rgba(0,0,0,0.87)}.jconfirm.jconfirm-material .jconfirm-box .jconfirm-buttons{text-align:right}.jconfirm.jconfirm-material .jconfirm-box .jconfirm-buttons button{text-transform:uppercase;font-weight:500}.jconfirm.jconfirm-material.jconfirm-rtl .jconfirm-title-c .jconfirm-icon-c{margin-left:8px;margin-right:0}.jconfirm.jconfirm-bootstrap .jconfirm-bg{background-color:rgba(0,0,0,0.21)}.jconfirm.jconfirm-bootstrap .jconfirm-box{background-color:white;box-shadow:0 3px 8px 0 rgba(0,0,0,0.2);border:solid 1px rgba(0,0,0,0.4);padding:15px 0 0}.jconfirm.jconfirm-bootstrap .jconfirm-box .jconfirm-title-c .jconfirm-icon-c{margin-right:8px;margin-left:0}.jconfirm.jconfirm-bootstrap .jconfirm-box div.jconfirm-closeIcon{color:rgba(0,0,0,0.87)}.jconfirm.jconfirm-bootstrap .jconfirm-box div.jconfirm-title-c{color:rgba(0,0,0,0.87);font-size:22px;font-weight:bold;padding-left:15px;padding-right:15px}.jconfirm.jconfirm-bootstrap .jconfirm-box div.jconfirm-content{color:rgba(0,0,0,0.87);padding:0 15px}.jconfirm.jconfirm-bootstrap .jconfirm-box .jconfirm-buttons{text-align:right;padding:10px;margin:-5px 0 0;border-top:solid 1px #ddd;overflow:hidden;border-radius:0 0 4px 4px}.jconfirm.jconfirm-bootstrap .jconfirm-box .jconfirm-buttons button{font-weight:500}.jconfirm.jconfirm-bootstrap.jconfirm-rtl .jconfirm-title-c .jconfirm-icon-c{margin-left:8px;margin-right:0}.jconfirm.jconfirm-modern .jconfirm-bg{background-color:slategray;opacity:.6}.jconfirm.jconfirm-modern .jconfirm-box{background-color:white;box-shadow:0 7px 8px -4px rgba(0,0,0,0.2),0 13px 19px 2px rgba(0,0,0,0.14),0 5px 24px 4px rgba(0,0,0,0.12);padding:30px 30px 15px}.jconfirm.jconfirm-modern .jconfirm-box div.jconfirm-closeIcon{color:rgba(0,0,0,0.87);top:15px;right:15px}.jconfirm.jconfirm-modern .jconfirm-box div.jconfirm-title-c{color:rgba(0,0,0,0.87);font-size:24px;font-weight:bold;text-align:center;margin-bottom:10px}.jconfirm.jconfirm-modern .jconfirm-box div.jconfirm-title-c .jconfirm-icon-c{-webkit-transition:-webkit-transform .5s;transition:transform .5s;-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0);display:block;margin-right:0;margin-left:0;margin-bottom:10px;font-size:69px;color:#aaa}.jconfirm.jconfirm-modern .jconfirm-box div.jconfirm-content{text-align:center;font-size:15px;color:#777;margin-bottom:25px}.jconfirm.jconfirm-modern .jconfirm-box .jconfirm-buttons{text-align:center}.jconfirm.jconfirm-modern .jconfirm-box .jconfirm-buttons button{font-weight:bold;text-transform:uppercase;-webkit-transition:background .1s;transition:background .1s;padding:10px 20px}.jconfirm.jconfirm-modern .jconfirm-box .jconfirm-buttons button+button{margin-left:4px}.jconfirm.jconfirm-modern.jconfirm-open .jconfirm-box .jconfirm-title-c .jconfirm-icon-c{-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1)} \ No newline at end of file diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 71a9915e..6b350bf1 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -9,6 +9,7 @@ // min-height: 75rem; // padding-top: 4.5rem; // } + .others-payment{ line-height:100px; text-align:center; @@ -41,17 +42,50 @@ .pay{ width: 98%; - height:211px; + height:211px; line-height:211px; text-align:center; font-size:20px; color:white; } +.payment{ + height:70px;line-height:70px;align:center;color:white;font-size:16px;margin-bottom:1px; +} + +.cash-color{ + background-color:#80CBC4; +} + +.credit-color{ + background-color:#FFCCBC; +} + +.other-payment-color{ + background-color:#E1BEE7; +} + .cashier_number:hover{ background:#A9F5F2; } +.action-btn { + height: 60px; + margin-bottom: 5px; +} + +.bottom-5 { + margin-bottom: 5px; +} + +.fluid { + width: 100%; +} + +.style2 { + border-top: 3px double #8c8b8b; +} + .long{ width:49%; } @@ -69,6 +103,11 @@ background-color: blue !important; } +.selected-account { + color: #fff !important; + background-color: blue !important; +} + /* Reciept Style */ #order-charges-table td { border-top: none !important; @@ -89,6 +128,13 @@ text-align: right; } +.display-none{ + display: none; +} + +.text-white{ + color: #fff; +} /* Colors */ .purple { @@ -103,6 +149,10 @@ background-color: #009900 } +.orange{ + background-color: #FF8C00 +} + .left{ margin-left:1px; } diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index cd2f8b47..2b9f2834 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -9,15 +9,17 @@ class Api::BillController < Api::ApiController #create Bill by Booking ID if (params[:booking_id]) booking = Booking.find(params[:booking_id]) - if booking - if booking.sale_id.nil? - @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee) - else - @status = true - @sale_id = booking.sale_id + + if booking + if booking.sale_id.nil? + @sale = Sale.new + @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee) + else + @status = true + @sale_id = booking.sale_id + end end - end + elsif (params[:order_id]) @sale = Sale.new @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee) diff --git a/app/controllers/api/bookings_controller.rb b/app/controllers/api/bookings_controller.rb index 401cd4a8..24973d63 100644 --- a/app/controllers/api/bookings_controller.rb +++ b/app/controllers/api/bookings_controller.rb @@ -6,11 +6,9 @@ class Api::BookingsController < Api::ApiController end def show - @booking = Booking.find(params[:id]) + booking = Booking.find(params[:id]) + if booking.dining_facility_id.to_i == params[:table_id].to_i + @booking = booking + end end - - # private - # def Bookings_params - # params.permit(:id, :order_id) - # end end diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index c383fafb..b42de7c5 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -7,11 +7,45 @@ class Api::OrdersController < Api::ApiController order = Order.find(params[:order_id]) order.order_items end + def get_order order = Order.find(params[:order_id]) order.order_items end + # API - This api will retrive current booking for android with table or room id + def view_orders + booking_id = params[:booking_id] + table_id = params[:table_id] + if Booking.exists?(booking_id) + booking = Booking.find(booking_id) + + if booking + if booking.dining_facility_id.to_i == table_id.to_i + @booking = booking + else + table = DiningFacility.find(table_id) + booking = table.get_current_booking + if booking + if booking.dining_facility_id.to_i == table_id.to_i + @booking = booking + end + end + end + end + else + puts "only table" + table = DiningFacility.find(table_id) + booking = table.get_current_booking + puts booking + if booking + if booking.dining_facility_id.to_i == table_id.to_i + @booking = booking + end + end + end + end + # Description # This API allow new order creation # Input Params @@ -38,18 +72,50 @@ class Api::OrdersController < Api::ApiController if !params["booking_id"].nil? # check booking id is already completed. booking = Booking.find(params[:booking_id]) - if !booking.sale_id.nil? - if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" - @order.new_booking = true + if booking + if booking.dining_facility_id.to_i == params[:table_id].to_i + if !booking.sale_id.nil? + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" + @order.new_booking = true + else + @order.new_booking = false + @order.booking_id = params[:booking_id] + end + else + @order.new_booking = false + @order.booking_id = params[:booking_id] + puts "booking sale is null" + end else - @order.new_booking = false - @order.booking_id = params[:booking_id] + # booking.table id not equal current table + table = DiningFacility.find(params[:table_id]) + if table + booking = table.get_current_booking + if booking + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" + @order.new_booking = true + else + @order.new_booking = false + @order.booking_id = booking.booking_id + end + end + end end - else - @order.new_booking = false - @order.booking_id = params[:booking_id] - puts "booking sale is null" - end + end #booking exists + else + #no booking id + table = DiningFacility.find(params[:table_id]) + if table + booking = table.get_current_booking + if booking + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" + @order.new_booking = true + else + @order.new_booking = false + @order.booking_id = booking.booking_id + end + end + end end @status, @booking = @order.generate diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bfde77c9..50278d71 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,6 +8,16 @@ class ApplicationController < ActionController::Base #this is base api base controller to need to inherit. #all token authentication must be done here #response format must be set to JSON + + # rescue_from CanCan::AccessDenied do |exception| + # flash[:warning] = exception.message + # redirect_to root_path + # end + + def current_user + @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] + end + def current_company begin return Company.first diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 290f6ca1..646f6475 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -7,23 +7,19 @@ class Crm::CustomersController < BaseCrmController filter = params[:filter] if filter.nil? - @crm_customers = Customer.order("customer_id").page(params[:page]) - #@products = Product.order("name").page(params[:page]).per(5) + @crm_customers = Customer.all else @crm_customers = Customer.search(filter) end #@crm_customers = Customer.all - @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) + @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) @crm_customer = Customer.new + @count_customer = Customer.count_customer # if flash["errors"] # @crm_customer.valid? # end - # @membership = Customer.get_member_group - # if @membership["status"] == true - # @member_group = @membership["data"] - # end respond_to do |format| format.html # index.html.erb format.json { render json: @crm_customers } @@ -51,14 +47,7 @@ class Crm::CustomersController < BaseCrmController #get customer amount @customer = Customer.find(params[:id]) - response = Customer.get_member_account(@customer) - - if(response["status"] == true) - @membership = response["data"] - else - @membership = 0 - end - + @response = Customer.get_membership_transactions(@customer) #end customer amount end @@ -87,6 +76,8 @@ class Crm::CustomersController < BaseCrmController phone = customer_params[:contact_no] email = customer_params[:email] dob = customer_params[:date_of_birth] + address = customer_params[:address] + nrc = customer_params[:nrc_no] member_group_id = params[:member_group_id] membership = MembershipSetting.find_by_membership_type("paypar_url") @@ -95,14 +86,18 @@ class Crm::CustomersController < BaseCrmController auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + begin response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, - dob: dob, + dob: dob,address: address,nrc:nrc, member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } ) + rescue Net::OpenTimeout + response = { status: false } + end if response["status"] == true @@ -151,6 +146,8 @@ end phone = customer_params[:contact_no] email = customer_params[:email] dob = customer_params[:date_of_birth] + address = customer_params[:address] + nrc = customer_params[:nrc_no] id = @crm_customer.membership_id member_group_id = params[:member_group_id] @@ -159,22 +156,24 @@ end merchant_uid = memberaction.merchant_account_id.to_s auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - + begin response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, - dob: dob, + dob: dob,address: address,nrc:nrc, id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } ) - + rescue Net::OpenTimeout + response = { status: false } + end format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' } format.json { render :show, status: :ok, location: @crm_customer } else - flash[:errors] = @crm_customers.errors + flash[:errors] = @crm_customer.errors format.html { redirect_to crm_customers_path} format.json { render json: @crm_customer.errors, status: :unprocessable_entity } end @@ -201,6 +200,7 @@ end # Never trust parameters from the scary internet, only allow the white list through. def customer_params - params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth) + params.require(:customer).permit(:name, :company, :contact_no, :email, + :date_of_birth,:salution,:gender,:nrc_no,:address,:card_no) end end diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 251b0781..734793b3 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -84,12 +84,15 @@ class Crm::DiningQueuesController < BaseCrmController queue = DiningQueue.find(params[:id]) table_id = params[:table_id] - queue.update_attributes(dining_facility_id: table_id,status:"Assign") - DiningFacility.find(table_id).update_attributes(status: "occupied") - respond_to do |format| - format.html { redirect_to crm_dining_queues_path, notice: 'Table was successfully assigned.' } - format.json { head :no_content } - end + status = queue.update_attributes(dining_facility_id: table_id,status:"Assign") + status = DiningFacility.find(table_id).update_attributes(status: "occupied") + + + if status == true + render json: JSON.generate({:status => true , notice: 'Dining queue was successfully assigned .'}) + else + render json: JSON.generate({:status => false, :error_message => "Record not found"}) + end end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 14d79857..b4d564f2 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -30,14 +30,14 @@ class Oqs::HomeController < BaseOqsController dining = DiningFacility.find_by_name(table_name); # oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) # if status == "" - # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi| - # oi = OrderItem.find_by_item_code(aoi.item_code) - # items.push(oi) + # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi| + # oi = OrderItem.find_by_item_code(aoi.item_code) + # items.push(oi) # end # else - # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi| - # oi = OrderItem.find_by_item_code(aoi.item_code) - # items.push(oi) + # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi| + # oi = OrderItem.find_by_item_code(aoi.item_code) + # items.push(oi) # end # end @@ -49,7 +49,7 @@ class Oqs::HomeController < BaseOqsController end end - # booking_id = dining.get_new_booking + # booking_id = dining.get_new_booking # BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo| # order=Order.find(bo.order_id); # order.order_items.each do |oi| @@ -81,6 +81,8 @@ class Oqs::HomeController < BaseOqsController # Query for OQS with status def queue_items_query(status) + puts status + puts "put what is status" # AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") # .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id # left join dining_facilities as df on df.zone_id = oqpz.zone_id @@ -88,9 +90,9 @@ class Oqs::HomeController < BaseOqsController # left join orders as od ON od.order_id = assigned_order_items.order_id # left join order_items as odt ON odt.item_code = assigned_order_items.item_code # left join customers as cus ON cus.customer_id = od.customer_id") - # .where("assigned_order_items.delivery_status = #{status}") + # .where("assigned_order_items.delivery_status = #{status}") # .group("assigned_order_items.assigned_order_item_id") - # .order("odt.item_name DESC") + # .order("odt.item_name DESC") AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id left join orders as od ON od.order_id = assigned_order_items.order_id @@ -99,7 +101,7 @@ class Oqs::HomeController < BaseOqsController left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join bookings as bk on bk.booking_id = bo.booking_id left join dining_facilities as df on df.id = bk.dining_facility_id") - .where("assigned_order_items.delivery_status = #{status}") - .group("assigned_order_items.assigned_order_item_id") + .where("assigned_order_items.delivery_status = #{status}") + .group("assigned_order_items.assigned_order_item_id,oqs.station_name,oqs.is_active,df.name,odt.item_code,odt.item_name,odt.price, odt.qty, odt.item_order_by,cus.name,odt.created_at") end end diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index f5f7db9e..6c0a4c8d 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -6,52 +6,91 @@ class Origami::DiscountsController < BaseOrigamiController if Sale.exists?(sale_id) @sale_data = Sale.find(sale_id) end + + @accounts = Account.all + end + + #discount page show from origami index with selected order + def create + sale_id = params[:sale_id] + discount_items = JSON.parse(params[:discount_items]) + overall_discount = params[:overall_discount] + sub_total = params[:sub_total] + + if Sale.exists?(sale_id) + sale = Sale.find(sale_id) + sale.total_discount = overall_discount.to_f + sale.total_amount = sub_total.to_f + sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax; + sale.save + if discount_items.length > 0 + #save sale item for discount + discount_items.each do |di| + puts di + origin_sale_item = SaleItem.find(di["id"]) + sale_item = SaleItem.new + + sale_item.sale_id = sale_id + sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id + sale_item.product_name = di["name"] + sale_item.remark = "Discount" + + sale_item.qty = 1 + sale_item.unit_price = di["price"] + sale_item.taxable_price = di["price"] + sale_item.is_taxable = 0 + + sale_item.price = di["price"] + sale_item.save + end + end + end end #discount for selected order - def create - sale_id = params[:sale_id] - sale_item_id = params[:sale_item_id] - discount_type = params[:discount_type] - discount_value = params[:discount_value] - discount_amount = params[:discount_amount] - grand_total = params[:grand_total] - product_name = "Overall Discount" + # def create + # sale_id = params[:sale_id] + # sale_item_id = params[:sale_item_id] + # discount_type = params[:discount_type] + # discount_value = params[:discount_value] + # discount_amount = params[:discount_amount] + # grand_total = params[:grand_total] + # product_name = "Overall Discount" - if discount_type == 0 - remark="Discount " + discount_amount + " as net" - else - remark="Discount " + discount_amount + " as percentage" - end + # if discount_type == 0 + # remark="Discount " + discount_amount + " as net" + # else + # remark="Discount " + discount_amount + " as percentage" + # end - #update discount for sale - sale = Sale.find(sale_id) - sale.total_discount = sale.total_discount + discount_amount.to_f - sale.grand_total = grand_total - sale.save + # #update discount for sale + # sale = Sale.find(sale_id) + # sale.total_discount = sale.total_discount + discount_amount.to_f + # sale.grand_total = grand_total + # sale.save - #save sale item for discount - if sale_item_id != nil - origin_sale_item = SaleItem.find(sale_item_id) - product_name = origin_sale_item.product_name + "-Disocunt" - end - sale_item = SaleItem.new + # #save sale item for discount + # if sale_item_id != nil + # origin_sale_item = SaleItem.find(sale_item_id) + # product_name = origin_sale_item.product_name + "-Disocunt" + # end + # sale_item = SaleItem.new - #pull - sale_item.sale_id = sale_id - sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id - sale_item.product_name = product_name - sale_item.remark = remark + # #pull + # sale_item.sale_id = sale_id + # sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id + # sale_item.product_name = product_name + # sale_item.remark = remark - sale_item.qty = 1 - sale_item.unit_price = (0-discount_amount.to_f) - sale_item.taxable_price = discount_amount - sale_item.is_taxable = 0 + # sale_item.qty = 1 + # sale_item.unit_price = (0-discount_amount.to_f) + # sale_item.taxable_price = discount_amount + # sale_item.is_taxable = 0 - sale_item.price = sale_item.qty * sale_item.unit_price - sale_item.save + # sale_item.price = sale_item.qty * sale_item.unit_price + # sale_item.save - redirect_to origami_path(sale_id) - end + # redirect_to origami_path(sale_id) + # end end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 1aca9b2d..4c35a918 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -1,84 +1,54 @@ class Origami::HomeController < BaseOrigamiController + before_action :set_dining, only: [:show] + def index - if params[:booking_id] != nil - type=params[:booking_id].split('-')[0]; - # Sale - if type == "SAL" - @selected_item = Sale.find(params[:booking_id]) - @selected_item_type="Sale" - # Booking - else - @selected_item = Order.find(params[:booking_id]) - @selected_item_type="Order" - end - end - - @completed_orders = Order.get_completed_order() - @booking_orders = Order.get_booking_order_table() - @booking_rooms = Order.get_booking_order_rooms() - @orders = Order.get_orders() + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') + @complete = Sale.complete_sale + @orders = Order.all.order('date desc') end - def item_show - selection(params[:booking_id],1) - end + # origami table detail + def show + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') + @complete = Sale.complete_sale + @orders = Order.all.order('date desc') + @status_order = "" + @status_sale = "" + @sale_array = Array.new + @dining.bookings.each do |booking| + if booking.sale_id.nil? + @order_items = Array.new + booking.booking_orders.each do |booking_order| - def selection(selected_id, is_ajax) - str = [] - type=selected_id.split('-')[0]; - # Sale - if type == "SAL" - @order_details = SaleItem.get_order_items_details(params[:booking_id]) - @order_details.each do |ord_detail| - str.push(ord_detail) - end - # Booking - else - @order_details = OrderItem.get_order_items_details(params[:booking_id]) - @order_details.each do |ord_detail| - str.push(ord_detail) - end - end - - if is_ajax == 1 - render :json => str.to_json - else - str + order = Order.find(booking_order.order_id) + @obj_order = order + @date = order.created_at + order.order_items.each do |item| + @order_items.push(item) + end + end + @status_order = 'order' + else + sale = Sale.find(booking.sale_id) + if sale.sale_status != "completed" + @sale_array.push(sale) + if @status_order == 'order' + @status_order = 'sale' + end + @date = sale.created_at + @status_sale = 'sale' + @obj_sale = sale + end + end end end - def update_sale_by_customer +private - id = params[:sale_id][0,3] - if(id == "SAL") - sale = Sale.find(params[:sale_id]) - else - sale = Order.find(params[:sale_id]) - end - - status = sale.update_attributes(customer_id: params[:customer_id]) - - if status == true - render json: JSON.generate({:status => true}) - else - render json: JSON.generate({:status => false, :error_message => "Record not found"}) - - end - end - - def get_customer - - @customer = Customer.find(params[:customer_id]) - - response = Customer.get_member_account(@customer) - - respond_to do |format| - format.js do - render :json => { - :response_data => response.as_json, - :customer => @customer} - end - end - end +def set_dining + @dining = DiningFacility.find(params[:dining_id]) +end end diff --git a/app/controllers/origami/home_controller_bk.rb b/app/controllers/origami/home_controller_bk.rb new file mode 100644 index 00000000..1aca9b2d --- /dev/null +++ b/app/controllers/origami/home_controller_bk.rb @@ -0,0 +1,84 @@ +class Origami::HomeController < BaseOrigamiController + def index + if params[:booking_id] != nil + type=params[:booking_id].split('-')[0]; + # Sale + if type == "SAL" + @selected_item = Sale.find(params[:booking_id]) + @selected_item_type="Sale" + # Booking + else + @selected_item = Order.find(params[:booking_id]) + @selected_item_type="Order" + end + end + + @completed_orders = Order.get_completed_order() + @booking_orders = Order.get_booking_order_table() + @booking_rooms = Order.get_booking_order_rooms() + @orders = Order.get_orders() + end + + def item_show + selection(params[:booking_id],1) + end + + def selection(selected_id, is_ajax) + str = [] + type=selected_id.split('-')[0]; + # Sale + if type == "SAL" + @order_details = SaleItem.get_order_items_details(params[:booking_id]) + @order_details.each do |ord_detail| + str.push(ord_detail) + end + # Booking + else + @order_details = OrderItem.get_order_items_details(params[:booking_id]) + @order_details.each do |ord_detail| + str.push(ord_detail) + end + end + + if is_ajax == 1 + render :json => str.to_json + else + str + end + end + + def update_sale_by_customer + + id = params[:sale_id][0,3] + if(id == "SAL") + sale = Sale.find(params[:sale_id]) + else + sale = Order.find(params[:sale_id]) + end + + status = sale.update_attributes(customer_id: params[:customer_id]) + + if status == true + render json: JSON.generate({:status => true}) + else + render json: JSON.generate({:status => false, :error_message => "Record not found"}) + + end + end + + def get_customer + + @customer = Customer.find(params[:customer_id]) + + response = Customer.get_member_account(@customer) + + respond_to do |format| + format.js do + render :json => { + :response_data => response.as_json, + :customer => @customer} + end + end + end + +end diff --git a/app/controllers/origami/moveroom_controller.rb b/app/controllers/origami/moveroom_controller.rb new file mode 100644 index 00000000..c51fcbb1 --- /dev/null +++ b/app/controllers/origami/moveroom_controller.rb @@ -0,0 +1,37 @@ +class Origami::MoveroomController < BaseOrigamiController + + def move_dining + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') + @complete = Sale.all + @orders = Order.all.order('date desc') + + @status_order = "" + @dining = DiningFacility.find(params[:dining_id]) + @dining.bookings.each do |booking| + if booking.sale_id.nil? + @order_items = Array.new + booking.booking_orders.each do |booking_order| + order = Order.find(booking_order.order_id) + @obj_order = order + @date = order.created_at + order.order_items.each do |item| + @order_items.push(item) + end + end + @status_order = 'order' + else + sale = Sale.find(booking.sale_id) + if sale.sale_status != "completed" + if @status_order == 'order' + @status_order = 'sale' + end + @date = sale.created_at + @status_sale = 'sale' + @obj_sale = sale + end + end + end + end + +end diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb new file mode 100644 index 00000000..cc6281ce --- /dev/null +++ b/app/controllers/origami/movetable_controller.rb @@ -0,0 +1,53 @@ +class Origami::MovetableController < BaseOrigamiController + + def move_dining + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') + @complete = Sale.all + @orders = Order.all.order('date desc') + @dining = DiningFacility.find(params[:dining_id]) + + @status_order = "" + @status_sale = "" + @sale_array = Array.new + @dining.bookings.each do |booking| + if booking.sale_id.nil? + @order_items = Array.new + booking.booking_orders.each do |booking_order| + + order = Order.find(booking_order.order_id) + @obj_order = order + @date = order.created_at + order.order_items.each do |item| + @order_items.push(item) + end + end + @status_order = 'order' + else + sale = Sale.find(booking.sale_id) + if sale.sale_status != "completed" + @sale_array.push(sale) + if @status_order == 'order' + @status_order = 'sale' + end + @date = sale.created_at + @status_sale = 'sale' + @obj_sale = sale + end + end + end + end + + def moving + change_to = params[:change_to] #new + change_from = params[:change_from] #original + bookings = Booking.where('dining_facility_id=?',change_from) + booking_array = Array.new + bookings.each do | booking | + if booking.sale_id.nil? || booking.sale.sale_status != 'completed' + booking_array.push(booking) + end + end + @get_type = Booking.update_dining_facility(booking_array,change_to,change_from) + end +end diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb new file mode 100644 index 00000000..e5eb2808 --- /dev/null +++ b/app/controllers/origami/orders_controller.rb @@ -0,0 +1,15 @@ +class Origami::OrdersController < BaseOrigamiController + + def show + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') + @complete = Sale.complete_sale + @orders = Order.all.order('status desc') + @order = Order.find(params[:order_id]) + sale_order = SaleOrder.find_by_order_id(@order.order_id) + if sale_order + sale = Sale.find(sale_order.sale_id) + @sale_status = sale.sale_status + end + end +end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 44de8eb2..38225fae 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -10,11 +10,13 @@ class Origami::PaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) sale_payment = SalePayment.new - sale_payment.process_payment(saleObj, @user, cash, "cash") + sale_payment.process_payment(saleObj, @user, cash, "cash") + + rebate_amount = nil unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) - + rebate_amount = Customer.get_membership_transactions(customer) # get member information member_info = Customer.get_member_account(customer) @@ -24,7 +26,7 @@ class Origami::PaymentsController < BaseOrigamiController food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount) end end @@ -88,7 +90,7 @@ class Origami::PaymentsController < BaseOrigamiController # get member information member_info = Customer.get_member_account(customer) - + rebate_amount = Customer.get_membership_transactions(customer) # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -96,7 +98,7 @@ class Origami::PaymentsController < BaseOrigamiController food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount) end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index e848366c..37eef687 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -4,8 +4,9 @@ class Origami::RequestBillsController < BaseOrigamiController @sale = Sale.new sale_order=SaleOrder.new - booking_id = params[:id] - check_booking = Booking.find_by_booking_id(booking_id) + order_id = params[:id] # order_id + bk_order = BookingOrder.find_by_order_id(order_id) + check_booking = Booking.find_by_booking_id(bk_order.booking_id) if check_booking.sale_id.nil? # Create Sale if it doesn't exist puts "current_login_employee" @@ -19,8 +20,11 @@ class Origami::RequestBillsController < BaseOrigamiController end unique_code = "ReceiptBillPdf" - customer= Customer.where('customer_id=' + @sale_data.customer_id) - + # customer= Customer.where('customer_id=' +.customer_id) + + customer= Customer.find( @sale_data.customer_id) + # get member information + member_info = Customer.get_member_account(customer) # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -31,7 +35,9 @@ class Origami::RequestBillsController < BaseOrigamiController food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total) - redirect_to origami_path(@sale_data.sale_id) + + printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total,member_info) + # redirect_to origami_path(@sale_data.sale_id) + end end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb new file mode 100644 index 00000000..56030d4f --- /dev/null +++ b/app/controllers/origami/rooms_controller.rb @@ -0,0 +1,32 @@ +class Origami::RoomsController < BaseOrigamiController + + def show + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') + @complete = Sale.complete_sale + @orders = Order.all.order('date desc') + @room = DiningFacility.find(params[:room_id]) + @room.bookings.each do |booking| + if booking.sale_id.nil? + @order_items = Array.new + booking.booking_orders.each do |booking_order| + order = Order.find(booking_order.order_id) + @obj = order + order.order_items.each do |item| + @order_items.push(item) + end + end + @status = 'order' + else + + sale = Sale.find(booking.sale_id) + if sale.sale_status != "completed" + @status = 'sale' + @obj = sale + end + end + end + end + + +end diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb new file mode 100644 index 00000000..b5200114 --- /dev/null +++ b/app/controllers/origami/sales_controller.rb @@ -0,0 +1,10 @@ +class Origami::SalesController < BaseOrigamiController + + def show + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') + @complete = Sale.complete_sale + @orders = Order.all.order('date desc') + @sale = Sale.find(params[:sale_id]) + end +end diff --git a/app/controllers/reports/daily_sale_controller.rb b/app/controllers/reports/daily_sale_controller.rb index 86e60702..6e1eb85a 100644 --- a/app/controllers/reports/daily_sale_controller.rb +++ b/app/controllers/reports/daily_sale_controller.rb @@ -1,23 +1,11 @@ class Reports::DailySaleController < BaseReportController def index - from, to = get_date_range_from_params + from, to ,report_type = get_date_range_from_params @sale_data = Sale.daily_sales_list(from,to) @tax = SaleTax.get_tax(from,to) end - - # @locations = Location.all - # branch,from, to, report_type = get_date_range_from_params - - # @location = Location.find_by_id(current_location) - # @sale_data = Sale.daily_sales_report(current_location,from,to) - # @tax = SaleT.get_tax(current_location,from,to) - - # if @sale_data.blank? && @tax.blank? && request.post? - # flash.now[:notice] = "No data available for selected filters" - # end - def show end diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 8569c051..86c8d981 100644 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -1,4 +1,5 @@ class Reports::ReceiptNoController < BaseReportController + def index from, to = get_date_range_from_params puts "from..." diff --git a/app/controllers/reports/sale_item_controller.rb b/app/controllers/reports/sale_item_controller.rb new file mode 100644 index 00000000..1da31aff --- /dev/null +++ b/app/controllers/reports/sale_item_controller.rb @@ -0,0 +1,14 @@ +class Reports::SaleItemController < BaseReportController + + def index + + from, to, report_type = get_date_range_from_params + + @sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type) + end + + def show + + end + +end \ No newline at end of file diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index 31e93d97..dc7093f3 100644 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -1,6 +1,8 @@ class Settings::EmployeesController < ApplicationController + # load_and_authorize_resource before_action :set_employee, only: [:show, :edit, :update, :destroy] + # GET /employees # GET /employees.json def index diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index bc7766a7..5a540ddb 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -27,6 +27,7 @@ class Settings::OrderQueueStationsController < ApplicationController def create @settings_order_queue_station = OrderQueueStation.new(settings_order_queue_station_params) @settings_order_queue_station.created_by = current_login_employee.name + @settings_order_queue_station.processing_items = "[]" respond_to do |format| if @settings_order_queue_station.save format.html { redirect_to settings_order_queue_stations_path, notice: 'Order queue station was successfully created.' } diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index fed62a34..0a069b1b 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -53,13 +53,7 @@ class Transactions::SalesController < ApplicationController #get customer amount @customer = Customer.find(@sale.customer_id) - response = Customer.get_member_account(@customer) - - if(response["status"] == true) - @membership = response["data"] - else - @membership = 0 - end + @response = Customer.get_membership_transactions(@customer) #end customer amount respond_to do |format| diff --git a/app/models/ability.rb b/app/models/ability.rb new file mode 100644 index 00000000..2b28ab61 --- /dev/null +++ b/app/models/ability.rb @@ -0,0 +1,33 @@ +class Ability + include CanCan::Ability + + def initialize(user) + user ||= Employee.new + + if user.role? :administrator + + can :manage, :all + + elsif user.role? :cashier + can :read, Order + can :update, Order + can :completed_order_item, Order + + can :read, Sale + can :update, Sale + + + elsif user.role? :accountant + + can :read, Order + can :update, Order + can :completed_order_item, Order + + can :read, Sale + can :update, Sale + can :manual_complete_sale, Sale + + end + + end +end \ No newline at end of file diff --git a/app/models/booking.rb b/app/models/booking.rb index 01cf0f46..79fbad4a 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -10,6 +10,19 @@ class Booking < ApplicationRecord has_many :booking_orders has_many :orders, :through => :booking_orders + def self.update_dining_facility(booking_arr, newd, old) + booking_arr.each do |booking| + booking.dining_facility_id = newd + booking.save + end + new_dining = DiningFacility.find(newd) + new_dining.make_occupied + old_dining = DiningFacility.find(old) + old_dining.make_available + + return new_dining.type + end + private def generate_custom_id self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI") diff --git a/app/models/booking_order.rb b/app/models/booking_order.rb index ddf5ed18..c9f748f0 100644 --- a/app/models/booking_order.rb +++ b/app/models/booking_order.rb @@ -1,5 +1,5 @@ class BookingOrder < ApplicationRecord - #primary key - need to be unique + #primary key - need to be unique belongs_to :booking belongs_to :order diff --git a/app/models/customer.rb b/app/models/customer.rb index de9846f2..4e25c9bc 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -6,9 +6,10 @@ class Customer < ApplicationRecord has_many :orders has_many :sales - validates_presence_of :name, :contact_no, :email + validates_presence_of :name, :contact_no, :email,:company,:card_no validates :contact_no, uniqueness: true validates :email, uniqueness: true + validates :card_no, uniqueness: true paginates_per 50 @@ -36,52 +37,52 @@ class Customer < ApplicationRecord end + def self.get_membership_transactions(customer) + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("get_member_transactions") + merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s +# urltest =self.url_exist?(url) + + begin + response = HTTParty.get(url, :body => { membership_id: customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + }, + :timeout => 10 + ) + rescue Net::OpenTimeout + response = { status: false } + end + + return response; + + end + def self.search(search) if search # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) - where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",) + where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%",) else find(:all) end end -# require "net/http" -# def self.url_exist?(url_string) -# url = URI.parse(url_string) - - -# req = Net::HTTP.new(url.host, url.port) -# puts "hhhhhhhhhhhh" -# puts req.to_json -# req.use_ssl = (url.scheme == 'https') -# puts "aaaaaaaaaaaa" -# puts req.use_ssl? -# path = url.path if url.path.present? -# puts "bbbbbbbbbbbbb" -# puts path -# res = req.request_head(path || '/') -# puts "cccccccccccccc" -# puts res.to_json -# puts "ddddddddd" -# puts res.kind_of?(Net::HTTPRedirection) -# if res.kind_of?(Net::HTTPRedirection) -# url_exist?(res['location']) # Go after any redirect and make sure you can access the redirected URL -# else -# ! %W(4 5).include?(res.code[0]) # Not from 4xx or 5xx families -# end -# rescue Errno::ENOENT -# false #false if can't find the server -# end - - - # def self.search(search) - # where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",) - # end - def lastest_invoices sales.where(:customer_id => self.id).order("created_at desc").limit(5) end + def self.count_customer + all = self.all.count+1 + count = all-2 + + end + + WALKIN = "CUS-000000000001" + TAKEAWAY = "CUS-000000000002" + private def generate_custom_id self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS") diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index 6f898989..abf39d7a 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -8,12 +8,21 @@ class DiningFacility < ApplicationRecord scope :active, -> {where(is_active: true)} + def make_available + self.status = 'available' + self.save + end + + def make_occupied + self.status = 'occupied' + self.save + end + def get_current_booking - puts "enter booking" - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) if booking.count > 0 then - return booking[0].booking_id + return booking[0] else return nil end @@ -21,10 +30,10 @@ class DiningFacility < ApplicationRecord def get_new_booking # query for new - # if status + # if status # to ask when req bill booking_status? booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id is null and checkout_at is null").limit(1) - # else + # else # booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id not null").limit(1) # end diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 89967e2e..50b70e66 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -24,6 +24,7 @@ class MenuItem < ApplicationRecord if (!mt_instance.nil?) menu_item = MenuItem.find(mt_instance.menu_item_id) menu_item_hash[:type] = menu_item.type + menu_item_hash[:account_id] = menu_item.account_id menu_item_hash[:item_code] = menu_item.item_code menu_item_hash[:item_instance_code] = mt_instance.item_instance_code menu_item_hash[:name] = menu_item.name.to_s + " - " + mt_instance.item_instance_name.to_s diff --git a/app/models/order.rb b/app/models/order.rb index a4328d76..78585b52 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -4,14 +4,14 @@ class Order < ApplicationRecord #primary key - need to be unique before_create :generate_custom_id before_create :set_order_date - + has_many :sale_orders belongs_to :customer has_many :order_items, autosave: true , inverse_of: :order has_many :assigned_order_items #internal references attributes for business logic control attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id - + scope :active, -> { where("date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } #Main Controller method to create new order - validate all inputs and generate new order # order_item : { # order_item_code : "", @@ -82,7 +82,7 @@ class Order < ApplicationRecord set_order_items end - OrderItem.processs_item(menu_item[:item_code], menu_item[:name], + OrderItem.processs_item(menu_item[:item_code], menu_item[:name], menu_item[:account_id], item[:quantity],menu_item[:price], item[:options], set_order_items, self.id, self.employee_name) @@ -231,7 +231,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id @@ -246,7 +246,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='completed'") - .group("sales.sale_id") + .group("sales.sale_id,bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") # For PG #bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id end @@ -262,7 +262,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 564aa939..2c9a9ba0 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -20,12 +20,13 @@ class OrderItem < ApplicationRecord # option_values : [], # sub_order_items : [], # } - def self.processs_item (item_code, menu_name, qty,price, options, set_menu_items, order_id, item_order_by) + def self.processs_item (item_code, menu_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by) orderitem = OrderItem.create do |oitem| oitem.order_id = order_id oitem.item_code = item_code oitem.item_name = menu_name + oitem.account_id = account_id oitem.qty = qty oitem.price = price oitem.options = options diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index bfef5588..969b9d44 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil) + def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount=nil) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info) + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info,rebate_amount) pdf.render_file "tmp/receipt_bill.pdf" self.print("tmp/receipt_bill.pdf") diff --git a/app/models/room.rb b/app/models/room.rb index d99708a3..87f232e9 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -1,3 +1,4 @@ class Room < DiningFacility + has_many :bookings, :foreign_key => 'dining_facility_id' end diff --git a/app/models/sale.rb b/app/models/sale.rb index 2ffb53ef..6b02e4c8 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -15,6 +15,15 @@ class Sale < ApplicationRecord has_many :bookings scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } + scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } + + REPORT_TYPE = { + "daily" => 0, + "monthly" => 1, + "yearly" => 2 + } + + SALE_STATUS_COMPLETED = "completed" def generate_invoice_from_booking(booking_id, requested_by) booking = Booking.find(booking_id) @@ -23,7 +32,7 @@ class Sale < ApplicationRecord if (booking) Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s #get all order attached to this booking and combine into 1 invoice - + booking.booking_orders.each do |order| if booking.sale_id status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by) @@ -132,6 +141,7 @@ class Sale < ApplicationRecord #pull sale_item.product_code = item.item_code sale_item.product_name = item.item_name + sale_item.account_id = item.account_id sale_item.remark = item.remark sale_item.qty = item.qty @@ -281,15 +291,15 @@ class Sale < ApplicationRecord end end - def self.daily_sales_list(from,to) + def self.daily_sales_list(from,to) payments_total = Sale.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date, - SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, - SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount, - SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount, - SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount, - SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount, - SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount, - SUM(case when (sale_payments.payment_method='credit') then sale_payments.payment_amount else 0 end) as credit_amount, + SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, + SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount, + SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount, + SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount, + SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount, + SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount, + SUM(case when (sale_payments.payment_method='credit') then sale_payments.payment_amount else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount") .joins("join (select * from sale_payments group by sale_payments.sale_id, sale_payments.payment_method) sale_payments on sale_payments.sale_id = sales.sale_id") .where("sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0", 'completed', from, to) @@ -304,27 +314,27 @@ class Sale < ApplicationRecord from_date = sale_date.beginning_of_day.utc - diff to_date = sale_date.end_of_day.utc - diff - total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total, - IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount, - IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount, + total_sale = Sale.select("IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total, + IFNULL(SUM(case when (sale_status='completed') then total_discount else 0 end),0) as total_discount, + IFNULL(SUM(case when (sale_status='void') then grand_total else 0 end),0) as void_amount, IFNULL(SUM(case when (sale_status='completed') then rounding_adjustment else 0 end),0) as rounding_adj") .where("(sale_status = ? OR sale_status = ?) AND receipt_date between ? and ? AND total_amount != 0", 'completed', 'void', from_date, to_date) - + total_sale.each do |sale| grand_total = sale.grand_total total_discount = sale.total_discount - void_amount = sale.void_amount - total = {:sale_date => pay.sale_date, + void_amount = sale.void_amount + total = {:sale_date => pay.sale_date, :mpu_amount => pay.mpu_amount, :master_amount => pay.master_amount, :visa_amount => pay.visa_amount, :jcb_amount => pay.jcb_amount, :paypar_amount => pay.paypar_amount, - :cash_amount => pay.cash_amount, - :credit_amount => pay.credit_amount, + :cash_amount => pay.cash_amount, + :credit_amount => pay.credit_amount, :foc_amount => pay.foc_amount, - :total_discount => total_discount, - :grand_total => grand_total, + :total_discount => total_discount, + :grand_total => grand_total, :void_amount => void_amount, :rounding_adj => sale.rounding_adj} daily_total.push(total) @@ -334,6 +344,40 @@ class Sale < ApplicationRecord return daily_total end +def self.get_by_range_by_saleitems(from,to,status,report_type) + + query = Sale.select(" + mi.item_code as code,(SUM(i.qty) * i.unit_price) as grand_total, + SUM(i.qty) as total_item," + + " i.unit_price as unit_price, + mi.name as product_name, + mc.name as menu_category_name, + mc.id as menu_category_id ") + .group('mi.id') + .order("mi.menu_category_id") + + query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id + JOIN menu_items mi ON i.product_code = mi.item_code" + + " JOIN menu_categories mc ON mc.id = mi.menu_category_id + JOIN employees ea ON ea.id = sales.cashier_id") + + + query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status) + + + + case report_type.to_i + when REPORT_TYPE["daily"] + return query + when REPORT_TYPE["monthly"] + + return query.group("MONTH(date)") + when REPORT_TYPE["yearly"] + return query.group("YEAR(date)") + end + +end + private def generate_custom_id diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index b872e3b0..eacdadb6 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -54,8 +54,8 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}" sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by) - - return true, self.sale + + return true, self.save else #record an payment in sale-audit remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]" @@ -67,7 +67,7 @@ class SalePayment < ApplicationRecord end def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid,auth_token) - # Control for Paypar Cloud + # Control for Paypar Cloud begin response = HTTParty.get(url, :body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, @@ -84,21 +84,24 @@ class SalePayment < ApplicationRecord def self.redeem(paypar_url,token,membership_id,received_amount,sale_id) membership_actions_data = MembershipAction.find_by_membership_type("redeem"); + if !membership_actions_data.nil? + url = paypar_url.to_s + membership_actions_data.gateway_url.to_s merchant_uid = membership_actions_data.merchant_account_id auth_token = membership_actions_data.auth_token campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"] sale_data = Sale.find_by_sale_id(sale_id) + if sale_data - # Control for Paypar Cloud + # Control for Paypar Cloud begin response = HTTParty.post(url, :body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' - }, + }, :timeout => 10 ) rescue Net::OpenTimeout @@ -199,6 +202,10 @@ class SalePayment < ApplicationRecord customer_data = Customer.find_by_customer_id(self.sale.customer_id) membership_setting = MembershipSetting.find_by_membership_type("paypar_url") membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id) + puts 'mmmmmmmmmmmmmmmmmmmmmmmmmmm' + puts membership_data.to_json + puts "amountttttttttttttttttttttt" + puts self.received_amount if membership_data["status"]==true self.payment_method = "paypar" self.payment_amount = self.received_amount @@ -238,10 +245,17 @@ class SalePayment < ApplicationRecord end def table_update_status(sale_obj) - booking = Booking.find_by_sale_id(sale_obj.id) + status = true + booking = Booking.find_by_sale_id(sale_obj.id) if booking table = DiningFacility.find(booking.dining_facility_id) - if table + bookings = table.bookings + bookings.each do |tablebooking| + if tablebooking.sale.sale_status != 'completed' + status = false + end + end + if status table.status = "available" table.save end @@ -250,7 +264,7 @@ class SalePayment < ApplicationRecord def rebat(sObj) rebate_prices = SaleItem.calculate_food_beverage(sObj.sale_items) - puts "rebate_prices" + puts "eeeeeeeeeeeeeeeeeeeeeeee" puts rebate_prices generic_customer_id = sObj.customer.membership_id if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0 @@ -274,7 +288,7 @@ class SalePayment < ApplicationRecord auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - # Control for Paypar Cloud + # Control for Paypar Cloud begin response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, receipt_no: receipt_no,auth_token:auth_token}.to_json, @@ -285,8 +299,8 @@ class SalePayment < ApplicationRecord rescue Net::OpenTimeout response = { status: false } end - - # puts response.to_json + return response + # puts response.to_json end end end diff --git a/app/models/table.rb b/app/models/table.rb index 31614e12..db953c27 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -1,4 +1,4 @@ class Table < DiningFacility has_many :dining_ins - + has_many :bookings, :foreign_key => 'dining_facility_id' end diff --git a/app/models/table_booking.rb b/app/models/table_booking.rb index 4b76f158..3f2b42d7 100644 --- a/app/models/table_booking.rb +++ b/app/models/table_booking.rb @@ -1,3 +1,2 @@ class TableBooking < Booking - end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index c1ba4936..bdeb58a3 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,6 +1,6 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width - def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil) + def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount = nil) self.page_width = 210 self.page_height = 2500 self.margin = 5 @@ -32,9 +32,13 @@ class ReceiptBillPdf < Prawn::Document line_items(sale_items, food_total, beverage_total) all_total(sale_data) + if member_info != nil - member_info(member_info) + member_info(member_info,customer_name,rebate_amount,sale_data) end + + customer(customer_name) + footer end @@ -60,6 +64,15 @@ class ReceiptBillPdf < Prawn::Document end move_down 5 + # y_position = cursor + # bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do + # text "Customer:", :size => self.item_font_size,:align => :left + # end + # bounding_box([self.label_width,y_position], :width =>self.item_width) do + # text "#{customer_name}" , :size => self.item_font_size,:align => :left + # end + # move_down 5 + y_position = cursor bounding_box([0, y_position], :width =>self.item_width) do text "Waiter: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left @@ -98,7 +111,7 @@ class ReceiptBillPdf < Prawn::Document text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "Total", :at =>[(self.item_width+self.price_width),y_position], :width => self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } @@ -128,7 +141,7 @@ class ReceiptBillPdf < Prawn::Document text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{total_price}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{total_price}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } move_down 3 end @@ -200,33 +213,111 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor move_down 5 bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Grand Total", :size => self.item_font_size,:align => :left + text "Grand Total", :size => self.header_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right + text "#{sale_data.grand_total}" , :size => self.header_font_size,:align => :right end move_down 5 - # stroke_horizontal_rule + + sale_payment(sale_data) + + end + + def sale_payment(sale_data) + + stroke_horizontal_rule + move_down 5 + SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment| + + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ payment.payment_amount }" , :size => self.item_font_size,:align => :right + end + move_down 5 + end + if sale_data.amount_received > 0 + y_position = cursor + move_down 5 + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Change Amount", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{sale_data.amount_changed}" , :size => self.item_font_size,:align => :right + end + move_down 5 + end + end # show member information - def member_info(member_info) + def member_info(member_info,customer_name,rebate_amount,sale_data) - move_down 7 + if rebate_amount != nil + + if rebate_amount["status"] == true + stroke_horizontal_rule + rebate_amount["data"].each do |res| + + if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate" + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Rebate Amount", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ res["rebate"] }" , :size => self.item_font_size,:align => :right + end + end + if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem" + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Redeem Amount", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ res["redeem"] }" , :size => self.item_font_size,:align => :right + end + end + + end + end + end if member_info["status"] == true member_info["data"].each do |res| - move_down 5 - y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{ res["accountable_type"] }", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right + if res["accountable_type"]== "RebateAccount" + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Current Balance", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right + end + end end end + + end + + def customer(customer_name) + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Customer Name", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ customer_name }" , :size => self.item_font_size,:align => :right + end end def footer diff --git a/app/views/api/bookings/show.json.jbuilder b/app/views/api/bookings/show.json.jbuilder index e1ebd5a9..a8236f05 100644 --- a/app/views/api/bookings/show.json.jbuilder +++ b/app/views/api/bookings/show.json.jbuilder @@ -1,4 +1,5 @@ if (@booking) + json.success true json.id @booking.booking_id json.status @booking.booking_status if Sale.exists?(@booking.sale_id) @@ -43,5 +44,6 @@ if (@booking) json.sub_total @total_amount json.commerical_tax @total_amount * 0.05 json.total @total_amount + (@total_amount * 0.05) - +else + json.success false end diff --git a/app/views/api/customers/index.json.jbuilder b/app/views/api/customers/index.json.jbuilder index 900e6c6b..2c3c07a7 100644 --- a/app/views/api/customers/index.json.jbuilder +++ b/app/views/api/customers/index.json.jbuilder @@ -1 +1,3 @@ -json.array! @customers, :id, :name, :company, :contact_no, :email, :membership_id, :membership_type +json.array! @customers, :id, :name, :company, :contact_no,:salution, + :gender,:nrc_no,:address,:card_no, :membership_type, + :membership_id, :created_at diff --git a/app/views/api/customers/show.json.jbuilder b/app/views/api/customers/show.json.jbuilder index 79397308..db56961b 100644 --- a/app/views/api/customers/show.json.jbuilder +++ b/app/views/api/customers/show.json.jbuilder @@ -1,4 +1,6 @@ -json.extract! @customer, :id, :name, :company, :contact_no, :membership_type, :membership_id, :created_at +json.extract! @customer, :id, :name, :company, :contact_no,:salution, + :gender,:nrc_no,:address,:card_no, :membership_type, + :membership_id, :created_at json.invoices do json.array! @customer.lastest_invoices ,:id, :receipt_no, :receipt_date, :sale_status, :payment_status end diff --git a/app/views/api/orders/view_orders.json.jbuilder b/app/views/api/orders/view_orders.json.jbuilder new file mode 100644 index 00000000..ef927af0 --- /dev/null +++ b/app/views/api/orders/view_orders.json.jbuilder @@ -0,0 +1,49 @@ +if (@booking) + json.success true + json.booking_id @booking.booking_id + json.status @booking.booking_status + if Sale.exists?(@booking.sale_id) + json.sale_status Sale.find(@booking.sale_id).sale_status + else + json.sale_status "" + end + json.checkin_at @booking.checkin_at.strftime("%d-%m-%Y") + json.checkin_by @booking.checkin_by + json.table_name @booking.dining_facility.name + + if @booking.type == "TableBooking" + json.table_id @booking.dining_facility_id + else + json.room_id @booking.dining_facility_id + end + @total_amount = 0.00 + @total_tax = 0.00 + + if @booking.booking_orders + order_items = [] + @booking.booking_orders.each do |bo| + order = Order.find(bo.order_id) + #if (order.status == "new") + order_items = order_items + order.order_items + #end + end + + json.order_items order_items do |item| + json.item_instance_code item.item_code + json.item_name item.item_name + json.price item.price + json.qty item.qty + json.options item.options + json.remark item.remark + json.item_status item.order_item_status + @total_amount = @total_amount + (item.price * item.qty) + end + + end + + json.sub_total @total_amount + json.commerical_tax @total_amount * 0.05 + json.total @total_amount + (@total_amount * 0.05) +else + json.success false +end diff --git a/app/views/api/restaurant/zones/index.json.jbuilder b/app/views/api/restaurant/zones/index.json.jbuilder index cbcf1424..e2d040c6 100644 --- a/app/views/api/restaurant/zones/index.json.jbuilder +++ b/app/views/api/restaurant/zones/index.json.jbuilder @@ -8,7 +8,7 @@ if @zones json.name table.name json.status table.status json.zone_id table.zone_id #Add this zone_id to keep data structure consistance - json.current_booking table.get_current_booking + json.current_booking table.get_current_booking.booking_id rescue "" end json.rooms zone.rooms do |room| @@ -16,7 +16,7 @@ if @zones json.name room.name json.status room.status json.zone_id room.zone_id #Add this zone_id to keep data structure consistance - json.current_booking room.get_current_booking + json.current_booking room.get_current_booking.booking_id rescue "" end end @@ -26,7 +26,7 @@ else #list all tables and rooms with out zones json.name table.name json.status table.status json.zone_id table.zone_id #Add this zone_id to keep data structure consistance - json.current_booking table.get_current_booking + json.current_booking table.get_current_booking.booking_id rescue "" end @@ -35,7 +35,7 @@ else #list all tables and rooms with out zones json.name room.name json.status room.status json.zone_id room.zone_id #Add this zone_id to keep data structure consistance - json.current_booking room.get_current_booking + json.current_booking room.get_current_booking.booking_id rescue "" end diff --git a/app/views/crm/customers/_card_read_form.html.erb b/app/views/crm/customers/_card_read_form.html.erb new file mode 100644 index 00000000..4d6a9528 --- /dev/null +++ b/app/views/crm/customers/_card_read_form.html.erb @@ -0,0 +1,20 @@ + + \ No newline at end of file diff --git a/app/views/crm/customers/_error_messages.html.erb b/app/views/crm/customers/_error_messages.html.erb deleted file mode 100644 index bbff284b..00000000 --- a/app/views/crm/customers/_error_messages.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -
- -
diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb new file mode 100644 index 00000000..968d2ca9 --- /dev/null +++ b/app/views/crm/customers/_new_form.html.erb @@ -0,0 +1,122 @@ +
+ + <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> + + + <%= f.hidden_field :id, :class => "form-control col-md-6 " %> + +
"> + <%= f.input :card_no, :class => "form-control col-md-6 card_no"%> + <% flash.each do |name, msg| %> + <% str="[\"#{msg['name']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end -%> +
+ +
+
+ + + + +
+ +
"> + <%= f.input :name, :class => "form-control col-md-6 name", :required => true %> + <% flash.each do |name, msg| %> + <% str="[\"#{msg['name']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end -%> +
+ +
+
+ + +
+ +
+ <%= f.input :nrc_no, :class => "form-control nrc_no" %> +
+ +
+ <%= f.input :company, :class => "form-control col-md-6 company",:required => true%> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['company']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end -%> +
+
"> + <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['contact_no']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end -%> +
+ +
"> + <%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['contact_no']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end -%> +
+ +
+ <%= f.input :address, :class => "form-control col-md-6 address" %> +
+ +
+ + +
+ +
+ + <%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%> +
+ +
+ + + +
+ + +
+ <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> + <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> + <%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %> +
+ <%end%> +
\ No newline at end of file diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index f97de091..e7b47460 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -11,8 +11,6 @@ - -
@@ -26,14 +24,18 @@ <%= form_tag crm_customers_path, :method => :get do %>
- - + + + + +
<% end %> Select + Sr.no Name Company Contact no @@ -42,12 +44,13 @@ - <% if @crm_customers.count > 0 %> + <% @i = 0 %> <% @crm_customers.each do |crm_customer| %> <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + <%= @i += 1 %> <%= crm_customer.name %> <%= crm_customer.company rescue '-' %> <%= crm_customer.contact_no %> @@ -57,9 +60,7 @@ <% end %> <% end %> - <%else%> -

There are no record for your search

- <% end %> +
@@ -67,85 +68,33 @@ <%= paginate @crm_customers %>
- + <%= render 'card_read_form' %> -
- <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> + <%= render 'new_form', crm_customer: @crm_customer %> - - <%= f.hidden_field :id, :class => "form-control col-md-6 " %> - -
"> - <%= f.input :name, :class => "form-control col-md-6 name" %> - <% flash.each do |name, msg| %> - <%= msg['name'] %> - <% end -%> - -
-
- <%= f.input :company, :class => "form-control col-md-6 company" %> -
-
"> - <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> - <% flash.each do |name, msg| %> - <%= msg['contact_no'] %> - <% end -%> -
- -
"> - <%= f.input :email, :class => "form-control col-md-6 email" %> - - <% flash.each do |name, msg| %> - <%= msg['email'] %> - <% end -%> -
- -
- - <%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%> -
- -
- - - -
- - -
- <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> - <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> - <%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %> -
- <%end%> -
-
-
+
+
Back -
+
+ diff --git a/app/views/crm/dining_queues/index.html.erb b/app/views/crm/dining_queues/index.html.erb index 7050885d..ac247771 100644 --- a/app/views/crm/dining_queues/index.html.erb +++ b/app/views/crm/dining_queues/index.html.erb @@ -9,39 +9,41 @@
-
+ +
-
- <% @i = 0 %> . - <% @dining_queues.each do |queue| %> -
-
" style="border:1px solid #ccc;margin-bottom: 10px "> -
- - -

<%= @i += 1 %> . Queue No

-

<%= queue.queue_no %>

-

- Name : <%= queue.name %>
- Contact : <%= queue.contact_no %> -
- Status : <%= queue.status rescue '-' %> -

-
-
+
-
- <% end %> -
- - -
+ +
+
+
+ <% @i =0 %> + <% @dining_queues.each do |queue| %> +
" data-id="<%= queue.id %>"> +
+ + + + <%= @i += 1 %> . Queue No +

+ <%= queue.queue_no %> +

+ +
+
+ + <% end %> +
+
+
+
+ +
- -
\ No newline at end of file diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb index f1a43726..dc6cfc61 100644 --- a/app/views/layouts/CRM.html.erb +++ b/app/views/layouts/CRM.html.erb @@ -11,6 +11,8 @@ <%= stylesheet_link_tag 'CRM', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'CRM', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag 'jquery-confirm', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'jquery-confirm', 'data-turbolinks-track': 'reload' %> diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 40ddae1f..c528003d 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -39,7 +39,7 @@ diff --git a/app/views/layouts/_header_orgiami.html.erb b/app/views/layouts/_header_orgiami.html.erb index 894e7a1f..0ae18ff5 100644 --- a/app/views/layouts/_header_orgiami.html.erb +++ b/app/views/layouts/_header_orgiami.html.erb @@ -1,7 +1,7 @@
-
- CASHIER STATION 1 - CLOCK +
+ Cashier Station 1 -
<% if current_login_employee %> @@ -10,3 +10,29 @@
+ +
diff --git a/app/views/layouts/origami.html.erb b/app/views/layouts/origami.html.erb index 179d9ae1..1f519d2b 100644 --- a/app/views/layouts/origami.html.erb +++ b/app/views/layouts/origami.html.erb @@ -10,7 +10,9 @@ <%= csrf_meta_tags %> <%= stylesheet_link_tag 'origami', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= javascript_include_tag 'origami', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag 'jquery-confirm', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'jquery-confirm', 'data-turbolinks-track': 'reload' %> @@ -23,7 +25,7 @@ <%=message%>
<% end %> - + <% end %> <%= yield %> diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index dd2b1b99..3b192319 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -2,12 +2,6 @@
@@ -15,11 +9,11 @@
- +
- + @@ -35,6 +29,7 @@ + @@ -44,17 +39,19 @@ <% if @crm_customers.count > 0 %> + <% @i = 0 %> <% @crm_customers.each do |crm_customer| %> - <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + - - + + <% end %> <% end %> @@ -64,7 +61,7 @@
SelectSr.no Name Company Contact no
<%= @i += 1 %> <%= crm_customer.name %> <%= crm_customer.company rescue '-' %> <%= crm_customer.contact_no %> <%= crm_customer.email %>

- + <%= paginate @crm_customers %>
@@ -79,31 +76,85 @@ <%= f.error_notification %> <%= f.hidden_field :id, :class => "form-control col-md-6 " %> +
+
+ + + + +
+
"> - <%= f.input :name, :class => "form-control col-md-6 name" %> + <%= f.input :name, :class => "form-control col-md-6 name", :required => true %> + <% flash.each do |name, msg| %> - <%= msg['name'] %> + <% str="[\"#{msg['name']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> <% end -%> - +
+ +
+
+ + +
+ +
+ <%= f.input :nrc_no, :class => "form-control nrc_no" %>
- <%= f.input :company, :class => "form-control col-md-6 company" %> -
-
"> - <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> + <%= f.input :company, :class => "form-control col-md-6 company",:required => true%> + <% flash.each do |name, msg| %> - <%= msg['contact_no'] %> + <% str="[\"#{msg['company']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end -%> +
+
"> + <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['contact_no']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> <% end -%>
"> - <%= f.input :email, :class => "form-control col-md-6 email" %> - + <%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%> <% flash.each do |name, msg| %> - <%= msg['email'] %> + <% str="[\"#{msg['contact_no']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> <% end -%>
+
+ <%= f.input :address, :class => "form-control col-md-6 address" %> +
+ +
+ + +
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%> @@ -116,7 +167,7 @@ <%end %> - +
@@ -133,8 +184,6 @@
- - - - - - diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 4f6b7c9a..4e4d2b77 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -1,7 +1,6 @@
-
Discount: - (<%=@sale_data.total_discount rescue 0%>) + (<%=@sale_data.total_discount rescue 0%>) Tax: @@ -75,104 +75,476 @@
-
+
-
+
-
Overall Discount
+
Discount Control
-
-
- -
-
+
+
-
- +
+ <% + @accounts.each do |acc| + %> + + <% end %> +
+

-
-
-
-
5%
-
-
-
-
1
-
2
-
3
-
-
-
+
+
+
+
+
5%
+
+
+
1
+
2
+
3
+
+
-
-
-
10%
-
-
-
-
4
-
5
-
6
-
-
-
+
+
+
10%
+
+
+
4
+
5
+
6
+
+
-
-
-
20%
-
-
-
-
7
-
8
-
9
-
-
-
+
+
+
20%
+
+
+
7
+
8
+
9
+
+
-
-
-
30%
-
-
-
-
0
-
.
-
00
-
-
-
+
+
+
30%
+
+
+
0
+
.
+
00
+
+
-
-
-
50%
-
-
-
-
-
DEL
-
CLR
-
-
-
-
+
+
+
50%
+
+
+
+
DEL
+
CLR
+
+
+
+ +
+
+ + + +
+
+
+ + diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index ce2b3a94..08f53998 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -1,388 +1,186 @@ -
- -
+
+ +
- - - + + + -
- -
-
- <% - @completed_orders.each do |cpo| - # ToDo no need check new - # Assigned Id for new Order? Sale? - unique_id = "" - customer_id = "" +
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %> +
+
+ <% end %> +
+
- # For CSS- Class for Order? Sale? - # sale_status="" - # if cpo.order_status == 'new' - # unique_id=cpo.booking_id + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> +
+
+ Zone <%= table.zone_id %>
+ Table <%= table.name %> ( <%= table.seater %> Seat ) +
+
+ <% else %> +
+
+ Zone <%= table.zone_id %>
+ Table <%= table.name %> ( <%= table.seater %> Seat ) +
+
+ <% end %> + <% end %> +
+
- # customer_id=cpo.order_customer_id - # # check selected item and assign - # if @selected_item_type == "Sale" - # if cpo.order_id == @selected_item.order_id - # sale_status = sale_status + " selected-item" - # end - # end - # else - unique_id=cpo.sale_id - customer_id=cpo.sale_customer_id - sale_status="paid" - # check selected item and assign - if @selected_item != nil - if unique_id == @selected_item.sale_id - sale_status = sale_status + " selected-item" - end - end - # end - %> -
-
+ +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> +
+
+ <%= room.name %> +
+
+ <% else %> +
+
+ <%= room.name %> +
+
+ <% end %> + <% end %> +
+
- - - -

<%= cpo.table_name %>

-

- Receipt No : - - <%= cpo.receipt_no %> - -

-

- Order Status : - <%= cpo.sale_status %> - -

-
-
- <% - end - %> -
-
+ +
+
+ <% @orders.each do |order| %> +
+
+ <%= order.order_id %> +
+
+ <% end %> +
- -
-
- <% - @booking_orders.each do |bko| - # No Show completed - if bko.sale_status == 'completed' - next - end - - # Assigned Id for new Order? Sale? - unique_id="" - customer_id="" - # For CSS- Class for Order? Sale? - sale_status="" - if bko.order_status == 'new' - unique_id=bko.booking_id - customer_id=bko.order_customer_id - # check selected item and assign - # if @selected_item != nil - # if bko.order_id == @selected_item.order_id - # sale_status = sale_status + " selected-item" - # end - # end - else - unique_id=bko.sale_id - customer_id=bko.sale_customer_id - sale_status="sold" - # check selected item and assign - if @selected_item != nil - if unique_id == @selected_item.sale_id - sale_status = sale_status + " selected-item" - end - end - end - %> -
-
- - - -

<%= bko.table_name %>

-

- Receipt No : - - <%= bko.receipt_no %> - -

-

- Order Status : - <%= bko.order_status %> - -

-
-
- <% - end - %> -
-
- - -
-
- <% - @booking_rooms.each do |rmo| - # No Show completed - if rmo.sale_status == 'completed' - next - end - - # Assigned Id for new Order? Sale? - unique_id="" - customer_id="" - # For CSS- Class for Order? Sale? - sale_status="" - - if rmo.order_status == 'new' - unique_id=rmo.booking_id - customer_id=rmo.order_customer_id - # check selected item and assign - # if @selected_item != nil - # if rmo.order_id == @selected_item.order_id - # sale_status = sale_status + " selected-item" - # end - # end - else - unique_id=rmo.sale_id - customer_id=rmo.sale_customer_id - sale_status="sold" - # check selected item and assign - if @selected_item != nil - if unique_id == @selected_item.sale_id - sale_status = sale_status + " selected-item" - end - end - end - %> -
-
- - - -

<%= rmo.room_name %>

-

- Receipt No : - - <%= rmo.receipt_no %> - -

-

- Order Status : - <%= rmo.order_status %> - -

-
-
- <% - end - %> -
-
- - -
-
- <% - @orders.each do |odr| - # No Show completed - if odr.sale_status == 'completed' - next - end - # Assigned Id for new Order? Sale? - unique_id="" - customer_id="" - # For CSS- Class for Order? Sale? - sale_status="" - - if odr.order_status == 'new' - unique_id=odr.booking_id - customer_id = odr.order_customer_id - # if @selected_item != nil - # if odr.order_id == @selected_item.order_id - # sale_status = sale_status + " selected-item" - # end - # end - else - unique_id=odr.sale_id - customer_id = odr.sale_customer_id - sale_status="sold" - # check selected item and assign - if @selected_item != nil - if unique_id == @selected_item.sale_id - sale_status = sale_status + " selected-item" - end - end - end - %> -
-
- - - -

<%= odr.table_name %>

- Receipt No : - - <%= odr.receipt_no %> - -

-

- Order Status : - <%= odr.order_status %> - -

-
-
- <% - end - %> -
- -
-
- -
- - - -
-
-
-
ORDER DETAILS -
-
-
-
-
-

Receipt No: <%=@selected_item.receipt_no rescue ' '%>

- -
-
-

Date: <%=@selected_item.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

-
-
-
-
-

Customer :

- -
- -
-
- - - - - - - - <% - # For Sale Items - sub_total = 0 - if @selected_item_type == "Sale" - @selected_item.sale_items.each do |sale_item| - sub_total = sub_total + sale_item.price - %> - - - - - - <% - end - end - %> - - <% - # For Order Items - if @selected_item_type == "Order" - @selected_item.order_items.each do |order_item| - sub_total = sub_total + (order_item.qty*order_item.price) - %> - - - - - - <% - end - end - %> - -
ItemsQTY - Price -
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
-
- -
-
+
+ +
+
+ +
+
+ + diff --git a/app/views/origami/home/index_bk.html.erb b/app/views/origami/home/index_bk.html.erb new file mode 100644 index 00000000..ce2b3a94 --- /dev/null +++ b/app/views/origami/home/index_bk.html.erb @@ -0,0 +1,388 @@ +
+ +
+ + + + + +
+ +
+
+ <% + @completed_orders.each do |cpo| + # ToDo no need check new + # Assigned Id for new Order? Sale? + unique_id = "" + customer_id = "" + + # For CSS- Class for Order? Sale? + # sale_status="" + # if cpo.order_status == 'new' + # unique_id=cpo.booking_id + + # customer_id=cpo.order_customer_id + # # check selected item and assign + # if @selected_item_type == "Sale" + # if cpo.order_id == @selected_item.order_id + # sale_status = sale_status + " selected-item" + # end + # end + # else + unique_id=cpo.sale_id + customer_id=cpo.sale_customer_id + sale_status="paid" + # check selected item and assign + if @selected_item != nil + if unique_id == @selected_item.sale_id + sale_status = sale_status + " selected-item" + end + end + # end + %> +
+
+ + + + +

<%= cpo.table_name %>

+

+ Receipt No : + + <%= cpo.receipt_no %> + +

+

+ Order Status : + <%= cpo.sale_status %> + +

+
+
+ <% + end + %> +
+
+ + +
+
+ <% + @booking_orders.each do |bko| + # No Show completed + if bko.sale_status == 'completed' + next + end + + # Assigned Id for new Order? Sale? + unique_id="" + customer_id="" + # For CSS- Class for Order? Sale? + sale_status="" + if bko.order_status == 'new' + unique_id=bko.booking_id + customer_id=bko.order_customer_id + # check selected item and assign + # if @selected_item != nil + # if bko.order_id == @selected_item.order_id + # sale_status = sale_status + " selected-item" + # end + # end + else + unique_id=bko.sale_id + customer_id=bko.sale_customer_id + sale_status="sold" + # check selected item and assign + if @selected_item != nil + if unique_id == @selected_item.sale_id + sale_status = sale_status + " selected-item" + end + end + end + %> +
+
+ + + +

<%= bko.table_name %>

+

+ Receipt No : + + <%= bko.receipt_no %> + +

+

+ Order Status : + <%= bko.order_status %> + +

+
+
+ <% + end + %> +
+
+ + +
+
+ <% + @booking_rooms.each do |rmo| + # No Show completed + if rmo.sale_status == 'completed' + next + end + + # Assigned Id for new Order? Sale? + unique_id="" + customer_id="" + # For CSS- Class for Order? Sale? + sale_status="" + + if rmo.order_status == 'new' + unique_id=rmo.booking_id + customer_id=rmo.order_customer_id + # check selected item and assign + # if @selected_item != nil + # if rmo.order_id == @selected_item.order_id + # sale_status = sale_status + " selected-item" + # end + # end + else + unique_id=rmo.sale_id + customer_id=rmo.sale_customer_id + sale_status="sold" + # check selected item and assign + if @selected_item != nil + if unique_id == @selected_item.sale_id + sale_status = sale_status + " selected-item" + end + end + end + %> +
+
+ + + +

<%= rmo.room_name %>

+

+ Receipt No : + + <%= rmo.receipt_no %> + +

+

+ Order Status : + <%= rmo.order_status %> + +

+
+
+ <% + end + %> +
+
+ + +
+
+ <% + @orders.each do |odr| + # No Show completed + if odr.sale_status == 'completed' + next + end + # Assigned Id for new Order? Sale? + unique_id="" + customer_id="" + # For CSS- Class for Order? Sale? + sale_status="" + + if odr.order_status == 'new' + unique_id=odr.booking_id + customer_id = odr.order_customer_id + # if @selected_item != nil + # if odr.order_id == @selected_item.order_id + # sale_status = sale_status + " selected-item" + # end + # end + else + unique_id=odr.sale_id + customer_id = odr.sale_customer_id + sale_status="sold" + # check selected item and assign + if @selected_item != nil + if unique_id == @selected_item.sale_id + sale_status = sale_status + " selected-item" + end + end + end + %> +
+
+ + + +

<%= odr.table_name %>

+ Receipt No : + + <%= odr.receipt_no %> + +

+

+ Order Status : + <%= odr.order_status %> + +

+
+
+ <% + end + %> +
+ +
+
+ +
+ + + +
+
+
+
ORDER DETAILS -
+
+
+
+
+

Receipt No: <%=@selected_item.receipt_no rescue ' '%>

+ +
+
+

Date: <%=@selected_item.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+ +
+ +
+
+ + + + + + + + <% + # For Sale Items + sub_total = 0 + if @selected_item_type == "Sale" + @selected_item.sale_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + + + + + + <% + end + end + %> + + <% + # For Order Items + if @selected_item_type == "Order" + @selected_item.order_items.each do |order_item| + sub_total = sub_total + (order_item.qty*order_item.price) + %> + + + + + + <% + end + end + %> + +
ItemsQTY + Price +
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ +
+
+
+ + +
+ + + + + + + + + + + +
+
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb new file mode 100644 index 00000000..139697e3 --- /dev/null +++ b/app/views/origami/home/show.html.erb @@ -0,0 +1,363 @@ +
+ +
+ + + + + +
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %> +
+
+ <% end %> +
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> +
+
+ <%= table.name %> +
+
+ <% else %> +
+
+ <%= table.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> +
+
+ <%= room.name %> +
+
+ <% else %> +
+
+ <%= room.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @orders.each do |order| %> +
+
+ <%= order.order_id %> +
+
+ <% end %> +
+
+ +
+ +
+ + + +
+
+
+ <% if @status_order == 'order' && @status_sale != 'sale' %> +
ORDER DETAILS
+ <% elsif @status_sale == 'sale' %> +
INVOICE DETAILS
+ <% end %> +
+
+
+
+

Receipt No: + <% if @status_sale == 'sale' %> + <%= @sale_array[0].receipt_no rescue '' %> + <% end %> +

+
+
+

Date: <%= @date.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + + <% + count = 0 + sub_total = 0 + if @status_sale == "sale" + puts @sale_array[0] + @sale_array[0].sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + + + + <% + end + end + end + + if @status_order == 'order' && @status_sale != 'sale' + unless @order_items.nil? + count = 0 + @order_items.each do |order_item | + puts @order_items.size + puts "view" + count += 1 + sub_total = sub_total + order_item.price + + unless order_item.price == 0 %> + + + + + + + <% + end + end + end + end + %> + +
#ItemsQTY + Price +
<%= count %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= count %><%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ +
+ + <% + if @status_sale == 'sale' + unless @order_items.nil? + %> + Pending New Order + + <% + @order_items.each do |order_item | + %> + + + + + + + + <% + end + %> +
<%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+ + <% + else + @sale_array.each do |sale| + if @sale_array.size > 1 + unless sale.receipt_no == @sale_array[0].receipt_no + %> + Pending New Invoice + + + + + +
Receipt No - <%= sale.receipt_no %>
+ <% + end + end + end + end + end + %> + +
+
+
+ + +
+ + + <% if @dining.bookings.length >= 1 %> + + + + + <% if @status_order == 'order' %> + + + <% else %> + + + <% end %> + + + + <% end %> +
+
+ diff --git a/app/views/origami/jcb/index.html.erb b/app/views/origami/jcb/index.html.erb index bb9f0740..e9cc09fa 100644 --- a/app/views/origami/jcb/index.html.erb +++ b/app/views/origami/jcb/index.html.erb @@ -68,9 +68,9 @@
00
-
Nett
+
Nett
Del
-
Clr
+
Clr
@@ -91,7 +91,7 @@
- +
@@ -134,6 +134,7 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#amount').text(); $('#amount').text(cash.substr(0,cash.length-1)); + break; case 'nett': var remain_amount = $('#validamount').val(); $('#amount').text(remain_amount); diff --git a/app/views/origami/master/index.html.erb b/app/views/origami/master/index.html.erb index 8099473d..6afc1081 100644 --- a/app/views/origami/master/index.html.erb +++ b/app/views/origami/master/index.html.erb @@ -68,9 +68,9 @@
00
-
Nett
+
Nett
Del
-
Clr
+
Clr
@@ -91,7 +91,7 @@
- +
@@ -133,6 +133,10 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#amount').text(); $('#amount').text(cash.substr(0,cash.length-1)); + break; + case 'nett': + var remain_amount = $('#validamount').val(); + $('#amount').text(remain_amount); break; } diff --git a/app/views/origami/moveroom/move_dining.html.erb b/app/views/origami/moveroom/move_dining.html.erb new file mode 100644 index 00000000..495e1514 --- /dev/null +++ b/app/views/origami/moveroom/move_dining.html.erb @@ -0,0 +1,207 @@ +
+ +
+ + + + + +
+ + + + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> +
+
+ <%= table.name %> +
+
+ <% else %> +
+
+ <%= table.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> +
+
+ <%= room.name %> +
+
+ <% else %> +
+
+ <%= room.name %> +
+
+ <% end %> + <% end %> +
+
+ + + + +
+ +
+ + + +
+
+
+
MOVE --> ' <%= @dining.name %>' to
+ +
+
+
+
+

Receipt No: + <% if @status_sale == 'sale' %> + <%= @obj_sale.receipt_no rescue '' %> + <% end %> +

+
+
+

Date: <%= @date.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + <% + sub_total = 0 + if @status_sale == "sale" + @obj_sale.sale_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + + <% unless sale_item.price <= 0 %> + + + + + + <% + end + end + end + + if @status_order == 'order' + unless @order_items.nil? + @order_items.each do |order_item | + sub_total = sub_total + order_item.price + + unless order_item.price <= 0 %> + + + + + + <% + end + end + end + end + %> + +
ItemsQTY + Price +
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+
+
+
MOVE TABLE
+
+
+
+
+
+ + +
+ + + + +
+
+ diff --git a/app/views/origami/movetable/move_dining.html.erb b/app/views/origami/movetable/move_dining.html.erb new file mode 100644 index 00000000..83419ca0 --- /dev/null +++ b/app/views/origami/movetable/move_dining.html.erb @@ -0,0 +1,258 @@ +
+ +
+ + + + + +
+ + + + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> +
+
+ <%= table.name %> +
+
+ <% else %> +
+
+ <%= table.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> +
+
+ <%= room.name %> +
+
+ <% else %> +
+
+ <%= room.name %> +
+
+ <% end %> + <% end %> +
+
+ + + + +
+ +
+ + + +
+
+
+
MOVE --> ' <%= @dining.name %> ' to
+ +
+
+
+
+

Receipt No: + <% if @status_sale == 'sale' %> + <%= @sale_array[0].receipt_no rescue '' %> + <% end %> +

+
+
+

Date: <%= @date.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + + <% + count = 0 + sub_total = 0 + if @status_sale == "sale" + puts @sale_array[0] + @sale_array[0].sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% unless sale_item.price <= 0 %> + + + + + + + <% + end + end + end + + if @status_order == 'order' && @status_sale != 'sale' + unless @order_items.nil? + count = 0 + @order_items.each do |order_item | + puts @order_items.size + puts "view" + count += 1 + sub_total = sub_total + order_item.price + + unless order_item.price <= 0 %> + + + + + + + <% + end + end + end + end + %> + +
#ItemsQTY + Price +
<%= count %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= count %><%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ <% + if @status_sale == 'sale' + unless @order_items.nil? + %> + Pending New Order + + <% + @order_items.each do |order_item | + %> + + + + + + + + <% + end + %> +
<%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+ + <% + else + @sale_array.each do |sale| + if @sale_array.size > 1 + unless sale.receipt_no == @sale_array[0].receipt_no + %> + Pending New Invoice + + + + + +
Receipt No - <%= sale.receipt_no %>
+ <% + end + end + end + end + end + %> +
+
+
MOVE TABLE
+
+
+
+
+
+ + +
+ + + + +
+
+ diff --git a/app/views/origami/movetable/moving.json.jbuilder b/app/views/origami/movetable/moving.json.jbuilder new file mode 100644 index 00000000..8030f9fe --- /dev/null +++ b/app/views/origami/movetable/moving.json.jbuilder @@ -0,0 +1,2 @@ +json.status true +json.get_type @get_type diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb index ed176375..e8e25b2f 100644 --- a/app/views/origami/mpu/index.html.erb +++ b/app/views/origami/mpu/index.html.erb @@ -68,9 +68,9 @@
00
-
Nett
+
Nett
Del
-
Clr
+
Clr
@@ -91,7 +91,7 @@
- +
@@ -133,6 +133,7 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#amount').text(); $('#amount').text(cash.substr(0,cash.length-1)); + break; case 'nett': var remain_amount = $('#validamount').val(); $('#amount').text(remain_amount); diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb new file mode 100644 index 00000000..a480593a --- /dev/null +++ b/app/views/origami/orders/show.html.erb @@ -0,0 +1,214 @@ +
+ +
+ + + + + +
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %> +
+
+ <% end %> +
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> +
+
+ <%= table.name %> +
+
+ <% else %> +
+
+ <%= table.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> +
+
+ <%= room.name %> +
+
+ <% else %> +
+
+ <%= room.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @orders.each do |order| %> +
+
+ <% + order_status = "" + sale_order = SaleOrder.find_by_order_id(order) + if sale_order + sale = Sale.find(sale_order.sale_id) + order_status = sale.sale_status + if order_status == 'new' + order_status = order.status + end + else + order_status = order.status + end + %> + <%= order.order_id %> | <%= order_status %> +
+
+ <% end %> +
+
+ +
+ +
+ + + +
+
+
+
ORDERS DETAILS
+
+
+
+
+

Receipt No: +

+
+
+

Date: <%= @order.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + <% + sub_total = 0 + @order.order_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + <% unless sale_item.price <= 0 %> + + + + + + <% + end + end + %> + +
ItemsQTY + Price +
<%= sale_item.item_name %><%= sale_item.qty %><%= sale_item.price %>
+
+ +
+
+
+ + +
+ + <% if @sale_status != 'completed' %> + + <% end %> + +
+
+ diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb index 4b2397a2..9ca152ac 100644 --- a/app/views/origami/others_payments/index.html.erb +++ b/app/views/origami/others_payments/index.html.erb @@ -1,5 +1,5 @@
- +
<% @payment_method_setting.each do |payment_method|%> @@ -8,6 +8,10 @@
+
+ +
+
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 91d5b6b2..ae642a9d 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -90,31 +90,30 @@
Amount Due
<%= @sale_data.grand_total %>
-
-
+
+
Cash
<%= @cash %>
-
-
+ +
Credit
0.0
-
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%> -
+
Other Payments
<%= @other %>
<% else %> -
+
Other Payments
<% end %> <% if @other != 0.0 %> -
+
MPU
<%= @other %>
@@ -128,7 +127,7 @@ <% end %> <% if @ppamount != 0.0 %> -
+
Paypar
<%= @ppamount %>
@@ -142,7 +141,7 @@ <% end %> <% if @visacount != 0.0 %> -
+
Visa
<%= @visacount %>
@@ -156,7 +155,7 @@ <% end %> <% if @jcbcount != 0.0 %> -
+
JCB
<%= @jcbcount %>
@@ -170,7 +169,7 @@ <% end %> <% if @mastercount != 0.0 %> -
+
Master
<%= @mastercount %>
@@ -182,12 +181,12 @@
0.0
<% end %> -
+
Balance
<%= @sale_data.grand_total %>
-
+
@@ -212,9 +211,9 @@
00
-
Nett
+
Nett
Del
-
Clr
+
Clr
@@ -235,7 +234,7 @@
- + diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index 83b24213..023912ca 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -66,9 +66,9 @@
00
-
Nett
+
Nett
Del
-
Clr
+
Clr
@@ -91,7 +91,7 @@
- +
@@ -129,6 +129,7 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#used_amount').text(); $('#used_amount').text(cash.substr(0,cash.length-1)); + break; case 'nett': alert($('#valid_amount').text()) $('#used_amount').text($('#valid_amount').text()); diff --git a/app/views/origami/request_bills/print.json.jbuilder b/app/views/origami/request_bills/print.json.jbuilder new file mode 100644 index 00000000..08bf292c --- /dev/null +++ b/app/views/origami/request_bills/print.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb new file mode 100644 index 00000000..c1797158 --- /dev/null +++ b/app/views/origami/rooms/show.html.erb @@ -0,0 +1,274 @@ +
+ +
+ + + + + +
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %> +
+
+ <% end %> +
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> +
+
+ <%= table.name %> +
+
+ <% else %> +
+
+ <%= table.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> +
+
+ <%= room.name %> +
+
+ <% else %> +
+
+ <%= room.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @orders.each do |order| %> +
+
+ <%= order.order_id %> +
+
+ <% end %> +
+
+ +
+ +
+ + + +
+
+
+ <% if @status == "order" %> +
ORDER DETAILS
+ <% else %> +
INVOICE DETAILS
+ <% end %> +
+
+
+
+

Receipt No: + <% if @status == 'sale' %> + <%= @obj.receipt_no rescue '' %> + <% end %> +

+
+
+

Date: <%= @obj.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + <% + sub_total = 0 + if @status == "sale" + @obj.sale_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + + <% unless sale_item.price <= 0 %> + + + + + + <% + end + end + end + + if @status == 'order' + unless @order_items.nil? + @order_items.each do |order_item | + sub_total = sub_total + order_item.price + + unless order_item.price <= 0 %> + + + + + + <% + end + end + end + end + %> + +
ItemsQTY + Price +
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+
+ +
+ + <% + if @status == 'sale' + unless @order_items.nil? + %> + Added New Order + + <% + @order_items.each do |order_item | + %> + + + + + + + + <% + end + %> +
<%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+ + <% + end + end + %> + +
+
+
+ + +
+ + + + + + + + + + + + +
+
+ diff --git a/app/views/origami/sales/show.html.erb b/app/views/origami/sales/show.html.erb new file mode 100644 index 00000000..e896a50a --- /dev/null +++ b/app/views/origami/sales/show.html.erb @@ -0,0 +1,215 @@ +
+ +
+ + + + + +
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %> +
+
+ <% end %> +
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> +
+
+ <%= table.name %> +
+
+ <% else %> +
+
+ <%= table.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> +
+
+ <%= room.name %> +
+
+ <% else %> +
+
+ <%= room.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @orders.each do |order| %> +
+
+ <%= order.order_id %> +
+
+ <% end %> +
+
+ +
+ +
+ + + +
+
+
+
INVOICE DETAILS
+
+
+
+
+

Receipt No: + <%= @sale.receipt_no rescue '' %> +

+
+
+

Date: <%= @sale.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + <% + sub_total = 0 + @sale.sale_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + + <% unless sale_item.price <= 0 %> + + + + + + <% + + end + end + + %> + +
ItemsQTY + Price +
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
+
+ +
+
+
+ + +
+ + + +
+
+ diff --git a/app/views/origami/visa/index.html.erb b/app/views/origami/visa/index.html.erb index 5eaf2e28..1589ca1b 100644 --- a/app/views/origami/visa/index.html.erb +++ b/app/views/origami/visa/index.html.erb @@ -68,9 +68,9 @@
00
-
Nett
+
Nett
Del
-
Clr
+
Clr
@@ -91,7 +91,7 @@
- +
@@ -133,6 +133,7 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#amount').text(); $('#amount').text(cash.substr(0,cash.length-1)); + break; case 'nett': var remain_amount = $('#validamount').val(); $('#amount').text(remain_amount); diff --git a/app/views/reports/daily_sale/_shift_sale_report_filter.html.erb b/app/views/reports/daily_sale/_shift_sale_report_filter.html.erb index 815cf24c..3a5d788c 100644 --- a/app/views/reports/daily_sale/_shift_sale_report_filter.html.erb +++ b/app/views/reports/daily_sale/_shift_sale_report_filter.html.erb @@ -145,68 +145,7 @@ $(function(){ // window.location = url; }); - var item = $('#item').val(); - var payment_type = $('#payment_type'); - - if(item == 'order'){ - $('#cashier').hide(); - $('#waiter').show(); - if(payment_type){ - $('#payment_type').hide(); - } - } - else if(item == 'sale'){ - $('#waiter').hide(); - $('#cashier').show(); - } - else{ - $('#waiter').hide(); - $('#cashier').show(); - $("#item").val('sale'); - } }); -//Reset the form to pervious values -$("#branch").val(<%=params[:branch]%>); -$("#waiter").val("<%=params[:waiter]%>"); -$("#cashier").val(<%=params[:cashier]%>); -$("#product").val(<%=params[:product]%>); -$("#singer").val(<%=params[:singer]%>); -$("#item").val('<%=params[:item]%>'); -$("#guest_role").val('<%=params[:guest_role]%>'); - -$("#from").val("<%=params[:from]%>"); -$("#to").val("<%=params[:to]%>"); -$("#sel_period").val(<%=params[:period]%>); -$("#sel_sale_type").val(<%=params[:sale_type]%>); - -<% if params[:period_type] == 1 || params[:period_type] == "1" %> - $("#rd_period_type_1").attr("checked","checked"); -<% else %> - $("#rd_period_type_0").attr("checked","checked"); -<% end %> -$(".btn-group button").removeClass("active"); -<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %> -$("#btn_report_type_<%= report_type %>").addClass("active"); - -$('#item').change(function(){ - var item = $('#item').val(); - var payment_type = $('#payment_type'); - - if(item == 'sale'){ - $('#waiter').hide(); - $('#cashier').show(); - if(payment_type){ - $('#payment_type').show(); - } - } - else{ - $('#cashier').hide(); - $('#waiter').show(); - if(payment_type){ - $('#payment_type').hide(); - } - } -}); \ No newline at end of file diff --git a/app/views/reports/daily_sale/index.html.erb b/app/views/reports/daily_sale/index.html.erb index 4aa0c841..a2403045 100644 --- a/app/views/reports/daily_sale/index.html.erb +++ b/app/views/reports/daily_sale/index.html.erb @@ -32,16 +32,16 @@ Sr.no Date - Daily Void Amount - Daily mpu Sales - Daily master Sales - Daily visa Sales - Daily jcb Sales - Daily paypar Sales - Daily Cash Sales - Daily Credit Sales - Daily FOC Sales - (Daily Discount) + Void Amount + Mpu Sales + Master Sales + Visa Sales + Jcb Sales + Paypar Sales + Cash Sales + Credit Sales + FOC Sales + (Discount) Grand Total +
Rounding Adj. Rounding Adj. Grand Total diff --git a/app/views/reports/daily_sale/index.xls.erb b/app/views/reports/daily_sale/index.xls.erb index dfcc18d4..67e76e3c 100644 --- a/app/views/reports/daily_sale/index.xls.erb +++ b/app/views/reports/daily_sale/index.xls.erb @@ -10,16 +10,16 @@ Sr.no Date - Daily Void Amount - Daily mpu Sales - Daily master Sales - Daily visa Sales - Daily jcb Sales - Daily paypar Sales - Daily Cash Sales - Daily Credit Sales - Daily FOC Sales - (Daily Discount) + Void Amount + Mpu Sales + Master Sales + Visa Sales + Jcb Sales + Paypar Sales + Cash Sales + Credit Sales + FOC Sales + (Discount) Grand Total +
Rounding Adj. Rounding Adj. Grand Total diff --git a/app/views/reports/daily_sale_report.html.erb b/app/views/reports/daily_sale_report.html.erb deleted file mode 100644 index 786951f5..00000000 --- a/app/views/reports/daily_sale_report.html.erb +++ /dev/null @@ -1,20 +0,0 @@ - - -
- <%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_receipt_no_index_path} %> -
-
- -
-
- -
-
diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 4dd239e7..86307066 100644 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -30,7 +30,9 @@ Gross Sales Discount Total Sales - CT + <% TaxProfile.all.each do |r|%> + <%=r.name%> + <% end %> Nett Sales @@ -48,7 +50,10 @@ <%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %> - <%= number_with_delimiter(sprintf("%.2f",sale.total_tax.to_f), :delimiter => ',') %> + <% sale.sale_taxes.each do |sale|%> + <%= number_with_delimiter(sprintf("%.2f",sale.tax_payable_amount.to_f), :delimiter => ',') %> + <% end %> + <%= number_with_delimiter(sprintf("%.2f",net_sales.to_f), :delimiter => ',') %> <% end %> diff --git a/app/views/reports/_shift_sale_report_filter.html.erb b/app/views/reports/sale_item/_shift_sale_report_filter.html.erb similarity index 77% rename from app/views/reports/_shift_sale_report_filter.html.erb rename to app/views/reports/sale_item/_shift_sale_report_filter.html.erb index 1b4082f5..7f95b6b9 100644 --- a/app/views/reports/_shift_sale_report_filter.html.erb +++ b/app/views/reports/sale_item/_shift_sale_report_filter.html.erb @@ -18,7 +18,8 @@
-
+ +
@@ -143,69 +144,13 @@ $(function(){ $('#frm_report').submit(); // window.location = url; }); + + function export_to(path) +{ + var form_params = $("#frm_report").serialize(); + window.location = path+"?"+ form_params; +} - var item = $('#item').val(); - var payment_type = $('#payment_type'); - - if(item == 'order'){ - $('#cashier').hide(); - $('#waiter').show(); - if(payment_type){ - $('#payment_type').hide(); - } - } - else if(item == 'sale'){ - $('#waiter').hide(); - $('#cashier').show(); - } - else{ - $('#waiter').hide(); - $('#cashier').show(); - $("#item").val('sale'); - } }); -//Reset the form to pervious values -$("#branch").val(<%=params[:branch]%>); -$("#waiter").val("<%=params[:waiter]%>"); -$("#cashier").val(<%=params[:cashier]%>); -$("#product").val(<%=params[:product]%>); -$("#singer").val(<%=params[:singer]%>); -$("#item").val('<%=params[:item]%>'); -$("#guest_role").val('<%=params[:guest_role]%>'); - - -$("#from").val("<%=params[:from]%>"); -$("#to").val("<%=params[:to]%>"); -$("#sel_period").val(<%=params[:period]%>); -$("#sel_sale_type").val(<%=params[:sale_type]%>); - -<% if params[:period_type] == 1 || params[:period_type] == "1" %> - $("#rd_period_type_1").attr("checked","checked"); -<% else %> - $("#rd_period_type_0").attr("checked","checked"); -<% end %> -$(".btn-group button").removeClass("active"); -<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %> -$("#btn_report_type_<%= report_type %>").addClass("active"); - -$('#item').change(function(){ - var item = $('#item').val(); - var payment_type = $('#payment_type'); - - if(item == 'sale'){ - $('#waiter').hide(); - $('#cashier').show(); - if(payment_type){ - $('#payment_type').show(); - } - } - else{ - $('#cashier').hide(); - $('#waiter').show(); - if(payment_type){ - $('#payment_type').hide(); - } - } -}); \ No newline at end of file diff --git a/app/views/reports/sale_item/index.html.erb b/app/views/reports/sale_item/index.html.erb new file mode 100644 index 00000000..cce5a210 --- /dev/null +++ b/app/views/reports/sale_item/index.html.erb @@ -0,0 +1,141 @@ + + +
+ <%= render :partial=>'shift_sale_report_filter', + :locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_sale_item_index_path} %> +
+
+ +
+
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + +
Date
Menu CategoryCodeProductTotal ItemUnit PriceRevenue
+
+
+
+ + \ No newline at end of file diff --git a/app/views/reports/sale_item/index.xls.erb b/app/views/reports/sale_item/index.xls.erb new file mode 100644 index 00000000..dfcc18d4 --- /dev/null +++ b/app/views/reports/sale_item/index.xls.erb @@ -0,0 +1,116 @@ +
+
+ + + <% if params[:from]%> + + + + <% end %> + + + + + + + + + + + + + + + + + + + <% unless @sale_data.empty? %> + + + <% void = 0 %> + <% mpu = 0 %> + <% master = 0 %> + <% visa = 0 %> + <% jcb = 0 %> + <% paypar = 0 %> + <% cash = 0 %> + <% credit = 0 %> + <% foc = 0 %> + <% discount = 0 %> + <% total = 0 %> + <% grand_total = 0 %> + <% count = 1 %> <% rounding_adj = 0 %> + <% @sale_data.each do |sale| %> + <% void += sale[:void_amount] %> + <% mpu += sale[:mpu_amount] %> + <% master += sale[:master_amount] %> + <% visa += sale[:visa_amount] %> + <% jcb += sale[:jcb_amount] %> + <% paypar += sale[:paypar_amount] %> + <% cash += sale[:cash_amount] %> + <% credit += sale[:credit_amount] %> + <% foc += sale[:foc_amount] %> + <% discount += sale[:total_discount] %> + <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %> + <% grand_total += sale[:grand_total].to_f %> + <% rounding_adj += sale[:rounding_adj].to_f %> + + + + + + + + + + + + + + + + + + <% count = count + 1 %> + <% end %> + + + + + + + + + + + + + + + + + + <% total_tax = 0 %> + <% unless @tax.empty? %> + <% @tax.each do |tax| %> + <% total_tax += tax.tax_amount.to_f %> + + + + + + + <% end %> + <% net = total - total_tax %> + + + + + + <% end %> + + <% end %> +
Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)
Sr.noDateDaily Void AmountDaily mpu SalesDaily master SalesDaily visa SalesDaily jcb SalesDaily paypar SalesDaily Cash SalesDaily Credit SalesDaily FOC Sales(Daily Discount)Grand Total +
Rounding Adj.
Rounding Adj.Grand Total
<%= count %><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%>
Total<%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%>
<%= tax.tax_name rescue '-'%><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%> 
Net Amount<%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%> 
+
+
\ No newline at end of file diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 1e5cc41a..04343380 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -66,7 +66,7 @@ <%= @sale.receipt_no %> <%= @sale.cashier_name rescue '-' %> <%= @sale.sale_status %> - <%= @sale.requested_at %> + <%= @sale.requested_at.strftime("%m-%d-%Y %H:%M %p") %> Sale item name @@ -175,63 +175,63 @@
- -
-
-
-
-

Customer Profile

-
- - - - - - - - - - - - - - - - - - - - - - - -
Name<%= @customer.name %>
Email<%= @customer.email %>
Contact no<%= @customer.contact_no %>
Company<%= @customer.company %>
Date Of Birth<%= @customer.date_of_birth %>
-
-
-
-
-

Membership Detail

-
- - - <% if @membership == 0 %> - - - - <% else %> - <% @membership.each do |member| %> - - - - - <% end %> - - <% end %> - -
"There is no membership data"
<%= member["accountable_type"] %><%= member["balance"] %>
-
-
-
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% + if @response["status"] == true %> + <% @response["data"].each do |transaction| %> + + + + + + + + + + + <% end %> + <% end %> + +
Card NoNameCompanyContact noEmailNRC/Passport NoAddressDOB
<%= @customer.card_no rescue '-'%><%= @customer.name %><%= @customer.company rescue '-' %><%= @customer.contact_no %><%= @customer.email %><%= @customer.nrc_no %><%= @customer.address%><%= @customer.date_of_birth %>
Membership Transactions
DateRedeemRebateBalanceStatusReceipt No
<%= transaction["date"]%><%= transaction["redeem"]%><%= transaction["rebate"] %><%= transaction["balance"] %><%= transaction["status"] %><%= transaction["receipt_no"] %>
diff --git a/config/environment.rb b/config/environment.rb index 426333bb..f467c11e 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -3,3 +3,4 @@ require_relative 'application' # Initialize the Rails application. Rails.application.initialize! + diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 9952a7bc..461f6489 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -12,7 +12,7 @@ Rails.application.config.assets.version = '1.0' # --- Waiter/ Cashier - Orgiami ---- Rails.application.config.assets.precompile += %w( origami.css ) -Rails.application.config.assets.precompile += %w( origami.js ) +# Rails.application.config.assets.precompile += %w( origami.js ) # -- Order Queue Station ----- Rails.application.config.assets.precompile += %w( OQS.css ) Rails.application.config.assets.precompile += %w( OQS.js ) @@ -22,3 +22,7 @@ Rails.application.config.assets.precompile += %w( settings.css ) # --- Customer/ Customer - Crm ---- Rails.application.config.assets.precompile += %w( CRM.css ) Rails.application.config.assets.precompile += %w( CRM.js ) + +# --- Customer/ Customer - Crm ---- +Rails.application.config.assets.precompile += %w( jquery-confirm.css ) +Rails.application.config.assets.precompile += %w( jquery-confirm.js ) diff --git a/config/routes.rb b/config/routes.rb index 6253a95f..7ec8b9e5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,10 +44,9 @@ Rails.application.routes.draw do #Order Controller resources :orders, only: [:create, :show, :update] do - post "bill" => "bill#create" - end + get 'view_orders' => "orders#view_orders" #Current active bookings resources :bookings, only: [:index, :show, :create, :update] @@ -72,17 +71,24 @@ Rails.application.routes.draw do #--------- Cashier ------------# namespace :origami do root "home#index" - get "/:booking_id" => "home#index" do #origami/:booking_id will show + get "table/:dining_id" => "home#show" do #origami/:booking_id will show # resources :discounts, only: [:index,:new, :create ] #add discount type resources :customers #add customer type end + post 'moving' => "movetable#moving" + + get 'table/:dining_id/movetable' => "movetable#move_dining" + get 'table/:dining_id/moveroom' => "moveroom#move_dining" + get 'sale/:sale_id' => 'sales#show' + get 'room/:room_id' => 'rooms#show' + get 'order/:order_id' => "orders#show" post '/:booking_id' => 'home#item_show' get "/:id/discount" => "discounts#index" post "/:id/discount" => "discounts#create" - get "/:id/request_bills" => "request_bills#print" + post "/:id/request_bills" => "request_bills#print" ,:defaults => { :format => 'json' } get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' } #--------- Payment ------------# get 'sale/:sale_id/payment' => 'payments#show' @@ -212,6 +218,7 @@ Rails.application.routes.draw do namespace :reports do resources :receipt_no, :only => [:index, :show] resources :daily_sale, :only => [:index, :show] + resources :sale_item, :only => [:index, :show] # resources :sales, :only => [:index, :show] # resources :orders, :only => [:index, :show] # resources :customers, :only => [:index, :show] diff --git a/db/migrate/20170403140820_create_order_items.rb b/db/migrate/20170403140820_create_order_items.rb index c5382030..ca1166dc 100644 --- a/db/migrate/20170403140820_create_order_items.rb +++ b/db/migrate/20170403140820_create_order_items.rb @@ -7,6 +7,7 @@ class CreateOrderItems < ActiveRecord::Migration[5.1] t.string :item_order_by #person who order this t.string :item_code, :null => false t.string :item_name, :null => false + t.integer :account_id, :limit => 8, :null => false, :default => 1 t.decimal :qty, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :price, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.string :remark diff --git a/db/migrate/20170403161857_create_sale_items.rb b/db/migrate/20170403161857_create_sale_items.rb index cb07db08..48b1363e 100644 --- a/db/migrate/20170403161857_create_sale_items.rb +++ b/db/migrate/20170403161857_create_sale_items.rb @@ -5,6 +5,7 @@ class CreateSaleItems < ActiveRecord::Migration[5.1] t.string :sale_id, foreign_key: true, :limit => 16 t.string :product_code, :null => false t.string :product_name, :null => false + t.integer :account_id, :limit => 8, :null => false, :default => 1 t.string :remark t.decimal :qty, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :unit_price, :precision => 10, :scale => 2, :null => false, :default => 0.00 diff --git a/db/migrate/20170403135121_create_customers.rb b/db/migrate/20170621085729_create_customers.rb similarity index 79% rename from db/migrate/20170403135121_create_customers.rb rename to db/migrate/20170621085729_create_customers.rb index 318e7bf1..57553010 100644 --- a/db/migrate/20170403135121_create_customers.rb +++ b/db/migrate/20170621085729_create_customers.rb @@ -10,6 +10,11 @@ class CreateCustomers < ActiveRecord::Migration[5.1] t.string :membership_id t.string :membership_type t.string :membership_authentication_code + t.string :salution + t.string :gender + t.string :nrc_no + t.string :address + t.string :card_no, :unique => true t.timestamps end diff --git a/db/seeds.rb b/db/seeds.rb index 56591e2c..c3d9a354 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -83,8 +83,8 @@ void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manag {lookup_type:'void_reason', name: 'Waiter Mistake', value: 'Waiter Mistake'}]) #WALK CUSTOMER - Default CUSTOMER (take key 1) -customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000"}) -customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111"}) +customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000", card_no:'000' }) +customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111", card_no:'111' }) #Default ZOne # zone = Zone.create({id:1, name: "Normal Zone", is_active:true, created_by: "SYSTEM DEFAULT"}) @@ -161,7 +161,8 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance", {membership_type:"update_membership_customer",gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, {membership_type:"get_all_member_group",gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, {membership_type:"rebate",gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, - {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"} + {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}, + {membership_type:"get_member_transactions",gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"} ]) payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://192.168.1.47:3006"})