diff --git a/assets/angular/core/app.js b/assets/angular/core/app.js index e0158c0..559a367 100644 --- a/assets/angular/core/app.js +++ b/assets/angular/core/app.js @@ -84,6 +84,10 @@ angular.module("EmmetBlue") }, history: { menu: false + }, + mobile: { + swipe_dismiss: true, + styling: true } }); }; @@ -149,13 +153,19 @@ angular.module("EmmetBlue") services.serverUpload = function(url, requestType, data={}){ var deferred = $q.defer(); - return $http({ + var _req = { url: url, method: requestType, data: data, transformRequest: angular.identity, headers: {'Content-Type': undefined} - }).then(function(result){ + } + + if (typeof $cookies.getObject(CONSTANTS.USER_COOKIE_IDENTIFIER) !== "undefined"){ + _req.headers.Authorization = $cookies.getObject(CONSTANTS.USER_COOKIE_IDENTIFIER).token; + } + + return $http(_req).then(function(result){ deferred.resolve(result.data.contentData); return deferred.promise; }, function(result){ @@ -281,6 +291,10 @@ angular.module("EmmetBlue") } } + services.newWebSocket = function(){ + return new WebSocket(CONSTANTS.WEB_SOCKET_SERVER); + } + services.substringMatcher = function(strs) { return function findMatches(q, cb) { var matches, substringRegex; @@ -305,6 +319,11 @@ angular.module("EmmetBlue") }; }; + services.generateQrCode = function(content, type="label"){ + var data = {type: type, content: content}; + return generateQrCode(JSON.stringify(data)); + } + services.globalConstants = CONSTANTS; services.serializeParams = $httpParamSerializer; diff --git a/assets/angular/core/controllers/core/core-controller.js b/assets/angular/core/controllers/core/core-controller.js index a38af45..ed6fc16 100644 --- a/assets/angular/core/controllers/core/core-controller.js +++ b/assets/angular/core/controllers/core/core-controller.js @@ -164,4 +164,10 @@ angular.module("EmmetBlue") }) } } + + var userSessionQrCodeHandler = function(){ + $(".userSessionQrCodeSvg").html(utils.generateQrCode(JSON.stringify(utils.userSession.cookie()), "user")); + } + + userSessionQrCodeHandler(); }); \ No newline at end of file diff --git a/assets/angular/core/defaults.js b/assets/angular/core/defaults.js index b3c30d7..3354347 100644 --- a/assets/angular/core/defaults.js +++ b/assets/angular/core/defaults.js @@ -11,7 +11,8 @@ angular.module('EmmetBlue', [ 'ngStorage', 'ngPrint', 'angularUtils.directives.dirPagination', - 'angular-toArrayFilter' //<--- LIFE SAVER! Thanks https://github.com/petebacondarwin! (in case, paradventure, probably, you ever read this code) + 'angular-toArrayFilter', //<--- LIFE SAVER! Thanks https://github.com/petebacondarwin! (in case, paradventure, probably, you ever read this code) + 'mwl.calendar' ]) .constant("CONSTANTS", getConstants()) diff --git a/assets/angular/core/templates/header.html b/assets/angular/core/templates/header.html index 9f26a09..9cfb1b5 100644 --- a/assets/angular/core/templates/header.html +++ b/assets/angular/core/templates/header.html @@ -8,7 +8,7 @@ - + + + + + \ No newline at end of file diff --git a/assets/angular/libraries/angular-bootstrap-calendar/angular-bootstrap-calendar-tpls.min.js b/assets/angular/libraries/angular-bootstrap-calendar/angular-bootstrap-calendar-tpls.min.js new file mode 100644 index 0000000..b2e212f --- /dev/null +++ b/assets/angular/libraries/angular-bootstrap-calendar/angular-bootstrap-calendar-tpls.min.js @@ -0,0 +1,8 @@ +/** + * angular-bootstrap-calendar - A pure AngularJS bootstrap themed responsive calendar that can display events and has views for year, month, week and day + * @version v1.0.0 + * @link https://github.com/mattlewis92/angular-bootstrap-calendar + * @license MIT + */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("angular"),require("moment"),function(){try{return require("interactjs")}catch(e){}}()):"function"==typeof define&&define.amd?define(["angular","moment","interact"],t):"object"==typeof exports?exports.angularBootstrapCalendarModuleName=t(require("angular"),require("moment"),function(){try{return require("interactjs")}catch(e){}}()):e.angularBootstrapCalendarModuleName=t(e.angular,e.moment,e.interact)}("undefined"!=typeof self?self:this,function(e,t,n){return function(e){function t(a){if(n[a])return n[a].exports;var r=n[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,a){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:a})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=7)}([function(t,n){t.exports=e},function(e,t,n){function a(e,t){if(c(e))return new Date(e.getTime());if("string"!=typeof e)return new Date(e);var n=t||{},a=n.additionalDigits;a=null==a?u:Number(a);var s=r(e),v=i(s.date,a),p=v.year,f=v.restDateString,w=l(f,p);if(w){var g,y=w.getTime(),h=0;return s.time&&(h=o(s.time)),s.timezone?g=d(s.timezone):(g=new Date(y+h).getTimezoneOffset(),g=new Date(y+h+g*m).getTimezoneOffset()),new Date(y+h+g*m)}return new Date(e)}function r(e){var t,n={},a=e.split(p);if(f.test(a[0])?(n.date=null,t=a[0]):(n.date=a[0],t=a[1]),t){var r=A.exec(t);r?(n.time=t.replace(r[1],""),n.timezone=r[1]):n.time=t}return n}function i(e,t){var n,a=g[t],r=h[t];if(n=y.exec(e)||r.exec(e)){var i=n[1];return{year:parseInt(i,10),restDateString:e.slice(i.length)}}if(n=w.exec(e)||a.exec(e)){var l=n[1];return{year:100*parseInt(l,10),restDateString:e.slice(l.length)}}return{year:null}}function l(e,t){if(null===t)return null;var n,a,r,i;if(0===e.length)return a=new Date(0),a.setUTCFullYear(t),a;if(n=D.exec(e))return a=new Date(0),r=parseInt(n[1],10)-1,a.setUTCFullYear(t,r),a;if(n=S.exec(e)){a=new Date(0);var l=parseInt(n[1],10);return a.setUTCFullYear(t,0,l),a}if(n=b.exec(e)){a=new Date(0),r=parseInt(n[1],10)-1;var o=parseInt(n[2],10);return a.setUTCFullYear(t,r,o),a}if(n=E.exec(e))return i=parseInt(n[1],10)-1,s(t,i);if(n=x.exec(e)){i=parseInt(n[1],10)-1;return s(t,i,parseInt(n[2],10)-1)}return null}function o(e){var t,n,a;if(t=C.exec(e))return(n=parseFloat(t[1].replace(",",".")))%24*v;if(t=k.exec(e))return n=parseInt(t[1],10),a=parseFloat(t[2].replace(",",".")),n%24*v+a*m;if(t=T.exec(e)){n=parseInt(t[1],10),a=parseInt(t[2],10);var r=parseFloat(t[3].replace(",","."));return n%24*v+a*m+1e3*r}return null}function d(e){var t,n;return(t=M.exec(e))?0:(t=V.exec(e))?(n=60*parseInt(t[2],10),"+"===t[1]?-n:n):(t=$.exec(e),t?(n=60*parseInt(t[2],10)+parseInt(t[3],10),"+"===t[1]?-n:n):0)}function s(e,t,n){t=t||0,n=n||0;var a=new Date(0);a.setUTCFullYear(e,0,4);var r=a.getUTCDay()||7,i=7*t+n+1-r;return a.setUTCDate(a.getUTCDate()+i),a}var c=n(5),v=36e5,m=6e4,u=2,p=/[T ]/,f=/:/,w=/^(\d{2})$/,g=[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],y=/^(\d{4})/,h=[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],D=/^-(\d{2})$/,S=/^-?(\d{3})$/,b=/^-?(\d{2})-?(\d{2})$/,E=/^-?W(\d{2})$/,x=/^-?W(\d{2})-?(\d{1})$/,C=/^(\d{2}([.,]\d*)?)$/,k=/^(\d{2}):?(\d{2}([.,]\d*)?)$/,T=/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,A=/([Z+-].*)$/,M=/^(Z)$/,V=/^([+-])(\d{2})$/,$=/^([+-])(\d{2}):?(\d{2})$/;e.exports=a},function(e,t,n){function a(e,t){var n=r(e).getTime(),a=Number(t);return new Date(n+a)}var r=n(1);e.exports=a},function(e,t,n){function a(e){var t=r(e);return t.setHours(0,0,0,0),t}var r=n(1);e.exports=a},function(e,t,n){"use strict";function a(e){var t=e.startDate,n=e.seconds,a=e.excluded,i=e.precision,l=void 0===i?"days":i;if(a.length<1)return 0;for(var o=x()(t,n-1),d=H()(t),s=H()(x()(o,0)),c=0,v=t;vme&&(d=me-c),(d-=a({startDate:s,seconds:d,excluded:i,precision:o}))/ve}function l(e){var t=e.event,n=e.startOfWeek,r=e.excluded,i=void 0===r?[]:r,l=e.precision,o=void 0===l?"days":l;if(t.startn&&rn&&ia||(!(!G()(r,n)&&!G()(r,a))||!(!G()(i,n)&&!G()(i,a)))))}function d(e){var t=e.events,n=e.periodStart,a=e.periodEnd;return t.filter(function(e){return o({event:e,periodStart:n,periodEnd:a})})}function s(e){var t=e.date,n=e.weekendDays,a=void 0===n?oe:n,r=ee()(new Date);return{date:t,isPast:tr,isWeekend:a.indexOf(H()(t))>-1}}function c(e){for(var t=e.viewDate,n=e.weekStartsOn,a=e.excluded,r=void 0===a?[]:a,i=e.weekendDays,l=le()(t,{weekStartsOn:n}),o=[],d=0;d0}).map(function(e){return{event:e.event,offset:e.offset,span:e.span,startsBeforeWeek:e.event.startf}}).sort(function(e,t){var n=V()(e.event.start,t.event.start);return 0===n?V()(t.event.end||t.event.start,e.event.end||e.event.start):n}),y=[],h=[];return g.forEach(function(e,t){if(-1===h.indexOf(e)){h.push(e);var n=e.span+e.offset,a=g.slice(t+1).filter(function(e){if(e.offset>=n&&n+e.span<=de&&-1===h.indexOf(e)){var t=e.offset-n;return u||(e.offset=t),n+=e.span+t,h.push(e),!0}});y.push({row:[e].concat(a)})}}),y}function m(e){var t=e.events,n=void 0===t?[]:t,a=e.viewDate,r=e.weekStartsOn,i=e.excluded,l=void 0===i?[]:i,o=e.viewStart,c=void 0===o?re()(a):o,v=e.viewEnd,m=void 0===v?I()(a):v,u=e.weekendDays;n||(n=[]);for(var p,f=le()(c,{weekStartsOn:r}),w=W()(m,{weekStartsOn:r}),g=d({events:n,periodStart:f,periodEnd:w}),y=[],h=0;hv,l=r*s/ce,d=0;t>c&&(d+=A()(t,c)),d*=l;var u=a?c:t,p=i?v:n,f=A()(p,u);e.end?f*=l:f=s;for(var w=d+f,g=m.filter(function(e){var t=e.top,n=e.top+e.height;return d0&&m.push(h),h}).filter(function(e){return e.height>0});return{events:u,width:Math.max.apply(Math,u.map(function(e){return e.left+e.width})),allDayEvents:d({events:n.filter(function(e){return e.allDay}),periodStart:ee()(c),periodEnd:O()(v)})}}function p(e){for(var t=e.viewDate,n=e.hourSegments,a=e.dayStart,r=e.dayEnd,i=[],l=Q()(Z()(ee()(t),a.hour),a.minute),o=Q()(Z()(ne()(O()(t)),r.hour),r.minute),d=ce/n,s=ee()(t),c=0;c=l&&u0&&i.push({segments:v})}return i}function f(e,t){function n(e,n){t(e,n),a=!1}var a=!0;return Array.isArray(e)?(e.forEach(function(e){e.start?z()(e.start)||n(ue.StartPropertyNotDate,e):n(ue.StartPropertyMissing,e),e.end&&(z()(e.end)||n(ue.EndPropertyNotDate,e),e.start>e.end&&n(ue.EndsBeforeStart,e))}),a):(t(ue.NotArray,e),!1)}Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"DAYS_OF_WEEK",function(){return w}),n.d(t,"SECONDS_IN_DAY",function(){return ve}),n.d(t,"SECONDS_IN_WEEK",function(){return me}),t.getWeekViewEventOffset=l,t.getEventsInPeriod=d,t.getWeekViewHeader=c,t.getWeekView=v,t.getMonthView=m,t.getDayView=u,t.getDayViewHourGrid=p,n.d(t,"EventValidationErrorMessage",function(){return ue}),t.validateEvents=f;var w,g=n(23),y=n.n(g),h=n(24),D=n.n(h),S=n(25),b=n.n(S),E=n(26),x=n.n(E),C=n(27),k=n.n(C),T=n(30),A=n.n(T),M=n(31),V=n.n(M),$=n(32),O=n.n($),R=n(33),I=n.n(R),N=n(34),W=n.n(N),j=n(35),H=n.n(j),F=n(5),z=n.n(F),Y=n(36),U=n.n(Y),B=n(37),P=n.n(B),L=n(38),G=n.n(L),q=n(40),_=n.n(q),K=n(41),Z=n.n(K),J=n(42),Q=n.n(J),X=n(3),ee=n.n(X),te=n(43),ne=n.n(te),ae=n(44),re=n.n(ae),ie=n(45),le=n.n(ie);!function(e){e[e.SUNDAY=0]="SUNDAY",e[e.MONDAY=1]="MONDAY",e[e.TUESDAY=2]="TUESDAY",e[e.WEDNESDAY=3]="WEDNESDAY",e[e.THURSDAY=4]="THURSDAY",e[e.FRIDAY=5]="FRIDAY",e[e.SATURDAY=6]="SATURDAY"}(w||(w={}));var oe=[w.SUNDAY,w.SATURDAY],de=7,se=24,ce=60,ve=86400,me=ve*de,ue={NotArray:"Events must be an array",StartPropertyMissing:"Event is missing the `start` property",StartPropertyNotDate:"Event `start` property should be a javascript date object. Do `new Date(event.start)` to fix it.",EndPropertyNotDate:"Event `end` property should be a javascript date object. Do `new Date(event.end)` to fix it.",EndsBeforeStart:"Event `start` property occurs after the `end`"}},function(e,t){function n(e){return e instanceof Date}e.exports=n},function(e,t,n){function a(e,t){var n=r(e),a=r(t);return n.getTime()-a.getTime()}var r=n(1);e.exports=a},function(e,t,n){"use strict";function a(e){e.keys().forEach(e)}n(8);var r=n(0),i={},l=n(9);l.keys().forEach(function(e){var t=e.replace("./",""),n="mwl/"+t,a=t.replace(".html","");i[a]={cacheTemplateName:n,template:l(e)}}),e.exports=r.module("mwl.calendar",[]).config(["calendarConfig",function(e){r.forEach(i,function(t,n){e.templates[n]||(e.templates[n]=t.cacheTemplateName)})}]).run(["$templateCache","$interpolate",function(e,t){r.forEach(i,function(n){if(!e.get(n.cacheTemplateName)){var a=n.template.replace("{{",t.startSymbol()).replace("}}",t.endSymbol());e.put(n.cacheTemplateName,a)}})}]).name,a(n(19)),a(n(58)),a(n(63))},function(e,t){},function(e,t,n){function a(e){return n(r(e))}function r(e){var t=i[e];if(!(t+1))throw new Error("Cannot find module '"+e+"'.");return t}var i={"./calendar.html":10,"./calendarDayView.html":11,"./calendarHourList.html":12,"./calendarMonthCell.html":13,"./calendarMonthCellEvents.html":14,"./calendarMonthView.html":15,"./calendarSlideBox.html":16,"./calendarWeekView.html":17,"./calendarYearView.html":18};a.keys=function(){return Object.keys(i)},a.resolve=r,e.exports=a,a.id=9},function(e,t){e.exports="
The value passed to the view attribute of the calendar is not set
The value passed to view-date attribute of the calendar is not set
"},function(e,t){e.exports='
-
'},function(e,t){e.exports='
 
'},function(e,t){e.exports='
'},function(e,t){e.exports=' '},function(e,t){e.exports='
'},function(e,t){e.exports='
'},function(e,t){e.exports=' '},function(e,t){e.exports='
'},function(e,t,n){function a(e){return n(r(e))}function r(e){var t=i[e];if(!(t+1))throw new Error("Cannot find module '"+e+"'.");return t}var i={"./mwlCalendar.js":20,"./mwlCalendarDay.js":21,"./mwlCalendarHourList.js":22,"./mwlCalendarMonth.js":46,"./mwlCalendarSlideBox.js":47,"./mwlCalendarWeek.js":48,"./mwlCalendarYear.js":49,"./mwlCollapseFallback.js":50,"./mwlDateModifier.js":51,"./mwlDragSelect.js":52,"./mwlDraggable.js":53,"./mwlDroppable.js":54,"./mwlDynamicDirectiveTemplate.js":55,"./mwlElementDimensions.js":56,"./mwlResizable.js":57};a.keys=function(){return Object.keys(i)},a.resolve=r,e.exports=a,a.id=19},function(e,t,n){"use strict";var a=n(0),r="Bootstrap calendar:";a.module("mwl.calendar").controller("MwlCalendarCtrl",["$scope","$log","$timeout","$attrs","$locale","moment","calendarTitle","calendarHelper",function(e,t,n,i,l,o,d,s){var c=this;c.changeView=function(e,t){c.view=e,c.viewDate=t},c.dateClicked=function(e){var t=o(e).toDate(),n={year:"month",month:"day",week:"day"};!1!==c.onViewChangeClick({calendarDate:t,calendarNextView:n[c.view]})&&c.changeView(n[c.view],t)},c.$onInit=function(){function v(e){e.startsAt?a.isDate(e.startsAt)||t.warn(r,"Event startsAt should be a javascript date object. Do `new Date(event.startsAt)` to fix it.",e):t.warn(r,"Event is missing the startsAt field",e),e.endsAt&&(a.isDate(e.endsAt)||t.warn(r,"Event endsAt should be a javascript date object. Do `new Date(event.endsAt)` to fix it.",e),o(e.startsAt).isAfter(o(e.endsAt))&&t.warn(r,"Event cannot start after it finishes",e))}function m(){d[c.view]&&a.isDefined(i.viewTitle)&&(c.viewTitle=d[c.view](c.viewDate)),c.events.forEach(function(e,t){v(e),e.calendarEventId=t});var t=o(c.viewDate),r=!0;u.clone().startOf(c.view).isSame(t.clone().startOf(c.view))&&!u.isSame(t)&&c.view===p&&(r=!1),u=t,p=c.view,r&&n(function(){e.$broadcast("calendar.refreshView")})}c.slideBoxDisabled&&t.warn(r,"The `slide-box-disabled` option is deprecated and will be removed in the next release. Instead set `cell-auto-open-disabled` to true"),c.events=c.events||[],c.excludedDays=c.excludedDays||[];var u=o(c.viewDate),p=c.view;s.loadTemplates().then(function(){c.templatesLoaded=!0;var t=!1;e.$watchGroup(["vm.viewDate","vm.view","vm.cellIsOpen",function(){return o.locale()+l.id}],function(){t?m():(t=!0,e.$watch("vm.events",m,!0))})}).catch(function(e){t.error("Could not load all calendar templates",e)})},a.version.minor<5&&c.$onInit()}]).directive("mwlCalendar",function(){return{template:'
',restrict:"E",scope:{events:"=",view:"=",viewTitle:"=?",viewDate:"=",cellIsOpen:"=?",cellAutoOpenDisabled:"=?",excludedDays:"=?",slideBoxDisabled:"=?",customTemplateUrls:"=?",draggableAutoScroll:"=?",onEventClick:"&",onEventTimesChanged:"&",onTimespanClick:"&",onDateRangeSelect:"&?",onViewChangeClick:"&",cellModifier:"&",dayViewStart:"@",dayViewSegmentSize:"@",dayViewEnd:"@",dayViewSplit:"@",dayViewEventChunkSize:"@",dayViewEventWidth:"@",templateScope:"=?",dayViewTimePosition:"@"},controller:"MwlCalendarCtrl as vm",bindToController:!0}})},function(e,t,n){"use strict";n(0).module("mwl.calendar").controller("MwlCalendarDayCtrl",["$scope","moment","calendarHelper","calendarEventTitle",function(e,t,n,a){function r(){i.timeHidden="hidden"===i.dayViewTimePosition,i.dayViewTimePositionOffset="default"!==i.dayViewTimePosition?0:60,i.dayViewSplit=i.dayViewSplit||30,i.dayViewHeight=n.getDayViewHeight(i.dayViewStart,i.dayViewEnd,i.dayViewSplit,i.dayViewSegmentSize);var e=n.getDayView(i.events,i.viewDate,i.dayViewStart,i.dayViewEnd,i.dayViewSplit,i.dayViewEventWidth,i.dayViewSegmentSize);i.allDayEvents=e.allDayEvents,i.nonAllDayEvents=e.events,i.viewWidth=e.width+62}var i=this;i.calendarEventTitle=a,e.$on("calendar.refreshView",r),e.$watchGroup(["vm.dayViewStart","vm.dayViewEnd","vm.dayViewSplit"],r),i.eventDragComplete=function(e,n){var a=n*i.dayViewSplit,r=t(e.startsAt).add(a,"minutes"),l=t(e.endsAt).add(a,"minutes");delete e.tempStartsAt,i.onEventTimesChanged({calendarEvent:e,calendarNewEventStart:r.toDate(),calendarNewEventEnd:e.endsAt?l.toDate():null})},i.eventDragged=function(e,n){var a=n*i.dayViewSplit;e.tempStartsAt=t(e.startsAt).add(a,"minutes").toDate()},i.eventResizeComplete=function(e,n,a){var r=a*i.dayViewSplit,l=t(e.startsAt),o=t(e.endsAt);"start"===n?l.add(r,"minutes"):o.add(r,"minutes"),delete e.tempStartsAt,i.onEventTimesChanged({calendarEvent:e,calendarNewEventStart:l.toDate(),calendarNewEventEnd:o.toDate()})},i.eventResized=function(e,n,a){var r=a*i.dayViewSplit;"start"===n&&(e.tempStartsAt=t(e.startsAt).add(r,"minutes").toDate())}}]).directive("mwlCalendarDay",function(){return{template:'
',restrict:"E",require:"^mwlCalendar",scope:{events:"=",viewDate:"=",onEventClick:"=",onEventTimesChanged:"=",onTimespanClick:"=",onDateRangeSelect:"=",dayViewStart:"=",dayViewEnd:"=",dayViewSplit:"=",dayViewEventChunkSize:"=",dayViewSegmentSize:"=",dayViewEventWidth:"=",customTemplateUrls:"=?",cellModifier:"=",templateScope:"=",dayViewTimePosition:"=",draggableAutoScroll:"="},controller:"MwlCalendarDayCtrl as vm",bindToController:!0}})},function(e,t,n){"use strict";var a=n(0),r=n(4);a.module("mwl.calendar").controller("MwlCalendarHourListCtrl",["$scope","$document","moment","calendarHelper",function(e,t,n,a){function i(){l.dayViewSplit=parseInt(l.dayViewSplit);var e=(l.dayViewStart||"00:00").split(":"),t=(l.dayViewEnd||"23:59").split(":");l.hourGrid=r.getDayViewHourGrid({viewDate:"week"===l.view?n(l.viewDate).startOf("week").toDate():n(l.viewDate).toDate(),hourSegments:60/l.dayViewSplit,dayStart:{hour:e[0],minute:e[1]},dayEnd:{hour:t[0],minute:t[1]}}),l.hourGrid.forEach(function(e){e.segments.forEach(function(e){if(e.date=n(e.date),e.nextSegmentDate=e.date.clone().add(l.dayViewSplit,"minutes"),"week"===l.view){e.days=[];for(var t=0;t<7;t++){var a={date:n(e.date).add(t,"days")};a.nextSegmentDate=a.date.clone().add(l.dayViewSplit,"minutes"),l.cellModifier({calendarCell:a}),e.days.push(a)}}else l.cellModifier({calendarCell:e})})})}var l=this;l.scrollBarWidth=function(){var e=t[0].createElement("div");e.style.visibility="hidden",e.style.width="100px",e.style.msOverflowStyle="scrollbar",t[0].body.appendChild(e);var n=e.offsetWidth;e.style.overflow="scroll";var a=t[0].createElement("div");a.style.width="100%",e.appendChild(a);var r=a.offsetWidth;return e.parentNode.removeChild(e),n-r}();var o=n.locale();e.$on("calendar.refreshView",function(){o!==n.locale()&&(o=n.locale(),i())}),e.$watchGroup(["vm.dayViewStart","vm.dayViewEnd","vm.dayViewSplit","vm.viewDate"],function(){i()}),l.eventDropped=function(e,t){var r=n(t),i=a.adjustEndDateFromStartDiff(e.startsAt,r,e.endsAt);l.onEventTimesChanged({calendarEvent:e,calendarDate:t,calendarNewEventStart:r.toDate(),calendarNewEventEnd:i?i.toDate():null})},l.onDragSelectStart=function(e,t){l.dateRangeSelect||(l.dateRangeSelect={active:!0,startDate:e,endDate:e,dayIndex:t})},l.onDragSelectMove=function(e){l.dateRangeSelect&&(l.dateRangeSelect.endDate=e)},l.onDragSelectEnd=function(e){l.dateRangeSelect&&(l.dateRangeSelect.endDate=e,l.dateRangeSelect.endDate>l.dateRangeSelect.startDate&&l.onDateRangeSelect({calendarRangeStartDate:l.dateRangeSelect.startDate.toDate(),calendarRangeEndDate:l.dateRangeSelect.endDate.toDate()}),delete l.dateRangeSelect)}}]).directive("mwlCalendarHourList",function(){return{restrict:"E",template:'
',controller:"MwlCalendarHourListCtrl as vm",scope:{viewDate:"=",dayViewStart:"=",dayViewEnd:"=",dayViewSplit:"=",dayWidth:"=?",onTimespanClick:"=",onDateRangeSelect:"=",onEventTimesChanged:"=",customTemplateUrls:"=?",cellModifier:"=",templateScope:"=",view:"@"},bindToController:!0}})},function(e,t,n){function a(e,t){var n=r(e),a=Number(t);return n.setDate(n.getDate()+a),n}var r=n(1);e.exports=a},function(e,t,n){function a(e,t){var n=Number(t);return r(e,n*i)}var r=n(2),i=36e5;e.exports=a},function(e,t,n){function a(e,t){var n=Number(t);return r(e,n*i)}var r=n(2),i=6e4;e.exports=a},function(e,t,n){function a(e,t){var n=Number(t);return r(e,1e3*n)}var r=n(2);e.exports=a},function(e,t,n){function a(e,t){var n=r(e),a=r(t),o=l(n,a),d=Math.abs(i(n,a));return n.setDate(n.getDate()-o*d),o*(d-(l(n,a)===-o))}var r=n(1),i=n(28),l=n(29);e.exports=a},function(e,t,n){function a(e,t){var n=r(e),a=r(t),o=n.getTime()-n.getTimezoneOffset()*i,d=a.getTime()-a.getTimezoneOffset()*i;return Math.round((o-d)/l)}var r=n(3),i=6e4,l=864e5;e.exports=a},function(e,t,n){function a(e,t){var n=r(e),a=n.getTime(),i=r(t),l=i.getTime();return al?1:0}var r=n(1);e.exports=a},function(e,t,n){function a(e,t){var n=r(e,t)/i;return n>0?Math.floor(n):Math.ceil(n)}var r=n(6),i=6e4;e.exports=a},function(e,t,n){function a(e,t){var n=r(e,t)/1e3;return n>0?Math.floor(n):Math.ceil(n)}var r=n(6);e.exports=a},function(e,t,n){function a(e){var t=r(e);return t.setHours(23,59,59,999),t}var r=n(1);e.exports=a},function(e,t,n){function a(e){var t=r(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}var r=n(1);e.exports=a},function(e,t,n){function a(e,t){var n=t?Number(t.weekStartsOn)||0:0,a=r(e),i=a.getDay(),l=6+(i-1&&(n.backgroundColor=e.color?e.color.secondary:"")}})},o.handleEventDrop=function(e,a,r){var i=t(e.startsAt).year(t(a).year()).month(t(a).month()).date(t(a).date()),l=n.adjustEndDateFromStartDiff(e.startsAt,i,e.endsAt);o.onEventTimesChanged({calendarEvent:e,calendarDate:a,calendarNewEventStart:i.toDate(),calendarNewEventEnd:l?l.toDate():null,calendarDraggedFromDate:r})},o.getWeekNumberLabel=function(e){var t=e.date.clone().add(1,"day").isoWeek();return"function"==typeof r.i18nStrings.weekNumber?r.i18nStrings.weekNumber({weekNumber:t}):r.i18nStrings.weekNumber.replace("{week}",t)},o.onDragSelectStart=function(e){o.dateRangeSelect||(o.dateRangeSelect={startDate:e.date,endDate:e.date})},o.onDragSelectMove=function(e){o.dateRangeSelect&&(o.dateRangeSelect.endDate=e.date)},o.onDragSelectEnd=function(e){o.dateRangeSelect&&(o.dateRangeSelect.endDate=e.date,o.dateRangeSelect.endDate>o.dateRangeSelect.startDate&&o.onDateRangeSelect({calendarRangeStartDate:o.dateRangeSelect.startDate.clone().startOf("day").toDate(),calendarRangeEndDate:o.dateRangeSelect.endDate.clone().endOf("day").toDate()}),delete o.dateRangeSelect)},o.$onInit=function(){o.cellAutoOpenDisabled&&e.$watchGroup(["vm.cellIsOpen","vm.viewDate"],l)},a.version.minor<5&&o.$onInit()}]).directive("mwlCalendarMonth",function(){return{template:'
',restrict:"E",require:"^mwlCalendar",scope:{events:"=",viewDate:"=",excludedDays:"=",onEventClick:"=",onEventTimesChanged:"=",onDateRangeSelect:"=",cellIsOpen:"=",cellAutoOpenDisabled:"=",onTimespanClick:"=",cellModifier:"=",slideBoxDisabled:"=",customTemplateUrls:"=?",templateScope:"=",draggableAutoScroll:"="},controller:"MwlCalendarMonthCtrl as vm",link:function(e,t,n,a){e.vm.calendarCtrl=a},bindToController:!0}})},function(e,t,n){"use strict";n(0).module("mwl.calendar").controller("MwlCalendarSlideBoxCtrl",["$scope","$timeout","calendarConfig","calendarEventTitle",function(e,t,n,a){var r=this;r.calendarConfig=n,r.calendarEventTitle=a,r.isCollapsed=!0,e.$watch("vm.isOpen",function(e){t(function(){r.isCollapsed=!e})})}]).directive("mwlCalendarSlideBox",function(){return{restrict:"E",template:'
',replace:!0,controller:"MwlCalendarSlideBoxCtrl as vm",require:["^?mwlCalendarMonth","^?mwlCalendarYear"],link:function(e,t,n,a){e.isMonthView=!!a[0],e.isYearView=!!a[1]},scope:{isOpen:"=",events:"=",onEventClick:"=",cell:"=",customTemplateUrls:"=?",templateScope:"=",draggableAutoScroll:"="},bindToController:!0}})},function(e,t,n){"use strict";n(0).module("mwl.calendar").controller("MwlCalendarWeekCtrl",["$scope","moment","calendarHelper","calendarConfig","calendarEventTitle",function(e,t,n,a,r){var i=this;i.showTimes=a.showTimesOnWeekView,i.calendarEventTitle=r,e.$on("calendar.refreshView",function(){i.dayViewSplit=i.dayViewSplit||30,i.dayViewHeight=n.getDayViewHeight(i.dayViewStart,i.dayViewEnd,i.dayViewSplit),i.showTimes?i.view=n.getWeekViewWithTimes(i.events,i.viewDate,i.dayViewStart,i.dayViewEnd,i.dayViewSplit):i.view=n.getWeekView(i.events,i.viewDate,i.excludedDays)}),i.weekDragged=function(e,n,a){var r=t(e.startsAt).add(n,"days"),l=t(e.endsAt).add(n,"days");if(a){var o=a*i.dayViewSplit;r=r.add(o,"minutes"),l=l.add(o,"minutes")}delete e.tempStartsAt,i.onEventTimesChanged({calendarEvent:e,calendarNewEventStart:r.toDate(),calendarNewEventEnd:e.endsAt?l.toDate():null})},i.eventDropped=function(e,n){var a=t(n).diff(t(e.startsAt),"days");i.weekDragged(e,a)},i.weekResized=function(e,n,a){var r=t(e.startsAt),l=t(e.endsAt);"start"===n?r.add(a,"days"):l.add(a,"days"),i.onEventTimesChanged({calendarEvent:e,calendarNewEventStart:r.toDate(),calendarNewEventEnd:l.toDate()})},i.tempTimeChanged=function(e,n){var a=n*i.dayViewSplit;e.tempStartsAt=t(e.startsAt).add(a,"minutes").toDate()}}]).directive("mwlCalendarWeek",function(){return{template:'
',restrict:"E",require:"^mwlCalendar",scope:{events:"=",viewDate:"=",excludedDays:"=",onEventClick:"=",onEventTimesChanged:"=",dayViewStart:"=",dayViewEnd:"=",dayViewSplit:"=",dayViewEventChunkSize:"=",onTimespanClick:"=",onDateRangeSelect:"=",customTemplateUrls:"=?",cellModifier:"=",templateScope:"=",draggableAutoScroll:"="},controller:"MwlCalendarWeekCtrl as vm",link:function(e,t,n,a){e.vm.calendarCtrl=a},bindToController:!0}})},function(e,t,n){"use strict";var a=n(0);a.module("mwl.calendar").controller("MwlCalendarYearCtrl",["$scope","moment","calendarHelper",function(e,t,n){function r(){i.openRowIndex=null,i.openMonthIndex=null,i.cellIsOpen&&i.view&&i.view.forEach(function(e,n){t(i.viewDate).startOf("month").isSame(e.date)&&(i.openMonthIndex=n,i.openRowIndex=Math.floor(n/4))})}var i=this;i.openMonthIndex=null,e.$on("calendar.refreshView",function(){i.view=n.getYearView(i.events,i.viewDate,i.cellModifier),i.cellAutoOpenDisabled?r():!i.cellAutoOpenDisabled&&i.cellIsOpen&&null===i.openMonthIndex&&(i.openMonthIndex=null,i.view.forEach(function(e){t(i.viewDate).startOf("month").isSame(e.date)&&i.monthClicked(e,!0)}))}),i.monthClicked=function(e,t,n){if((t||(i.onTimespanClick({calendarDate:e.date.toDate(),calendarCell:e,$event:n}),!n||!n.defaultPrevented))&&!i.cellAutoOpenDisabled){i.openRowIndex=null;var a=i.view.indexOf(e);a===i.openMonthIndex?(i.openMonthIndex=null,i.cellIsOpen=!1):(i.openMonthIndex=a,i.openRowIndex=Math.floor(a/4),i.cellIsOpen=!0)}},i.handleEventDrop=function(e,a){var r=t(e.startsAt).year(t(a).year()).month(t(a).month()),l=n.adjustEndDateFromStartDiff(e.startsAt,r,e.endsAt);i.onEventTimesChanged({calendarEvent:e,calendarDate:a,calendarNewEventStart:r.toDate(),calendarNewEventEnd:l?l.toDate():null})},i.$onInit=function(){i.cellAutoOpenDisabled&&e.$watchGroup(["vm.cellIsOpen","vm.viewDate"],r)},a.version.minor<5&&i.$onInit()}]).directive("mwlCalendarYear",function(){return{template:'
',restrict:"E",require:"^mwlCalendar",scope:{events:"=",viewDate:"=",onEventClick:"=",onEventTimesChanged:"=",cellIsOpen:"=",cellAutoOpenDisabled:"=",onTimespanClick:"=",cellModifier:"=",slideBoxDisabled:"=",customTemplateUrls:"=?",templateScope:"="},controller:"MwlCalendarYearCtrl as vm",link:function(e,t,n,a){e.vm.calendarCtrl=a},bindToController:!0}})},function(e,t,n){"use strict";n(0).module("mwl.calendar").controller("MwlCollapseFallbackCtrl",["$scope","$attrs","$element",function(e,t,n){e.$watch(t.mwlCollapseFallback,function(e){e?n.addClass("ng-hide"):n.removeClass("ng-hide")})}]).directive("mwlCollapseFallback",["$injector",function(e){return e.has("uibCollapseDirective")?{}:{restrict:"A",controller:"MwlCollapseFallbackCtrl"}}])},function(e,t,n){"use strict";var a=n(0);a.module("mwl.calendar").controller("MwlDateModifierCtrl",["$element","$attrs","$scope","moment",function(e,t,n,r){function i(){if(a.isDefined(t.setToToday))l.date=new Date;else if(a.isDefined(t.increment)){if(l.date=r(l.date).add(1,l.increment),l.excludedDays&&l.increment.indexOf("day")>-1)for(;l.excludedDays.indexOf(l.date.day())>-1;)l.date.add(1,l.increment);l.date=l.date.toDate()}else if(a.isDefined(t.decrement)){if(l.date=r(l.date).subtract(1,l.decrement),l.excludedDays&&l.decrement.indexOf("day")>-1)for(;l.excludedDays.indexOf(l.date.day())>-1;)l.date.subtract(1,l.decrement);l.date=l.date.toDate()}n.$apply()}var l=this;e.bind("click",i),n.$on("$destroy",function(){e.unbind("click",i)})}]).directive("mwlDateModifier",function(){return{restrict:"A",controller:"MwlDateModifierCtrl as vm",scope:{date:"=",increment:"=",decrement:"=",excludedDays:"=?"},bindToController:!0}})},function(e,t,n){"use strict";n(0).module("mwl.calendar").controller("MwlDragSelectCtrl",["$scope","$element","$parse","$attrs",function(e,t,n,a){function r(t){return function(a){t&&2!==a.button&&(n(t)(e),e.$apply()),a.preventDefault()}}function i(){t.on("mousedown",o),t.on("mousemove",d),t.on("mouseup",s)}function l(){t.off("mousedown",o),t.off("mousemove",d),t.off("mouseup",s)}var o=r(a.onDragSelectStart),d=r(a.onDragSelectMove),s=r(a.onDragSelectEnd);e.$watch(a.mwlDragSelect,function(e){e?i():l()}),e.$on("$destroy",function(){l()})}]).directive("mwlDragSelect",function(){return{restrict:"A",controller:"MwlDragSelectCtrl"}})},function(e,t,n){"use strict";var a=n(0);a.module("mwl.calendar").controller("MwlDraggableCtrl",["$element","$scope","$window","$parse","$attrs","$timeout","interact",function(e,t,n,r,i,l,o){function d(e,t){return e.css("-ms-transform",t).css("-webkit-transform",t).css("transform",t)}if(o){var s,c;i.snapGrid&&(c=r(i.snapGrid)(t),s={targets:[o.createSnapGrid(c)]});var v=r(i.autoScroll)(t);void 0===v&&(v=!0),o(e[0]).draggable({autoScroll:v,snap:s,onstart:function(e){a.element(e.target).addClass("dragging-active"),e.target.dropData=r(i.dropData)(t),e.target.style.pointerEvents="none",i.onDragStart&&(r(i.onDragStart)(t),t.$apply())},onmove:function(e){var l=a.element(e.target),o=(parseFloat(l.attr("data-x"))||0)+(e.dx||0),s=(parseFloat(l.attr("data-y"))||0)+(e.dy||0);switch(r(i.axis)(t)){case"x":s=0;break;case"y":o=0}"static"===n.getComputedStyle(l[0]).position&&l.css("position","relative"),d(l,"translate("+o+"px, "+s+"px)").css("z-index",50).attr("data-x",o).attr("data-y",s),i.onDrag&&(r(i.onDrag)(t,{x:o,y:s}),t.$apply())},onend:function(e){var n=a.element(e.target),o=n.attr("data-x"),s=n.attr("data-y");e.target.style.pointerEvents="auto",i.onDragEnd&&(r(i.onDragEnd)(t,{x:o,y:s}),t.$apply()),l(function(){d(n,"").css("z-index","auto").removeAttr("data-x").removeAttr("data-y").removeClass("dragging-active")})}}),t.$watch(i.mwlDraggable,function(t){o(e[0]).draggable({enabled:t})}),t.$on("$destroy",function(){o(e[0]).unset()})}}]).directive("mwlDraggable",function(){return{restrict:"A",controller:"MwlDraggableCtrl"}})},function(e,t,n){"use strict";var a=n(0);a.module("mwl.calendar").controller("MwlDroppableCtrl",["$element","$scope","$parse","$attrs","interact",function(e,t,n,r,i){if(i){var l=r.dropActiveClass||"drop-active",o=r.dropOverlap||"pointer";i(e[0]).dropzone({ondragenter:function(e){a.element(e.target).addClass(l)},ondragleave:function(e){a.element(e.target).removeClass(l)},ondropdeactivate:function(e){a.element(e.target).removeClass(l)},ondrop:function(e){e.relatedTarget.dropData&&(n(r.onDrop)(t,{dropData:e.relatedTarget.dropData}),t.$apply())},overlap:o}),t.$on("$destroy",function(){i(e[0]).unset()})}}]).directive("mwlDroppable",function(){return{restrict:"A",controller:"MwlDroppableCtrl"}})},function(e,t,n){"use strict";var a=n(0);a.module("mwl.calendar").controller("MwlDynamicDirectiveTemplateCtrl",["$compile","$scope","$attrs","$element","$templateCache","$log","calendarConfig",function(e,t,n,r,i,l,o){t.$watch(n.overrides,function(d){var s=o.templates[n.name];d&&a.isObject(d)&&d[n.name]&&(i.get(d[n.name])?s=d[n.name]:l.warn("Bootstrap Calendar","The custom template for "+d[n.name]+' was not found in the template cache. Please ensure it is pre-loaded via a script tag + + + + +
+
+
+ + + + +
+
+
+
+
{{patientInfo.patientfullname}} ({{patientInfo.categoryname}})
+
+ +
+
+ +
+ +
+
+
+
+ + +
+ + \ No newline at end of file diff --git a/plugins/nursing/ward/assets/controllers/nursing-patient-discharge-controller.js b/plugins/nursing/ward/assets/controllers/nursing-patient-discharge-controller.js index 6269b15..20b323b 100644 --- a/plugins/nursing/ward/assets/controllers/nursing-patient-discharge-controller.js +++ b/plugins/nursing/ward/assets/controllers/nursing-patient-discharge-controller.js @@ -14,7 +14,6 @@ angular.module("EmmetBlue") }; function dtAction(data, full, meta, type){ - console.log(data); observationButtonAction = "manage('process',"+data.PatientAdmissionID+")"; viewButtonAction = "manage('view',"+data.PatientAdmissionID+")"; redirectButtonAction = "manage('gotoWorkspace',"+data.PatientAdmissionID+")"; @@ -41,11 +40,38 @@ angular.module("EmmetBlue") $scope.dtInstance = {}; $scope.dtOptions = utils.DT.optionsBuilder - .fromFnPromise(function(){ - return utils.serverRequest('/consultancy/patient-admission/view-discharged-patients?resourceId='+$scope.currentWard, 'GET'); + .newOptions() + .withFnServerData(function(source, data, callback, settings){ + var draw = data[0].value; + var order = data[2].value; + var start = data[3].value; + var length = data[4].value; + + var url = '/consultancy/patient-admission/view-discharged-patients?resourceId='+$scope.currentWard+'&paginate&from='+start+'&size='+length; + if (typeof data[5] !== "undefined" && data[5].value.value != ""){ + url += "&keywordsearch="+data[5].value.value; + } + + var discharges = utils.serverRequest(url, 'GET'); + discharges.then(function(response){ + var records = { + data: response.data, + draw: draw, + recordsTotal: response.total, + recordsFiltered: response.filtered + }; + + callback(records); + }, function(error){ + utils.errorHandler(error); + }); }) + .withDataProp('data') + .withOption('processing', true) + .withOption('serverSide', true) + .withOption('paging', true) .withPaginationType('full_numbers') - .withDisplayLength(50) + .withDisplayLength(10) .withOption('createdRow', function(row, data, dataIndex){ utils.compile(angular.element(row).contents())($scope); }) @@ -153,6 +179,7 @@ angular.module("EmmetBlue") $scope.dtInstance.reloadData(); } + $scope.manage = function(value, id){ switch(value) { @@ -247,7 +274,7 @@ angular.module("EmmetBlue") $scope.forwardEnabled = true; }) - $scope.$watch(function(){ return $scope.currentWard; }, function(nv){ + $scope.$watch(function(){ return $scope.currentWard; }, function(ov, nv){ if (typeof nv != "undefined"){ reloadTable(); } diff --git a/plugins/nursing/ward/assets/controllers/nursing-patient-workspace-controller.js b/plugins/nursing/ward/assets/controllers/nursing-patient-workspace-controller.js index 867cb6b..9cf4766 100644 --- a/plugins/nursing/ward/assets/controllers/nursing-patient-workspace-controller.js +++ b/plugins/nursing/ward/assets/controllers/nursing-patient-workspace-controller.js @@ -245,6 +245,11 @@ function nursingPatientWorkspaceController($rootScope, $scope, utils){ staffId: staffID }; + $rootScope.$broadcast("examinationObservationConducted", { + result: $scope.data.observation, + name: $scope.data.observationTypeName + }); + utils.serverRequest("/nursing/observation/new", "POST", $scope.data).then(function(response){ utils.notify("Operation Completed Successfully", "Observation Published Successfuly", "success"); $scope.observationResult = {}; diff --git a/plugins/pharmacy/assets/controllers.js b/plugins/pharmacy/assets/controllers.js index 2e7dc7f..de3aeac 100644 --- a/plugins/pharmacy/assets/controllers.js +++ b/plugins/pharmacy/assets/controllers.js @@ -5,12 +5,14 @@ head.load(controllersLocation+"store-inventory-controller.js"); head.load(controllersLocation+"dispensation-controller.js"); head.load(controllersLocation+"reports-controller.js"); head.load(controllersLocation+"transfer-reports-controller.js"); +head.load(controllersLocation+"purchase-invoice-controller.js"); head.load(controllersLocation+"dashboard-controller.js"); head.load(controllersLocation+"new-store-restock-controller.js"); head.load(controllersLocation+"store-transfer-controller.js"); head.load(controllersLocation+"inventory-controller.js"); head.load(controllersLocation+"dashboard-store-inventory-controller.js"); head.load(controllersLocation+"store-management-segment-controller.js"); +head.load(controllersLocation+"statistics-dashboard-controller.js"); head.load(controllersLocation+"setting/dispensory-store-link-controller.js"); head.load(controllersLocation+"setting/dispensories-controller.js"); \ No newline at end of file diff --git a/plugins/pharmacy/assets/controllers/dispensation-controller.js b/plugins/pharmacy/assets/controllers/dispensation-controller.js index 708c5c8..4aa618e 100644 --- a/plugins/pharmacy/assets/controllers/dispensation-controller.js +++ b/plugins/pharmacy/assets/controllers/dispensation-controller.js @@ -515,7 +515,8 @@ angular.module("EmmetBlue") resourceId: $scope.currentRequestID, status: 1, staff: utils.userSession.getID(), - itemStatus: [] + itemStatus: [], + labels:[] }; angular.forEach($scope.selectedItems, function(value, key){ @@ -525,12 +526,45 @@ angular.module("EmmetBlue") } }); - utils.serverRequest('/pharmacy/pharmacy-request/close', 'PUT', data).then(function(response){ - $("#ack_view_modal").modal("hide"); - $scope.reloadDispensationsTable(); - }, function(error){ - utils.errorHandler(error); - }); + var containsUnscanItems = false; + for (var i = 0; i < $scope.currrentDispensedItems.length; i++){ + if (typeof $scope.currrentDispensedItems[i].label == "undefined"){ + if (data.status == -2 && data.itemStatus.indexOf($scope.currrentDispensedItems[i].DispensedItemsID) != -1){ + continue; + } + else { + containsUnscanItems = true; + break; + } + } else { + for (var k = $scope.currrentDispensedItems[i].label.length - 1; k >= 0; k--) { + var _label = $scope.currrentDispensedItems[i].label[k]; + data.labels.push({ + LabelID: _label.LabelID, + LabelUUID: _label.LabelUUID, + ItemDispensedUnit: _label.ItemDispensedUnit + }); + } + + if (data.labels.length == 0){ + containsUnscanItems = true; + } + } + } + + if (containsUnscanItems){ + utils.notify("Some items not scanned"); + $scope.initScanner(); + } + else { + utils.serverRequest('/pharmacy/pharmacy-request/close', 'PUT', data).then(function(response){ + $("#ack_view_modal").modal("hide"); + $scope.reloadDispensationsTable(); + }, function(error){ + utils.errorHandler(error); + }); + } + break; } case "retract":{ @@ -616,6 +650,9 @@ angular.module("EmmetBlue") utils.serverRequest("/pharmacy/pharmacy-request/view?resourceId="+$scope.currentRequestID, "GET") .then(function(response){ $scope._currentRequest = response; + if (response.Acknowledged == -1 || response.Acknowledged == -2){ + $scope.initScanner(); + } }, function(error){ utils.errorHandler(eror); }); @@ -697,4 +734,119 @@ angular.module("EmmetBlue") $scope.exists = function(p, ind){ return typeof p[ind] != "undefined" } + + $scope.processLabelScan = function(data){ + var uuid = data; + + var req = utils.serverRequest("/pharmacy/inventory-label/get-label-details?uuid="+uuid, "GET"); + req.then(function(response){ + var item = response.ItemID; + var found = false; + if (response.AvailableQuantity > 0){ + for (var i = 0; i < $scope.currrentDispensedItems.length; i++){ + if ($scope.currrentDispensedItems[i].ItemID == item){ + var reqQty = parseInt($scope.currrentDispensedItems[i].DispensedQuantity); + + if (typeof $scope.currrentDispensedItems[i]["label"] == "undefined"){ + $scope.currrentDispensedItems[i]["label"] = []; + if (reqQty > response.AvailableQuantity){ + reqQty = response.AvailableQuantity + } + } + else { + var disQty = 0; + for (var k = $scope.currrentDispensedItems[i]["label"].length - 1; k >= 0; k--) { + disQty += $scope.currrentDispensedItems[i]["label"][k].ItemDispensedUnit + } + + if (reqQty > disQty){ + reqQty = reqQty - disQty; + } + else { + reqQty = 0; + } + } + + response.ItemDispensedUnit = reqQty; + $scope.currrentDispensedItems[i]["label"].push(response); + found = true; + break; + } + }; + } + + if (found){ + utils.notify("Scan completed successfully", "", "success"); + } + else { + if (response.AvailableQuantity <= 0){ + utils.notify("Invalid Scan Detected", "Scanned Item Has Exceeded Its Max Threshold", "warning"); + } + else { + utils.notify("Invalid Scan Detected", "Scanned Item Not In Dispensation List Or Is Unrecognized", "error"); + } + } + + }, function(error){ + utils.errorHandler(error); + }); + } + + $scope.removeLabel = function(index, parent){ + $scope.currrentDispensedItems[parent].label.splice(index, 1); + $scope.initScanner(); + } + + $scope.initLabelScanner = function(){ + var socket = utils.newWebSocket(); + + socket.onopen = function(event){ + var data = {"to":"0", "content":utils.userSession.getID()}; + socket.send(JSON.stringify(data)); + } + + socket.onmessage = function(data){ + data = (JSON.parse(data.data)); + switch(data.type){ + case "broadcast":{ + var label = data.content; + if (label.to == utils.userSession.getID()){ + var content = JSON.parse(label.content); + + $scope.processLabelScan(content); + } + else { + console.log("Intercepted scan meant for a different device"); + } + break; + } + + default:{ + console.log("socket message intercepted"); + } + } + } + } + + $scope.initScanner = function(){ + $("#scanned-code").focus(); + $('#scanned-code').on({ + keypress: function() { typed_into = true; }, + change: function() { + if (typed_into) { + $scope.processLabelScan($(this).val()); + typed_into = false; + $(this).val(""); + } + } + }); + } + + $scope.isExpired = function(date){ + return new Date() >= new Date(date); + } + + $scope.toDateString = function(date){ + return (new Date(date)).toLocaleDateString(); + } }); \ No newline at end of file diff --git a/plugins/pharmacy/assets/controllers/inventory-controller.js b/plugins/pharmacy/assets/controllers/inventory-controller.js index 76c0a29..7884eb0 100644 --- a/plugins/pharmacy/assets/controllers/inventory-controller.js +++ b/plugins/pharmacy/assets/controllers/inventory-controller.js @@ -88,9 +88,9 @@ angular.module("EmmetBlue") }), utils.DT.columnBuilder.newColumn('_meta.totalQuantity').withTitle("Total Quantity Available"), utils.DT.columnBuilder.newColumn(null).withTitle("Manage").renderWith(function(data, type, full){ - var editButtonAction = "manageStore('edit', "+data.ItemID+")"; - var deleteButtonAction = "manageStore('delete', "+data.ItemID+")"; - var inventoryButtonAction = "manageStore('tags', "+data.ItemID+")"; + var editButtonAction = "manageStore('edit', "+data.ItemID+", "+data.Item+")"; + var deleteButtonAction = "manageStore('delete', "+data.ItemID+", "+data.Item+")"; + var inventoryButtonAction = "manageStore('labels', "+data.ItemID+", "+data.Item+")"; var tags = JSON.stringify(data.Tags); @@ -100,7 +100,7 @@ angular.module("EmmetBlue") ""+ ""+ @@ -203,7 +203,7 @@ angular.module("EmmetBlue") }) } - $scope.manageStore = function(manageGroup, id){ + $scope.manageStore = function(manageGroup, id, item=""){ switch(manageGroup.toLowerCase()){ case "edit":{ $scope.tempHolder = {}; @@ -217,11 +217,23 @@ angular.module("EmmetBlue") break; } case "delete":{ - functions.manageAccount.changeAccountType(id); break; } - case "tags":{ - functions.manageAccount.toggleAccountStatus(id); + case "labels":{ + $scope.newLabelHolder = {}; + $scope.newLabelHolder.item = id; + $scope.newInvLabel = { + data: { + dispensableInUnits: false, + totalUnit: 1 + } + }; + + $scope.searchLabel = {}; + $scope.printableLabels = []; + + $("#inventory_label_manager").modal("show"); + // functions.manageAccount.toggleAccountStatus(id); break; } } @@ -271,4 +283,101 @@ angular.module("EmmetBlue") utils.errorHandler(error); }) } + + $scope.generateNewLabels = function(){ + $scope.newInvLabel.item = $scope.newLabelHolder.item; + $scope.newInvLabel.staff = utils.userSession.getID(); + $scope.newInvLabel.data.manufacturedDate = (new Date($scope.newInvLabel.data.manufacturedDate)).toLocaleDateString(); + $scope.newInvLabel.data.expiryDate = (new Date($scope.newInvLabel.data.expiryDate)).toLocaleDateString(); + + var title = "Please Read This Carefully"; + var text = "Do you really want to generate "+$scope.newInvLabel.labelQty+" labels with the following data?"+ + "\nBatch Number: "+ $scope.newInvLabel.data.batchNumber+ + "\nSerial Number: "+ $scope.newInvLabel.data.serialNumber+ + "\nExpiry Date: "+ $scope.newInvLabel.data.expiryDate+ + "\nManufactured Date: "+ $scope.newInvLabel.data.manufacturedDate+ + "\nItem Dispensable In Units: "+ $scope.newInvLabel.data.dispensableInUnits+ + "\nTotal Units Per Item: "+ $scope.newInvLabel.data.totalUnit+ + "\n\nLABEL QUANTITY: "+ $scope.newInvLabel.labelQty; + var close = true; + var type = "info"; + var btnText = "Yes, continue"; + + var callback = function(){ + var req = utils.serverRequest("/pharmacy/inventory-label/new-label", "POST", $scope.newInvLabel); + req.then(function(response){ + utils.notify("Operation Successful", "Labels generated successfully", "success"); + + $scope.newInvLabel = { + data: { + dispensableInUnits: false, + totalUnit: 1 + } + }; + }, function(error){ + utils.errorHandler(error); + }); + } + + utils.confirm(title, text, close, callback, type, btnText); + } + + $scope.$watch("newInvLabel.data.dispensableInUnits", function(newVal){ + if (!newVal){ + $("#newLabelTotalUnits").attr("disabled", "disabled"); + $("#newLabelTotalUnits").val(1); + $scope.newInvLabel.data.totalUnit = 1; + } + else { + $("#newLabelTotalUnits").removeAttr("disabled"); + $("#newLabelTotalUnits").val(null); + $scope.newInvLabel.data.totalUnit = null; + } + }) + + + $scope.searchLabels = function(){ + var item = $scope.newLabelHolder.item; + var mfDate = (new Date($scope.searchLabel.mfDate)).toLocaleDateString(); + var exDate = (new Date($scope.searchLabel.expDate)).toLocaleDateString(); + + var url = "/pharmacy/inventory-label/get-printable-labels?resourceId="+item+"&manufacturedDate="+mfDate+"&expiryDate="+exDate; + if (typeof $scope.searchLabel.btchNo != "undefined"){ + url += "&batchNumber="+$scope.searchLabel.btchNo; + } + + var req = utils.serverRequest(url, "GET"); + req.then(function(response){ + $scope.printableLabels = response; + $scope.printLabelQuantity = response.length; + }, function(error){ + utils.errorHandler(error); + }) + } + + $scope.printLabels = function(qty, show=false){ + if (show){ + $("#print_inventory_labels").modal("show"); + $("#qr_labels > .row").html(""); + } + var generatedLabels = []; + for (var i = 0; i < qty; i++){ + var label = $scope.printableLabels[i]; + // $scope.printableGeneratedLabels.push(label); + var img = $("", {id: "barCode-"+i, class: "ins-page-brk"}); + $("#qr_labels > .row").append(img).append("

"); + + img.JsBarcode(label.LabelID, { + fontOptions: "bold", + width: 3 + }); + } + + // $scope.printableGeneratedLabels = generatedLabels; + + JsBarcode("#barCode", $scope.printableLabels[0].LabelID, { + fontOptions: "bold", + width: 3 + }); + } }); \ No newline at end of file diff --git a/plugins/pharmacy/assets/controllers/purchase-invoice-controller.js b/plugins/pharmacy/assets/controllers/purchase-invoice-controller.js new file mode 100644 index 0000000..b4ba6b4 --- /dev/null +++ b/plugins/pharmacy/assets/controllers/purchase-invoice-controller.js @@ -0,0 +1,402 @@ +angular.module("EmmetBlue") + +.controller('pharmacyPurchaseInvoiceController', function($scope, utils, patientEventLogger, $rootScope){ + $scope.loadImage = utils.loadImage; + $scope.patient = {}; + + $scope.getDateRange = function(selector){ + var today = new Date(); + switch(selector){ + case "today":{ + return today.toLocaleDateString() + " - " + today.toLocaleDateString(); + } + case "yesterday":{ + var yesterday = new Date(new Date(new Date()).setDate(new Date().getDate() - 1)).toLocaleDateString(); + return yesterday + " - " + yesterday; + break; + } + case "week":{ + var d = new Date(today); + var day = d.getDay(), diff = d.getDate() - day + (day == 0 ? -6 : 1); + + return new Date(d.setDate(diff)).toLocaleDateString() + " - " + today.toLocaleDateString(); + break; + } + case "month":{ + var year = today.getFullYear(); + var month = today.getMonth() + 1; + + return month+'/1/'+year + ' - ' + today.toLocaleDateString(); + break; + } + } + } + + $scope.requestFilter = { + type: 'nil', + description: 'Current Months\'s Invoices', + value: $scope.getDateRange("month") + } + + $scope.createdFilters = []; + $scope.createdFilters.push($scope.requestFilter); + + $scope.dateRange = $scope.getDateRange("month"); + + $scope.$watch("dateRange", function(nv){ + var dates = nv.split(" - "); + if (dates[0] == dates[1]){ + $scope.requestFilter = { + type: "nil", + description: "All transfers on "+(new Date(dates[0])).toDateString(), + value: nv + }; + } + else { + $scope.requestFilter = { + type: "nil", + description: "Date Range Between "+(new Date(dates[0])).toDateString()+" and "+(new Date(dates[1])).toDateString(), + value: nv + }; + } + + $scope.reloadLogTable(true); + }) + + $("option[status='disabled']").attr("disabled", "disabled"); + + $scope.dtInstance = {}; + $scope.dtOptions = utils.DT.optionsBuilder + .newOptions() + .withFnServerData(function(source, data, callback, settings){ + var filter = $scope.createdFilters; + + var draw = data[0].value; + var order = data[2].value; + var start = data[3].value; + var length = data[4].value; + + var dates = filter[0].value.split(" - "); + + // filter.splice(0, 1); + + var datum = { + "startdate": dates[0], + "enddate": dates[1], + "resourceId":0, + "paginate":true, + "from":start, + "size":length, + "filtertype":"filtercombo", + "query":[] + } + + if (typeof data[5] !== "undefined" && data[5].value.value != ""){ + datum.keywordsearch = data[5].value.value; + } + + for (var i = filter.length - 1; i >= 1; i--) { + var _filter = filter[i]; + if (_filter.use){ + datum.query.push({ + type:_filter.type, + value:_filter.value + }); + } + } + + var url = '/pharmacy/purchase-log/view'; + + var transfers = utils.serverRequest(url, 'POST', datum); + transfers.then(function(response){ + var records = { + data: response.data, + draw: draw, + recordsTotal: response.total, + recordsFiltered: response.filtered + }; + callback(records); + }, function(error){ + utils.errorHandler(error); + }); + }) + .withDataProp('data') + .withOption('processing', true) + .withOption('serverSide', true) + .withOption('paging', true) + .withPaginationType('full_numbers') + .withDisplayLength(10) + .withOption('createdRow', function(row, data, dataIndex){ + utils.compile(angular.element(row).contents())($scope); + }) + .withOption('headerCallback', function(header) { + if (!$scope.headerCompiled) { + $scope.headerCompiled = true; + utils.compile(angular.element(header).contents())($scope); + } + }) + .withButtons([ + { + text: ' New Invoice Log', + key: { + key: 'n', + ctrlKey: false, + altKey: true + }, + action: function(){ + $("#new_purchase_log").modal("show"); + } + }, + { + extend: 'print', + text: ' Print this data page', + key: { + key: 'p', + ctrlKey: false, + altKey: true + } + }, + { + extend: 'copy', + text: ' Copy this data', + key: { + key: 'c', + ctrlKey: false, + altKey: true + } + } + ]); + + $scope.dtColumns = [ + utils.DT.columnBuilder.newColumn(null).withTitle("Invoice No.").renderWith(function(data){ + if (data.InvoiceNumber == null){ + data.InvoiceNumber = "N/A"; + } + return ""+data.InvoiceNumber+"" + }), + utils.DT.columnBuilder.newColumn(null).withTitle("Item").renderWith(function(data){ + return ""+data.BillingTypeItemName+ + "
Brand: "+data.ItemBrand; + }), + utils.DT.columnBuilder.newColumn(null).withTitle("Vendor").renderWith(function(data){ + if (data.VendorAddress == null){ + data.VendorAddress = ""; + } + + return ""+data.VendorName+ + "
"+data.VendorAddress; + }), + utils.DT.columnBuilder.newColumn(null).withTitle("Cost Price").renderWith(function(data){ + return ""+""+data.ItemCostPrice+""; + }), + utils.DT.columnBuilder.newColumn(null).withTitle("Purchased Quantity").renderWith(function(data){ + return ""+data.ItemQuantity+""; + }), + utils.DT.columnBuilder.newColumn(null).withTitle("Purchased By").renderWith(function(data){ + return ""+data.ItemBuyee+""; + }), + utils.DT.columnBuilder.newColumn(null).withTitle("Purchased Date").renderWith(function(data){ + return (new Date(data.ItemPurchaseDate)).toDateString(); + }), + utils.DT.columnBuilder.newColumn(null).withTitle("Logged By").renderWith(function(data, full, meta){ + var image = $scope.loadImage(data.staffInfo.StaffPicture); + var html = ""+ + "
"+ + ""+ + "
"+ + "
"+ + ""+ + "
"+ + data.staffInfo.Role+ + "
"+ + "
"+ + ""; + + return html; + }), + utils.DT.columnBuilder.newColumn(null).withTitle("Date Logged").renderWith(function(data, a, b){ + return (new Date(data.DateCreated)).toDateString()+"
"+(new Date(data.DateCreated)).toLocaleTimeString(); + }) + ]; + + $scope.reloadLogTable = function(applyToFirstIndex=false){ + if (typeof $scope.requestFilter.type !== "undefined"){ + var data = { + description: $scope.requestFilter.description, + value: $scope.requestFilter.value, + type: $scope.requestFilter.type, + use: true + }; + + if (applyToFirstIndex){ + $scope.createdFilters[0] = data; + } + else{ + $scope.createdFilters.push(data); + } + $scope.requestFilter = {}; + } + + rerenderTable(); + } + + function rerenderTable(){ + if (angular.isFunction($scope.dtInstance.rerender)){ + $scope.dtInstance.rerender(); + } + } + + $scope.stores = {}; + var loadStores = function(){ + var request = utils.serverRequest("/pharmacy/store/view", "GET"); + request.then(function(result){ + $scope.stores = result; + }, function(error){ + utils.errorHandler(error); + }) + }(); + + $scope.billingTypes = {}; + + var loadBillingTypes = function(){ + var request = utils.serverRequest("/accounts-biller/billing-type/view", "GET"); + request.then(function(result){ + $scope.billingTypes = result; + }, function(error){ + utils.errorHandler(error); + }) + }(); + + $scope.patientTypes = {}; + + $scope.loadPatientTypes = function(){ + if (typeof (utils.userSession.getID()) !== "undefined"){ + var requestData = utils.serverRequest("/patients/patient-type-category/view", "GET"); + requestData.then(function(response){ + $scope.patientTypes = response; + }, function(responseObject){ + utils.errorHandler(responseObject); + }); + } + } + + $scope.loadPatientTypes(); + + // loadStores(); + + $scope.activateFilter = function(){ + var selector = $scope.filterSelector; + switch(selector.type){ + case "dateRange":{ + $scope.requestFilter.type = "date"; + var value = selector.value.split(" - "); + $scope.requestFilter.value= selector.value; + $scope.requestFilter.description = "Date Ranges Between: "+ new Date(value[0]).toDateString()+" And "+ new Date(value[1]).toDateString(); + $scope.reloadLogTable(true); + break; + } + case "staff":{ + $scope.requestFilter.type = "staff"; + $scope.requestFilter.value= selector.value; + $scope.requestFilter.description = "Staff Search: '"+selector.value+"'"; + + var req = utils.serverRequest("/human-resources/staff/get-staff-id?name="+selector.value, "GET"); + req.then(function(result){ + if (typeof result["StaffID"] !== "undefined"){ + $scope.requestFilter.value = result["StaffID"]; + $scope.reloadLogTable(); + } + else { + utils.notify("Invalid Staff Username", "Please enter a valid username to continue", "warning"); + } + }, function(error){ + utils.errorHandler(error); + }) + break; + } + case "invoice number":{ + $scope.requestFilter.type = "invoicenumber"; + var value = selector.value; + $scope.requestFilter.value = value; + $scope.requestFilter.description = "Invoice Number: '"+value+"'"; + $scope.reloadLogTable(); + break; + } + case "item code":{ + $scope.requestFilter.type = "itemcode"; + $scope.requestFilter.value= selector.value; + $scope.requestFilter.description = "Item Code: '"+selector.value+"'"; + $scope.reloadLogTable(); + break; + } + default:{ + $scope.requestFilter.type = "date"; + var value = selector.type.split(""); + $scope.requestFilter.value = value[1]; + $scope.requestFilter.description = value[0]; + $scope.reloadLogTable(); + } + } + } + + function loadInventoryItems(){ + var request = utils.serverRequest("/pharmacy/store-inventory/view", "GET"); + + request.then(function(response){ + $scope.inventoryItems = response; + }, function(error){ + utils.errorHandler(error); + }); + } + + loadInventoryItems(); + + function loadVendors(){ + var request = utils.serverRequest("/financial-accounts/corporate-vendor/view", "GET"); + + request.then(function(response){ + $scope.corporateVendors = response; + }, function(error){ + utils.errorHandler(error); + }); + } + + loadVendors(); + + $scope.listItem = {}; + $scope.newItem = {}; + + $scope.newItem.items = []; + + $scope.addItemToInvoice = function(){ + var item = $scope.listItem; + selector = item.itemSelector.split("|"); + item.item = selector[1]; + item._item = selector[0]; + $scope.newItem.items.push(item); + $scope.listItem = {}; + } + + $scope.removeItemFromInvoice = function(index){ + $scope.newItem.items.splice(index, 1); + } + + $scope.saveInvoice = function(){ + var data = $scope.newItem; + data.staff = utils.userSession.getID(); + + var request = utils.serverRequest("/pharmacy/purchase-log/new", "POST", data); + request.then(function(response){ + if (response){ + utils.notify("Operation Successful", "Invoice has been logged successfully", "success"); + $("#new_purchase_log").modal("hide"); + $scope.reloadLogTable(); + } + else { + utils.notify("An error occurred", "Please try again", "error"); + } + }, function(error){ + utils.errorHandler(error); + }); + } +}); \ No newline at end of file diff --git a/plugins/pharmacy/assets/controllers/reports-controller.js b/plugins/pharmacy/assets/controllers/reports-controller.js index 7c2e54c..ce0c44d 100644 --- a/plugins/pharmacy/assets/controllers/reports-controller.js +++ b/plugins/pharmacy/assets/controllers/reports-controller.js @@ -84,7 +84,7 @@ angular.module("EmmetBlue") // filter.splice(0, 1); - var data = { + var datum = { "startdate": dates[0], "enddate": dates[1], "resourceId":0, @@ -96,13 +96,13 @@ angular.module("EmmetBlue") } if (typeof data[5] !== "undefined" && data[5].value.value != ""){ - data.keywordsearch = data[5].value.value; + datum.keywordsearch = data[5].value.value; } for (var i = filter.length - 1; i >= 1; i--) { var _filter = filter[i]; if (_filter.use){ - data.query.push({ + datum.query.push({ type:_filter.type, value:_filter.value }); @@ -111,7 +111,7 @@ angular.module("EmmetBlue") var url = '/pharmacy/dispensation/retrieve-dispensed-items-report'; - var dispensations = utils.serverRequest(url, 'POST', data); + var dispensations = utils.serverRequest(url, 'POST', datum); dispensations.then(function(response){ var records = { data: response.data, diff --git a/plugins/pharmacy/assets/controllers/statistics-dashboard-controller.js b/plugins/pharmacy/assets/controllers/statistics-dashboard-controller.js new file mode 100644 index 0000000..d93e74e --- /dev/null +++ b/plugins/pharmacy/assets/controllers/statistics-dashboard-controller.js @@ -0,0 +1,60 @@ +angular.module("EmmetBlue") + +.controller("statisticsDashboardController", function($scope, utils){ + $scope.dtInstance = {}; + $scope.dtOptions = utils.DT.optionsBuilder + .fromFnPromise(function(){ + return utils.serverRequest('/pharmacy/statistics/out-of-stock-items?resourceId='+$scope.storeID, 'GET'); + }) + .withOption('createdRow', function(row, data, dataIndex){ + utils.compile(angular.element(row).contents())($scope); + }) + .withOption('order', [0, 'desc']) + .withOption('headerCallback', function(header) { + if (!$scope.headerCompiled) { + $scope.headerCompiled = true; + utils.compile(angular.element(header).contents())($scope); + } + }) + .withButtons([ + { + extend: 'print', + text: 'Print this data page', + key: { + key: 'p', + ctrlKey: true, + altKey: true + } + }, + { + extend: 'copy', + text: 'Copy this data', + key: { + key: 'c', + ctrlKey: true, + } + } + ]); + + $scope.dtColumns = [ + utils.DT.columnBuilder.newColumn('ItemID').withTitle('Item ID').notSortable(), + utils.DT.columnBuilder.newColumn('BillingTypeItemName').withTitle('Item').notSortable(), + utils.DT.columnBuilder.newColumn('ItemBrand').withTitle('Category').notSortable(), + utils.DT.columnBuilder.newColumn('ItemManufacturer').withTitle('Manufacturer').notSortable() + ]; + + $scope.reloadOSTable = function(){ + $scope.dtInstance.rerender(); + } + + if (typeof utils.storage.inventoryStoreID != "undefined"){ + $scope.storeID = utils.storage.inventoryStoreID; + } + + $scope.$watch(function(){return utils.storage.inventoryStoreID}, function(newValue, oldValue){ + if (typeof newValue !== "undefined"){ + $scope.storeID = newValue; + $scope.reloadOSTable(); + } + }); +}) \ No newline at end of file diff --git a/plugins/pharmacy/assets/controllers/store-transfer-controller.js b/plugins/pharmacy/assets/controllers/store-transfer-controller.js index 42c0347..508f757 100644 --- a/plugins/pharmacy/assets/controllers/store-transfer-controller.js +++ b/plugins/pharmacy/assets/controllers/store-transfer-controller.js @@ -105,7 +105,13 @@ angular.module("EmmetBlue") data.storeId = $scope.storeID; data.receivingStore = $scope.receivingStore; + var data2 = { + store: data.receivingStore, + labels: $scope.globalLabels + } + var req = utils.serverRequest('/pharmacy/store-transfer/new', 'POST', data); + var req2 = utils.serverRequest('/pharmacy/inventory-label/print-labels', 'POST', data2); req.then(function(response){ utils.alert("Inventory Items Transferred", "You have just updated the inventory items database successfully", "success"); @@ -113,6 +119,77 @@ angular.module("EmmetBlue") $rootScope.$broadcast("reloadStats"); }, function(error){ utils.errorHandler(error); + }); + + req2.then(function(response){ + $scope.globalLabels = []; + }, function(error){ + utils.errorHandler(error); + }); + } + + $scope.showLabelManager = function(id, qty){ + $scope.searchLabel = {}; + $scope.searchLabel.item = id; + $scope.searchLabel.qty = qty + + $("#inventory_label_manager").modal("show"); + } + + $scope.searchLabels = function(){ + var item = $scope.searchLabel.item; + var mfDate = (new Date($scope.searchLabel.mfDate)).toLocaleDateString(); + var exDate = (new Date($scope.searchLabel.expDate)).toLocaleDateString(); + + var url = "/pharmacy/inventory-label/get-printable-labels?resourceId="+item+"&manufacturedDate="+mfDate+"&expiryDate="+exDate; + if (typeof $scope.searchLabel.btchNo != "undefined"){ + url += "&batchNumber="+$scope.searchLabel.btchNo; + url += "&count="+$scope.searchLabel.qty + } + + var req = utils.serverRequest(url, "GET"); + req.then(function(response){ + $scope.printableLabels = response; + $scope.printLabelQuantity = response.length; + }, function(error){ + utils.errorHandler(error); }) } + + $scope.printLabels = function(qty, show=false){ + if (show){ + $("#print_inventory_labels").modal("show"); + $("#qr_labels > .row").html(""); + } + var generatedLabels = []; + for (var i = 0; i < qty; i++){ + var label = $scope.printableLabels[i]; + // $scope.printableGeneratedLabels.push(label); + var img = $("", {id: "barCode-"+i, class: "ins-page-brk"}); + $("#qr_labels > .row").append(img).append("

"); + + img.JsBarcode(label.LabelID, { + fontOptions: "bold", + width: 3 + }); + } + + // $scope.printableGeneratedLabels = generatedLabels; + + JsBarcode("#barCode", $scope.printableLabels[0].LabelID, { + fontOptions: "bold", + width: 3 + }); + } + + $scope.globalLabels = []; + + $scope.storePrintedLabels = function(){ + for (var i = $scope.printableLabels.length - 1; i >= 0; i--) { + $scope.globalLabels.push($scope.printableLabels[i].LabelID); + } + + $("#inventory_label_manager").modal("hide"); + $("#print_inventory_labels").modal("hide"); + } }) \ No newline at end of file diff --git a/plugins/pharmacy/assets/controllers/transfer-reports-controller.js b/plugins/pharmacy/assets/controllers/transfer-reports-controller.js index a9cb1c9..798ff33 100644 --- a/plugins/pharmacy/assets/controllers/transfer-reports-controller.js +++ b/plugins/pharmacy/assets/controllers/transfer-reports-controller.js @@ -84,7 +84,7 @@ angular.module("EmmetBlue") // filter.splice(0, 1); - var data = { + var datum = { "startdate": dates[0], "enddate": dates[1], "resourceId":0, @@ -96,13 +96,13 @@ angular.module("EmmetBlue") } if (typeof data[5] !== "undefined" && data[5].value.value != ""){ - data.keywordsearch = data[5].value.value; + datum.keywordsearch = data[5].value.value; } for (var i = filter.length - 1; i >= 1; i--) { var _filter = filter[i]; if (_filter.use){ - data.query.push({ + datum.query.push({ type:_filter.type, value:_filter.value }); @@ -111,7 +111,7 @@ angular.module("EmmetBlue") var url = '/pharmacy/store-transfer/view'; - var transfers = utils.serverRequest(url, 'POST', data); + var transfers = utils.serverRequest(url, 'POST', datum); transfers.then(function(response){ var records = { data: response.data, diff --git a/plugins/pharmacy/assets/includes/dispensory.html b/plugins/pharmacy/assets/includes/dispensory.html index be9705c..be5d8fe 100644 --- a/plugins/pharmacy/assets/includes/dispensory.html +++ b/plugins/pharmacy/assets/includes/dispensory.html @@ -94,7 +94,7 @@ \ No newline at end of file diff --git a/plugins/pharmacy/assets/includes/store-transfer.html b/plugins/pharmacy/assets/includes/store-transfer.html index e6f2ccf..5ba3fd5 100644 --- a/plugins/pharmacy/assets/includes/store-transfer.html +++ b/plugins/pharmacy/assets/includes/store-transfer.html @@ -12,8 +12,8 @@
@@ -32,7 +32,7 @@ S/N Item Name Quantity Left In Stock - Quantity Added + Quantity Added @@ -43,15 +43,93 @@ {{item.itemName}} {{item.quantityBefore}} {{item.quantityAdded}} + Assign Labels remove - + {{globalLabels.length}} labels printed Complete Transfer
+ + + + \ No newline at end of file diff --git a/plugins/pharmacy/inventory-items.html b/plugins/pharmacy/inventory-items.html index 4f6f7b6..5f38eae 100644 --- a/plugins/pharmacy/inventory-items.html +++ b/plugins/pharmacy/inventory-items.html @@ -1,6 +1,19 @@ + +
@@ -158,6 +171,120 @@
+ + +
\ No newline at end of file diff --git a/plugins/pharmacy/purchase-invoices.html b/plugins/pharmacy/purchase-invoices.html new file mode 100644 index 0000000..997f220 --- /dev/null +++ b/plugins/pharmacy/purchase-invoices.html @@ -0,0 +1,183 @@ + + + + + + + + +
+
+
+
Purchase Invoice Log
+
+ + + +
    +
  • + +
  • +
+
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+
+ +
+ +
+
+
+
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/plugins/records/patient/assets/controllers/manage-patients-controller.js b/plugins/records/patient/assets/controllers/manage-patients-controller.js index aa3ce0e..f56b832 100644 --- a/plugins/records/patient/assets/controllers/manage-patients-controller.js +++ b/plugins/records/patient/assets/controllers/manage-patients-controller.js @@ -142,47 +142,10 @@ angular.module("EmmetBlue") } }; - // $scope.dtOptions = utils.DT.optionsBuilder.fromFnPromise(function(){ - // var request = utils.serverRequest("/patients/patient/view", "GET"); - - // return request; - // }) - // .withPaginationType('full_numbers') - // .withDisplayLength(10) - // .withFixedHeader() - // .withOption('createdRow', function(row, data, dataIndex){ - // utils.compile(angular.element(row).contents())($scope); - // }); - - // $scope.dtColumns = [ - // utils.DT.columnBuilder.newColumn("PatientUUID").withTitle("Patient Number").notVisible(), - // utils.DT.columnBuilder.newColumn("PatientFullName").withTitle("Name"), - // utils.DT.columnBuilder.newColumn(null).withTitle("Action").renderWith(actionMarkup).notSortable() - // ] - - // function actionMarkup(data, type, full, meta){ - // var list = ""; - - // return list; - // } - - // $scope.dtInstance = {}; - // $scope.reloadTable = function(){ - // $scope.dtInstance.reloadData(); - // } - $scope.saveNewPatient = function(){ var patient = $scope.newPatient; + patient.createdBy = utils.userSession.getID(); var request = utils.serverRequest("/patients/patient/new", "POST", patient); @@ -273,6 +236,8 @@ angular.module("EmmetBlue") var data = $scope.newPatient; if (typeof $scope.newPatient['First Name'] !== "undefined" || typeof $scope.newPatient['Last Name'] !== "undefined") { data.patientName = $scope.newPatient['First Name'] + " " + $scope.newPatient['Last Name']; + data.createdBy = utils.userSession.getID(); + $('.loader').addClass('show'); var submitData = utils.serverRequest("/patients/patient/new", "POST", data); diff --git a/plugins/records/patient/assets/controllers/manage-repository-controller.js b/plugins/records/patient/assets/controllers/manage-repository-controller.js index 77099ad..501a18b 100644 --- a/plugins/records/patient/assets/controllers/manage-repository-controller.js +++ b/plugins/records/patient/assets/controllers/manage-repository-controller.js @@ -760,6 +760,7 @@ angular.module("EmmetBlue") var recordsPatientManageRepositoryController = function($scope, utils, $http){ // $scope.currentRepository = 7; + $scope.utils = utils; $scope.loadImage = utils.loadImage; $scope.$watch(function(){ return $scope.currentRepository @@ -869,6 +870,13 @@ var recordsPatientManageRepositoryController = function($scope, utils, $http){ }, function(error){ utils.notify("An error occurred", "Unable to load document", "error"); }); + + utils.serverRequest("/lab/lab-result/view-by-repository-id?resourceId="+$scope.repository.RepositoryID, "GET").then(function(response){ + $scope.labResultMeta = response; + $scope.issetLabMeta = (typeof response.PatientPicture !== "undefined"); + }, function(error){ + utils.notify("An error occurred", "Unable to load document", "error"); + }); $("#view-json-document").modal("show"); } diff --git a/plugins/records/patient/assets/controllers/patient-grid-directive.js b/plugins/records/patient/assets/controllers/patient-grid-directive.js index bbd81c4..ca81668 100644 --- a/plugins/records/patient/assets/controllers/patient-grid-directive.js +++ b/plugins/records/patient/assets/controllers/patient-grid-directive.js @@ -105,6 +105,30 @@ angular.module("EmmetBlue") } $scope.loadAppointments($scope.patientInfo.patientid); + + function loadDoctors(){ + utils.serverRequest("/nursing/load-doctors/view-queue-count", "GET").then(function(response){ + $scope.doctors = response; + }, function(error){ + utils.errorHandler(error); + }) + }; + loadDoctors(); + + $scope.selectedDoctor = ""; + $scope.queuePatient = function(){ + var data = { + consultant: $scope.selectedDoctor, + patient: $scope.patientInfo.patientid + }; + + utils.serverRequest("/consultancy/patient-queue/new", "POST", data).then(function(response){ + utils.alert("Doctor queue updated successfully", "Patient can go to consulting room", "info", "notify"); + $scope.unlockProfile($scope.patientInfo.patientid); + }, function(error){ + utils.errorHandler(error); + }) + } } } }) \ No newline at end of file diff --git a/plugins/records/patient/assets/controllers/patient-profile-directive.js b/plugins/records/patient/assets/controllers/patient-profile-directive.js index aa5e4d1..dae9d28 100644 --- a/plugins/records/patient/assets/controllers/patient-profile-directive.js +++ b/plugins/records/patient/assets/controllers/patient-profile-directive.js @@ -12,6 +12,13 @@ angular.module("EmmetBlue") $scope.getAge = utils.getAge; var loadDiagnosis = function(id){ + utils.serverRequest("/patients/patient-diagnosis/get-diagnosis-date-group?resourceId="+id, "GET") + .then(function(response){ + $scope.diagnosesDateGroups = response; + }, function(error){ + utils.errorHandler(error); + }) + utils.serverRequest("/patients/patient-diagnosis/view?resourceId="+id, "GET") .then(function(response){ $scope.diagnoses = response; @@ -22,6 +29,29 @@ angular.module("EmmetBlue") $scope.loadDiagnosis = loadDiagnosis; + $scope.$watch("selectedDateGroup", function(newValue, old){ + var id = $scope.patientInfo.patientid; + if (newValue == 0){ + utils.serverRequest("/patients/patient-diagnosis/view?resourceId="+id, "GET") + .then(function(response){ + $scope.diagnoses = response; + }, function(error){ + utils.errorHandler(error); + }) + } + else { + var val = JSON.parse(newValue); + var year = val.YearDate; + var month = val.MonthDate; + utils.serverRequest("/patients/patient-diagnosis/view-diagnosis-in-date-groups?resourceId="+id+"&year="+year+"&month="+month, "GET") + .then(function(response){ + $scope.diagnoses = response; + }, function(error){ + utils.errorHandler(error); + }) + } + }) + // $scope.$watch(function(){ // return $scope.patientInfo.patientid // }, function(nv){ @@ -37,12 +67,17 @@ angular.module("EmmetBlue") } $scope.toDateString = function(date){ - return new Date(date).toDateString(); + return new Date(date).toDateString()+ " " + new Date(date).toLocaleTimeString(); } $scope.getTime = function(date){ return new Date(date).toLocaleTimeString(); } + + $scope.exists = function(p, ind){ + return typeof p[ind] != "undefined" + } + } } }) \ No newline at end of file diff --git a/plugins/records/patient/assets/includes/patient-card-template.html b/plugins/records/patient/assets/includes/patient-card-template.html index 113a28b..480a387 100644 --- a/plugins/records/patient/assets/includes/patient-card-template.html +++ b/plugins/records/patient/assets/includes/patient-card-template.html @@ -38,6 +38,10 @@

Issued On:

{{toDateString(patientInfo["lastmodified"])}}

+
+ +

{{patientInfo["createdByProfile"].StaffFullName}}

+
diff --git a/plugins/records/patient/assets/includes/patient-grid-template.html b/plugins/records/patient/assets/includes/patient-grid-template.html index e444f8d..c966209 100644 --- a/plugins/records/patient/assets/includes/patient-grid-template.html +++ b/plugins/records/patient/assets/includes/patient-grid-template.html @@ -151,7 +151,7 @@