0)for(i=0;n>i;i+=1)t.cancelling=!0,a[i].abort();return t._setProgressCancelled(),t._getThumbs().each(function(){var i=e(this),a=i.attr("data-fileindex");i.removeClass("file-uploading"),void 0!==t.filestack[a]&&(i.find(".kv-file-upload").removeClass("disabled").removeAttr("disabled"),i.find(".kv-file-remove").removeClass("disabled").removeAttr("disabled")),t.unlock()}),t.$element},clear:function(){var t,a=this;if(a._raise("fileclear"))return a.$btnUpload.removeAttr("disabled"),a._getThumbs().find("video,audio,img").each(function(){i.cleanMemory(e(this))}),a._resetUpload(),a.clearStack(),a._clearFileInput(),a._resetErrors(!0),a._hasInitialPreview()?(a._showFileIcon(),a._resetPreview(),a._initPreviewActions(),a.$container.removeClass("file-input-new")):(a._getThumbs().each(function(){a._clearObjects(e(this))}),a.isUploadable&&(a.previewCache.data={}),a.$preview.html(""),t=!a.overwriteInitial&&a.initialCaption.length>0?a.initialCaption:"",a.$caption.html(t),a.$caption.attr("title",""),i.addCss(a.$container,"file-input-new"),a._validateDefaultPreview()),0===a.$container.find(i.FRAMES).length&&(a._initCaption()||a.$captionContainer.find(".kv-caption-icon").hide()),a._hideFileIcon(),a._raise("filecleared"),a.$captionContainer.focus(),a._setFileDropZoneTitle(),a.$element},reset:function(){var e=this;if(e._raise("filereset"))return e._resetPreview(),e.$container.find(".fileinput-filename").text(""),i.addCss(e.$container,"file-input-new"),(e.getFrames().length||e.isUploadable&&e.dropZoneEnabled)&&e.$container.removeClass("file-input-new"),e.clearStack(),e.formdata={},e._setFileDropZoneTitle(),e.$element},disable:function(){var e=this;return e.isDisabled=!0,e._raise("filedisabled"),e.$element.attr("disabled","disabled"),e.$container.find(".kv-fileinput-caption").addClass("file-caption-disabled"),e.$container.find(".btn-file, .fileinput-remove, .fileinput-upload, .file-preview-frame button").attr("disabled",!0),e._initDragDrop(),e.$element},enable:function(){var e=this;return e.isDisabled=!1,e._raise("fileenabled"),e.$element.removeAttr("disabled"),e.$container.find(".kv-fileinput-caption").removeClass("file-caption-disabled"),e.$container.find(".btn-file, .fileinput-remove, .fileinput-upload, .file-preview-frame button").removeAttr("disabled"),e._initDragDrop(),e.$element},upload:function(){var t,a,n,r=this,o=r.getFileStack().length,l=!e.isEmptyObject(r._getExtraData());if(r.isUploadable&&!r.isDisabled&&r._isFileSelectionValid(o)){if(r._resetUpload(),0===o&&!l)return void r._showUploadError(r.msgUploadEmpty);if(r.$progress.removeClass("hide"),r.uploadCount=0,r.uploadStatus={},r.uploadLog=[],r.lock(),r._setProgress(2),0===o&&l)return void r._uploadExtraOnly();if(n=r.filestack.length,r.hasInitData=!1,!r.uploadAsync)return r._uploadBatch(),r.$element;for(a=r._getOutData(),r._raise("filebatchpreupload",[a]),r.fileBatchCompleted=!1,r.uploadCache={content:[],config:[],tags:[],append:!0},r.uploadAsyncCount=r.getFileStack().length,t=0;n>t;t++)r.uploadCache.content[t]=null,r.uploadCache.config[t]=null,r.uploadCache.tags[t]=null;for(r.$preview.find(".file-preview-initial").removeClass(i.SORT_CSS),r._initSortable(),r.cacheInitialPreview=r.getPreview(),t=0;n>t;t++)r.filestack[t]&&r._uploadSingle(t,!0)}},destroy:function(){var i=this,t=i.$form,a=i.$container,n=i.$element,r=i.namespace;return e(document).off(r),e(window).off(r),t&&t.length&&t.off(r),i.isUploadable&&i._clearFileInput(),i._cleanup(),i._initPreviewCache(),n.insertBefore(a).off(r).removeData(),a.off().remove(),n},refresh:function(i){var t=this,a=t.$element;return i=i?e.extend(!0,{},t.options,i):t.options,t.destroy(),a.fileinput(i),t=a.data("fileinput"),t.isUploadable&&t._clearFileInput(),a.val()&&a.trigger("change.fileinput"),a},zoom:function(e){var t=this,a=t._getFrame(e),n=t.$modal;a&&(i.initModal(n),n.html(t._getModalContent()),t._setZoomContent(a),n.modal("show"),t._initZoomButtons())},getExif:function(e){var i=this,t=i._getFrame(e);return t&&t.data("exif")||null},getFrames:function(e){var t=this;return e=e||"",t.$preview.find(i.FRAMES+e)},getPreview:function(){var e=this;return{content:e.initialPreview,config:e.initialPreviewConfig,tags:e.initialPreviewThumbTags}}},e.fn.fileinput=function(a){if(i.hasFileAPISupport()||i.isIE(9)){var n=Array.apply(null,arguments),r=[];switch(n.shift(),this.each(function(){var o,l=e(this),s=l.data("fileinput"),d="object"==typeof a&&a,c=d.theme||l.data("theme"),u={},p={},f=d.language||l.data("language")||e.fn.fileinput.defaults.language||"en";s||(c&&(p=e.fn.fileinputThemes[c]||{}),"en"===f||i.isEmpty(e.fn.fileinputLocales[f])||(u=e.fn.fileinputLocales[f]||{}),o=e.extend(!0,{},e.fn.fileinput.defaults,p,e.fn.fileinputLocales.en,u,d,l.data()),s=new t(this,o),l.data("fileinput",s)),"string"==typeof a&&r.push(s[a].apply(s,n))}),r.length){case 0:return this;case 1:return r[0];default:return r}}},e.fn.fileinput.defaults={language:"en",showCaption:!0,showBrowse:!0,showPreview:!0,showRemove:!0,showUpload:!0,showCancel:!0,showClose:!0,showUploadedThumbs:!0,browseOnZoneClick:!1,autoReplace:!1,autoOrientImage:!0,required:!1,rtl:!1,hideThumbnailContent:!1,generateFileId:null,previewClass:"",captionClass:"",frameClass:"krajee-default",mainClass:"file-caption-main",mainTemplate:null,purifyHtml:!0,fileSizeGetter:null,initialCaption:"",initialPreview:[],initialPreviewDelimiter:"*$$*",initialPreviewAsData:!1,initialPreviewFileType:"image",initialPreviewConfig:[],initialPreviewThumbTags:[],previewThumbTags:{},initialPreviewShowDelete:!0,removeFromPreviewOnError:!1,deleteUrl:"",deleteExtraData:{},overwriteInitial:!0,previewZoomButtonIcons:{prev:'',next:'',toggleheader:'',fullscreen:'',borderless:'',close:''},previewZoomButtonClasses:{prev:"btn btn-navigate",next:"btn btn-navigate",toggleheader:"btn btn-default btn-header-toggle",fullscreen:"btn btn-default",borderless:"btn btn-default",close:"btn btn-default"},preferIconicPreview:!1,preferIconicZoomPreview:!1,allowedPreviewTypes:void 0,allowedPreviewMimeTypes:null,allowedFileTypes:null,allowedFileExtensions:null,defaultPreviewContent:null,customLayoutTags:{},customPreviewTags:{},previewFileIcon:'',previewFileIconClass:"file-other-icon",previewFileIconSettings:{},previewFileExtSettings:{},buttonLabelClass:"hidden-xs",browseIcon:' ',browseClass:"btn btn-primary",removeIcon:'',removeClass:"btn btn-default",cancelIcon:'',cancelClass:"btn btn-default",uploadIcon:'',uploadClass:"btn btn-default",uploadUrl:null,uploadAsync:!0,uploadExtraData:{},zoomModalHeight:480,minImageWidth:null,minImageHeight:null,maxImageWidth:null,maxImageHeight:null,resizeImage:!1,resizePreference:"width",resizeQuality:.92,resizeDefaultImageType:"image/jpeg",resizeIfSizeMoreThan:0,minFileSize:0,maxFileSize:0,maxFilePreviewSize:25600,minFileCount:0,maxFileCount:0,validateInitialCount:!1,msgValidationErrorClass:"text-danger",msgValidationErrorIcon:' ',msgErrorClass:"file-error-message",progressThumbClass:"progress-bar progress-bar-success progress-bar-striped active",progressClass:"progress-bar progress-bar-success progress-bar-striped active",progressCompleteClass:"progress-bar progress-bar-success",progressErrorClass:"progress-bar progress-bar-danger",progressUploadThreshold:99,previewFileType:"image",elCaptionContainer:null,elCaptionText:null,elPreviewContainer:null,elPreviewImage:null,elPreviewStatus:null,elErrorContainer:null,errorCloseButton:'×',slugCallback:null,dropZoneEnabled:!0,dropZoneTitleClass:"file-drop-zone-title",fileActionSettings:{},otherActionButtons:"",textEncoding:"UTF-8",ajaxSettings:{},ajaxDeleteSettings:{},showAjaxErrorDetails:!0},e.fn.fileinputLocales.en={fileSingle:"file",filePlural:"files",browseLabel:"Browse …",removeLabel:"Remove",removeTitle:"Clear selected files",cancelLabel:"Cancel",cancelTitle:"Abort ongoing upload",uploadLabel:"Upload",uploadTitle:"Upload selected files",msgNo:"No",msgNoFilesSelected:"No files selected",msgCancelled:"Cancelled",msgZoomModalHeading:"Detailed Preview",msgFileRequired:"You must select a file to upload.",msgSizeTooSmall:'File "{name}" ({size} KB) is too small and must be larger than {minSize} KB.',msgSizeTooLarge:'File "{name}" ({size} KB) exceeds maximum allowed upload size of {maxSize} KB.',msgFilesTooLess:"You must select at least {n} {files} to upload.",msgFilesTooMany:"Number of files selected for upload ({n}) exceeds maximum allowed limit of {m}.",msgFileNotFound:'File "{name}" not found!',msgFileSecured:'Security restrictions prevent reading the file "{name}".',msgFileNotReadable:'File "{name}" is not readable.',msgFilePreviewAborted:'File preview aborted for "{name}".',msgFilePreviewError:'An error occurred while reading the file "{name}".',msgInvalidFileName:'Invalid or unsupported characters in file name "{name}".',msgInvalidFileType:'Invalid type for file "{name}". Only "{types}" files are supported.',msgInvalidFileExtension:'Invalid extension for file "{name}". Only "{extensions}" files are supported.',msgFileTypes:{image:"image",html:"HTML",text:"text",video:"video",audio:"audio",flash:"flash",pdf:"PDF",object:"object"},msgUploadAborted:"The file upload was aborted",msgUploadThreshold:"Processing...",msgUploadBegin:"Initializing...",msgUploadEnd:"Done",msgUploadEmpty:"No valid data available for upload.",msgValidationError:"Validation Error",msgLoading:"Loading file {index} of {files} …",msgProgress:"Loading file {index} of {files} - {name} - {percent}% completed.",msgSelected:"{n} {files} selected",msgFoldersNotAllowed:"Drag & drop files only! {n} folder(s) dropped were skipped.",msgImageWidthSmall:'Width of image file "{name}" must be at least {size} px.',msgImageHeightSmall:'Height of image file "{name}" must be at least {size} px.',msgImageWidthLarge:'Width of image file "{name}" cannot exceed {size} px.',msgImageHeightLarge:'Height of image file "{name}" cannot exceed {size} px.',msgImageResizeError:"Could not get the image dimensions to resize.",msgImageResizeException:"Error while resizing the image.{errors}",msgAjaxError:"Something went wrong with the {operation} operation. Please try again later!",msgAjaxProgressError:"{operation} failed",ajaxOperations:{deleteThumb:"file delete",uploadThumb:"file upload",uploadBatch:"batch file upload",uploadExtra:"form data upload"},dropZoneTitle:"Drag & drop files here …",dropZoneClickTitle:"
(or click to select {files})",previewZoomButtonTitles:{prev:"View previous file",next:"View next file",toggleheader:"Toggle header",fullscreen:"Toggle full screen",borderless:"Toggle borderless mode",close:"Close detailed preview"}},e.fn.fileinput.Constructor=t,e(document).ready(function(){var i=e("input.file[type=file]");i.length&&i.fileinput()})});
\ No newline at end of file
diff --git a/app/assets/javascripts/origami/addorders.coffee b/app/assets/javascripts/origami/addorders.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/origami/addorders.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/settings/item_sets.coffee b/app/assets/javascripts/settings/item_sets.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/settings/item_sets.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/settings/menu_item_sets.coffee b/app/assets/javascripts/settings/menu_item_sets.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/settings/menu_item_sets.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/stylesheets/fileinput.min.css b/app/assets/stylesheets/fileinput.min.css
new file mode 100755
index 00000000..058787f7
--- /dev/null
+++ b/app/assets/stylesheets/fileinput.min.css
@@ -0,0 +1,12 @@
+/*!
+ * bootstrap-fileinput v4.4.3
+ * http://plugins.krajee.com/file-input
+ *
+ * Krajee default styling for bootstrap-fileinput.
+ *
+ * Author: Kartik Visweswaran
+ * Copyright: 2014 - 2017, Kartik Visweswaran, Krajee.com
+ *
+ * Licensed under the BSD 3-Clause
+ * https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md
+ */.file-drop-zone,.krajee-default .file-preview-audio audio,.krajee-default .file-preview-image,.krajee-default .file-preview-other{vertical-align:middle}.file-loading{top:0;right:0;width:25px;height:25px;font-size:999px;text-align:right;color:#fff;background:url(../img/loading.gif) top left no-repeat;border:none}.file-object{margin:0 0 -5px;padding:0}.btn-file{position:relative;overflow:hidden}.btn-file input[type=file]{position:absolute;top:0;right:0;min-width:100%;min-height:100%;text-align:right;opacity:0;background:none;cursor:inherit;display:block}.file-caption-name{display:inline-block;overflow:hidden;height:20px;word-break:break-all}.input-group-lg .file-caption-name{height:25px}.file-zoom-dialog{text-align:left}.file-error-message{color:#a94442;background-color:#f2dede;margin:5px;border:1px solid #ebccd1;border-radius:4px;padding:15px}.file-error-message pre,.file-error-message ul{margin:0;text-align:left}.file-error-message pre{margin:5px 0}.file-caption-disabled{background-color:#EEE;cursor:not-allowed;opacity:1}.file-preview{border-radius:5px;border:1px solid #ddd;padding:5px;width:100%;margin-bottom:5px}.file-preview-image{font:40px Impact,Charcoal,sans-serif;color:green}.krajee-default.file-preview-frame{position:relative;display:table;margin:8px;border:1px solid #ddd;box-shadow:1px 1px 5px 0 #a2958a;padding:6px;float:left;text-align:center}.krajee-default.file-preview-frame:not(.file-preview-error):hover{box-shadow:3px 3px 5px 0 #333}.krajee-default.file-preview-frame .kv-file-content{height:170px}.krajee-default.file-preview-frame .file-thumbnail-footer{height:70px}.krajee-default .file-preview-text{display:block;color:#428bca;border:1px solid #ddd;font-family:Menlo,Monaco,Consolas,"Courier New",monospace;outline:0;padding:8px;resize:none}.krajee-default .file-preview-html{border:1px solid #ddd;padding:8px;overflow:auto}.krajee-default[data-template=audio] .file-preview-audio{display:table-cell;vertical-align:middle;height:170px;border:1px solid #ddd;border-radius:5px}.krajee-default .file-zoom-dialog .file-preview-text{font-size:1.2em}.krajee-default .file-preview-other{left:0;top:0;right:0;bottom:0;margin:auto;text-align:center;padding:10px}.krajee-default .file-preview-other:hover{opacity:.8}.krajee-default .file-actions,.krajee-default .file-other-error{text-align:left}.krajee-default .file-other-icon{font-size:8em}.krajee-default .file-actions{margin-top:15px}.krajee-default .file-footer-buttons{float:right}.krajee-default .file-footer-caption{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:160px;text-align:center;padding-top:4px;font-size:11px;color:#777;margin:5px auto}.file-input-ajax-new .fileinput-remove-button,.file-input-ajax-new .fileinput-upload-button,.file-input-ajax-new .no-browse .input-group-btn,.file-input-new .close,.file-input-new .file-preview,.file-input-new .fileinput-remove-button,.file-input-new .fileinput-upload-button,.file-input-new .glyphicon-file,.file-input-new .no-browse .input-group-btn,.hide-content .kv-file-content{display:none}.krajee-default .file-preview-error{opacity:.65;box-shadow:none}.krajee-default .file-preview-frame:not(.file-preview-error) .file-footer-caption:hover{color:#000}.krajee-default .file-drag-handle,.krajee-default .file-upload-indicator{position:absolute;text-align:center;bottom:-6px;left:-6px;padding:8px 8px 1px 3px;border-left:none;border-bottom:none;border-right:1px solid #8a6d3b;border-top:1px solid #8a6d3b;border-top-right-radius:24px;font-size:12px}.krajee-default .file-drag-handle{background-color:#d9edf7;border-color:#bce8f1}.krajee-default .file-upload-indicator{font-size:13px;background-color:#fcf8e3;border-color:#faebcc;padding-bottom:0}.krajee-default.file-preview-error .file-upload-indicator{background-color:#f2dede;border-color:#ebccd1}.krajee-default.file-preview-success .file-upload-indicator{background-color:#dff0d8;border-color:#d6e9c6}.krajee-default.file-preview-loading .file-upload-indicator{background-color:#e5e5e5;border-color:#777}.krajee-default .file-thumb-progress .progress,.krajee-default .file-thumb-progress .progress-bar{height:10px;font-size:9px;line-height:10px}.krajee-default .file-thumbnail-footer{position:relative}.krajee-default .file-thumb-progress{height:10px;position:absolute;top:35px;left:0;right:0}.krajee-default.kvsortable-ghost{background:#e1edf7;border:2px solid #a1abff}.file-zoom-dialog .file-other-icon{font-size:22em;font-size:50vmin}.file-caption-main{width:100%}.file-input-ajax-new .no-browse .form-control,.file-input-new .no-browse .form-control{border-top-right-radius:4px;border-bottom-right-radius:4px}.file-thumb-loading{background:url(../img/loading.gif) center center no-repeat content-box!important}.file-sortable .file-drag-handle{cursor:move;cursor:-webkit-grabbing;opacity:1}.file-sortable .file-drag-handle:hover{opacity:.7}.file-drop-zone{border:1px dashed #aaa;border-radius:4px;height:100%;text-align:center;margin:12px 15px 12px 12px;padding:5px}.file-drop-zone-title{color:#aaa;font-size:1.6em;padding:85px 10px;cursor:default}.clickable .file-drop-zone-title,.file-preview .clickable{cursor:pointer}.file-drop-zone.clickable:hover{border:2px dashed #999}.file-drop-zone.clickable:focus{border:2px solid #5acde2}.file-drop-zone .file-preview-thumbnails{cursor:default}.file-highlighted{border:2px dashed #999!important;background-color:#f0f0f0}.file-uploading{background:url(../img/loading-sm.gif) center bottom 10px no-repeat;opacity:.65}.file-zoom-fullscreen.modal{position:fixed;top:0;right:0;bottom:0;left:0}.file-zoom-fullscreen .modal-dialog{position:fixed;margin:0;width:100%;height:100%;padding:0}.file-zoom-fullscreen .modal-content{border-radius:0;box-shadow:none}.file-zoom-fullscreen .modal-body{overflow-y:auto}.file-zoom-dialog .modal-body{position:relative!important}.file-zoom-dialog .btn-navigate{position:absolute;padding:0;margin:0;background:0 0;text-decoration:none;outline:0;opacity:.7;top:45%;font-size:4em;color:#1c94c4}.file-zoom-dialog .floating-buttons{position:absolute;top:5px;right:10px}.floating-buttons,.floating-buttons .btn{z-index:3000}.file-zoom-dialog .kv-zoom-actions .btn,.floating-buttons .btn{margin-left:3px}.file-zoom-dialog .btn-navigate:not([disabled]):focus,.file-zoom-dialog .btn-navigate:not([disabled]):hover{outline:0;box-shadow:none;opacity:.5}.file-zoom-dialog .btn-navigate[disabled]{opacity:.3}.file-zoom-dialog .btn-prev{left:1px}.file-zoom-dialog .btn-next{right:1px}.file-zoom-content{height:480px;text-align:center}.file-zoom-content .file-preview-image,.file-zoom-content .file-preview-video{max-height:100%}.file-zoom-content>.file-object.type-image{width:auto;height:auto;min-height:inherit;max-width:100%;max-height:100%}.file-zoom-content>.file-object.type-flash,.file-zoom-content>.file-object.type-video{width:auto;height:100%;max-width:100%;max-height:100%}.file-zoom-content>.file-object.type-audio{width:auto;height:30px}.file-zoom-content>.file-object.type-default,.file-zoom-content>.file-object.type-html,.file-zoom-content>.file-object.type-pdf,.file-zoom-content>.file-object.type-text{width:100%}.file-preview-initial.sortable-chosen{background-color:#d9edf7}.btn-file ::-ms-browse{font-size:10000px;width:100%;height:100%}.rotate-2{transform:rotateY(180deg)}.rotate-3{transform:rotate(180deg)}.rotate-4{transform:rotate(180deg) rotateY(180deg)}.rotate-5{transform:rotate(270deg) rotateY(180deg)}.rotate-6{transform:rotate(90deg)}.rotate-7{transform:rotate(90deg) rotateY(180deg)}.rotate-8{transform:rotate(270deg)}.file-zoom-content .is-portrait-gt4{margin-top:60px}
\ No newline at end of file
diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss
index 0139f1d0..10e2b319 100644
--- a/app/assets/stylesheets/origami.scss
+++ b/app/assets/stylesheets/origami.scss
@@ -268,4 +268,3 @@ tr.discount-item-row:hover {
-moz-opacity: 1; /* mozilla */
}
-
diff --git a/app/assets/stylesheets/origami/addorders.scss b/app/assets/stylesheets/origami/addorders.scss
new file mode 100644
index 00000000..f45d06f3
--- /dev/null
+++ b/app/assets/stylesheets/origami/addorders.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the origami/addorders controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/settings.scss b/app/assets/stylesheets/settings.scss
index 37064f07..ec02f7c4 100644
--- a/app/assets/stylesheets/settings.scss
+++ b/app/assets/stylesheets/settings.scss
@@ -26,7 +26,38 @@ ul.dropdown-menu li a{
background-color: transparent !important;
margin-bottom: 0px !important;
}
+
.page-header{
border-bottom :0px solid #000 !important;
margin :0px !important;
-}
\ No newline at end of file
+}
+
+.center-text {
+ text-align:center;
+ background-color:#ddd;
+}
+
+.footer {
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ height: auto;
+ background-color: #ef404a;
+ width: 100%;
+ }
+
+ .footer-header {
+ color : #ef404a;
+ font-weight:bold;
+ font-style:italic;
+ margin-bottom:0px;
+ }
+
+ .menu-item-img {
+ margin: 10px;
+ text-align: center;
+ }
+
+ .padding-10 {
+ padding: 10px;
+ }
\ No newline at end of file
diff --git a/app/assets/stylesheets/settings/item_sets.scss b/app/assets/stylesheets/settings/item_sets.scss
new file mode 100644
index 00000000..004d8d6b
--- /dev/null
+++ b/app/assets/stylesheets/settings/item_sets.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Settings/ItemSets controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/settings/menu_item_sets.scss b/app/assets/stylesheets/settings/menu_item_sets.scss
new file mode 100644
index 00000000..7f56c1b8
--- /dev/null
+++ b/app/assets/stylesheets/settings/menu_item_sets.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Settings/Menu_item_sets controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/api/restaurant/item_sets_controller.rb b/app/controllers/api/restaurant/item_sets_controller.rb
new file mode 100644
index 00000000..a7ad9efc
--- /dev/null
+++ b/app/controllers/api/restaurant/item_sets_controller.rb
@@ -0,0 +1,9 @@
+class Api::Restaurant::ItemSetsController < Api::ApiController
+
+ #Description
+ # Pull the default menu details and also other available (active) menus
+ # Input Params - order_id
+ def index
+ @item_sets = ItemSet.all
+ end
+end
diff --git a/app/controllers/api/restaurant/menu_categories.rb b/app/controllers/api/restaurant/menu_categories_controller.rb
similarity index 63%
rename from app/controllers/api/restaurant/menu_categories.rb
rename to app/controllers/api/restaurant/menu_categories_controller.rb
index fe7983ea..f1f3e6d0 100644
--- a/app/controllers/api/restaurant/menu_categories.rb
+++ b/app/controllers/api/restaurant/menu_categories_controller.rb
@@ -1,11 +1,11 @@
-class Api::Restaurant::MenuController < Api::ApiController
-
+class Api::Restaurant::MenuCategoriesController < Api::ApiController
+ skip_before_action :authenticate
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
- @menus = Menu.all
- @current_menu = Menu.current_menu
+ @menus = MenuCategory.all
+ @current_menu = MenuCategory.current_menu
end
@@ -21,10 +21,10 @@ class Api::Restaurant::MenuController < Api::ApiController
def menu_detail (menu_id)
if (menu_id)
#Pull this menu
- menu = Menu.find_by_id(menu_id)
+ menu = MenuCategory.find_by_id(menu_id)
return menu
else
- Menu.current_menu
+ MenuCategory.current_menu
end
end
diff --git a/app/controllers/api/restaurant/menu_controller.rb b/app/controllers/api/restaurant/menu_controller.rb
index fe7983ea..b45e1189 100644
--- a/app/controllers/api/restaurant/menu_controller.rb
+++ b/app/controllers/api/restaurant/menu_controller.rb
@@ -1,12 +1,11 @@
class Api::Restaurant::MenuController < Api::ApiController
-
+ skip_before_action :authenticate
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
@menus = Menu.all
- @current_menu = Menu.current_menu
-
+ # @current_menu = Menu.current_menu
end
#Description
diff --git a/app/controllers/api/restaurant/menu_item_attributes_controller.rb b/app/controllers/api/restaurant/menu_item_attributes_controller.rb
index f2aead8f..1b6a48d4 100644
--- a/app/controllers/api/restaurant/menu_item_attributes_controller.rb
+++ b/app/controllers/api/restaurant/menu_item_attributes_controller.rb
@@ -6,8 +6,4 @@ class Api::Restaurant::MenuItemAttributesController < Api::ApiController
def index
@menu_attributes = MenuItemAttribute.all
end
-
-
-
-
end
diff --git a/app/controllers/api/restaurant/menu_item_options_controller.rb b/app/controllers/api/restaurant/menu_item_options_controller.rb
index cc898add..16bd2f90 100644
--- a/app/controllers/api/restaurant/menu_item_options_controller.rb
+++ b/app/controllers/api/restaurant/menu_item_options_controller.rb
@@ -1,13 +1,8 @@
class Api::Restaurant::MenuItemOptionsController < Api::ApiController
-
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
@menu_options = MenuItemOption.all
end
-
-
-
-
end
diff --git a/app/controllers/concerns/token_verification.rb b/app/controllers/concerns/token_verification.rb
index 0cc6c263..66658b6a 100644
--- a/app/controllers/concerns/token_verification.rb
+++ b/app/controllers/concerns/token_verification.rb
@@ -14,10 +14,9 @@ module TokenVerification
end
def authenticate_token
- authenticate_with_http_token do |token, options|
+ authenticate_with_http_token do |token, options|
#@current_user = User.find_by(api_key: token)
Rails.logger.debug "token - " + token.to_s
-
@user = Employee.authenticate_by_token(token)
if @user
return true
diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb
index 49c64e52..ffa714a2 100644
--- a/app/controllers/crm/customers_controller.rb
+++ b/app/controllers/crm/customers_controller.rb
@@ -17,6 +17,8 @@ class Crm::CustomersController < BaseCrmController
@crm_customer = Customer.new
@count_customer = Customer.count_customer
+ @taxes = TaxProfile.all.order("order_by asc")
+
# if flash["errors"]
# @crm_customer.valid?
# end
@@ -63,15 +65,21 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers/1/edit
def edit
+ @customer = Customer.find(params[:id])
end
# POST /crm/customers
# POST /crm/customers.json
- def create
+ def create
+ # Remove "" default first
+ params[:customer][:tax_profiles].delete_at(0)
@crm_customers = Customer.new(customer_params)
respond_to do |format|
if @crm_customers.save
+ # update tax profile
+ customer = Customer.find(@crm_customers.customer_id)
+ customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
@@ -188,10 +196,12 @@ end
# PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json
def update
-
+ # Remove "" default first
+ params[:customer][:tax_profiles].delete_at(0)
respond_to do |format|
if @crm_customer.update(customer_params)
-
+ # update tax profile
+ @crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
@@ -346,7 +356,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,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no)
+ params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
+ :date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type)
end
end
diff --git a/app/controllers/oqs/backhome_controller.rb b/app/controllers/oqs/backhome_controller.rb
new file mode 100644
index 00000000..4ac5f0a2
--- /dev/null
+++ b/app/controllers/oqs/backhome_controller.rb
@@ -0,0 +1,126 @@
+class Oqs::HomeController < BaseOqsController
+ def index
+ queue_stations=OrderQueueStation.all
+
+ # Query for OQS with delivery status false
+ @queue_items_details = queue_items_query(false)
+
+ # Query for OQS with delivery status true
+ @queue_completed_item = completed_order
+
+ @queue_stations_items=Array.new
+
+ # Calculate Count for each station tab
+ queue_stations.each do |que|
+ i = 0
+ zone_id = 0
+ @queue_items_details.each do |qid|
+ dining = DiningFacility.find_by_name(qid.zone)
+ que.order_queue_process_by_zones.each do |qz|
+ if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
+ zone_id = qid.zone_id
+ i=i+1
+ end
+ end
+ end
+ @queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
+ end
+
+ # @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
+ @queue_stations_items
+ end
+
+ # Get Order items
+ def get_order_items
+ items = []
+ table_name = params[:table_id]
+ status = params[:status]
+ dining = DiningFacility.find_by_name(table_name);
+ # oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
+ # if status == ""
+ # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi|
+ # oi = OrderItem.find_by_item_code(aoi.item_code)
+ # items.push(oi)
+ # end
+ # else
+ # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi|
+ # oi = OrderItem.find_by_item_code(aoi.item_code)
+ # items.push(oi)
+ # end
+ # end
+
+ booking = Booking.find_by_dining_facility_id(dining.id)
+ BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo|
+ order=Order.find(bo.order_id)
+ order.order_items.each do |oi|
+ items.push(oi)
+ end
+ end
+
+ # booking_id = dining.get_new_booking
+ # BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
+ # order=Order.find(bo.order_id);
+ # order.order_items.each do |oi|
+ # items.push(oi)
+ # end
+ # end
+
+ render :json => items.to_json
+ end
+
+ def show
+ end
+
+ # update delivery status when complete click
+ def update_delivery_status
+ removed_item = []
+ assigned_item_id = params[:id]
+ assigned_item=AssignedOrderItem.find(assigned_item_id)
+ assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
+
+ # update delivery status for completed same order items
+ assigned_items.each do |ai|
+ ai.delivery_status=true
+ ai.save
+ removed_item.push(ai.assigned_order_item_id)
+ end
+ render :json => removed_item.to_json
+ end
+
+ # Query for OQS with delivery status
+ def queue_items_query(status)
+ AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
+ .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
+ left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
+ left join orders as od ON od.order_id = assigned_order_items.order_id
+ left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
+ left join customers as cus ON cus.customer_id = od.customer_id
+ left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
+ left join bookings as bk on bk.booking_id = bo.booking_id
+ left join dining_facilities as df on df.id = bk.dining_facility_id")
+ .where("assigned_order_items.delivery_status = 0 AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
+ .group("assigned_order_items.assigned_order_item_id")
+ .order("assigned_order_items.created_at")
+ end
+
+ # Completed Order
+ def completed_order
+ AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
+ .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
+ left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
+ left join orders as od ON od.order_id = assigned_order_items.order_id
+ left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
+ left join customers as cus ON cus.customer_id = od.customer_id
+ left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
+ left join bookings as bk on bk.booking_id = bo.booking_id
+ left join dining_facilities as df on df.id = bk.dining_facility_id")
+ .where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
+ .group("assigned_order_items.order_id")
+ .limit(20)
+ .order("assigned_order_items.created_at")
+
+
+ # completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
+ end
+
+end
diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb
index cef7c6b6..dae8b02f 100644
--- a/app/controllers/oqs/home_controller.rb
+++ b/app/controllers/oqs/home_controller.rb
@@ -1,33 +1,44 @@
class Oqs::HomeController < BaseOqsController
def index
- queue_stations=OrderQueueStation.all
+
+ @queue_stations = OrderQueueStation.all
# Query for OQS with delivery status false
- @queue_items_details = queue_items_query(false)
+ # @queue_items_details = queue_items_query(false)
# Query for OQS with delivery status true
- @queue_completed_item = completed_order
+
- @queue_stations_items=Array.new
+ @filter = params[:filter]
+
+ @queue_completed_item = completed_order(@filter)
+ if !@filter.nil?
+ @count = queue_items_count_query(false,@filter)
+ @count.each do |count|
- # Calculate Count for each station tab
- queue_stations.each do |que|
- i = 0
- zone_id = 0
- @queue_items_details.each do |qid|
- dining = DiningFacility.find_by_name(qid.zone)
- que.order_queue_process_by_zones.each do |qz|
- if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
- zone_id = qid.zone_id
- i=i+1
- end
- end
end
- @queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
end
- # @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
- @queue_stations_items
+ # @queue_stations_items=Array.new
+
+ # Calculate Count for each station tab
+ # @queue_stations.each do |que|
+ # i = 0
+ # zone_id = 0
+ # @queue_items_details.each do |qid|
+ # dining = DiningFacility.find_by_name(qid.zone)
+ # que.order_queue_process_by_zones.each do |qz|
+ # if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
+ # zone_id = qid.zone_id
+ # i=i+1
+ # end
+ # end
+ # end
+ # @queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
+ # end
+
+ # # @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
+ # @queue_stations_items
end
# Get Order items
@@ -68,6 +79,13 @@ class Oqs::HomeController < BaseOqsController
render :json => items.to_json
end
+ def get_items_by_oqs
+ oqs_id = params[:id]
+ filter = params[:filter]
+ items = queue_items_query(false,oqs_id,filter)
+ render :json => items.to_json
+ end
+
def show
end
@@ -87,9 +105,22 @@ class Oqs::HomeController < BaseOqsController
render :json => removed_item.to_json
end
+
# Query for OQS with delivery status
- def queue_items_query(status)
- AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
+ def queue_items_query(status,oqs_id=nil,filter)
+ if oqs_id == nil
+ oqs = ''
+ else
+ oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
+ end
+
+ query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
+ oqs.id as station_id, oqs.station_name,
+ oqs.is_active, oqpz.zone_id,
+ df.name as zone, df.type as table_type,
+ odt.order_id, odt.item_code, odt.item_name,
+ odt.price, odt.qty, odt.item_order_by, odt.options,
+ cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
@@ -98,14 +129,15 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
- .where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
+ .where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
+ query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("assigned_order_items.assigned_order_item_id")
- .order("assigned_order_items.created_at")
+
end
# Completed Order
- def completed_order
- AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
+ def completed_order(filter)
+ query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
@@ -115,12 +147,28 @@ class Oqs::HomeController < BaseOqsController
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
- .group("assigned_order_items.order_id")
- .limit(20)
- .order("assigned_order_items.created_at")
+ query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
+ .group("assigned_order_items.order_id")
+ .limit(20)
+ .order("assigned_order_items.created_at")
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
+ def queue_items_count_query(status,filter)
+ query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
+ .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
+ left join orders as od ON od.order_id = assigned_order_items.order_id
+ left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
+ left join customers as cus ON cus.customer_id = od.customer_id
+ left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
+ left join bookings as bk on bk.booking_id = bo.booking_id
+ left join dining_facilities as df on df.id = bk.dining_facility_id")
+ .where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
+ query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
+ .group("oqs.id")
+
+ end
+
end
diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb
new file mode 100644
index 00000000..e65b24b7
--- /dev/null
+++ b/app/controllers/origami/addorders_controller.rb
@@ -0,0 +1,22 @@
+class Origami::AddordersController < BaseOrigamiController
+ before_action :set_dining, only: [:show]
+
+ def index
+ @tables = Table.all.active.order('zone_id asc').group("zone_id")
+ @rooms = Room.all.active.order('zone_id asc').group("zone_id")
+ @all_table = Table.all.active.order('status desc')
+ @all_room = Room.all.active.order('status desc')
+ end
+
+ def show
+ @menu = MenuCategory.all
+ @table_id = params[:id]
+ end
+
+ private
+
+ def set_dining
+ @dining = DiningFacility.find(params[:id])
+ end
+
+end
diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb
index 026e59e3..8faaa221 100644
--- a/app/controllers/origami/customers_controller.rb
+++ b/app/controllers/origami/customers_controller.rb
@@ -37,14 +37,14 @@ class Origami::CustomersController < BaseOrigamiController
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
- @crm_customers = Customer.search(filter)
-
+ @crm_customers = Customer.search(filter)
end
#@crm_customers = Customer.all
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
@crm_customer = Customer.new
@count_customer = Customer.count_customer
+ @taxes = TaxProfile.all.order("order_by asc")
# if flash["errors"]
# @crm_customer.valid?
# end
@@ -60,6 +60,7 @@ class Origami::CustomersController < BaseOrigamiController
id = params[:sale_id][0,3]
customer_id = params[:customer_id]
+ customer = Customer.find(customer_id)
# Check and find with card no
# if(!customer_id.include? "CUS")
@@ -74,7 +75,7 @@ class Origami::CustomersController < BaseOrigamiController
status = sale.update_attributes(customer_id: customer_id)
sale.sale_orders.each do |sale_order|
order = Order.find(sale_order.order_id)
- status = order.update_attributes(customer_id: customer_id)
+ status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
end
else
@booking = BookingOrder.find_by_order_id(params[:sale_id])
@@ -82,13 +83,15 @@ class Origami::CustomersController < BaseOrigamiController
@orders.each do |bo|
order = Order.find(bo.order_id)
- status = order.update_attributes(customer_id: customer_id)
+ status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
end
end
if status == true
render json: JSON.generate({:status => true})
+ # Re-calc All Amount in Sale
+ sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb
index 0e7f3388..27822a17 100644
--- a/app/controllers/origami/home_controller.rb
+++ b/app/controllers/origami/home_controller.rb
@@ -2,10 +2,12 @@ class Origami::HomeController < BaseOrigamiController
before_action :set_dining, only: [:show]
def index
- @tables = Table.all.active.order('status desc')
- @rooms = Room.all.active.order('status desc')
+ @tables = Table.all.active.order('status desc')
+ @rooms = Room.all.active.order('status desc')
@complete = Sale.where("sale_status != 'new'")
- @orders = Order.all.order('date desc')
+ @orders = Order.all.order('date desc')
+ @shop = Shop.find_by_id(1)
+
# @shift = ShiftSale.current_open_shift(current_user.id)
end
@@ -38,7 +40,6 @@ class Origami::HomeController < BaseOrigamiController
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
- puts "enter"
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb
index 8c328030..109138a5 100644
--- a/app/controllers/origami/payments_controller.rb
+++ b/app/controllers/origami/payments_controller.rb
@@ -163,6 +163,35 @@ class Origami::PaymentsController < BaseOrigamiController
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
end
+ def foc
+ cash = params[:cash]
+ sale_id = params[:sale_id]
+ sub_total = params[:sub_total]
+ member_info = nil
+ rebate_amount = nil
+
+ if(Sale.exists?(sale_id))
+ saleObj = Sale.find(sale_id)
+ sale_payment = SalePayment.new
+ sale_payment.process_payment(saleObj, @user, cash, "foc")
+
+ unique_code = "ReceiptBillPdf"
+ customer= Customer.find(saleObj.customer_id)
+
+ #shop detail
+ shop_details = Shop.find(1)
+
+ # get printer info
+ print_settings=PrintSetting.find_by_unique_code(unique_code)
+ # Calculate Food and Beverage Total
+ item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
+ discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
+
+ printer = Printer::ReceiptPrinter.new(print_settings)
+ printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC")
+ end
+ end
+
def rounding_adj
saleObj = Sale.find(params[:sale_id])
diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb
index e03dd0fc..31c68edf 100644
--- a/app/controllers/origami/shifts_controller.rb
+++ b/app/controllers/origami/shifts_controller.rb
@@ -31,15 +31,21 @@ class Origami::ShiftsController < BaseOrigamiController
unique_code = "CloseCashierPdf"
shop_details = Shop.find(1)
#get tax
- shift_obj = ShiftSale.where('id =?',@shift.id)
- @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
-
+ shift_obj = ShiftSale.where('id =?',@shift.id)
+ @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
+ #other payment details for mpu or visa like card
+ @other_payment = ShiftSale.get_by_shift_other_payment(@shift)
+
+ # Calculate price_by_accounts
+ @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
+ @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
+ @total_member_discount = ShiftSale.get_total_member_discount(@shift)
# get printer info
- print_settings=PrintSetting.find_by_unique_code(unique_code)
+ print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
- printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes)
+ printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
end
@@ -52,6 +58,21 @@ class Origami::ShiftsController < BaseOrigamiController
def sale_summary
@shift = ShiftSale.current_open_shift(current_user.id)
+
+ # @shift = ShiftSale.find_by_id(shift_id)
+ if @shift
+ #get tax
+ shift_obj = ShiftSale.where('id =?',@shift.id)
+ @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
+ #other payment details for mpu or visa like card
+ @other_payment = ShiftSale.get_by_shift_other_payment(@shift)
+
+ # Calculate price_by_accounts
+ @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
+ @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
+ @total_member_discount = ShiftSale.get_total_member_discount(@shift)
+
+ end
end
diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb
index 73f89d13..1cf1ec65 100644
--- a/app/controllers/origami/void_controller.rb
+++ b/app/controllers/origami/void_controller.rb
@@ -6,18 +6,19 @@ class Origami::VoidController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
- sale.payment_status = 'void'
- sale.sale_status = 'void'
- sale.save
-
+
# update count for shift sale
- if(sale.sale_status == "void")
+ if(sale.sale_status == "completed")
if sale.shift_sale_id != nil
shift = ShiftSale.find(sale.shift_sale_id)
shift.calculate(sale_id, "void")
end
end
+ sale.payment_status = 'void'
+ sale.sale_status = 'void'
+ sale.save
+
bookings = sale.bookings
bookings.each do |booking|
orders = booking.orders
diff --git a/app/controllers/origami/voucher_controller.rb b/app/controllers/origami/voucher_controller.rb
index 7eda6084..e65abc85 100644
--- a/app/controllers/origami/voucher_controller.rb
+++ b/app/controllers/origami/voucher_controller.rb
@@ -22,7 +22,7 @@ class Origami::VoucherController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
- sale_id = params[:refnumber]
+ voucher_no = params[:refnumber]
if(Sale.exists?(sale_id))
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
@@ -37,11 +37,12 @@ class Origami::VoucherController < BaseOrigamiController
auth_token = member_actions.auth_token.to_s
# membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
# if membership_data["status"]==true
+ # app_token: token,membership_id:membership_id,
+ # campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,
+ # auth_token:auth_token
begin
response = HTTParty.get(url,
- :body => { app_token: token,membership_id:membership_id,
- campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,
- auth_token:auth_token
+ :body => { voucher_no: voucher_no,membership_id:membership_id
}.to_json,
:headers => {
'Content-Type' => 'application/json',
diff --git a/app/controllers/settings/item_sets_controller.rb b/app/controllers/settings/item_sets_controller.rb
new file mode 100644
index 00000000..cbd74edb
--- /dev/null
+++ b/app/controllers/settings/item_sets_controller.rb
@@ -0,0 +1,74 @@
+class Settings::ItemSetsController < ApplicationController
+ before_action :set_settings_item_set, only: [:show, :edit, :update, :destroy]
+ load_and_authorize_resource except: [:create]
+ # GET /settings/item_sets
+ # GET /settings/item_sets.json
+ def index
+ @settings_item_sets = ItemSet.all
+ end
+
+ # GET /settings/item_sets/1
+ # GET /settings/item_sets/1.json
+ def show
+ end
+
+ # GET /settings/item_sets/new
+ def new
+ @settings_item_set = ItemSet.new
+ end
+
+ # GET /settings/item_sets/1/edit
+ def edit
+ end
+
+ # POST /settings/item_sets
+ # POST /settings/item_sets.json
+ def create
+ @settings_item_set = ItemSet.new(settings_item_set_params)
+
+ respond_to do |format|
+ if @settings_item_set.save
+ format.html { redirect_to settings_item_sets_path, notice: 'Item set was successfully created.' }
+ format.json { render :show, status: :created, location: @settings_item_set }
+ else
+ format.html { render :new }
+ format.json { render json: @settings_item_set.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /settings/item_sets/1
+ # PATCH/PUT /settings/item_sets/1.json
+ def update
+ respond_to do |format|
+ if @settings_item_set.update(settings_item_set_params)
+ format.html { redirect_to settings_item_sets_path, notice: 'Item set was successfully updated.' }
+ format.json { render :show, status: :ok, location: @settings_item_set }
+ else
+ format.html { render :edit }
+ format.json { render json: @settings_item_set.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /settings/item_sets/1
+ # DELETE /settings/item_sets/1.json
+ def destroy
+ @settings_item_set.destroy
+ respond_to do |format|
+ format.html { redirect_to settings_item_sets_url, notice: 'Item set was successfully destroyed.' }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_settings_item_set
+ @settings_item_set = ItemSet.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def settings_item_set_params
+ params.require(:item_set).permit(:name, :alt_name, :min_selectable_qty, :max_selectable_qty)
+ end
+end
diff --git a/app/controllers/settings/menu_categories_controller.rb b/app/controllers/settings/menu_categories_controller.rb
index 8ca9cfb4..a15cca20 100644
--- a/app/controllers/settings/menu_categories_controller.rb
+++ b/app/controllers/settings/menu_categories_controller.rb
@@ -89,6 +89,6 @@ class Settings::MenuCategoriesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_category_params
- params.require(:menu_category).permit(:code, :menu_id, :name, :alt_name, :order_by, :menu_category_id)
+ params.require(:menu_category).permit(:code, :menu_id, :name, :alt_name, :order_by, :menu_category_id, :is_available)
end
end
diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb
index fd651e5e..0d276602 100644
--- a/app/controllers/settings/menu_item_instances_controller.rb
+++ b/app/controllers/settings/menu_item_instances_controller.rb
@@ -21,12 +21,14 @@ class Settings::MenuItemInstancesController < ApplicationController
id = MenuItemInstance.findParentCategory(@item)
@category = MenuCategory.find(id)
@settings_menu_item_instances = MenuItemInstance.new
+ @item_sets = ItemSet.all
end
# GET /settings/menu_item_instances/1/edit
def edit
id = MenuItemInstance.findParentCategory(@item)
@category = MenuCategory.find(id)
+ @item_sets = ItemSet.all
end
# POST /settings/menu_item_instances
@@ -45,6 +47,18 @@ class Settings::MenuItemInstancesController < ApplicationController
id = MenuItemInstance.findParentCategory(catID)
category = MenuCategory.find(id)
+
+ # Bind for Item Sets
+ if params[:menu_item_instance][:item_sets].count > 1
+ params[:menu_item_instance][:item_sets].delete_at(0)
+
+ sets = ItemSet.find(params[:menu_item_instance][:item_sets])
+
+ if sets.count > 0
+ @settings_menu_item.item_sets = sets
+ end
+ end
+
respond_to do |format|
if @settings_menu_item_instances.save
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?)
@@ -70,6 +84,18 @@ class Settings::MenuItemInstancesController < ApplicationController
id = MenuItemInstance.findParentCategory(catID)
category = MenuCategory.find(id)
+
+ # Bind for Item Sets
+ if params[:menu_item_instance][:item_sets].count > 1
+ params[:menu_item_instance][:item_sets].delete_at(0)
+
+ sets = ItemSet.find(params[:menu_item_instance][:item_sets])
+
+ if sets.count > 0
+ @settings_menu_item.item_sets = sets
+ end
+ end
+
respond_to do |format|
if @settings_menu_item_instances.update(settings_menu_item_instance_params)
@@ -122,8 +148,6 @@ class Settings::MenuItemInstancesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_instance_params
-
- params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :item_attributes, :is_on_promotion, :promotion_price, :is_available,:menu_category_id,:menu_item_id)
-
+ params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :item_attributes, :is_on_promotion, :promotion_price, :is_available,:menu_category_id,:menu_item_id, :is_default, :item_sets)
end
end
diff --git a/app/controllers/settings/menu_item_options_controller.rb b/app/controllers/settings/menu_item_options_controller.rb
index 41679796..f74b0689 100644
--- a/app/controllers/settings/menu_item_options_controller.rb
+++ b/app/controllers/settings/menu_item_options_controller.rb
@@ -70,6 +70,6 @@ class Settings::MenuItemOptionsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_option_params
- params.require(:menu_item_option).permit(:name, :value)
+ params.require(:menu_item_option).permit(:option_type, :name, :value)
end
end
diff --git a/app/controllers/settings/menu_item_sets_controller.rb b/app/controllers/settings/menu_item_sets_controller.rb
new file mode 100644
index 00000000..eb710e8c
--- /dev/null
+++ b/app/controllers/settings/menu_item_sets_controller.rb
@@ -0,0 +1,74 @@
+class Settings::MenuItemSetsController < ApplicationController
+ before_action :set_settings_menu_item_set, only: [:show, :edit, :update, :destroy]
+ load_and_authorize_resource except: [:create]
+ # GET /settings/menu_item_sets
+ # GET /settings/menu_item_sets.json
+ def index
+ @settings_menu_item_sets = MenuItemSet.all
+ end
+
+ # GET /settings/menu_item_sets/1
+ # GET /settings/menu_item_sets/1.json
+ def show
+ end
+
+ # GET /settings/menu_item_sets/new
+ def new
+ @settings_menu_item_set = MenuItemSet.new
+ end
+
+ # GET /settings/menu_item_sets/1/edit
+ def edit
+ end
+
+ # POST /settings/menu_item_sets
+ # POST /settings/menu_item_sets.json
+ def create
+ @settings_menu_item_set = MenuItemSet.new(settings_menu_item_set_params)
+
+ respond_to do |format|
+ if @settings_menu_item_set.save
+ format.html { redirect_to settings_menu_item_sets_path, notice: 'Menu item set was successfully created.' }
+ format.json { render :show, status: :created, location: @settings_menu_item_set }
+ else
+ format.html { render :new }
+ format.json { render json: @settings_menu_item_set.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /settings/menu_item_sets/1
+ # PATCH/PUT /settings/menu_item_sets/1.json
+ def update
+ respond_to do |format|
+ if @settings_menu_item_set.update(settings_menu_item_set_params)
+ format.html { redirect_to settings_menu_item_sets_path, notice: 'Menu item set was successfully updated.' }
+ format.json { render :show, status: :ok, location: @settings_menu_item_set }
+ else
+ format.html { render :edit }
+ format.json { render json: @settings_menu_item_set.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /settings/menu_item_sets/1
+ # DELETE /settings/menu_item_sets/1.json
+ def destroy
+ @settings_menu_item_set.destroy
+ respond_to do |format|
+ format.html { redirect_to settings_menu_item_sets_url, notice: 'Menu item set was successfully destroyed.' }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_settings_menu_item_set
+ @settings_menu_item_set = MenuItemSet.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def settings_menu_item_set_params
+ params.require(:menu_item_set).permit(:item_set_id, :menu_item_id)
+ end
+end
diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb
index 5946ff49..4f451de5 100644
--- a/app/controllers/settings/set_menu_items_controller.rb
+++ b/app/controllers/settings/set_menu_items_controller.rb
@@ -1,6 +1,8 @@
class Settings::SetMenuItemsController < ApplicationController
before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy]
before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update]
+ before_action :set_settings_item_attribute, only: [:index, :show, :edit, :new, :update ,:create]
+ before_action :set_settings_item_option, only: [:index, :show, :edit, :new, :update ,:create]
# GET /settings/menu_items
# GET /settings/menu_items.json
def index
@@ -10,32 +12,52 @@ class Settings::SetMenuItemsController < ApplicationController
# GET /settings/menu_items/1
# GET /settings/menu_items/1.json
def show
- @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
-
+ # @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
@menu_item_instance = MenuItemInstance.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
-
end
# GET /settings/menu_items/new
def new
@settings_menu_item = MenuItem.new
@settings_menu_item.type = "SetMenuItem"
+ @item_sets = ItemSet.all
end
# GET /settings/menu_items/1/edit
def edit
+ @item_sets = ItemSet.all
end
# POST /settings/menu_items
# POST /settings/menu_items.json
def create
@settings_menu_item = MenuItem.new(settings_menu_item_params)
- if params[:simple_menu_item][:menu_item_id] == ''
- @settings_menu_item.menu_category_id = params[:menu_category_id]
- end
+
+ # if params[:set_menu_item][:menu_item_id] == ''
+ @settings_menu_item.menu_category_id = params[:menu_category_id]
+ # end
@settings_menu_item.created_by = current_login_employee.name
+
+ # Remove "" default first
+ params[:set_menu_item][:item_attributes].delete_at(0)
+ params[:set_menu_item][:item_options].delete_at(0)
+
+ # Bind for Item Sets
+ if params[:set_menu_item][:item_sets].count > 1
+ params[:set_menu_item][:item_sets].delete_at(0)
+
+ sets = ItemSet.find(params[:set_menu_item][:item_sets])
+
+ if sets.count > 0
+ @settings_menu_item.item_sets = sets
+ end
+ end
+
respond_to do |format|
if @settings_menu_item.save
+ menu_item = MenuItem.find(@settings_menu_item.id)
+ menu_item.update_attributes(item_attributes: params[:set_menu_item][:item_attributes], item_options: params[:set_menu_item][:item_options])
+
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item }
else
@@ -48,8 +70,27 @@ class Settings::SetMenuItemsController < ApplicationController
# PATCH/PUT /settings/menu_items/1
# PATCH/PUT /settings/menu_items/1.json
def update
+ # Remove "" default first
+ params[:set_menu_item][:item_attributes].delete_at(0)
+ params[:set_menu_item][:item_options].delete_at(0)
+
+ # Bind for Item Sets
+ if params[:set_menu_item][:item_sets].count > 1
+ params[:set_menu_item][:item_sets].delete_at(0)
+
+ sets = ItemSet.find(params[:set_menu_item][:item_sets])
+
+ if sets.count > 0
+ @settings_menu_item.item_sets = sets
+ end
+ end
+
+ @settings_menu_item.menu_category_id = params[:menu_category_id]
+
respond_to do |format|
if @settings_menu_item.update(settings_menu_item_params)
+ @settings_menu_item.update_attributes(item_attributes: params[:set_menu_item][:item_attributes], item_options: params[:set_menu_item][:item_options])
+
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_menu_item }
else
@@ -62,6 +103,8 @@ class Settings::SetMenuItemsController < ApplicationController
# DELETE /settings/menu_items/1
# DELETE /settings/menu_items/1.json
def destroy
+ path_to_file = @settings_menu_item.image_path.to_s
+ File.delete(path_to_file) if File.exist?(path_to_file)
abc = MenuItem.deleteRecursive(@settings_menu_item)
respond_to do |format|
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully destroyed.' }
@@ -79,8 +122,16 @@ class Settings::SetMenuItemsController < ApplicationController
@category = MenuCategory.find(params[:menu_category_id])
end
+ def set_settings_item_attribute
+ @item_attributes = MenuItemAttribute.all.order("id asc").map{|a| [a.name, a.value]}
+ end
+
+ def set_settings_item_option
+ @item_options = MenuItemOption.all
+ end
+
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_params
- params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id , :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
+ params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets)
end
end
diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb
index 05952d0d..4cf9318c 100644
--- a/app/controllers/settings/simple_menu_items_controller.rb
+++ b/app/controllers/settings/simple_menu_items_controller.rb
@@ -1,6 +1,8 @@
class Settings::SimpleMenuItemsController < ApplicationController
before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy ]
before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update ,:create]
+ before_action :set_settings_item_attribute, only: [:index, :show, :edit, :new, :update ,:create]
+ before_action :set_settings_item_option, only: [:index, :show, :edit, :new, :update ,:create]
# GET /settings/menu_items
# GET /settings/menu_items.json
def index
@@ -10,29 +12,75 @@ class Settings::SimpleMenuItemsController < ApplicationController
# GET /settings/menu_items/1
# GET /settings/menu_items/1.json
def show
- @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
+ # @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
@menu_item_instance = MenuItemInstance.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
end
# GET /settings/menu_items/new
def new
- @settings_menu_item = MenuItem.new
+ @settings_menu_item = MenuItem.new
+ @item_sets = ItemSet.all
end
# GET /settings/menu_items/1/edit
- def edit
+ def edit
+ @item_sets = ItemSet.all
end
# POST /settings/menu_items
# POST /settings/menu_items.json
def create
@settings_menu_item = MenuItem.new(settings_menu_item_params)
- if params[:simple_menu_item][:menu_item_id] == ''
- @settings_menu_item.menu_category_id = params[:menu_category_id]
- end
+
+ # if params[:simple_menu_item][:menu_item_id] == ''
+ @settings_menu_item.menu_category_id = params[:menu_category_id]
+ # end
@settings_menu_item.created_by = current_login_employee.name
+
+ # Remove "" default first
+ params[:simple_menu_item][:item_attributes].delete_at(0)
+ params[:simple_menu_item][:item_options].delete_at(0)
+
+ # attr_format = []
+ # param_count = params[:simple_menu_item][:item_attributes].count
+ # # Format for attributes json
+ # params[:simple_menu_item][:item_attributes].each do|attr_id|
+ # menu_attr = MenuItemAttribute.find(attr_id)
+ # if attr_format.count == 0
+ # attr_format.push({ type: menu_attr.attribute_type, value: [] })
+ # end
+
+ # attr_format.each do |af|
+ # if menu_attr.attribute_type == af[:type]
+ # af[:value].push(menu_attr.value)
+ # else
+ # new_attr = {type: menu_attr.attribute_type, value: [ menu_attr.value ] }
+ # attr_format.push(new_attr)
+ # end
+
+ # break if attr_format.count > param_count
+ # end
+
+ # param_count -= 1
+ # end
+ # @settings_menu_item.item_attributes = attr_format
+
+ # Bind for Item Sets
+ if params[:simple_menu_item][:item_sets].count > 1
+ params[:simple_menu_item][:item_sets].delete_at(0)
+
+ sets = ItemSet.find(params[:simple_menu_item][:item_sets])
+
+ if sets.count > 0
+ @settings_menu_item.item_sets = sets
+ end
+ end
+
respond_to do |format|
if @settings_menu_item.save
+ menu_item = MenuItem.find(@settings_menu_item.id)
+ menu_item.update_attributes(item_options: params[:simple_menu_item][:item_options])
+
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item }
else
@@ -45,8 +93,26 @@ class Settings::SimpleMenuItemsController < ApplicationController
# PATCH/PUT /settings/menu_items/1
# PATCH/PUT /settings/menu_items/1.json
def update
+ # Remove "" default first
+ params[:simple_menu_item][:item_attributes].delete_at(0)
+ params[:simple_menu_item][:item_options].delete_at(0)
+
+ # Bind for Item Sets
+ if params[:simple_menu_item][:item_sets].count > 1
+ params[:simple_menu_item][:item_sets].delete_at(0)
+
+ sets = ItemSet.find(params[:simple_menu_item][:item_sets])
+
+ if sets.count > 0
+ @settings_menu_item.item_sets = sets
+ end
+ end
+
+ @settings_menu_item.menu_category_id = params[:menu_category_id]
+
respond_to do |format|
if @settings_menu_item.update(settings_menu_item_params)
+ @settings_menu_item.update_attributes(item_attributes: params[:simple_menu_item][:item_attributes], item_options: params[:simple_menu_item][:item_options])
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_menu_item }
else
@@ -59,6 +125,8 @@ class Settings::SimpleMenuItemsController < ApplicationController
# DELETE /settings/menu_items/1
# DELETE /settings/menu_items/1.json
def destroy
+ path_to_file = @settings_menu_item.image_path.to_s
+ File.delete(path_to_file) if File.exist?(path_to_file)
abc = MenuItem.deleteRecursive(@settings_menu_item)
respond_to do |format|
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully destroyed.' }
@@ -76,8 +144,16 @@ class Settings::SimpleMenuItemsController < ApplicationController
@category = MenuCategory.find(params[:menu_category_id])
end
+ def set_settings_item_attribute
+ @item_attributes = MenuItemAttribute.all.order("id asc") #.map{|a| [a.name, a.value]}
+ end
+
+ def set_settings_item_option
+ @item_options = MenuItemOption.all
+ end
+
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_params
- params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
+ params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets)
end
end
diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb
index 4df88787..bd079d83 100644
--- a/app/controllers/transactions/orders_controller.rb
+++ b/app/controllers/transactions/orders_controller.rb
@@ -3,18 +3,17 @@ class Transactions::OrdersController < ApplicationController
def index
filter = params[:filter]
+ count = params[:count]
from = params[:from]
to = params[:to]
- if filter.nil? || from.nil? || to.nil?
+ if filter.nil? && from.nil? && to.nil? && count.nil?
orders = Order.order("order_id desc")
+ puts "ssssss"
else
- orders = Order.search(filter,from,to)
- # if order.count > 0
- # orders = order
- # else
- # orders = Order.order("order_id desc")
- # end
+ orders = Order.search(filter,from,to,count)
+ puts "aaaaa"
+
end
if !orders.nil?
@@ -22,6 +21,7 @@ class Transactions::OrdersController < ApplicationController
else
@orders = []
end
+ puts @orders.to_json
respond_to do |format|
format.html # index.html.erb
format.json { render json: @orders }
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index ae3934e4..037767c9 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,5 +1,4 @@
module ApplicationHelper
-
def flash_class(level)
case level
when :notice then "alert alert-info fade-in"
diff --git a/app/helpers/origami/addorders_helper.rb b/app/helpers/origami/addorders_helper.rb
new file mode 100644
index 00000000..c90e5344
--- /dev/null
+++ b/app/helpers/origami/addorders_helper.rb
@@ -0,0 +1,2 @@
+module Origami::AddordersHelper
+end
diff --git a/app/helpers/settings/item_sets_helper.rb b/app/helpers/settings/item_sets_helper.rb
new file mode 100644
index 00000000..59c3b632
--- /dev/null
+++ b/app/helpers/settings/item_sets_helper.rb
@@ -0,0 +1,2 @@
+module Settings::ItemSetsHelper
+end
diff --git a/app/helpers/settings/menu_item_sets_helper.rb b/app/helpers/settings/menu_item_sets_helper.rb
new file mode 100644
index 00000000..3e909848
--- /dev/null
+++ b/app/helpers/settings/menu_item_sets_helper.rb
@@ -0,0 +1,2 @@
+module Settings::MenuItemSetsHelper
+end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 6965ab05..38376d24 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -4,137 +4,131 @@ class Ability
def initialize(user)
user ||= Employee.new
- if user.role == 'administrator'
+ if user.role == "administrator"
+ can :manage, :all
+ elsif user.role == "manager"
+ can :manage, Menu
+ can :manage, MenuCategory
+ can :manage, MenuItemAttribute
+ can :manage, MenuItemInstance
+ can :manage, MenuItemOption
+ can :manage, SetMenuItem
+ can :manage, ItemSet
+ can :manage, MenuItemSet
+ can :manage, OrderQueueStation
+ can :manage, Zone
+ can :manage, CashierTerminal
+ can :manage, Employee
+ # can :manage, MembershipSetting
+ # can :manage, MembershipAction
+ # can :manage, PaymentMethodSetting
+ can :manage, TaxProfile
+ can :manage, PrintSetting
+ can :manage, Account
- can :manage, :all
+ can :manage, Order
+ can :manage, Sale
- elsif user.role == 'manager'
+ can :manage, Customer
+ can :manage, DiningQueue
- can :manage, Menu
- can :manage, MenuCategory
- can :manage, MenuItemAttribute
- can :manage, MenuItemInstance
- can :manage, MenuItemOption
- can :manage, SetMenuItem
- can :manage, OrderQueueStation
- can :manage, Zone
- can :manage, CashierTerminal
- can :manage, Employee
- # can :manage, MembershipSetting
- # can :manage, MembershipAction
- # can :manage, PaymentMethodSetting
- can :manage, TaxProfile
- can :manage, PrintSetting
- can :manage, Account
+ can :index, :dailysale
+ can :index, :saleitem
+ can :index, :receipt_no
+ can :index, :shiftsale
+ can :index, :credit_payment
+ can :index, :void_sale
- can :manage, Order
- can :manage, Sale
+ can :get_customer, Customer
+ can :add_customer, Customer
+ can :update_sale_by_customer, Customer
- can :manage, Customer
- can :manage, DiningQueue
+ can :index, :other_charge
+ can :create, :other_charge
+ can :index, :discount
+ can :create, :discount
+ can :remove_discount_items, :discount
+ can :remove_all_discount, :discount
- can :index, :dailysale
- can :index, :saleitem
- can :index, :receipt_no
- can :index, :shiftsale
- can :index, :credit_payment
- can :index, :void_sale
+ can :first_bill, :payment
+ can :show, :payment
+ can :create, :payment
+ can :reprint, :payment
+ can :rounding_adj, :payment
+ can :foc, :payment
- can :get_customer, Customer
- can :add_customer, Customer
- can :update_sale_by_customer, Customer
- can :index, :other_charge
- can :create, :other_charge
- can :index, :discount
- can :create, :discount
- can :remove_discount_items, :discount
- can :remove_all_discount, :discount
+ can :move_dining, :movetable
+ can :moving, :movetable
- can :first_bill, :payment
- can :show, :payment
- can :create, :payment
- can :reprint, :payment
- can :rounding_adj, :payment
+ can :move_dining, :moveroom
- can :move_dining, :movetable
- can :moving, :movetable
+ can :edit, :sale_edit
+ can :item_void, :sale_edit
+ can :item_void_cancel, :sale_edit
+ can :cancel_all_void, :sale_edit
+ can :apply_void, :sale_edit
- can :move_dining, :moveroom
+ can :overall_void, :void
- can :edit, :sale_edit
- can :item_void, :sale_edit
- can :item_void_cancel, :sale_edit
- can :cancel_all_void, :sale_edit
- can :apply_void, :sale_edit
+ elsif user.role == "cashier"
+
+ # can :overall_void, :void
- can :overall_void, :void
+ can :read, Order
+ can :update, Order
+
+ can :read, Sale
+ can :update, Sale
+ can :get_customer, Customer
+ can :add_customer, Customer
+ can :update_sale_by_customer, Customer
- elsif user.role == 'cashier'
+ can :index, :other_charge
+ can :create, :other_charge
+ can :index, :discount
+ can :create, :discount
+ can :remove_discount_items, :discount
+ can :remove_all_discount, :discount
+ can :member_discount, :discount
- # can :overall_void, :void
+ can :first_bill, :payment
+ can :show, :payment
+ can :create, :payment
+ can :reprint, :payment
+ can :rounding_adj, :payment
- can :read, Order
- can :update, Order
+ can :move_dining, :movetable
+ can :moving, :movetable
- can :read, Sale
- can :update, Sale
- can :get_customer, Customer
- can :add_customer, Customer
- can :update_sale_by_customer, Customer
+ can :move_dining, :moveroom
- can :index, :other_charge
- can :create, :other_charge
- can :index, :discount
- can :create, :discount
- can :remove_discount_items, :discount
- can :remove_all_discount, :discount
- can :member_discount, :discount
+ can :manage, DiningQueue
+
+ elsif user.role == "account"
- can :first_bill, :payment
- can :show, :payment
- can :create, :payment
- can :reprint, :payment
- can :rounding_adj, :payment
+ can :index, :dailysale
+ can :index, :saleitem
+ can :index, :receipt_no
+ can :index, :shiftsale
+ can :index, :credit_payment
+ can :index, :void_sale
- can :move_dining, :movetable
- can :moving, :movetable
+ elsif user.role == "supervisour"
- can :move_dining, :moveroom
+ can :edit, :sale_edit
+ can :item_void, :sale_edit
+ can :item_edit, :sale_edit
+ can :item_void_cancel, :sale_edit
+ can :cancel_all_void, :sale_edit
+ can :apply_void, :sale_edit
+ can :overall_void, :void
- can :first_bill, :payment
- can :show, :payment
- can :create, :payment
- can :reprint, :payment
-
- can :manage, DiningQueue
-
- elsif user.role == 'account'
-
- can :index, :dailysale
- can :index, :saleitem
- can :index, :receipt_no
- can :index, :shiftsale
- can :index, :credit_payment
- can :index, :void_sale
-
- elsif user.role == 'supervisour'
-
- can :edit, :sale_edit
- can :item_void, :sale_edit
- can :item_edit, :sale_edit
- can :item_void_cancel, :sale_edit
- can :cancel_all_void, :sale_edit
- can :apply_void, :sale_edit
- can :overall_void, :void
-
- can :first_bill, :payment
- can :create, :payment
- can :show, :payment
- can :reprint, :payment
- can :rounding_adj, :payment
+ can :first_bill, :payment
+ can :create, :payment
+ can :show, :payment
+ can :reprint, :payment
+ can :rounding_adj, :payment
end
-
end
-
end
diff --git a/app/models/employee.rb b/app/models/employee.rb
index 7693c448..85aeaec1 100644
--- a/app/models/employee.rb
+++ b/app/models/employee.rb
@@ -35,7 +35,6 @@ class Employee < ApplicationRecord
end
def self.authenticate_by_token(session_token)
-
if (session_token)
user = Employee.find_by_token_session(session_token)
if user && user.session_expiry.utc > DateTime.now.utc
diff --git a/app/models/item_set.rb b/app/models/item_set.rb
new file mode 100644
index 00000000..e4dca315
--- /dev/null
+++ b/app/models/item_set.rb
@@ -0,0 +1,9 @@
+class ItemSet < ApplicationRecord
+ has_many :menu_item_sets
+ has_many :menu_items, through: :menu_item_sets
+
+ has_many :menu_instance_item_sets
+ has_many :menu_item_instances, through: :menu_instance_item_sets
+
+ validates_presence_of :name
+end
diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb
index 71ad42c8..29484bcc 100644
--- a/app/models/menu_category.rb
+++ b/app/models/menu_category.rb
@@ -1,5 +1,5 @@
class MenuCategory < ApplicationRecord
- before_create :generate_menu_category_code
+ # before_create :generate_menu_category_code
belongs_to :menu
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
@@ -37,7 +37,7 @@ class MenuCategory < ApplicationRecord
private
- def generate_menu_category_code
- self.code = SeedGenerator.generate_code(self.class.name, "C")
- end
+ # def generate_menu_category_code
+ # self.code = SeedGenerator.generate_code(self.class.name, "C")
+ # end
end
diff --git a/app/models/menu_instance_item_set.rb b/app/models/menu_instance_item_set.rb
new file mode 100644
index 00000000..bc1d7aaf
--- /dev/null
+++ b/app/models/menu_instance_item_set.rb
@@ -0,0 +1,4 @@
+class MenuInstanceItemSet < ApplicationRecord
+ belongs_to :item_set
+ belongs_to :menu_item_instance
+end
diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb
index 1f1afbe4..8213ae88 100644
--- a/app/models/menu_item.rb
+++ b/app/models/menu_item.rb
@@ -1,20 +1,25 @@
class MenuItem < ApplicationRecord
-
- before_create :generate_menu_item_code
+ # before_create :generate_menu_item_code
belongs_to :menu_category, :optional => true
has_many :menu_item_instances
- belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
- has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
+ # belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
+ # has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
belongs_to :account
- validates_presence_of :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
+ has_many :menu_item_sets
+ has_many :item_sets, through: :menu_item_sets
+
+ validates_presence_of :name, :type, :min_qty, :taxable
default_scope { order('item_code asc') }
scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') }
scope :set_menu_item, -> { where(type: 'SetMenuItem') }
+ # Item Image Uploader
+ mount_uploader :image_path, MenuItemImageUploader
+
def self.collection
MenuItem.select("id, name").map { |e| [e.name, e.id] }
end
@@ -70,10 +75,10 @@ class MenuItem < ApplicationRecord
end
- private
+ # private
- def generate_menu_item_code
- self.item_code = SeedGenerator.generate_code(self.class.name, "I")
- end
+ # def generate_menu_item_code
+ # self.item_code = SeedGenerator.generate_code(self.class.name, "I")
+ # end
end
diff --git a/app/models/menu_item_attribute.rb b/app/models/menu_item_attribute.rb
index a2fd0d1c..54d2f34e 100644
--- a/app/models/menu_item_attribute.rb
+++ b/app/models/menu_item_attribute.rb
@@ -1,6 +1,6 @@
class MenuItemAttribute < ApplicationRecord
validates_presence_of :attribute_type, :name, :value
def self.collection
- MenuItemAttribute.select("id, name").map { |e| [e.name, e.id] }
+ MenuItemAttribute.select("name, value").map { |e| [e.name, e.value] }
end
end
diff --git a/app/models/menu_item_instance.rb b/app/models/menu_item_instance.rb
index f39c29a2..de5be7b5 100644
--- a/app/models/menu_item_instance.rb
+++ b/app/models/menu_item_instance.rb
@@ -1,6 +1,9 @@
class MenuItemInstance < ApplicationRecord
belongs_to :menu_item
- before_create :generate_menu_item_instance_code
+
+ has_many :menu_instance_item_sets
+ has_many :item_sets, through: :menu_instance_item_sets
+ # before_create :generate_menu_item_instance_code
def self.findParentCategory(item)
if item.menu_category_id
@@ -11,9 +14,9 @@ class MenuItemInstance < ApplicationRecord
end
end
- private
+ # private
- def generate_menu_item_instance_code
- self.item_instance_code = SeedGenerator.generate_code(self.class.name, "II")
- end
+ # def generate_menu_item_instance_code
+ # self.item_instance_code = SeedGenerator.generate_code(self.class.name, "II")
+ # end
end
diff --git a/app/models/menu_item_option.rb b/app/models/menu_item_option.rb
index fdf2d137..fffdf210 100644
--- a/app/models/menu_item_option.rb
+++ b/app/models/menu_item_option.rb
@@ -1,4 +1,3 @@
class MenuItemOption < ApplicationRecord
validates_presence_of :name, :value
-
end
diff --git a/app/models/menu_item_set.rb b/app/models/menu_item_set.rb
new file mode 100644
index 00000000..7cd94bcb
--- /dev/null
+++ b/app/models/menu_item_set.rb
@@ -0,0 +1,9 @@
+class MenuItemSet < ApplicationRecord
+ belongs_to :item_set
+ belongs_to :menu_item
+end
+
+# class Settings::MenuItemSet < ApplicationRecord
+# belongs_to :item_set_id
+# belongs_to :menu_item_id
+# end
diff --git a/app/models/order.rb b/app/models/order.rb
index 4d54f41f..0ef19729 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -65,7 +65,6 @@ class Order < ApplicationRecord
end
def adding_line_items
-
if self.items
#re-order to
ordered_list = re_order_items(self.items)
@@ -320,12 +319,18 @@ class Order < ApplicationRecord
end
- def self.search(filter,from,to)
- if !from.nil? && !to.nil?
- Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ?", from,to)
+ def self.search(filter,from,to,count)
+ if count.to_i > 0
+ item_count = "and item_count = '#{count}'"
else
- # find(:all)
- where("order_id LIKE ? OR item_count ='#{filter}'","%#{filter}%",)
+ item_count = ''
+ end
+ if from.present? && to.present?
+ Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ? #{item_count}", from,to)
+ elsif !from.present? && !to.present? && count.present?
+ Order.where("item_count = '#{count}'")
+ else
+ Order.where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
end
end
diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb
index 55bf8c39..91100145 100644
--- a/app/models/printer/cashier_station_printer.rb
+++ b/app/models/printer/cashier_station_printer.rb
@@ -22,14 +22,14 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# end
#Bill Receipt Print
- def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes)
+ def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
#Use CUPS service
#Generate PDF
#Print
cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
- pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes)
+ pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
pdf.render_file filename
self.print(filename)
diff --git a/app/models/sale.rb b/app/models/sale.rb
index b19aef3d..71994ca1 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -91,7 +91,7 @@ class Sale < ApplicationRecord
add_item(item)
end
- # link_order_sale(order.id)
+ link_order_sale(order.id)
end
self.save!
@@ -295,25 +295,33 @@ class Sale < ApplicationRecord
total_tax_amount = 0
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
-
+ customer = Customer.find(sale.customer_id)
# #Creat new tax records
tax_profiles.each do |tax|
- sale_tax = SaleTax.new(:sale => sale)
- sale_tax.tax_name = tax.name
- sale_tax.tax_rate = tax.rate
- #include or execulive
- # sale_tax.tax_payable_amount = total_taxable * tax.rate
+ customer.tax_profiles.each do |cus_tax|
+ if cus_tax.to_i == tax.id
+ sale_tax = SaleTax.new(:sale => sale)
+ sale_tax.tax_name = tax.name
+ sale_tax.tax_rate = tax.rate
- # substract , to give after discount
- total_tax = total_taxable - total_discount
- sale_tax.tax_payable_amount = total_tax * tax.rate / 100
- #new taxable amount is standard rule for step by step
- # total_taxable = total_taxable + sale_tax.tax_payable_amount
+ # substract , to give after discount
+ total_tax = total_taxable - total_discount
+ #include or execulive
+ if tax.inclusive
+ rate = tax.rate
+ divided_value = (100 + rate)/rate
+ sale_tax.tax_payable_amount = total_tax / divided_value
+ else
+ sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
+ end
+ #new taxable amount is standard rule for step by step
+ # total_taxable = total_taxable + sale_tax.tax_payable_amount
- sale_tax.inclusive = tax.inclusive
- sale_tax.save
-
- total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
+ sale_tax.inclusive = tax.inclusive
+ sale_tax.save
+ end
+ end
end
sale.total_tax = total_tax_amount
@@ -321,12 +329,6 @@ class Sale < ApplicationRecord
# Tax Calculate
def apply_tax(total_taxable)
- #if tax is not apply create new record
- # self.sale_taxes.each do |existing_tax|
- # #delete existing and create new
- # existing_tax.delete
- # end
-
#if tax is not apply create new record
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
#delete existing and create new
@@ -336,27 +338,38 @@ class Sale < ApplicationRecord
total_tax_amount = 0
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
+
+ customer = Customer.find(self.customer_id)
- # #Creat new tax records
+ #Create new tax records
tax_profiles.each do |tax|
- sale_tax = SaleTax.new(:sale => self)
- sale_tax.tax_name = tax.name
- sale_tax.tax_rate = tax.rate
- #include or execulive
- # sale_tax.tax_payable_amount = total_taxable * tax.rate
- total_tax = total_taxable - self.total_discount
- sale_tax.tax_payable_amount = total_tax * tax.rate / 100
- #new taxable amount is standard rule for step by step
- # total_taxable = total_taxable + sale_tax.tax_payable_amount
+ customer.tax_profiles.each do |cus_tax|
+ if cus_tax.to_i == tax.id
+ sale_tax = SaleTax.new(:sale => self)
+ sale_tax.tax_name = tax.name
+ sale_tax.tax_rate = tax.rate
- sale_tax.inclusive = tax.inclusive
- sale_tax.save
+ # substract , to give after discount
+ total_tax = total_taxable - self.total_discount
+ #include or execulive
+ if tax.inclusive
+ rate = tax.rate
+ divided_value = (100 + rate)/rate
+ sale_tax.tax_payable_amount = total_tax / divided_value
+ else
+ sale_tax.tax_payable_amount = total_tax * tax.rate / 100
+ total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
+ end
+
+ #new taxable amount is standard rule for step by step
+ # total_taxable = total_taxable + sale_tax.tax_payable_amount
- total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
+ sale_tax.inclusive = tax.inclusive
+ sale_tax.save
+ end
+ end
end
-
self.total_tax = total_tax_amount
-
end
def product_get_unit_price(item_code)
@@ -401,7 +414,6 @@ class Sale < ApplicationRecord
end
def self.search(filter,from,to)
-
if filter.blank?
keyword = ''
else
@@ -418,7 +430,6 @@ class Sale < ApplicationRecord
end
def self.search_credit_sales(customer,filter,from,to)
-
if filter.blank?
keyword = ''
else
@@ -436,7 +447,7 @@ class Sale < ApplicationRecord
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and sp.payment_method = 'creditnote' #{keyword} #{custo}", from,to)
else
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
- .where("sp.payment_method =? #{keyword} #{custo}",'creditnote')
+ .where("sp.payment_method ='creditnote' #{keyword} #{custo}")
end
@@ -537,31 +548,25 @@ class Sale < ApplicationRecord
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 = 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=?) AND i.unit_price <> 0",from,to,status)
-
-
+ 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=?) AND i.unit_price <> 0",from,to,status)
end
-
def self.get_by_shiftsales(from,to,shift)
if !shift.blank?
ShiftSale.where("id =?",shift.id)
@@ -591,79 +596,77 @@ def self.get_item_query()
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
query = query.group('i.product_code ').order("mi.account_id, mi.menu_category_id")
+end
+
+def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
+ # date_type_selection = get_sql_function_for_report_type(report_type)
+
+ query = self.get_item_query()
+ discount_query = 0
+ total_card_amount = 0
+ total_cash_amount = 0
+ total_credit_amount = 0
+ total_foc_amount = 0
+ total_grand_total = 0
+
+ if shift.present?
+ query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
+ discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
+ change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
+ SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
+ SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
+ .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
+ .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
+ sale_cash.each do |s_c|
+ total_cash_amount += s_c.cash_amount.to_f
+ total_card_amount += s_c.card_amount.to_f
+ total_credit_amount += s_c.credit_amount.to_f
+ total_foc_amount += s_c.foc_amount.to_f
+ end
+ total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
+
+ ### => get all sales range in shift_sales
+ elsif shift_sale_range.present?
+ query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
+ discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
+ change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
+ SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
+ SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
+ .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
+ .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
+ sale_cash.each do |s_c|
+ total_cash_amount += s_c.cash_amount.to_f
+ total_card_amount += s_c.card_amount.to_f
+ total_credit_amount += s_c.credit_amount.to_f
+ total_foc_amount += s_c.foc_amount.to_f
+ end
+ total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
+
+ else
+ query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
+ discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
+ change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
+ sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
+ SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
+ SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
+ SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
+ .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
+ .where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
+ sale_cash.each do |s_c|
+ total_cash_amount += s_c.cash_amount.to_f
+ total_card_amount += s_c.card_amount.to_f
+ total_credit_amount += s_c.credit_amount.to_f
+ total_foc_amount += s_c.foc_amount.to_f
+ end
+ total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
+
end
-
- def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
-
- # date_type_selection = get_sql_function_for_report_type(report_type)
-
- query = self.get_item_query()
- discount_query = 0
- total_card_amount = 0
- total_cash_amount = 0
- total_credit_amount = 0
- total_foc_amount = 0
- total_grand_total = 0
-
- if shift.present?
- query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
- discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
- change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
- SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
- SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
- SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
- .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
- .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
- sale_cash.each do |s_c|
- total_cash_amount += s_c.cash_amount.to_f
- total_card_amount += s_c.card_amount.to_f
- total_credit_amount += s_c.credit_amount.to_f
- total_foc_amount += s_c.foc_amount.to_f
- end
- total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
-
- ### => get all sales range in shift_sales
- elsif shift_sale_range.present?
- query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
- discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
- change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
- SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
- SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
- SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
- .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
- .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
- sale_cash.each do |s_c|
- total_cash_amount += s_c.cash_amount.to_f
- total_card_amount += s_c.card_amount.to_f
- total_credit_amount += s_c.credit_amount.to_f
- total_foc_amount += s_c.foc_amount.to_f
- end
- total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
-
- else
- query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
- discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
- change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
- sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
- SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
- SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
- SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
- .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
- .where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
- sale_cash.each do |s_c|
- total_cash_amount += s_c.cash_amount.to_f
- total_card_amount += s_c.card_amount.to_f
- total_credit_amount += s_c.credit_amount.to_f
- total_foc_amount += s_c.foc_amount.to_f
- end
- total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
-
- end
-
- return query, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
+ return query, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
end
def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_type)
diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb
index ff2f6e2f..3435190d 100644
--- a/app/models/sale_payment.rb
+++ b/app/models/sale_payment.rb
@@ -46,6 +46,8 @@ class SalePayment < ApplicationRecord
payment_status = giftcard_payment
when "paypar"
payment_status = paypar_payment
+ when "foc"
+ payment_status = foc_payment
else
puts "it was something else"
end
@@ -164,6 +166,17 @@ class SalePayment < ApplicationRecord
return payment_status
end
+ def foc_payment
+ payment_status = false
+ self.payment_method = "foc"
+ self.payment_amount = self.received_amount
+ self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
+ self.payment_status = "paid"
+ payment_method = self.save!
+ sale_update_payment_status(self.received_amount)
+ return payment_status
+ end
+
def creditnote_payment(customer_id)
payment_status = false
@@ -257,11 +270,15 @@ class SalePayment < ApplicationRecord
all_received_amount = 0.0
sObj = Sale.find(self.sale_id)
is_credit = 0
+ is_foc = 0
sObj.sale_payments.each do |spay|
all_received_amount += spay.payment_amount.to_f
if spay.payment_method == "creditnote"
is_credit = 1
end
+ if spay.payment_method == "foc"
+ is_foc = 1
+ end
end
if (self.sale.grand_total <= all_received_amount)
if is_credit == 0
@@ -269,9 +286,16 @@ class SalePayment < ApplicationRecord
else
self.sale.payment_status = "outstanding"
end
+
+ if is_foc == 0
+ self.sale.payment_status = "paid"
+ else
+ self.sale.payment_status = "foc"
+ end
+
self.sale.sale_status = "completed"
- if MembershipSetting.find_by_rebate(1)
+ if MembershipSetting.find_by_rebate(1) && is_foc == 0
response = rebat(sObj)
if !response.nil?
diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb
index b7ce7299..68c64cff 100644
--- a/app/models/shift_sale.rb
+++ b/app/models/shift_sale.rb
@@ -57,6 +57,11 @@ class ShiftSale < ApplicationRecord
self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f
self.total_rounding = self.total_rounding + saleobj.rounding_adjustment
self.total_receipt = self.total_receipt + 1
+ if saleobj.customer.customer_type == "Dinein"
+ self.dining_count = self.dining_count + 1
+ else
+ self.takeaway_count = self.takeaway_count + 1
+ end
self.save
end
@@ -79,6 +84,11 @@ class ShiftSale < ApplicationRecord
self.commercial_taxes = self.commercial_taxes.to_i - tax.to_f
self.total_rounding = self.total_rounding - saleobj.rounding_adjustment
self.total_void = self.total_void + saleobj.grand_total
+ if saleobj.customer.customer_type == "Dinein"
+ self.dining_count = self.dining_count - 1
+ else
+ self.takeaway_count = self.takeaway_count - 1
+ end
self.save
end
end
@@ -88,4 +98,40 @@ class ShiftSale < ApplicationRecord
closing_balance = shiftobj.grand_total + shiftobj.cash_in - shiftobj.cash_out + shiftobj.total_cash
return closing_balance
end
+
+ def self.get_by_shift_other_payment(shift)
+
+ other_payment = Sale.select("sale_payments.payment_method as name,
+ SUM(case when (sale_payments.payment_method='mpu') then (sale_payments.payment_amount) else 0 end) as mpu_amount,
+ SUM(case when (sale_payments.payment_method='visa') then (sale_payments.payment_amount) else 0 end) as visa_amount,
+ SUM(case when (sale_payments.payment_method='master') then (sale_payments.payment_amount) else 0 end) as master_amount,
+ SUM(case when (sale_payments.payment_method='jcb') then (sale_payments.payment_amount) else 0 end) as jcb_amount,
+ SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount,
+ SUM(case when (sale_payments.payment_method='paypar') then (sale_payments.payment_amount) else 0 end) as paypar_amount")
+ .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
+ .where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
+ end
+
+ def self.calculate_total_price_by_accounts(shift,type)
+ query = Sale.select("acc.title as account_name," +
+ "SUM(case when (acc.id=i.account_id) then (i.price) else 0 end) as total_price")
+
+ query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id "+
+ "JOIN accounts acc ON acc.id = i.account_id" +
+ " JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
+ if type == 'discount'
+ query = query.where("sales.shift_sale_id =? and sale_status = 'completed' and i.is_taxable = false and i.remark = 'Discount'", shift.id)
+ .group("acc.title").order("acc.id")
+ else
+ query = query.where("sales.shift_sale_id =? and sale_status = 'completed'", shift.id)
+ .group("acc.title").order("acc.id")
+ end
+ end
+
+ def self.get_total_member_discount(shift)
+ query = Sale.select("SUM(sales.total_discount) as member_discount")
+ .where("shift_sale_id =? and sale_status = 'completed' and discount_type = 'member_discount'", shift.id)
+
+ end
+
end
diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb
index 133d9c48..34a9779c 100644
--- a/app/pdf/close_cashier_pdf.rb
+++ b/app/pdf/close_cashier_pdf.rb
@@ -1,8 +1,9 @@
class CloseCashierPdf < 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,:text_width
- def initialize(printer_settings, shift_sale,shop_details,sale_taxes)
- self.page_width = PrintSetting.where("name = ?","Close Cashier").first.page_width
- self.page_height = PrintSetting.where("name = ?","Close Cashier").first.page_height
+
+ def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
+ self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
+ self.page_height = printer_settings.page_height
self.margin = 5
self.price_width = 40
self.qty_width = 20
@@ -26,16 +27,11 @@ class CloseCashierPdf < Prawn::Document
self.header_font_size = 10
self.item_font_size = 8
-
-
header( shop_details)
stroke_horizontal_rule
- shift_detail(shift_sale,sale_taxes)
-
-
-
+ shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
end
def header (shop_details)
@@ -51,7 +47,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
end
- def shift_detail(shift_sale,sale_taxes)
+ def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -151,6 +147,10 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.total_taxes}", :size => self.item_font_size, :align => :right
end
+ move_down -5
+ stroke_horizontal_rule
+ move_down 7
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash Payment :", :size => self.item_font_size, :align => :right
@@ -166,14 +166,91 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.credit_sales}", :size => self.item_font_size, :align => :right
end
+ #start other payment details
+ if shift_sale.other_sales > 0
+ other_payment.each do |other|
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Other Payment Details", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "", :size => self.item_font_size, :align => :right
+ end
- y_position = cursor
- bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "Other Payment :", :size => self.item_font_size, :align => :right
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "MPU Payment :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{other.mpu_amount.round(2)}", :size => self.item_font_size, :align => :right
+ end
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "VISA Payment :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{other.visa_amount.round(2)}", :size => self.item_font_size, :align => :right
+ end
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "JCB Payment :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{other.master_amount.round(2)}", :size => self.item_font_size, :align => :right
+ end
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Master Payment :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{other.jcb_amount.round(2)}", :size => self.item_font_size, :align => :right
+ end
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Reedem Payment :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{other.paypar_amount.round(2)}", :size => self.item_font_size, :align => :right
+ end
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "FOC :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{other.foc_amount.round(2)}", :size => self.item_font_size, :align => :right
+ end
+
+ end
+ else
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Other Payment :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{shift_sale.other_sales}", :size => self.item_font_size, :align => :right
+ end
end
- bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
- text "#{shift_sale.other_sales}", :size => self.item_font_size, :align => :right
+
+ # end other payment details
+ move_down -5
+ stroke_horizontal_rule
+ move_down 7
+ #start total amount by Account Like Food / Beverage /..
+ total_amount_by_account.each do |amount|
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Total #{amount.account_name} Amount:", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right
+ end
end
+ #end total amount by Account
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
@@ -183,14 +260,57 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
end
+ move_down -5
+ stroke_horizontal_rule
+ move_down 7
+ #start total amount by Account Like Food / Beverage /..
+ total_discount_by_account.each do |amount|
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right
+ end
+ end
+ #end total amount by Account
+
+ if total_member_discount[0].member_discount.present?
+ @member_discount = total_member_discount[0].member_discount rescue 0.0
+ @overall = shift_sale.total_discounts - @member_discount
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Total Member Discount :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{@member_discount}", :size => self.item_font_size, :align => :right
+ end
+ else
+ @overall = shift_sale.total_discounts
+ end
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
- text "Discount Amount :", :size => self.item_font_size, :align => :right
+ text "Total Overall Discount :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{@overall}", :size => self.item_font_size, :align => :right
+ end
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Total Discount Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.total_discounts}", :size => self.item_font_size, :align => :right
end
-
+
+ move_down -5
+ stroke_horizontal_rule
+ move_down 7
+
sale_taxes.each do |tax|
y_position = cursor
@@ -224,6 +344,22 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.total_receipt}", :size => self.item_font_size, :align => :right
end
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Dining Count :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{shift_sale.dining_count}", :size => self.item_font_size, :align => :right
+ end
+
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
+ text "Takeaway Count :", :size => self.item_font_size, :align => :right
+ end
+ bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
+ text "#{shift_sale.takeaway_count}", :size => self.item_font_size, :align => :right
+ end
+
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Void:", :size => self.item_font_size, :align => :right
@@ -236,8 +372,6 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
move_down 5
move_down 5
-
end
-
end
diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb
index 3027fb60..809f7678 100644
--- a/app/pdf/receipt_bill_pdf.rb
+++ b/app/pdf/receipt_bill_pdf.rb
@@ -54,8 +54,9 @@ class ReceiptBillPdf < Prawn::Document
end
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
+
+ sign(sale_data)
-
footer(printed_status)
end
@@ -237,12 +238,10 @@ class ReceiptBillPdf < Prawn::Document
end
- def sale_payment(sale_data,precision,delimiter)
-
+ def sale_payment(sale_data,precision,delimiter)
stroke_horizontal_rule
move_down 5
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
-
y_position = cursor
if payment.payment_method == "paypar"
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
@@ -269,15 +268,12 @@ class ReceiptBillPdf < Prawn::Document
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down 5
- end
-
+ end
end
# show member information
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter)
-
- if rebate_amount != nil
-
+ if rebate_amount != nil
if rebate_amount["status"] == true
stroke_horizontal_rule
total = 0
@@ -414,6 +410,43 @@ class ReceiptBillPdf < Prawn::Document
end
end
+ def sign(sale_data)
+ SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
+ if payment.payment_method == "creditnote"
+
+ y_position = cursor
+ stroke_horizontal_rule
+
+ bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
+ move_down 70
+ stroke_horizontal_rule
+ end
+
+ bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
+ move_down 73
+ text "Approved By" , :size => self.item_font_size,:align => :center
+ end
+ end
+ end
+ if sale_data.payment_status == "foc"
+
+ y_position = cursor
+ stroke_horizontal_rule
+
+ bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
+ move_down 70
+ stroke_horizontal_rule
+ end
+
+ bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
+ move_down 73
+ text "Acknowledged By" , :size => self.item_font_size,:align => :center
+ end
+ end
+
+
+ end
+
def footer(printed_status)
move_down 5
stroke_horizontal_rule
@@ -421,7 +454,7 @@ class ReceiptBillPdf < Prawn::Document
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do
- text "#{printed_status}", :size => self.item_font_size,:align => :left
+ text "#{printed_status}",:style => :bold, :size => self.header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left
@@ -429,6 +462,5 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
end
-
end
diff --git a/app/uploaders/menu_item_image_uploader.rb b/app/uploaders/menu_item_image_uploader.rb
new file mode 100644
index 00000000..4acbab3c
--- /dev/null
+++ b/app/uploaders/menu_item_image_uploader.rb
@@ -0,0 +1,58 @@
+class MenuItemImageUploader < CarrierWave::Uploader::Base
+
+ # Include RMagick or MiniMagick support:
+ # include CarrierWave::RMagick
+ # include CarrierWave::MiniMagick
+
+ # Choose what kind of storage to use for this uploader:
+ storage :file
+ # storage :fog
+
+ def root
+ Rails.root.join 'public/'
+ end
+
+ # Override the directory where uploaded files will be stored.
+ # This is a sensible default for uploaders that are meant to be mounted:
+ def store_dir
+ "image/menu_images"
+ # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
+ end
+
+ # def cache_dir
+ # '/tmp/images'
+ # end
+
+ # Provide a default URL as a default if there hasn't been a file uploaded:
+ # def default_url(*args)
+ # # For Rails 3.1+ asset pipeline compatibility:
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
+ #
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
+ # end
+
+ # Process files as they are uploaded:
+ # process scale: [200, 300]
+ #
+ # def scale(width, height)
+ # # do something
+ # end
+
+ # Create different versions of your uploaded files:
+ # version :thumb do
+ # process resize_to_fit: [50, 50]
+ # end
+
+ # Add a white list of extensions which are allowed to be uploaded.
+ # For images you might use something like this:
+ def extension_whitelist
+ %w(jpg jpeg gif png)
+ end
+
+ # Override the filename of the uploaded files:
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
+ # def filename
+ # "something.jpg" if original_filename
+ # end
+
+end
diff --git a/app/views/api/restaurant/item_sets/index.json.jbuilder b/app/views/api/restaurant/item_sets/index.json.jbuilder
new file mode 100644
index 00000000..73ebeb12
--- /dev/null
+++ b/app/views/api/restaurant/item_sets/index.json.jbuilder
@@ -0,0 +1,7 @@
+json.array! @item_sets do |set|
+ json.id set.id
+ json.name set.name
+ json.alt_name set.alt_name
+ json.min_selectable_qty set.min_selectable_qty
+ json.max_selectable_qty set.max_selectable_qty
+end
diff --git a/app/views/api/restaurant/menu/_menu.json.jbuilder b/app/views/api/restaurant/menu/_menu.json.jbuilder
index 43721ff0..cfa950d7 100644
--- a/app/views/api/restaurant/menu/_menu.json.jbuilder
+++ b/app/views/api/restaurant/menu/_menu.json.jbuilder
@@ -5,13 +5,14 @@ json.valid_time_from menu.valid_time_from.strftime("%H:%M")
json.valid_time_to menu.valid_time_to.strftime("%H:%M")
if (menu.menu_categories)
- json.menu_categories menu.menu_categories do |category|
+ json.categories menu.menu_categories do |category|
json.id category.id
json.name category.name
json.alt_name category.alt_name
+ json.is_available category.is_available
if category.menu_items
- json.menu_items category.menu_items do |item|
+ json.items category.menu_items do |item|
json.partial! 'api/restaurant/menu/menu_item', item: item
end
end
diff --git a/app/views/api/restaurant/menu/_menu_item.json.jbuilder b/app/views/api/restaurant/menu/_menu_item.json.jbuilder
index c93c3b12..cd8648db 100644
--- a/app/views/api/restaurant/menu/_menu_item.json.jbuilder
+++ b/app/views/api/restaurant/menu/_menu_item.json.jbuilder
@@ -1,40 +1,70 @@
+# Format for attributes json
+attr_format = []
+param_count = item.item_attributes.count
+# Format for attributes json
+item.item_attributes.each do|attr_id|
+ menu_attr = MenuItemAttribute.find(attr_id)
+ if attr_format.count == 0
+ attr_format.push({ type: menu_attr.attribute_type, value: [] })
+ end
+
+ attr_format.each do |af|
+ if menu_attr.attribute_type == af[:type]
+ af[:value].push(menu_attr.value)
+ else
+ new_attr = {type: menu_attr.attribute_type, value: [ menu_attr.value ] }
+ attr_format.push(new_attr)
+ end
+
+ break if attr_format.count > param_count
+ end
+
+ param_count -= 1
+end
#Menu Item Information
-json.item_code item.item_code
-json.name item.name
-json.alt_name item.alt_name
-json.type item.type
-json.min_qty item.min_qty
-json.min_selectable_item item.min_selectable_item
-json.max_selectable_item item.max_selectable_item
+json.id item.id
+json.item_code item.item_code
+json.name item.name
+json.alt_name item.alt_name
+json.image item.image_path.url
+json.description item.description
+json.Information item.information
+json.type item.type
+json.account_id item.account_id
+json.min_qty item.min_qty
+json.is_available item.is_available
+json.is_sub_item item.is_sub_item
+json.item_sets item.item_sets
+json.attributes attr_format
+json.options item.item_options
+# json.min_selectable_item item.min_selectable_item
+# json.max_selectable_item item.max_selectable_item
#Item instance
-if item.menu_item_instances.count == 1 then
-
- item_instance = item.menu_item_instances[0]
- json.price = item_instance.price
- json.is_available = item_instance.is_available
- json.is_on_promotion = item_instance.is_on_promotion
- json.promotion_price = item_instance.promotion_price
- json.item_attributes = item_instance.item_attributes
-
-elsif item.menu_item_instances.count > 1 then
-
- json.item_instances item.menu_item_instances do |is|
- json.item_instance_item_code = is.item_instance_code
- json.item_instance_name = is.item_instance_name
- json.price = is.price
- json.is_available = is.is_available
- json.is_on_promotion = is.is_on_promotion
- json.promotion_price = is.promotion_price
- json.item_attributes = is.item_attributes
- end
+# if item.menu_item_instances.count == 1 then
+# item_instance = item.menu_item_instances[0]
+# json.price = item_instance.price
+# json.is_available = item_instance.is_available
+# json.is_on_promotion = item_instance.is_on_promotion
+# json.promotion_price = item_instance.promotion_price
+# json.item_attributes = item_instance.item_attributes
+ json.instances item.menu_item_instances do |is|
+ json.code is.item_instance_code
+ json.name is.item_instance_name
+ json.price is.price
+ json.is_available is.is_available
+ json.is_default is.is_default
+ json.is_on_promotion is.is_on_promotion
+ json.promotion_price is.promotion_price
+ json.item_attributes is.item_attributes
+ json.item_sets is.item_sets
end
+
#Child Menu items
-if (item.children) then
- json.set_items item.children.each do |item|
- json.partial! 'api/restaurant/menu/menu_item', item: item
- end
-
-end
+# if (item.children) then
+# json.set_items item.children.each do |item|
+# json.partial! 'api/restaurant/menu/menu_item', item: item
+# end
+# end
\ No newline at end of file
diff --git a/app/views/api/restaurant/menu/index.json.jbuilder b/app/views/api/restaurant/menu/index.json.jbuilder
index b4241854..55e876f6 100644
--- a/app/views/api/restaurant/menu/index.json.jbuilder
+++ b/app/views/api/restaurant/menu/index.json.jbuilder
@@ -4,9 +4,11 @@ json.array! @menus do |menu|
json.valid_days menu.valid_days
json.valid_time_from menu.valid_time_from.strftime("%H:%M")
json.valid_time_to menu.valid_time_to.strftime("%H:%M")
- if (@current_menu)
- json.current_menu do
- json.partial! 'api/restaurant/menu/menu', menu: @current_menu
- end
- end
+
+ json.partial! 'api/restaurant/menu/menu', menu: menu
+ # if (@current_menu)
+ # json.current_menu do
+ # json.partial! 'api/restaurant/menu/menu', menu: @current_menu
+ # end
+ # end
end
diff --git a/app/views/api/restaurant/menu_categories/show.json.jbuilder b/app/views/api/restaurant/menu_categories/show.json.jbuilder
new file mode 100644
index 00000000..ad05acbf
--- /dev/null
+++ b/app/views/api/restaurant/menu_categories/show.json.jbuilder
@@ -0,0 +1,48 @@
+if @menu.menu_items
+ json.menu_items @menu.menu_items do |item|
+ #Menu Item Information
+ # json.item_code item.item_code
+ # json.name item.name
+ # json.alt_name item.alt_name
+ # json.type item.type
+ # json.min_qty item.min_qty
+ # json.min_selectable_item item.min_selectable_item
+ # json.max_selectable_item item.max_selectable_item
+
+ #Item instance
+ # if item.menu_item_instances.count == 1 then
+
+ # item_instance = item.menu_item_instances[0]
+ # json.price item_instance.price
+ # json.is_available item_instance.is_available
+ # json.is_on_promotion item_instance.is_on_promotion
+ # json.promotion_price item_instance.promotion_price
+ # json.item_attributes item_instance.item_attributes
+
+ # elsif item.menu_item_instances.count > 1 then
+
+ # json.item_instances item.menu_item_instances do |is|
+ # json.item_instance_item_code is.item_instance_code
+ # json.item_instance_name is.item_instance_name
+ # json.price is.price
+ # json.is_available is.is_available
+ # json.is_on_promotion is.is_on_promotion
+ # json.promotion_price is.promotion_price
+ # json.item_attributes is.item_attributes
+ # end
+
+ # end
+ #Child Menu items
+ # if (item.menu_item_sets) then
+ # json.set_items item.menu_item_sets.each do |item|
+ # json.partial! 'api/restaurant/menu/menu_item', item: item
+ # end
+
+ #end
+ # if category.menu_items
+ # json.items category.menu_items do |item|
+ json.partial! 'api/restaurant/menu/menu_item', item: item
+ # end
+ # end
+ end
+end
diff --git a/app/views/api/restaurant/menu_item_attributes/index.json.jbuilder b/app/views/api/restaurant/menu_item_attributes/index.json.jbuilder
index 0dc729eb..4a265fb6 100644
--- a/app/views/api/restaurant/menu_item_attributes/index.json.jbuilder
+++ b/app/views/api/restaurant/menu_item_attributes/index.json.jbuilder
@@ -1,4 +1,5 @@
json.array! @menu_attributes do |attribute|
+ json.id attribute.id
json.type attribute.attribute_type
json.name attribute.name
json.value attribute.value
diff --git a/app/views/api/restaurant/menu_item_options/index.json.jbuilder b/app/views/api/restaurant/menu_item_options/index.json.jbuilder
index eae1c761..c7ce21aa 100644
--- a/app/views/api/restaurant/menu_item_options/index.json.jbuilder
+++ b/app/views/api/restaurant/menu_item_options/index.json.jbuilder
@@ -1,4 +1,6 @@
json.array! @menu_options do |option|
+ json.id option.id
+ json.type option.option_type
json.name option.name
json.value option.value
end
diff --git a/app/views/crm/customers/_form.html.erb b/app/views/crm/customers/_form.html.erb
index c913651a..e9cef629 100644
--- a/app/views/crm/customers/_form.html.erb
+++ b/app/views/crm/customers/_form.html.erb
@@ -1,4 +1,3 @@
-
<%= simple_form_for([:crm,@crm_customer]) do |f| %>
<%= f.error_notification %>
diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb
index 1eda0bec..35c3a46d 100644
--- a/app/views/crm/customers/_new_form.html.erb
+++ b/app/views/crm/customers/_new_form.html.erb
@@ -1,25 +1,7 @@
<%= 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['card_no']}\"]"
- str.gsub!('["', '')
- str.gsub!('"]', '') %>
- <%= str %>
- <% end %>
-
-
-
+ <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
+
+
+
+
+
+
+
+ <%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control col-md-6 tax_profiles" %>
+
+
+
">
+ <%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
+ <% flash.each do |name, msg| %>
+ <% str="[\"#{msg['card_no']}\"]"
+ str.gsub!('["', '')
+ str.gsub!('"]', '') %>
+ <%= str %>
+ <% end %>
+
+
+
@@ -110,8 +124,7 @@
<%end %>
-
-
+
@@ -138,6 +151,11 @@
},100);
}
});
+
+ // $("#customer_card_no").click(function(){
+ // var ab=$("#customer_tax_profiles").val();
+ // console.log(JSON.stringify(ab));
+ // });
});
diff --git a/app/views/crm/customers/edit.json.jbuilder b/app/views/crm/customers/edit.json.jbuilder
new file mode 100644
index 00000000..60148085
--- /dev/null
+++ b/app/views/crm/customers/edit.json.jbuilder
@@ -0,0 +1,4 @@
+json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth,
+ :membership_id, :membership_type, :membership_authentication_code,
+ :salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :tax_profiles
+json.url crm_customer_url(@crm_customer, format: :json)
\ 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 4a4d13b8..71772c92 100644
--- a/app/views/crm/customers/index.html.erb
+++ b/app/views/crm/customers/index.html.erb
@@ -76,7 +76,7 @@
- <%= render 'new_form', crm_customer: @crm_customer %>
+ <%= render 'new_form', crm_customer: @crm_customer, taxes: @taxes %>
@@ -121,15 +121,24 @@ $(document).on('click',".customer_tr",function(){
update_sale(customer_id,sale_id);
}else{
- var url = "customers/"+customer_id;
+ var url = "customers/" + customer_id + "/edit";
}
+ $("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'});
+
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
- success: function(data) {
+ success: function(data) {
+ // Selected for Taxes
+ var taxes = JSON.stringify(data.tax_profiles);
+ var parse_taxes = JSON.parse(taxes);
+ $.each(parse_taxes, function(i, value){
+ $("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected").css({'color':'#fff','background':'#215d9c'});
+ });
+
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
@@ -138,6 +147,7 @@ $(document).on('click',".customer_tr",function(){
$('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no);
$('#customer_card_no').val(data.card_no);
+ $('#customer_type').val(data.customer_type);
$('#paypar_account_no').val(data.paypar_account_no);
$('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth);
diff --git a/app/views/crm/customers/show.json.jbuilder b/app/views/crm/customers/show.json.jbuilder
index 5fd0410a..ffc312a2 100644
--- a/app/views/crm/customers/show.json.jbuilder
+++ b/app/views/crm/customers/show.json.jbuilder
@@ -1,4 +1,4 @@
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth,
:membership_id, :membership_type, :membership_authentication_code,
- :salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no
+ :salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :tax_profiles
json.url crm_customer_url(@crm_customer, format: :json)
diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb
index 571360c3..511cd500 100644
--- a/app/views/home/dashboard.html.erb
+++ b/app/views/home/dashboard.html.erb
@@ -5,13 +5,10 @@
<% elsif current_login_employee.role = "cashier" %>
<%= link_to "Cashier Station", origami_path %>
-
<% elsif current_login_employee = "account" %>
<%= link_to "Cashier Station", oishi_path %>
-
<% else %>
<%= link_to "Cashier Station", oishi_path %>
-
<% end %>
<% shop = Shop.first %>
@@ -228,28 +225,21 @@