diff --git a/Gemfile b/Gemfile index 99489d5b..227cfa72 100644 --- a/Gemfile +++ b/Gemfile @@ -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..e4b905ea 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,7 @@ GEM nokogiri (1.8.0) mini_portile2 (~> 2.2.0) pdf-core (0.7.0) - pg (0.20.0) + pg (0.21.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -159,8 +160,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 +192,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 +246,7 @@ DEPENDENCIES bootstrap (~> 4.0.0.alpha3) bootstrap-datepicker-rails byebug + cancancan (~> 1.10) coffee-rails (~> 4.2) cups (~> 0.0.7) database_cleaner 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 47a4dace..7acdb485 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -8,8 +8,293 @@ //= require bootstrap-datepicker $(document).ready(function(){ - $(".orders").on('click', function(){ - var dining_id = $(this).attr("data-id"); - window.location.href = '/origami/' + dining_id; - }) + // 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'); + }); + + // $(".orders").on('click', function(){ + // var dining_id = $(this).attr("data-id"); + // window.location.href = '/origami/' + dining_id; + // }) + }); 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/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/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 0e850b00..37eef687 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -20,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) @@ -32,6 +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) + + 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/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/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/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/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/sale.rb b/app/models/sale.rb index 4998abfc..6b02e4c8 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -17,6 +17,14 @@ class Sale < ApplicationRecord 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) status = false @@ -336,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 e827113c..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}]" @@ -84,12 +84,15 @@ 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 begin @@ -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 @@ -257,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 @@ -292,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/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/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/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/origami.html.erb b/app/views/layouts/origami.html.erb index ea2c0ce4..1f519d2b 100644 --- a/app/views/layouts/origami.html.erb +++ b/app/views/layouts/origami.html.erb @@ -11,6 +11,8 @@ <%= stylesheet_link_tag 'origami', media: 'all', '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' %> diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index fd1134f9..3b192319 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -29,6 +29,7 @@ Select + Sr.no Name Company Contact no @@ -37,12 +38,14 @@ - <% if @crm_customers.count > 0 %> + <% 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 %> @@ -72,32 +75,86 @@ <%= 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"%> @@ -127,8 +184,6 @@
- - 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 3a596cee..461f6489 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -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 8f9b7dea..29c1960e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -89,7 +89,7 @@ Rails.application.routes.draw do get "/:id/discount" => "discounts#index" post "/:id/discount" => "discounts#create" - post "/: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' @@ -219,6 +219,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/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..a646bdad 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -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"})