From d9dca96a323da8a3b54692f264bc6ecada445fdb Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Mon, 27 May 2019 01:36:43 +0200 Subject: [PATCH] added punch-in punch-out / time-clock mode (#812) --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- assets/js/plugins/KimaiAjaxModalForm.js | 18 ++- config/packages/kimai.yaml | 2 +- public/build/app.js | 2 +- public/build/manifest.json | 2 +- src/API/TimesheetController.php | 2 + src/Configuration/TimesheetConfiguration.php | 6 + .../TimesheetAbstractController.php | 104 ++++++++++------- src/Controller/TimesheetTeamController.php | 11 ++ src/DependencyInjection/Configuration.php | 4 +- src/Form/TimesheetAdminEditForm.php | 23 ++++ src/Form/TimesheetEditForm.php | 105 ++++++++++-------- src/Form/Type/TimesheetModeType.php | 1 + src/Twig/TimesheetConfigExtension.php | 6 + templates/calendar/user.html.twig | 14 ++- .../TimesheetTeamControllerTest.php | 8 +- tests/Twig/TimesheetConfigExtensionTest.php | 14 ++- translations/messages.sv.xliff | 4 - translations/system-configuration.de.xliff | 8 +- translations/system-configuration.en.xliff | 8 +- 20 files changed, 231 insertions(+), 113 deletions(-) create mode 100644 src/Form/TimesheetAdminEditForm.php diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 912b20ab..4ab04b20 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,5 +8,5 @@ A clear and concise description of what this pull request adds or changes. ## Checklist - [ ] I verified that my code applies to the guidelines (`composer code-check`) -- [ ] I updated the documentation accordingly (see [here](https://github.com/kimai/www.kimai.org/tree/master/_documentation)) +- [ ] I updated the documentation (see [here](https://github.com/kimai/www.kimai.org/tree/master/_documentation)) - [ ] I agree that this code is used in Kimai and will be published under the [MIT license](https://github.com/kevinpapst/kimai2/blob/master/LICENSE) diff --git a/assets/js/plugins/KimaiAjaxModalForm.js b/assets/js/plugins/KimaiAjaxModalForm.js index 6dc66cd9..5533f882 100644 --- a/assets/js/plugins/KimaiAjaxModalForm.js +++ b/assets/js/plugins/KimaiAjaxModalForm.js @@ -34,16 +34,26 @@ export default class KimaiAjaxModalForm extends KimaiClickHandlerReducedInTableR }); } - openUrlInModal(url) { + openUrlInModal(url, errorHandler) { const self = this; + + if (errorHandler === undefined) { + errorHandler = function(xhr, err) { + if (xhr.status !== undefined && xhr.status === 403) { + const alert = self.getContainer().getPlugin('alert'); + alert.error(xhr.statusText); + return; + } + window.location = url; + }; + } + jQuery.ajax({ url: url, success: function(html) { self._openFormInModal(html); }, - error: function(xhr, err) { - window.location = url; - } + error: errorHandler }); } diff --git a/config/packages/kimai.yaml b/config/packages/kimai.yaml index 9648ac0b..c798b050 100644 --- a/config/packages/kimai.yaml +++ b/config/packages/kimai.yaml @@ -10,7 +10,7 @@ kimai: # -------------------------------------------------------------------------------- # AUTHENTICATION # You can disable some user management functions in the authentication screens. -# Both settings default to "true" +# Both settings default to "true", see https://www.kimai.org/documentation/users.html # -------------------------------------------------------------------------------- # user: # registration: false diff --git a/public/build/app.js b/public/build/app.js index c790dd59..d9273abe 100644 --- a/public/build/app.js +++ b/public/build/app.js @@ -81,7 +81,7 @@ if(void 0===t)throw new Error("AdminLTE requires jQuery");+function(t){"use stri * @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php * @website: http://www.daterangepicker.com/ */ -!function(r,a){i=[n("PJh5"),n("7t+N")],void 0!==(o=function(t,e){return e.fn||(e.fn={}),"function"!=typeof t&&t.default&&(t=t.default),a(t,e)}.apply(e,i))&&(t.exports=o)}(0,function(t,e){var n=function(n,i,o){if(this.parentEl="body",this.element=e(n),this.startDate=t().startOf("day"),this.endDate=t().endOf("day"),this.minDate=!1,this.maxDate=!1,this.maxSpan=!1,this.autoApply=!1,this.singleDatePicker=!1,this.showDropdowns=!1,this.minYear=t().subtract(100,"year").format("YYYY"),this.maxYear=t().add(100,"year").format("YYYY"),this.showWeekNumbers=!1,this.showISOWeekNumbers=!1,this.showCustomRangeLabel=!0,this.timePicker=!1,this.timePicker24Hour=!1,this.timePickerIncrement=1,this.timePickerSeconds=!1,this.linkedCalendars=!0,this.autoUpdateInput=!0,this.alwaysShowCalendars=!1,this.ranges={},this.opens="right",this.element.hasClass("pull-right")&&(this.opens="left"),this.drops="down",this.element.hasClass("dropup")&&(this.drops="up"),this.buttonClasses="btn btn-sm",this.applyButtonClasses="btn-primary",this.cancelButtonClasses="btn-default",this.locale={direction:"ltr",format:t.localeData().longDateFormat("L"),separator:" - ",applyLabel:"Apply",cancelLabel:"Cancel",weekLabel:"W",customRangeLabel:"Custom Range",daysOfWeek:t.weekdaysMin(),monthNames:t.monthsShort(),firstDay:t.localeData().firstDayOfWeek()},this.callback=function(){},this.isShowing=!1,this.leftCalendar={},this.rightCalendar={},"object"==typeof i&&null!==i||(i={}),i=e.extend(this.element.data(),i),"string"==typeof i.template||i.template instanceof e||(i.template='
'),this.parentEl=e(i.parentEl&&e(i.parentEl).length?i.parentEl:this.parentEl),this.container=e(i.template).appendTo(this.parentEl),"object"==typeof i.locale&&("string"==typeof i.locale.direction&&(this.locale.direction=i.locale.direction),"string"==typeof i.locale.format&&(this.locale.format=i.locale.format),"string"==typeof i.locale.separator&&(this.locale.separator=i.locale.separator),"object"==typeof i.locale.daysOfWeek&&(this.locale.daysOfWeek=i.locale.daysOfWeek.slice()),"object"==typeof i.locale.monthNames&&(this.locale.monthNames=i.locale.monthNames.slice()),"number"==typeof i.locale.firstDay&&(this.locale.firstDay=i.locale.firstDay),"string"==typeof i.locale.applyLabel&&(this.locale.applyLabel=i.locale.applyLabel),"string"==typeof i.locale.cancelLabel&&(this.locale.cancelLabel=i.locale.cancelLabel),"string"==typeof i.locale.weekLabel&&(this.locale.weekLabel=i.locale.weekLabel),"string"==typeof i.locale.customRangeLabel)){var r=document.createElement("textarea");r.innerHTML=i.locale.customRangeLabel;var a=r.value;this.locale.customRangeLabel=a}if(this.container.addClass(this.locale.direction),"string"==typeof i.startDate&&(this.startDate=t(i.startDate,this.locale.format)),"string"==typeof i.endDate&&(this.endDate=t(i.endDate,this.locale.format)),"string"==typeof i.minDate&&(this.minDate=t(i.minDate,this.locale.format)),"string"==typeof i.maxDate&&(this.maxDate=t(i.maxDate,this.locale.format)),"object"==typeof i.startDate&&(this.startDate=t(i.startDate)),"object"==typeof i.endDate&&(this.endDate=t(i.endDate)),"object"==typeof i.minDate&&(this.minDate=t(i.minDate)),"object"==typeof i.maxDate&&(this.maxDate=t(i.maxDate)),this.minDate&&this.startDate.isBefore(this.minDate)&&(this.startDate=this.minDate.clone()),this.maxDate&&this.endDate.isAfter(this.maxDate)&&(this.endDate=this.maxDate.clone()),"string"==typeof i.applyButtonClasses&&(this.applyButtonClasses=i.applyButtonClasses),"string"==typeof i.applyClass&&(this.applyButtonClasses=i.applyClass),"string"==typeof i.cancelButtonClasses&&(this.cancelButtonClasses=i.cancelButtonClasses),"string"==typeof i.cancelClass&&(this.cancelButtonClasses=i.cancelClass),"object"==typeof i.maxSpan&&(this.maxSpan=i.maxSpan),"object"==typeof i.dateLimit&&(this.maxSpan=i.dateLimit),"string"==typeof i.opens&&(this.opens=i.opens),"string"==typeof i.drops&&(this.drops=i.drops),"boolean"==typeof i.showWeekNumbers&&(this.showWeekNumbers=i.showWeekNumbers),"boolean"==typeof i.showISOWeekNumbers&&(this.showISOWeekNumbers=i.showISOWeekNumbers),"string"==typeof i.buttonClasses&&(this.buttonClasses=i.buttonClasses),"object"==typeof i.buttonClasses&&(this.buttonClasses=i.buttonClasses.join(" ")),"boolean"==typeof i.showDropdowns&&(this.showDropdowns=i.showDropdowns),"number"==typeof i.minYear&&(this.minYear=i.minYear),"number"==typeof i.maxYear&&(this.maxYear=i.maxYear),"boolean"==typeof i.showCustomRangeLabel&&(this.showCustomRangeLabel=i.showCustomRangeLabel),"boolean"==typeof i.singleDatePicker&&(this.singleDatePicker=i.singleDatePicker,this.singleDatePicker&&(this.endDate=this.startDate.clone())),"boolean"==typeof i.timePicker&&(this.timePicker=i.timePicker),"boolean"==typeof i.timePickerSeconds&&(this.timePickerSeconds=i.timePickerSeconds),"number"==typeof i.timePickerIncrement&&(this.timePickerIncrement=i.timePickerIncrement),"boolean"==typeof i.timePicker24Hour&&(this.timePicker24Hour=i.timePicker24Hour),"boolean"==typeof i.autoApply&&(this.autoApply=i.autoApply),"boolean"==typeof i.autoUpdateInput&&(this.autoUpdateInput=i.autoUpdateInput),"boolean"==typeof i.linkedCalendars&&(this.linkedCalendars=i.linkedCalendars),"function"==typeof i.isInvalidDate&&(this.isInvalidDate=i.isInvalidDate),"function"==typeof i.isCustomDate&&(this.isCustomDate=i.isCustomDate),"boolean"==typeof i.alwaysShowCalendars&&(this.alwaysShowCalendars=i.alwaysShowCalendars),0!=this.locale.firstDay)for(var s=this.locale.firstDay;s>0;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),s--;var l,u,c;if(void 0===i.startDate&&void 0===i.endDate&&e(this.element).is(":text")){var d=e(this.element).val(),h=d.split(this.locale.separator);l=u=null,2==h.length?(l=t(h[0],this.locale.format),u=t(h[1],this.locale.format)):this.singleDatePicker&&""!==d&&(l=t(d,this.locale.format),u=t(d,this.locale.format)),null!==l&&null!==u&&(this.setStartDate(l),this.setEndDate(u))}if("object"==typeof i.ranges){for(c in i.ranges){l="string"==typeof i.ranges[c][0]?t(i.ranges[c][0],this.locale.format):t(i.ranges[c][0]),u="string"==typeof i.ranges[c][1]?t(i.ranges[c][1],this.locale.format):t(i.ranges[c][1]),this.minDate&&l.isBefore(this.minDate)&&(l=this.minDate.clone());var f=this.maxDate;if(this.maxSpan&&f&&l.clone().add(this.maxSpan).isAfter(f)&&(f=l.clone().add(this.maxSpan)),f&&u.isAfter(f)&&(u=f.clone()),!(this.minDate&&u.isBefore(this.minDate,this.timepicker?"minute":"day")||f&&l.isAfter(f,this.timepicker?"minute":"day"))){var r=document.createElement("textarea");r.innerHTML=c;var a=r.value;this.ranges[a]=[l,u]}}var p="",this.container.find(".ranges").prepend(p)}"function"==typeof o&&(this.callback=o),this.timePicker||(this.startDate=this.startDate.startOf("day"),this.endDate=this.endDate.endOf("day"),this.container.find(".calendar-time").hide()),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.addClass("auto-apply"),"object"==typeof i.ranges&&this.container.addClass("show-ranges"),this.singleDatePicker&&(this.container.addClass("single"),this.container.find(".drp-calendar.left").addClass("single"),this.container.find(".drp-calendar.left").show(),this.container.find(".drp-calendar.right").hide(),this.timePicker||this.container.addClass("auto-apply")),(void 0===i.ranges&&!this.singleDatePicker||this.alwaysShowCalendars)&&this.container.addClass("show-calendar"),this.container.addClass("opens"+this.opens),this.container.find(".applyBtn, .cancelBtn").addClass(this.buttonClasses),this.applyButtonClasses.length&&this.container.find(".applyBtn").addClass(this.applyButtonClasses),this.cancelButtonClasses.length&&this.container.find(".cancelBtn").addClass(this.cancelButtonClasses),this.container.find(".applyBtn").html(this.locale.applyLabel),this.container.find(".cancelBtn").html(this.locale.cancelLabel),this.container.find(".drp-calendar").on("click.daterangepicker",".prev",e.proxy(this.clickPrev,this)).on("click.daterangepicker",".next",e.proxy(this.clickNext,this)).on("mousedown.daterangepicker","td.available",e.proxy(this.clickDate,this)).on("mouseenter.daterangepicker","td.available",e.proxy(this.hoverDate,this)).on("change.daterangepicker","select.yearselect",e.proxy(this.monthOrYearChanged,this)).on("change.daterangepicker","select.monthselect",e.proxy(this.monthOrYearChanged,this)).on("change.daterangepicker","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",e.proxy(this.timeChanged,this)),this.container.find(".ranges").on("click.daterangepicker","li",e.proxy(this.clickRange,this)),this.container.find(".drp-buttons").on("click.daterangepicker","button.applyBtn",e.proxy(this.clickApply,this)).on("click.daterangepicker","button.cancelBtn",e.proxy(this.clickCancel,this)),this.element.is("input")||this.element.is("button")?this.element.on({"click.daterangepicker":e.proxy(this.show,this),"focus.daterangepicker":e.proxy(this.show,this),"keyup.daterangepicker":e.proxy(this.elementChanged,this),"keydown.daterangepicker":e.proxy(this.keydown,this)}):(this.element.on("click.daterangepicker",e.proxy(this.toggle,this)),this.element.on("keydown.daterangepicker",e.proxy(this.toggle,this))),this.updateElement()};return n.prototype={constructor:n,setStartDate:function(e){"string"==typeof e&&(this.startDate=t(e,this.locale.format)),"object"==typeof e&&(this.startDate=t(e)),this.timePicker||(this.startDate=this.startDate.startOf("day")),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.round(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement),this.minDate&&this.startDate.isBefore(this.minDate)&&(this.startDate=this.minDate.clone(),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.round(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement)),this.maxDate&&this.startDate.isAfter(this.maxDate)&&(this.startDate=this.maxDate.clone(),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.floor(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement)),this.isShowing||this.updateElement(),this.updateMonthsInView()},setEndDate:function(e){"string"==typeof e&&(this.endDate=t(e,this.locale.format)),"object"==typeof e&&(this.endDate=t(e)),this.timePicker||(this.endDate=this.endDate.endOf("day")),this.timePicker&&this.timePickerIncrement&&this.endDate.minute(Math.round(this.endDate.minute()/this.timePickerIncrement)*this.timePickerIncrement),this.endDate.isBefore(this.startDate)&&(this.endDate=this.startDate.clone()),this.maxDate&&this.endDate.isAfter(this.maxDate)&&(this.endDate=this.maxDate.clone()),this.maxSpan&&this.startDate.clone().add(this.maxSpan).isBefore(this.endDate)&&(this.endDate=this.startDate.clone().add(this.maxSpan)),this.previousRightTime=this.endDate.clone(),this.container.find(".drp-selected").html(this.startDate.format(this.locale.format)+this.locale.separator+this.endDate.format(this.locale.format)),this.isShowing||this.updateElement(),this.updateMonthsInView()},isInvalidDate:function(){return!1},isCustomDate:function(){return!1},updateView:function(){this.timePicker&&(this.renderTimePicker("left"),this.renderTimePicker("right"),this.endDate?this.container.find(".right .calendar-time select").removeAttr("disabled").removeClass("disabled"):this.container.find(".right .calendar-time select").attr("disabled","disabled").addClass("disabled")),this.endDate&&this.container.find(".drp-selected").html(this.startDate.format(this.locale.format)+this.locale.separator+this.endDate.format(this.locale.format)),this.updateMonthsInView(),this.updateCalendars(),this.updateFormInputs()},updateMonthsInView:function(){if(this.endDate){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.startDate.format("YYYY-MM")==this.leftCalendar.month.format("YYYY-MM")||this.startDate.format("YYYY-MM")==this.rightCalendar.month.format("YYYY-MM"))&&(this.endDate.format("YYYY-MM")==this.leftCalendar.month.format("YYYY-MM")||this.endDate.format("YYYY-MM")==this.rightCalendar.month.format("YYYY-MM")))return;this.leftCalendar.month=this.startDate.clone().date(2),this.linkedCalendars||this.endDate.month()==this.startDate.month()&&this.endDate.year()==this.startDate.year()?this.rightCalendar.month=this.startDate.clone().date(2).add(1,"month"):this.rightCalendar.month=this.endDate.clone().date(2)}else this.leftCalendar.month.format("YYYY-MM")!=this.startDate.format("YYYY-MM")&&this.rightCalendar.month.format("YYYY-MM")!=this.startDate.format("YYYY-MM")&&(this.leftCalendar.month=this.startDate.clone().date(2),this.rightCalendar.month=this.startDate.clone().date(2).add(1,"month"));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.clone().date(2),this.leftCalendar.month=this.maxDate.clone().date(2).subtract(1,"month"))},updateCalendars:function(){if(this.timePicker){var t,e,n;if(this.endDate){if(t=parseInt(this.container.find(".left .hourselect").val(),10),e=parseInt(this.container.find(".left .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".left .minuteselect option:last").val(),10)),n=this.timePickerSeconds?parseInt(this.container.find(".left .secondselect").val(),10):0,!this.timePicker24Hour){var i=this.container.find(".left .ampmselect").val();"PM"===i&&t<12&&(t+=12),"AM"===i&&12===t&&(t=0)}}else if(t=parseInt(this.container.find(".right .hourselect").val(),10),e=parseInt(this.container.find(".right .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".right .minuteselect option:last").val(),10)),n=this.timePickerSeconds?parseInt(this.container.find(".right .secondselect").val(),10):0,!this.timePicker24Hour){var i=this.container.find(".right .ampmselect").val();"PM"===i&&t<12&&(t+=12),"AM"===i&&12===t&&(t=0)}this.leftCalendar.month.hour(t).minute(e).second(n),this.rightCalendar.month.hour(t).minute(e).second(n)}this.renderCalendar("left"),this.renderCalendar("right"),this.container.find(".ranges li").removeClass("active"),null!=this.endDate&&this.calculateChosenLabel()},renderCalendar:function(n){var i="left"==n?this.leftCalendar:this.rightCalendar,o=i.month.month(),r=i.month.year(),a=i.month.hour(),s=i.month.minute(),l=i.month.second(),u=t([r,o]).daysInMonth(),c=t([r,o,1]),d=t([r,o,u]),h=t(c).subtract(1,"month").month(),f=t(c).subtract(1,"month").year(),p=t([f,h]).daysInMonth(),m=c.day(),i=[];i.firstDay=c,i.lastDay=d;for(var g=0;g<6;g++)i[g]=[];var v=p-m+this.locale.firstDay+1;v>p&&(v-=7),m==this.locale.firstDay&&(v=p-6);for(var y,b,w=t([f,h,v,12,s,l]),g=0,y=0,b=0;g<42;g++,y++,w=t(w).add(24,"hour"))g>0&&y%7==0&&(y=0,b++),i[b][y]=w.clone().hour(a).minute(s).second(l),w.hour(12),this.minDate&&i[b][y].format("YYYY-MM-DD")==this.minDate.format("YYYY-MM-DD")&&i[b][y].isBefore(this.minDate)&&"left"==n&&(i[b][y]=this.minDate.clone()),this.maxDate&&i[b][y].format("YYYY-MM-DD")==this.maxDate.format("YYYY-MM-DD")&&i[b][y].isAfter(this.maxDate)&&"right"==n&&(i[b][y]=this.maxDate.clone());"left"==n?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var x="left"==n?this.minDate:this.startDate,_=this.maxDate,D=("left"==n?this.startDate:this.endDate,this.locale.direction,'');D+="",D+="",(this.showWeekNumbers||this.showISOWeekNumbers)&&(D+=""),x&&!x.isBefore(i.firstDay)||this.linkedCalendars&&"left"!=n?D+="":D+='';var k=this.locale.monthNames[i[1][1].month()]+i[1][1].format(" YYYY");if(this.showDropdowns){for(var S=i[1][1].month(),C=i[1][1].year(),M=_&&_.year()||this.maxYear,T=x&&x.year()||this.minYear,E=C==T,P=C==M,I='";for(var L='",k=I+L}if(D+='",_&&!_.isAfter(i.lastDay)||this.linkedCalendars&&"right"!=n&&!this.singleDatePicker?D+="":D+='',D+="",D+="",(this.showWeekNumbers||this.showISOWeekNumbers)&&(D+='"),e.each(this.locale.daysOfWeek,function(t,e){D+=""}),D+="",D+="",D+="",null==this.endDate&&this.maxSpan){var A=this.startDate.clone().add(this.maxSpan).endOf("day");_&&!A.isBefore(_)||(_=A)}for(var b=0;b<6;b++){D+="",this.showWeekNumbers?D+='":this.showISOWeekNumbers&&(D+='");for(var y=0;y<7;y++){var H=[];i[b][y].isSame(new Date,"day")&&H.push("today"),i[b][y].isoWeekday()>5&&H.push("weekend"),i[b][y].month()!=i[1][1].month()&&H.push("off","ends"),this.minDate&&i[b][y].isBefore(this.minDate,"day")&&H.push("off","disabled"),_&&i[b][y].isAfter(_,"day")&&H.push("off","disabled"),this.isInvalidDate(i[b][y])&&H.push("off","disabled"),i[b][y].format("YYYY-MM-DD")==this.startDate.format("YYYY-MM-DD")&&H.push("active","start-date"),null!=this.endDate&&i[b][y].format("YYYY-MM-DD")==this.endDate.format("YYYY-MM-DD")&&H.push("active","end-date"),null!=this.endDate&&i[b][y]>this.startDate&&i[b][y]'+i[b][y].date()+""}D+=""}D+="",D+="
'+k+"
'+this.locale.weekLabel+""+e+"
'+i[b][0].week()+"'+i[b][0].isoWeek()+"
",this.container.find(".drp-calendar."+n+" .calendar-table").html(D)},renderTimePicker:function(t){if("right"!=t||this.endDate){var e,n,i,o=this.maxDate;if(!this.maxSpan||this.maxDate&&!this.startDate.clone().add(this.maxSpan).isBefore(this.maxDate)||(o=this.startDate.clone().add(this.maxSpan)),"left"==t)n=this.startDate.clone(),i=this.minDate;else if("right"==t){n=this.endDate.clone(),i=this.startDate;var r=this.container.find(".drp-calendar.right .calendar-time");if(""!=r.html()&&(n.hour(isNaN(n.hour())?r.find(".hourselect option:selected").val():n.hour()),n.minute(isNaN(n.minute())?r.find(".minuteselect option:selected").val():n.minute()),n.second(isNaN(n.second())?r.find(".secondselect option:selected").val():n.second()),!this.timePicker24Hour)){var a=r.find(".ampmselect option:selected").val();"PM"===a&&n.hour()<12&&n.hour(n.hour()+12),"AM"===a&&12===n.hour()&&n.hour(0)}n.isBefore(this.startDate)&&(n=this.startDate.clone()),o&&n.isAfter(o)&&(n=o.clone())}e=' ",e+=': ",this.timePickerSeconds){e+=': "}if(!this.timePicker24Hour){e+='"}this.container.find(".drp-calendar."+t+" .calendar-time").html(e)}},updateFormInputs:function(){this.singleDatePicker||this.endDate&&(this.startDate.isBefore(this.endDate)||this.startDate.isSame(this.endDate))?this.container.find("button.applyBtn").removeAttr("disabled"):this.container.find("button.applyBtn").attr("disabled","disabled")},move:function(){var t,n={top:0,left:0},i=e(window).width();this.parentEl.is("body")||(n={top:this.parentEl.offset().top-this.parentEl.scrollTop(),left:this.parentEl.offset().left-this.parentEl.scrollLeft()},i=this.parentEl[0].clientWidth+this.parentEl.offset().left),t="up"==this.drops?this.element.offset().top-this.container.outerHeight()-n.top:this.element.offset().top+this.element.outerHeight()-n.top,this.container.css({top:0,left:0,right:"auto"});var o=this.container.outerWidth();if(this.container["up"==this.drops?"addClass":"removeClass"]("drop-up"),"left"==this.opens){var r=i-this.element.offset().left-this.element.outerWidth();o+r>e(window).width()?this.container.css({top:t,right:"auto",left:9}):this.container.css({top:t,right:r,left:"auto"})}else if("center"==this.opens){var a=this.element.offset().left-n.left+this.element.outerWidth()/2-o/2;a<0?this.container.css({top:t,right:"auto",left:9}):a+o>e(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:a,right:"auto"})}else{var a=this.element.offset().left-n.left;a+o>e(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:a,right:"auto"})}},show:function(t){this.isShowing||(this._outsideClickProxy=e.proxy(function(t){this.outsideClick(t)},this),e(document).on("mousedown.daterangepicker",this._outsideClickProxy).on("touchend.daterangepicker",this._outsideClickProxy).on("click.daterangepicker","[data-toggle=dropdown]",this._outsideClickProxy).on("focusin.daterangepicker",this._outsideClickProxy),e(window).on("resize.daterangepicker",e.proxy(function(t){this.move(t)},this)),this.oldStartDate=this.startDate.clone(),this.oldEndDate=this.endDate.clone(),this.previousRightTime=this.endDate.clone(),this.updateView(),this.container.show(),this.move(),this.element.trigger("show.daterangepicker",this),this.isShowing=!0)},hide:function(t){this.isShowing&&(this.endDate||(this.startDate=this.oldStartDate.clone(),this.endDate=this.oldEndDate.clone()),this.startDate.isSame(this.oldStartDate)&&this.endDate.isSame(this.oldEndDate)||this.callback(this.startDate.clone(),this.endDate.clone(),this.chosenLabel),this.updateElement(),e(document).off(".daterangepicker"),e(window).off(".daterangepicker"),this.container.hide(),this.element.trigger("hide.daterangepicker",this),this.isShowing=!1)},toggle:function(t){this.isShowing?this.hide():this.show()},outsideClick:function(t){var n=e(t.target);"focusin"==t.type||n.closest(this.element).length||n.closest(this.container).length||n.closest(".calendar-table").length||(this.hide(),this.element.trigger("outsideClick.daterangepicker",this))},showCalendars:function(){this.container.addClass("show-calendar"),this.move(),this.element.trigger("showCalendar.daterangepicker",this)},hideCalendars:function(){this.container.removeClass("show-calendar"),this.element.trigger("hideCalendar.daterangepicker",this)},clickRange:function(t){var e=t.target.getAttribute("data-range-key");if(this.chosenLabel=e,e==this.locale.customRangeLabel)this.showCalendars();else{var n=this.ranges[e];this.startDate=n[0],this.endDate=n[1],this.timePicker||(this.startDate.startOf("day"),this.endDate.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.clickApply()}},clickPrev:function(t){e(t.target).parents(".drp-calendar").hasClass("left")?(this.leftCalendar.month.subtract(1,"month"),this.linkedCalendars&&this.rightCalendar.month.subtract(1,"month")):this.rightCalendar.month.subtract(1,"month"),this.updateCalendars()},clickNext:function(t){e(t.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.month.add(1,"month"):(this.rightCalendar.month.add(1,"month"),this.linkedCalendars&&this.leftCalendar.month.add(1,"month")),this.updateCalendars()},hoverDate:function(t){if(e(t.target).hasClass("available")){var n=e(t.target).attr("data-title"),i=n.substr(1,1),o=n.substr(3,1),r=e(t.target).parents(".drp-calendar"),a=r.hasClass("left")?this.leftCalendar.calendar[i][o]:this.rightCalendar.calendar[i][o],s=this.leftCalendar,l=this.rightCalendar,u=this.startDate;this.endDate||this.container.find(".drp-calendar tbody td").each(function(t,n){if(!e(n).hasClass("week")){var i=e(n).attr("data-title"),o=i.substr(1,1),r=i.substr(3,1),c=e(n).parents(".drp-calendar"),d=c.hasClass("left")?s.calendar[o][r]:l.calendar[o][r];d.isAfter(u)&&d.isBefore(a)||d.isSame(a,"day")?e(n).addClass("in-range"):e(n).removeClass("in-range")}})}},clickDate:function(t){if(e(t.target).hasClass("available")){var n=e(t.target).attr("data-title"),i=n.substr(1,1),o=n.substr(3,1),r=e(t.target).parents(".drp-calendar"),a=r.hasClass("left")?this.leftCalendar.calendar[i][o]:this.rightCalendar.calendar[i][o];if(this.endDate||a.isBefore(this.startDate,"day")){if(this.timePicker){var s=parseInt(this.container.find(".left .hourselect").val(),10);if(!this.timePicker24Hour){var l=this.container.find(".left .ampmselect").val();"PM"===l&&s<12&&(s+=12),"AM"===l&&12===s&&(s=0)}var u=parseInt(this.container.find(".left .minuteselect").val(),10);isNaN(u)&&(u=parseInt(this.container.find(".left .minuteselect option:last").val(),10));var c=this.timePickerSeconds?parseInt(this.container.find(".left .secondselect").val(),10):0;a=a.clone().hour(s).minute(u).second(c)}this.endDate=null,this.setStartDate(a.clone())}else if(!this.endDate&&a.isBefore(this.startDate))this.setEndDate(this.startDate.clone());else{if(this.timePicker){var s=parseInt(this.container.find(".right .hourselect").val(),10);if(!this.timePicker24Hour){var l=this.container.find(".right .ampmselect").val();"PM"===l&&s<12&&(s+=12),"AM"===l&&12===s&&(s=0)}var u=parseInt(this.container.find(".right .minuteselect").val(),10);isNaN(u)&&(u=parseInt(this.container.find(".right .minuteselect option:last").val(),10));var c=this.timePickerSeconds?parseInt(this.container.find(".right .secondselect").val(),10):0;a=a.clone().hour(s).minute(u).second(c)}this.setEndDate(a.clone()),this.autoApply&&(this.calculateChosenLabel(),this.clickApply())}this.singleDatePicker&&(this.setEndDate(this.startDate),this.timePicker||this.clickApply()),this.updateView(),t.stopPropagation()}},calculateChosenLabel:function(){var t=!0,e=0;for(var n in this.ranges){if(this.timePicker){var i=this.timePickerSeconds?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD HH:mm";if(this.startDate.format(i)==this.ranges[n][0].format(i)&&this.endDate.format(i)==this.ranges[n][1].format(i)){t=!1,this.chosenLabel=this.container.find(".ranges li:eq("+e+")").addClass("active").attr("data-range-key");break}}else if(this.startDate.format("YYYY-MM-DD")==this.ranges[n][0].format("YYYY-MM-DD")&&this.endDate.format("YYYY-MM-DD")==this.ranges[n][1].format("YYYY-MM-DD")){t=!1,this.chosenLabel=this.container.find(".ranges li:eq("+e+")").addClass("active").attr("data-range-key");break}e++}t&&(this.showCustomRangeLabel?this.chosenLabel=this.container.find(".ranges li:last").addClass("active").attr("data-range-key"):this.chosenLabel=null,this.showCalendars())},clickApply:function(t){this.hide(),this.element.trigger("apply.daterangepicker",this)},clickCancel:function(t){this.startDate=this.oldStartDate,this.endDate=this.oldEndDate,this.hide(),this.element.trigger("cancel.daterangepicker",this)},monthOrYearChanged:function(t){var n=e(t.target).closest(".drp-calendar").hasClass("left"),i=n?"left":"right",o=this.container.find(".drp-calendar."+i),r=parseInt(o.find(".monthselect").val(),10),a=o.find(".yearselect").val();n||(athis.maxDate.year()||a==this.maxDate.year()&&r>this.maxDate.month())&&(r=this.maxDate.month(),a=this.maxDate.year()),n?(this.leftCalendar.month.month(r).year(a),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.clone().add(1,"month"))):(this.rightCalendar.month.month(r).year(a),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.clone().subtract(1,"month"))),this.updateCalendars()},timeChanged:function(t){var n=e(t.target).closest(".drp-calendar"),i=n.hasClass("left"),o=parseInt(n.find(".hourselect").val(),10),r=parseInt(n.find(".minuteselect").val(),10);isNaN(r)&&(r=parseInt(n.find(".minuteselect option:last").val(),10));var a=this.timePickerSeconds?parseInt(n.find(".secondselect").val(),10):0;if(!this.timePicker24Hour){var s=n.find(".ampmselect").val();"PM"===s&&o<12&&(o+=12),"AM"===s&&12===o&&(o=0)}if(i){var l=this.startDate.clone();l.hour(o),l.minute(r),l.second(a),this.setStartDate(l),this.singleDatePicker?this.endDate=this.startDate.clone():this.endDate&&this.endDate.format("YYYY-MM-DD")==l.format("YYYY-MM-DD")&&this.endDate.isBefore(l)&&this.setEndDate(l.clone())}else if(this.endDate){var u=this.endDate.clone();u.hour(o),u.minute(r),u.second(a),this.setEndDate(u)}this.updateCalendars(),this.updateFormInputs(),this.renderTimePicker("left"),this.renderTimePicker("right")},elementChanged:function(){if(this.element.is("input")&&this.element.val().length){var e=this.element.val().split(this.locale.separator),n=null,i=null;2===e.length&&(n=t(e[0],this.locale.format),i=t(e[1],this.locale.format)),(this.singleDatePicker||null===n||null===i)&&(n=t(this.element.val(),this.locale.format),i=n),n.isValid()&&i.isValid()&&(this.setStartDate(n),this.setEndDate(i),this.updateView())}},keydown:function(t){9!==t.keyCode&&13!==t.keyCode||this.hide(),27===t.keyCode&&(t.preventDefault(),t.stopPropagation(),this.hide())},updateElement:function(){if(this.element.is("input")&&this.autoUpdateInput){var t=this.startDate.format(this.locale.format);this.singleDatePicker||(t+=this.locale.separator+this.endDate.format(this.locale.format)),t!==this.element.val()&&this.element.val(t).trigger("change")}},remove:function(){this.container.remove(),this.element.off(".daterangepicker"),this.element.removeData()}},e.fn.daterangepicker=function(t,i){var o=e.extend(!0,{},e.fn.daterangepicker.defaultOptions,t);return this.each(function(){var t=e(this);t.data("daterangepicker")&&t.data("daterangepicker").remove(),t.data("daterangepicker",new n(t,o,i))}),this},n})},R6CI:function(t,e){},RvrG:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=n("7t+N"),s=n.n(a),l=n("ITav"),u=function(){function t(t,e){for(var n=0;n0&&(o.on("hidden.bs.modal",function(){o.hasClass("modal-danger")&&o.removeClass("modal-danger")}),s()(t).find("#form_modal").hasClass("modal-danger")&&o.addClass("modal-danger"),s()("#remote_form_modal .modal-content").replaceWith(s()(t).find("#form_modal .modal-content")),e.getContainer().getPlugin("date-time-picker").activateDateTimePicker(n),e.getContainer().getPlugin("autocomplete").activateAutocomplete(n+" .js-autocomplete"),s()(".selectpicker").selectpicker("refresh"));var r=s()(t).find("div.alert");r.length>0&&s()("#remote_form_modal .modal-body").prepend(r);var a=s.a.fn.modal.Constructor.prototype.enforceFocus;s.a.fn.modal.Constructor.prototype.enforceFocus=function(){},o.on("hidden.bs.modal",function(){s.a.fn.modal.Constructor.prototype.enforceFocus=a}),o.on("shown.bs.modal",function(){s()(this).find("input[type=text],textarea,select").filter(':not("[data-datetimepicker=on]")').filter(":visible:first").focus().delay(1e3).focus()}),o.modal("show"),i=s()(n),i.on("submit",function(t){var r=s()(n+" button[type=submit]").button("loading"),a=i.attr("data-form-event"),l=e.getContainer().getPlugin("event"),u=e.getContainer().getPlugin("alert");t.preventDefault(),t.stopPropagation(),s.a.ajax({url:i.attr("action"),type:i.attr("method"),data:i.serialize(),success:function(t){r.button("reset");var n=s()(t).find("#form_modal .modal-content .has-error").length>0,c=s()(t).find("#form_modal .modal-content ul.list-unstyled li.text-danger").length>0,d=s()(t).find("div.alert-error").length>0;if(n||c||d)e._openFormInModal(t);else{l.trigger(a);var h=i.attr("data-msg-success");if(null===h||void 0===h){var f=s()(t).find("section.content div.row div.alert.alert-success");if(f.length>0){var p=f.contents();3===p.length&&(h=p[2].textContent)}}null!==h&&void 0!==h||(h="action.update.success"),o.modal("hide"),u.success(h)}return!1},error:function(t,e){var n=i.attr("data-msg-error");null!==n&&void 0!==n||(n="action.update.error"),t.responseJSON&&t.responseJSON.message?e=t.responseJSON.message:t.status&&t.statusText&&(e="["+t.status+"] "+t.statusText),u.error(n,e)}})})}}]),e}(l.a);e.a=c},T4Pq:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=n("7t+N"),s=n.n(a),l=n("4klR"),u=function(){function t(t,e){for(var n=0;n'+i.text()+""),s.a.each(e,function(t,e){n.append('")}),n.trigger("change"),s()(".selectpicker").selectpicker("refresh")}}]),e}(l.a);e.a=c},TqGs:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=n("+NP7"),r=n("awG4"),a=n("4klR"),s=function(){function t(t,e){for(var n=0;n0;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),s--;var l,u,c;if(void 0===i.startDate&&void 0===i.endDate&&e(this.element).is(":text")){var d=e(this.element).val(),h=d.split(this.locale.separator);l=u=null,2==h.length?(l=t(h[0],this.locale.format),u=t(h[1],this.locale.format)):this.singleDatePicker&&""!==d&&(l=t(d,this.locale.format),u=t(d,this.locale.format)),null!==l&&null!==u&&(this.setStartDate(l),this.setEndDate(u))}if("object"==typeof i.ranges){for(c in i.ranges){l="string"==typeof i.ranges[c][0]?t(i.ranges[c][0],this.locale.format):t(i.ranges[c][0]),u="string"==typeof i.ranges[c][1]?t(i.ranges[c][1],this.locale.format):t(i.ranges[c][1]),this.minDate&&l.isBefore(this.minDate)&&(l=this.minDate.clone());var f=this.maxDate;if(this.maxSpan&&f&&l.clone().add(this.maxSpan).isAfter(f)&&(f=l.clone().add(this.maxSpan)),f&&u.isAfter(f)&&(u=f.clone()),!(this.minDate&&u.isBefore(this.minDate,this.timepicker?"minute":"day")||f&&l.isAfter(f,this.timepicker?"minute":"day"))){var r=document.createElement("textarea");r.innerHTML=c;var a=r.value;this.ranges[a]=[l,u]}}var p="
    ";for(c in this.ranges)p+='
  • '+c+"
  • ";this.showCustomRangeLabel&&(p+='
  • '+this.locale.customRangeLabel+"
  • "),p+="
",this.container.find(".ranges").prepend(p)}"function"==typeof o&&(this.callback=o),this.timePicker||(this.startDate=this.startDate.startOf("day"),this.endDate=this.endDate.endOf("day"),this.container.find(".calendar-time").hide()),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.addClass("auto-apply"),"object"==typeof i.ranges&&this.container.addClass("show-ranges"),this.singleDatePicker&&(this.container.addClass("single"),this.container.find(".drp-calendar.left").addClass("single"),this.container.find(".drp-calendar.left").show(),this.container.find(".drp-calendar.right").hide(),this.timePicker||this.container.addClass("auto-apply")),(void 0===i.ranges&&!this.singleDatePicker||this.alwaysShowCalendars)&&this.container.addClass("show-calendar"),this.container.addClass("opens"+this.opens),this.container.find(".applyBtn, .cancelBtn").addClass(this.buttonClasses),this.applyButtonClasses.length&&this.container.find(".applyBtn").addClass(this.applyButtonClasses),this.cancelButtonClasses.length&&this.container.find(".cancelBtn").addClass(this.cancelButtonClasses),this.container.find(".applyBtn").html(this.locale.applyLabel),this.container.find(".cancelBtn").html(this.locale.cancelLabel),this.container.find(".drp-calendar").on("click.daterangepicker",".prev",e.proxy(this.clickPrev,this)).on("click.daterangepicker",".next",e.proxy(this.clickNext,this)).on("mousedown.daterangepicker","td.available",e.proxy(this.clickDate,this)).on("mouseenter.daterangepicker","td.available",e.proxy(this.hoverDate,this)).on("change.daterangepicker","select.yearselect",e.proxy(this.monthOrYearChanged,this)).on("change.daterangepicker","select.monthselect",e.proxy(this.monthOrYearChanged,this)).on("change.daterangepicker","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",e.proxy(this.timeChanged,this)),this.container.find(".ranges").on("click.daterangepicker","li",e.proxy(this.clickRange,this)),this.container.find(".drp-buttons").on("click.daterangepicker","button.applyBtn",e.proxy(this.clickApply,this)).on("click.daterangepicker","button.cancelBtn",e.proxy(this.clickCancel,this)),this.element.is("input")||this.element.is("button")?this.element.on({"click.daterangepicker":e.proxy(this.show,this),"focus.daterangepicker":e.proxy(this.show,this),"keyup.daterangepicker":e.proxy(this.elementChanged,this),"keydown.daterangepicker":e.proxy(this.keydown,this)}):(this.element.on("click.daterangepicker",e.proxy(this.toggle,this)),this.element.on("keydown.daterangepicker",e.proxy(this.toggle,this))),this.updateElement()};return n.prototype={constructor:n,setStartDate:function(e){"string"==typeof e&&(this.startDate=t(e,this.locale.format)),"object"==typeof e&&(this.startDate=t(e)),this.timePicker||(this.startDate=this.startDate.startOf("day")),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.round(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement),this.minDate&&this.startDate.isBefore(this.minDate)&&(this.startDate=this.minDate.clone(),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.round(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement)),this.maxDate&&this.startDate.isAfter(this.maxDate)&&(this.startDate=this.maxDate.clone(),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.floor(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement)),this.isShowing||this.updateElement(),this.updateMonthsInView()},setEndDate:function(e){"string"==typeof e&&(this.endDate=t(e,this.locale.format)),"object"==typeof e&&(this.endDate=t(e)),this.timePicker||(this.endDate=this.endDate.endOf("day")),this.timePicker&&this.timePickerIncrement&&this.endDate.minute(Math.round(this.endDate.minute()/this.timePickerIncrement)*this.timePickerIncrement),this.endDate.isBefore(this.startDate)&&(this.endDate=this.startDate.clone()),this.maxDate&&this.endDate.isAfter(this.maxDate)&&(this.endDate=this.maxDate.clone()),this.maxSpan&&this.startDate.clone().add(this.maxSpan).isBefore(this.endDate)&&(this.endDate=this.startDate.clone().add(this.maxSpan)),this.previousRightTime=this.endDate.clone(),this.container.find(".drp-selected").html(this.startDate.format(this.locale.format)+this.locale.separator+this.endDate.format(this.locale.format)),this.isShowing||this.updateElement(),this.updateMonthsInView()},isInvalidDate:function(){return!1},isCustomDate:function(){return!1},updateView:function(){this.timePicker&&(this.renderTimePicker("left"),this.renderTimePicker("right"),this.endDate?this.container.find(".right .calendar-time select").removeAttr("disabled").removeClass("disabled"):this.container.find(".right .calendar-time select").attr("disabled","disabled").addClass("disabled")),this.endDate&&this.container.find(".drp-selected").html(this.startDate.format(this.locale.format)+this.locale.separator+this.endDate.format(this.locale.format)),this.updateMonthsInView(),this.updateCalendars(),this.updateFormInputs()},updateMonthsInView:function(){if(this.endDate){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.startDate.format("YYYY-MM")==this.leftCalendar.month.format("YYYY-MM")||this.startDate.format("YYYY-MM")==this.rightCalendar.month.format("YYYY-MM"))&&(this.endDate.format("YYYY-MM")==this.leftCalendar.month.format("YYYY-MM")||this.endDate.format("YYYY-MM")==this.rightCalendar.month.format("YYYY-MM")))return;this.leftCalendar.month=this.startDate.clone().date(2),this.linkedCalendars||this.endDate.month()==this.startDate.month()&&this.endDate.year()==this.startDate.year()?this.rightCalendar.month=this.startDate.clone().date(2).add(1,"month"):this.rightCalendar.month=this.endDate.clone().date(2)}else this.leftCalendar.month.format("YYYY-MM")!=this.startDate.format("YYYY-MM")&&this.rightCalendar.month.format("YYYY-MM")!=this.startDate.format("YYYY-MM")&&(this.leftCalendar.month=this.startDate.clone().date(2),this.rightCalendar.month=this.startDate.clone().date(2).add(1,"month"));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.clone().date(2),this.leftCalendar.month=this.maxDate.clone().date(2).subtract(1,"month"))},updateCalendars:function(){if(this.timePicker){var t,e,n;if(this.endDate){if(t=parseInt(this.container.find(".left .hourselect").val(),10),e=parseInt(this.container.find(".left .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".left .minuteselect option:last").val(),10)),n=this.timePickerSeconds?parseInt(this.container.find(".left .secondselect").val(),10):0,!this.timePicker24Hour){var i=this.container.find(".left .ampmselect").val();"PM"===i&&t<12&&(t+=12),"AM"===i&&12===t&&(t=0)}}else if(t=parseInt(this.container.find(".right .hourselect").val(),10),e=parseInt(this.container.find(".right .minuteselect").val(),10),isNaN(e)&&(e=parseInt(this.container.find(".right .minuteselect option:last").val(),10)),n=this.timePickerSeconds?parseInt(this.container.find(".right .secondselect").val(),10):0,!this.timePicker24Hour){var i=this.container.find(".right .ampmselect").val();"PM"===i&&t<12&&(t+=12),"AM"===i&&12===t&&(t=0)}this.leftCalendar.month.hour(t).minute(e).second(n),this.rightCalendar.month.hour(t).minute(e).second(n)}this.renderCalendar("left"),this.renderCalendar("right"),this.container.find(".ranges li").removeClass("active"),null!=this.endDate&&this.calculateChosenLabel()},renderCalendar:function(n){var i="left"==n?this.leftCalendar:this.rightCalendar,o=i.month.month(),r=i.month.year(),a=i.month.hour(),s=i.month.minute(),l=i.month.second(),u=t([r,o]).daysInMonth(),c=t([r,o,1]),d=t([r,o,u]),h=t(c).subtract(1,"month").month(),f=t(c).subtract(1,"month").year(),p=t([f,h]).daysInMonth(),m=c.day(),i=[];i.firstDay=c,i.lastDay=d;for(var g=0;g<6;g++)i[g]=[];var v=p-m+this.locale.firstDay+1;v>p&&(v-=7),m==this.locale.firstDay&&(v=p-6);for(var y,b,w=t([f,h,v,12,s,l]),g=0,y=0,b=0;g<42;g++,y++,w=t(w).add(24,"hour"))g>0&&y%7==0&&(y=0,b++),i[b][y]=w.clone().hour(a).minute(s).second(l),w.hour(12),this.minDate&&i[b][y].format("YYYY-MM-DD")==this.minDate.format("YYYY-MM-DD")&&i[b][y].isBefore(this.minDate)&&"left"==n&&(i[b][y]=this.minDate.clone()),this.maxDate&&i[b][y].format("YYYY-MM-DD")==this.maxDate.format("YYYY-MM-DD")&&i[b][y].isAfter(this.maxDate)&&"right"==n&&(i[b][y]=this.maxDate.clone());"left"==n?this.leftCalendar.calendar=i:this.rightCalendar.calendar=i;var x="left"==n?this.minDate:this.startDate,_=this.maxDate,D=("left"==n?this.startDate:this.endDate,this.locale.direction,'');D+="",D+="",(this.showWeekNumbers||this.showISOWeekNumbers)&&(D+=""),x&&!x.isBefore(i.firstDay)||this.linkedCalendars&&"left"!=n?D+="":D+='';var k=this.locale.monthNames[i[1][1].month()]+i[1][1].format(" YYYY");if(this.showDropdowns){for(var S=i[1][1].month(),C=i[1][1].year(),M=_&&_.year()||this.maxYear,T=x&&x.year()||this.minYear,E=C==T,P=C==M,I='";for(var L='",k=I+L}if(D+='",_&&!_.isAfter(i.lastDay)||this.linkedCalendars&&"right"!=n&&!this.singleDatePicker?D+="":D+='',D+="",D+="",(this.showWeekNumbers||this.showISOWeekNumbers)&&(D+='"),e.each(this.locale.daysOfWeek,function(t,e){D+=""}),D+="",D+="",D+="",null==this.endDate&&this.maxSpan){var A=this.startDate.clone().add(this.maxSpan).endOf("day");_&&!A.isBefore(_)||(_=A)}for(var b=0;b<6;b++){D+="",this.showWeekNumbers?D+='":this.showISOWeekNumbers&&(D+='");for(var y=0;y<7;y++){var H=[];i[b][y].isSame(new Date,"day")&&H.push("today"),i[b][y].isoWeekday()>5&&H.push("weekend"),i[b][y].month()!=i[1][1].month()&&H.push("off","ends"),this.minDate&&i[b][y].isBefore(this.minDate,"day")&&H.push("off","disabled"),_&&i[b][y].isAfter(_,"day")&&H.push("off","disabled"),this.isInvalidDate(i[b][y])&&H.push("off","disabled"),i[b][y].format("YYYY-MM-DD")==this.startDate.format("YYYY-MM-DD")&&H.push("active","start-date"),null!=this.endDate&&i[b][y].format("YYYY-MM-DD")==this.endDate.format("YYYY-MM-DD")&&H.push("active","end-date"),null!=this.endDate&&i[b][y]>this.startDate&&i[b][y]'+i[b][y].date()+""}D+=""}D+="",D+="
'+k+"
'+this.locale.weekLabel+""+e+"
'+i[b][0].week()+"'+i[b][0].isoWeek()+"
",this.container.find(".drp-calendar."+n+" .calendar-table").html(D)},renderTimePicker:function(t){if("right"!=t||this.endDate){var e,n,i,o=this.maxDate;if(!this.maxSpan||this.maxDate&&!this.startDate.clone().add(this.maxSpan).isBefore(this.maxDate)||(o=this.startDate.clone().add(this.maxSpan)),"left"==t)n=this.startDate.clone(),i=this.minDate;else if("right"==t){n=this.endDate.clone(),i=this.startDate;var r=this.container.find(".drp-calendar.right .calendar-time");if(""!=r.html()&&(n.hour(isNaN(n.hour())?r.find(".hourselect option:selected").val():n.hour()),n.minute(isNaN(n.minute())?r.find(".minuteselect option:selected").val():n.minute()),n.second(isNaN(n.second())?r.find(".secondselect option:selected").val():n.second()),!this.timePicker24Hour)){var a=r.find(".ampmselect option:selected").val();"PM"===a&&n.hour()<12&&n.hour(n.hour()+12),"AM"===a&&12===n.hour()&&n.hour(0)}n.isBefore(this.startDate)&&(n=this.startDate.clone()),o&&n.isAfter(o)&&(n=o.clone())}e=' ",e+=': ",this.timePickerSeconds){e+=': "}if(!this.timePicker24Hour){e+='"}this.container.find(".drp-calendar."+t+" .calendar-time").html(e)}},updateFormInputs:function(){this.singleDatePicker||this.endDate&&(this.startDate.isBefore(this.endDate)||this.startDate.isSame(this.endDate))?this.container.find("button.applyBtn").removeAttr("disabled"):this.container.find("button.applyBtn").attr("disabled","disabled")},move:function(){var t,n={top:0,left:0},i=e(window).width();this.parentEl.is("body")||(n={top:this.parentEl.offset().top-this.parentEl.scrollTop(),left:this.parentEl.offset().left-this.parentEl.scrollLeft()},i=this.parentEl[0].clientWidth+this.parentEl.offset().left),t="up"==this.drops?this.element.offset().top-this.container.outerHeight()-n.top:this.element.offset().top+this.element.outerHeight()-n.top,this.container.css({top:0,left:0,right:"auto"});var o=this.container.outerWidth();if(this.container["up"==this.drops?"addClass":"removeClass"]("drop-up"),"left"==this.opens){var r=i-this.element.offset().left-this.element.outerWidth();o+r>e(window).width()?this.container.css({top:t,right:"auto",left:9}):this.container.css({top:t,right:r,left:"auto"})}else if("center"==this.opens){var a=this.element.offset().left-n.left+this.element.outerWidth()/2-o/2;a<0?this.container.css({top:t,right:"auto",left:9}):a+o>e(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:a,right:"auto"})}else{var a=this.element.offset().left-n.left;a+o>e(window).width()?this.container.css({top:t,left:"auto",right:0}):this.container.css({top:t,left:a,right:"auto"})}},show:function(t){this.isShowing||(this._outsideClickProxy=e.proxy(function(t){this.outsideClick(t)},this),e(document).on("mousedown.daterangepicker",this._outsideClickProxy).on("touchend.daterangepicker",this._outsideClickProxy).on("click.daterangepicker","[data-toggle=dropdown]",this._outsideClickProxy).on("focusin.daterangepicker",this._outsideClickProxy),e(window).on("resize.daterangepicker",e.proxy(function(t){this.move(t)},this)),this.oldStartDate=this.startDate.clone(),this.oldEndDate=this.endDate.clone(),this.previousRightTime=this.endDate.clone(),this.updateView(),this.container.show(),this.move(),this.element.trigger("show.daterangepicker",this),this.isShowing=!0)},hide:function(t){this.isShowing&&(this.endDate||(this.startDate=this.oldStartDate.clone(),this.endDate=this.oldEndDate.clone()),this.startDate.isSame(this.oldStartDate)&&this.endDate.isSame(this.oldEndDate)||this.callback(this.startDate.clone(),this.endDate.clone(),this.chosenLabel),this.updateElement(),e(document).off(".daterangepicker"),e(window).off(".daterangepicker"),this.container.hide(),this.element.trigger("hide.daterangepicker",this),this.isShowing=!1)},toggle:function(t){this.isShowing?this.hide():this.show()},outsideClick:function(t){var n=e(t.target);"focusin"==t.type||n.closest(this.element).length||n.closest(this.container).length||n.closest(".calendar-table").length||(this.hide(),this.element.trigger("outsideClick.daterangepicker",this))},showCalendars:function(){this.container.addClass("show-calendar"),this.move(),this.element.trigger("showCalendar.daterangepicker",this)},hideCalendars:function(){this.container.removeClass("show-calendar"),this.element.trigger("hideCalendar.daterangepicker",this)},clickRange:function(t){var e=t.target.getAttribute("data-range-key");if(this.chosenLabel=e,e==this.locale.customRangeLabel)this.showCalendars();else{var n=this.ranges[e];this.startDate=n[0],this.endDate=n[1],this.timePicker||(this.startDate.startOf("day"),this.endDate.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.clickApply()}},clickPrev:function(t){e(t.target).parents(".drp-calendar").hasClass("left")?(this.leftCalendar.month.subtract(1,"month"),this.linkedCalendars&&this.rightCalendar.month.subtract(1,"month")):this.rightCalendar.month.subtract(1,"month"),this.updateCalendars()},clickNext:function(t){e(t.target).parents(".drp-calendar").hasClass("left")?this.leftCalendar.month.add(1,"month"):(this.rightCalendar.month.add(1,"month"),this.linkedCalendars&&this.leftCalendar.month.add(1,"month")),this.updateCalendars()},hoverDate:function(t){if(e(t.target).hasClass("available")){var n=e(t.target).attr("data-title"),i=n.substr(1,1),o=n.substr(3,1),r=e(t.target).parents(".drp-calendar"),a=r.hasClass("left")?this.leftCalendar.calendar[i][o]:this.rightCalendar.calendar[i][o],s=this.leftCalendar,l=this.rightCalendar,u=this.startDate;this.endDate||this.container.find(".drp-calendar tbody td").each(function(t,n){if(!e(n).hasClass("week")){var i=e(n).attr("data-title"),o=i.substr(1,1),r=i.substr(3,1),c=e(n).parents(".drp-calendar"),d=c.hasClass("left")?s.calendar[o][r]:l.calendar[o][r];d.isAfter(u)&&d.isBefore(a)||d.isSame(a,"day")?e(n).addClass("in-range"):e(n).removeClass("in-range")}})}},clickDate:function(t){if(e(t.target).hasClass("available")){var n=e(t.target).attr("data-title"),i=n.substr(1,1),o=n.substr(3,1),r=e(t.target).parents(".drp-calendar"),a=r.hasClass("left")?this.leftCalendar.calendar[i][o]:this.rightCalendar.calendar[i][o];if(this.endDate||a.isBefore(this.startDate,"day")){if(this.timePicker){var s=parseInt(this.container.find(".left .hourselect").val(),10);if(!this.timePicker24Hour){var l=this.container.find(".left .ampmselect").val();"PM"===l&&s<12&&(s+=12),"AM"===l&&12===s&&(s=0)}var u=parseInt(this.container.find(".left .minuteselect").val(),10);isNaN(u)&&(u=parseInt(this.container.find(".left .minuteselect option:last").val(),10));var c=this.timePickerSeconds?parseInt(this.container.find(".left .secondselect").val(),10):0;a=a.clone().hour(s).minute(u).second(c)}this.endDate=null,this.setStartDate(a.clone())}else if(!this.endDate&&a.isBefore(this.startDate))this.setEndDate(this.startDate.clone());else{if(this.timePicker){var s=parseInt(this.container.find(".right .hourselect").val(),10);if(!this.timePicker24Hour){var l=this.container.find(".right .ampmselect").val();"PM"===l&&s<12&&(s+=12),"AM"===l&&12===s&&(s=0)}var u=parseInt(this.container.find(".right .minuteselect").val(),10);isNaN(u)&&(u=parseInt(this.container.find(".right .minuteselect option:last").val(),10));var c=this.timePickerSeconds?parseInt(this.container.find(".right .secondselect").val(),10):0;a=a.clone().hour(s).minute(u).second(c)}this.setEndDate(a.clone()),this.autoApply&&(this.calculateChosenLabel(),this.clickApply())}this.singleDatePicker&&(this.setEndDate(this.startDate),this.timePicker||this.clickApply()),this.updateView(),t.stopPropagation()}},calculateChosenLabel:function(){var t=!0,e=0;for(var n in this.ranges){if(this.timePicker){var i=this.timePickerSeconds?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD HH:mm";if(this.startDate.format(i)==this.ranges[n][0].format(i)&&this.endDate.format(i)==this.ranges[n][1].format(i)){t=!1,this.chosenLabel=this.container.find(".ranges li:eq("+e+")").addClass("active").attr("data-range-key");break}}else if(this.startDate.format("YYYY-MM-DD")==this.ranges[n][0].format("YYYY-MM-DD")&&this.endDate.format("YYYY-MM-DD")==this.ranges[n][1].format("YYYY-MM-DD")){t=!1,this.chosenLabel=this.container.find(".ranges li:eq("+e+")").addClass("active").attr("data-range-key");break}e++}t&&(this.showCustomRangeLabel?this.chosenLabel=this.container.find(".ranges li:last").addClass("active").attr("data-range-key"):this.chosenLabel=null,this.showCalendars())},clickApply:function(t){this.hide(),this.element.trigger("apply.daterangepicker",this)},clickCancel:function(t){this.startDate=this.oldStartDate,this.endDate=this.oldEndDate,this.hide(),this.element.trigger("cancel.daterangepicker",this)},monthOrYearChanged:function(t){var n=e(t.target).closest(".drp-calendar").hasClass("left"),i=n?"left":"right",o=this.container.find(".drp-calendar."+i),r=parseInt(o.find(".monthselect").val(),10),a=o.find(".yearselect").val();n||(athis.maxDate.year()||a==this.maxDate.year()&&r>this.maxDate.month())&&(r=this.maxDate.month(),a=this.maxDate.year()),n?(this.leftCalendar.month.month(r).year(a),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.clone().add(1,"month"))):(this.rightCalendar.month.month(r).year(a),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.clone().subtract(1,"month"))),this.updateCalendars()},timeChanged:function(t){var n=e(t.target).closest(".drp-calendar"),i=n.hasClass("left"),o=parseInt(n.find(".hourselect").val(),10),r=parseInt(n.find(".minuteselect").val(),10);isNaN(r)&&(r=parseInt(n.find(".minuteselect option:last").val(),10));var a=this.timePickerSeconds?parseInt(n.find(".secondselect").val(),10):0;if(!this.timePicker24Hour){var s=n.find(".ampmselect").val();"PM"===s&&o<12&&(o+=12),"AM"===s&&12===o&&(o=0)}if(i){var l=this.startDate.clone();l.hour(o),l.minute(r),l.second(a),this.setStartDate(l),this.singleDatePicker?this.endDate=this.startDate.clone():this.endDate&&this.endDate.format("YYYY-MM-DD")==l.format("YYYY-MM-DD")&&this.endDate.isBefore(l)&&this.setEndDate(l.clone())}else if(this.endDate){var u=this.endDate.clone();u.hour(o),u.minute(r),u.second(a),this.setEndDate(u)}this.updateCalendars(),this.updateFormInputs(),this.renderTimePicker("left"),this.renderTimePicker("right")},elementChanged:function(){if(this.element.is("input")&&this.element.val().length){var e=this.element.val().split(this.locale.separator),n=null,i=null;2===e.length&&(n=t(e[0],this.locale.format),i=t(e[1],this.locale.format)),(this.singleDatePicker||null===n||null===i)&&(n=t(this.element.val(),this.locale.format),i=n),n.isValid()&&i.isValid()&&(this.setStartDate(n),this.setEndDate(i),this.updateView())}},keydown:function(t){9!==t.keyCode&&13!==t.keyCode||this.hide(),27===t.keyCode&&(t.preventDefault(),t.stopPropagation(),this.hide())},updateElement:function(){if(this.element.is("input")&&this.autoUpdateInput){var t=this.startDate.format(this.locale.format);this.singleDatePicker||(t+=this.locale.separator+this.endDate.format(this.locale.format)),t!==this.element.val()&&this.element.val(t).trigger("change")}},remove:function(){this.container.remove(),this.element.off(".daterangepicker"),this.element.removeData()}},e.fn.daterangepicker=function(t,i){var o=e.extend(!0,{},e.fn.daterangepicker.defaultOptions,t);return this.each(function(){var t=e(this);t.data("daterangepicker")&&t.data("daterangepicker").remove(),t.data("daterangepicker",new n(t,o,i))}),this},n})},R6CI:function(t,e){},RvrG:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=n("7t+N"),s=n.n(a),l=n("ITav"),u=function(){function t(t,e){for(var n=0;n0&&(o.on("hidden.bs.modal",function(){o.hasClass("modal-danger")&&o.removeClass("modal-danger")}),s()(t).find("#form_modal").hasClass("modal-danger")&&o.addClass("modal-danger"),s()("#remote_form_modal .modal-content").replaceWith(s()(t).find("#form_modal .modal-content")),e.getContainer().getPlugin("date-time-picker").activateDateTimePicker(n),e.getContainer().getPlugin("autocomplete").activateAutocomplete(n+" .js-autocomplete"),s()(".selectpicker").selectpicker("refresh"));var r=s()(t).find("div.alert");r.length>0&&s()("#remote_form_modal .modal-body").prepend(r);var a=s.a.fn.modal.Constructor.prototype.enforceFocus;s.a.fn.modal.Constructor.prototype.enforceFocus=function(){},o.on("hidden.bs.modal",function(){s.a.fn.modal.Constructor.prototype.enforceFocus=a}),o.on("shown.bs.modal",function(){s()(this).find("input[type=text],textarea,select").filter(':not("[data-datetimepicker=on]")').filter(":visible:first").focus().delay(1e3).focus()}),o.modal("show"),i=s()(n),i.on("submit",function(t){var r=s()(n+" button[type=submit]").button("loading"),a=i.attr("data-form-event"),l=e.getContainer().getPlugin("event"),u=e.getContainer().getPlugin("alert");t.preventDefault(),t.stopPropagation(),s.a.ajax({url:i.attr("action"),type:i.attr("method"),data:i.serialize(),success:function(t){r.button("reset");var n=s()(t).find("#form_modal .modal-content .has-error").length>0,c=s()(t).find("#form_modal .modal-content ul.list-unstyled li.text-danger").length>0,d=s()(t).find("div.alert-error").length>0;if(n||c||d)e._openFormInModal(t);else{l.trigger(a);var h=i.attr("data-msg-success");if(null===h||void 0===h){var f=s()(t).find("section.content div.row div.alert.alert-success");if(f.length>0){var p=f.contents();3===p.length&&(h=p[2].textContent)}}null!==h&&void 0!==h||(h="action.update.success"),o.modal("hide"),u.success(h)}return!1},error:function(t,e){var n=i.attr("data-msg-error");null!==n&&void 0!==n||(n="action.update.error"),t.responseJSON&&t.responseJSON.message?e=t.responseJSON.message:t.status&&t.statusText&&(e="["+t.status+"] "+t.statusText),u.error(n,e)}})})}}]),e}(l.a);e.a=c},T4Pq:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var a=n("7t+N"),s=n.n(a),l=n("4klR"),u=function(){function t(t,e){for(var n=0;n'+i.text()+""),s.a.each(e,function(t,e){n.append('")}),n.trigger("change"),s()(".selectpicker").selectpicker("refresh")}}]),e}(l.a);e.a=c},TqGs:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=n("+NP7"),r=n("awG4"),a=n("4klR"),s=function(){function t(t,e){for(var n=0;n false, 'include_rate' => $this->isGranted('edit_rate', $timesheet), 'include_exported' => $this->isGranted('edit_export', $timesheet), + 'include_datetime' => !$this->configuration->isPunchInOut(), 'date_format' => self::DATE_FORMAT, ]); @@ -352,6 +353,7 @@ class TimesheetController extends BaseApiController 'csrf_protection' => false, 'include_rate' => $this->isGranted('edit_rate', $timesheet), 'include_exported' => $this->isGranted('edit_export', $timesheet), + 'include_datetime' => !$this->configuration->isPunchInOut(), 'date_format' => self::DATE_FORMAT, ]); diff --git a/src/Configuration/TimesheetConfiguration.php b/src/Configuration/TimesheetConfiguration.php index 62e004bb..3c5db348 100644 --- a/src/Configuration/TimesheetConfiguration.php +++ b/src/Configuration/TimesheetConfiguration.php @@ -13,6 +13,7 @@ class TimesheetConfiguration implements SystemBundleConfiguration { public const MODE_DURATION_ONLY = 'duration_only'; public const MODE_DEFAULT = 'default'; + public const MODE_PUNCH_IN_OUT = 'punch'; use StringAccessibleConfigTrait; @@ -31,6 +32,11 @@ class TimesheetConfiguration implements SystemBundleConfiguration return $this->find('mode') === self::MODE_DURATION_ONLY; } + public function isPunchInOut(): bool + { + return $this->find('mode') === self::MODE_PUNCH_IN_OUT; + } + public function isMarkdownEnabled(): bool { return (bool) $this->find('markdown_content'); diff --git a/src/Controller/TimesheetAbstractController.php b/src/Controller/TimesheetAbstractController.php index db4991c1..31974c48 100644 --- a/src/Controller/TimesheetAbstractController.php +++ b/src/Controller/TimesheetAbstractController.php @@ -146,44 +146,7 @@ abstract class TimesheetAbstractController extends AbstractController $entry->setUser($this->getUser()); $entry->setBegin($this->dateTime->createDateTime()); - $start = $request->get('begin'); - if ($start !== null) { - $start = $this->dateTime->createDateTimeFromFormat('Y-m-d', $start); - if ($start !== false) { - $entry->setBegin($start); - - // only check for an end date if a begin date was given - $end = $request->get('end'); - if ($end !== null) { - $end = $this->dateTime->createDateTimeFromFormat('Y-m-d', $end); - if ($end !== false) { - $start->setTime(10, 0, 0); - $end->setTime(18, 0, 0); - - $entry->setEnd($end); - $entry->setDuration($end->getTimestamp() - $start->getTimestamp()); - } - } - } - } - - $from = $request->get('from'); - if ($from !== null) { - $from = $this->dateTime->createDateTime($from); - if ($from !== false) { - $entry->setBegin($from); - - // only check for an end datetime if a begin datetime was given - $to = $request->get('to'); - if ($to !== null) { - $to = $this->dateTime->createDateTime($to); - if ($to !== false) { - $entry->setEnd($to); - $entry->setDuration($to->getTimestamp() - $from->getTimestamp()); - } - } - } - } + $this->setBeginEndFromRequest($request, $entry); if ($request->query->get('project')) { $project = $projectRepository->find($request->query->get('project')); @@ -225,6 +188,52 @@ abstract class TimesheetAbstractController extends AbstractController ]); } + protected function setBeginEndFromRequest(Request $request, Timesheet $entry) + { + if ($this->configuration->isPunchInOut()) { + return; + } + + $start = $request->get('begin'); + if ($start !== null) { + $start = $this->dateTime->createDateTimeFromFormat('Y-m-d', $start); + if ($start !== false) { + $entry->setBegin($start); + + // only check for an end date if a begin date was given + $end = $request->get('end'); + if ($end !== null) { + $end = $this->dateTime->createDateTimeFromFormat('Y-m-d', $end); + if ($end !== false) { + $start->setTime(10, 0, 0); + $end->setTime(18, 0, 0); + + $entry->setEnd($end); + $entry->setDuration($end->getTimestamp() - $start->getTimestamp()); + } + } + } + } + + $from = $request->get('from'); + if ($from !== null) { + $from = $this->dateTime->createDateTime($from); + if ($from !== false) { + $entry->setBegin($from); + + // only check for an end datetime if a begin datetime was given + $to = $request->get('to'); + if ($to !== null) { + $to = $this->dateTime->createDateTime($to); + if ($to !== false) { + $entry->setEnd($to); + $entry->setDuration($to->getTimestamp() - $from->getTimestamp()); + } + } + } + } + } + /** * @param Request $request * @param string $renderTemplate @@ -274,10 +283,13 @@ abstract class TimesheetAbstractController extends AbstractController */ protected function getCreateForm(Timesheet $entry) { - return $this->createForm(TimesheetEditForm::class, $entry, [ + return $this->createForm($this->getCreateFormClassName(), $entry, [ 'action' => $this->generateUrl($this->getCreateRoute()), 'include_rate' => $this->isGranted('edit_rate', $entry), + 'include_exported' => $this->isGranted('edit_export', $entry), 'include_user' => $this->includeUserInForms(), + 'use_duration' => $this->configuration->isDurationOnly(), + 'include_datetime' => !$this->configuration->isPunchInOut(), 'customer' => true, ]); } @@ -289,7 +301,7 @@ abstract class TimesheetAbstractController extends AbstractController */ protected function getEditForm(Timesheet $entry, $page) { - return $this->createForm(TimesheetEditForm::class, $entry, [ + return $this->createForm($this->getEditFormClassName(), $entry, [ 'action' => $this->generateUrl($this->getEditRoute(), [ 'id' => $entry->getId(), 'page' => $page, @@ -297,6 +309,8 @@ abstract class TimesheetAbstractController extends AbstractController 'include_rate' => $this->isGranted('edit_rate', $entry), 'include_exported' => $this->isGranted('edit_export', $entry), 'include_user' => $this->includeUserInForms(), + 'include_datetime' => !$this->configuration->isPunchInOut(), + 'use_duration' => $this->configuration->isDurationOnly(), 'customer' => true, ]); } @@ -316,6 +330,16 @@ abstract class TimesheetAbstractController extends AbstractController ]); } + protected function getCreateFormClassName() + { + return TimesheetEditForm::class; + } + + protected function getEditFormClassName() + { + return TimesheetEditForm::class; + } + protected function includeSummary(): bool { return (bool) $this->getUser()->getPreferenceValue('timesheet.daily_stats', false); diff --git a/src/Controller/TimesheetTeamController.php b/src/Controller/TimesheetTeamController.php index 16d3939b..654620ff 100644 --- a/src/Controller/TimesheetTeamController.php +++ b/src/Controller/TimesheetTeamController.php @@ -10,6 +10,7 @@ namespace App\Controller; use App\Entity\Timesheet; +use App\Form\TimesheetAdminEditForm; use App\Repository\ActivityRepository; use App\Repository\ProjectRepository; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; @@ -74,6 +75,16 @@ class TimesheetTeamController extends TimesheetAbstractController return $this->create($request, 'timesheet-team/edit.html.twig', $projectRepository, $activityRepository); } + protected function getCreateFormClassName() + { + return TimesheetAdminEditForm::class; + } + + protected function getEditFormClassName() + { + return TimesheetAdminEditForm::class; + } + protected function includeUserInForms(): bool { return true; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index f53af8e6..ca9e7ed7 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -80,9 +80,9 @@ class Configuration implements ConfigurationInterface ->defaultValue('default') ->validate() ->ifTrue(function ($value) { - return !in_array($value, ['default', 'duration_only']); + return !in_array($value, ['default', 'duration_only', 'punch']); }) - ->thenInvalid('Chosen timesheet mode is invalid, allowed values: default, duration_only') + ->thenInvalid('Chosen timesheet mode is invalid, allowed values: default, duration_only, punch') ->end() ->end() ->booleanNode('markdown_content') diff --git a/src/Form/TimesheetAdminEditForm.php b/src/Form/TimesheetAdminEditForm.php new file mode 100644 index 00000000..a2835fe0 --- /dev/null +++ b/src/Form/TimesheetAdminEditForm.php @@ -0,0 +1,23 @@ +customers = $customer; $this->projects = $project; $this->dateTime = $dateTime; - $this->configuration = $config; } /** @@ -80,10 +73,10 @@ class TimesheetEditForm extends AbstractType $project = null; $customer = null; $currency = false; - $end = null; $begin = null; $customerCount = $this->customers->countCustomer(true); $projectCount = $this->projects->countProject(true); + $timezone = $this->dateTime->getTimezone()->getName(); $isNew = true; if (isset($options['data'])) { @@ -106,14 +99,9 @@ class TimesheetEditForm extends AbstractType $currency = $customer->getCurrency(); } - $begin = $entry->getBegin(); - $end = $entry->getEnd(); - } - - $timezone = $this->dateTime->getTimezone()->getName(); - - if (null !== $begin) { - $timezone = $begin->getTimezone()->getName(); + if (null !== ($begin = $entry->getBegin())) { + $timezone = $begin->getTimezone()->getName(); + } } $dateTimeOptions = [ @@ -126,44 +114,49 @@ class TimesheetEditForm extends AbstractType $dateTimeOptions['format'] = $options['date_format']; } - if ($isNew || null === $end || !$this->configuration->isDurationOnly()) { + if ($this->showTimeFields($options)) { $this->addBegin($builder, $dateTimeOptions); + + if ($options['use_duration']) { + $this->addDuration($builder); + } else { + $this->addEnd($builder, $dateTimeOptions); + } } - if ($this->configuration->isDurationOnly()) { - $this->addDuration($builder); - } else { - $this->addEnd($builder, $dateTimeOptions); - } - - $projectOptions = []; - - if ($customerCount < 2) { - $projectOptions['group_by'] = null; - } elseif ($options['customer']) { + if ($this->showCustomer($options, $isNew, $customerCount)) { $this->addCustomer($builder, $customer); } - if ($projectCount <= 1) { - $projectOptions['group_by'] = null; - } - - $this->addProject($builder, $projectOptions, $project, $customer); + $this->addProject($builder, $customerCount, $projectCount, $project, $customer); $this->addActivity($builder, $activity, $project); $this->addDescription($builder); $this->addTags($builder); + $this->addRates($builder, $currency, $options); + $this->addUser($builder, $options); + $this->addExported($builder, $options); + } - if ($options['include_rate']) { - $this->addRates($builder, $currency); + protected function showCustomer(array $options, bool $isNew, int $customerCount): bool + { + if (!$isNew && $options['customer']) { + return true; } - if ($options['include_user']) { - $this->addUser($builder); + if ($customerCount < 2) { + return false; } - if ($options['include_exported']) { - $this->addExported($builder); + if (!$options['customer']) { + return false; } + + return true; + } + + protected function showTimeFields(array $options): bool + { + return $options['include_datetime']; } protected function addCustomer(FormBuilderInterface $builder, ?Customer $customer = null) @@ -181,8 +174,18 @@ class TimesheetEditForm extends AbstractType ]); } - protected function addProject(FormBuilderInterface $builder, array $projectOptions, ?Project $project = null, ?Customer $customer = null) + protected function addProject(FormBuilderInterface $builder, int $customerCount, int $projectCount, ?Project $project = null, ?Customer $customer = null) { + $projectOptions = []; + + if ($customerCount < 2) { + $projectOptions['group_by'] = null; + } + + if ($projectCount < 2) { + $projectOptions['group_by'] = null; + } + $builder ->add( 'project', @@ -322,8 +325,12 @@ class TimesheetEditForm extends AbstractType ]); } - protected function addRates(FormBuilderInterface $builder, $currency) + protected function addRates(FormBuilderInterface $builder, $currency, array $options) { + if (!$options['include_rate']) { + return; + } + $builder ->add('fixedRate', FixedRateType::class, [ 'currency' => $currency, @@ -333,13 +340,21 @@ class TimesheetEditForm extends AbstractType ]); } - protected function addUser(FormBuilderInterface $builder) + protected function addUser(FormBuilderInterface $builder, array $options) { + if (!$options['include_user']) { + return; + } + $builder->add('user', UserType::class); } - protected function addExported(FormBuilderInterface $builder) + protected function addExported(FormBuilderInterface $builder, array $options) { + if (!$options['include_exported']) { + return; + } + $builder->add('exported', YesNoType::class, [ 'label' => 'label.exported' ]); @@ -362,6 +377,8 @@ class TimesheetEditForm extends AbstractType 'method' => 'POST', 'date_format' => null, 'customer' => false, // for API usage + 'use_duration' => false, // duration instead of end (for duration_only mode) + 'include_datetime' => true, 'attr' => [ 'data-form-event' => 'kimai.timesheetUpdate', 'data-msg-success' => 'action.update.success', diff --git a/src/Form/Type/TimesheetModeType.php b/src/Form/Type/TimesheetModeType.php index e254e6ce..748fa18b 100644 --- a/src/Form/Type/TimesheetModeType.php +++ b/src/Form/Type/TimesheetModeType.php @@ -28,6 +28,7 @@ class TimesheetModeType extends AbstractType 'label' => 'label.timesheet.mode', 'choices' => [ 'label.timesheet.mode_default' => TimesheetConfiguration::MODE_DEFAULT, + 'label.timesheet.mode_punch' => TimesheetConfiguration::MODE_PUNCH_IN_OUT, 'label.timesheet.mode_duration_only' => TimesheetConfiguration::MODE_DURATION_ONLY, ], ]); diff --git a/src/Twig/TimesheetConfigExtension.php b/src/Twig/TimesheetConfigExtension.php index c7f88ec0..266e3ad4 100644 --- a/src/Twig/TimesheetConfigExtension.php +++ b/src/Twig/TimesheetConfigExtension.php @@ -32,6 +32,7 @@ class TimesheetConfigExtension extends AbstractExtension { return [ new TwigFunction('is_duration_only', [$this, 'isDurationOnly']), + new TwigFunction('is_punch_mode', [$this, 'isPunchInOut']), ]; } @@ -39,4 +40,9 @@ class TimesheetConfigExtension extends AbstractExtension { return $this->configuration->isDurationOnly(); } + + public function isPunchInOut(): bool + { + return $this->configuration->isPunchInOut(); + } } diff --git a/templates/calendar/user.html.twig b/templates/calendar/user.html.twig index f2baa1bf..74de14e1 100644 --- a/templates/calendar/user.html.twig +++ b/templates/calendar/user.html.twig @@ -153,11 +153,11 @@ html: true }); }, - {% if is_granted('create_own_timesheet') %} - // day-clicks are always triggered, unless a selection was created - // so clicking in a day (month view) or any slot (week and day view) will trigger a dayClick - // BEFORE triggering a select - make sure not two create dialogs are requested + {% if not is_punch_mode() and is_granted('create_own_timesheet') %} dayClick: function(date, jsEvent, view) { + // day-clicks are always triggered, unless a selection was created + // so clicking in a day (month view) or any slot (week and day view) will trigger a dayClick + // BEFORE triggering a select - make sure not two create dialogs are requested if(view.type !== 'month') { return; } @@ -177,8 +177,8 @@ var createUrl = '{{ path('timesheet_create') }}' + '?from=' + start.format() + '&to=' + end.format(); kimai.getPlugin('modal').openUrlInModal(createUrl); }, - {% endif %} - {% if is_granted('edit_own_timesheet') %} + {% endif %} + {% if is_granted('edit_own_timesheet') %} eventClick: function(eventObj, jsEvent, view) { if (eventObj.source.ajaxSettings !== undefined) { jsEvent.preventDefault(); @@ -187,6 +187,7 @@ var editUrl = '{{ path('timesheet_edit', {id: '-XX-'}) }}'.replace('-XX-', eventObj.id); kimai.getPlugin('modal').openUrlInModal(editUrl); }, + {% if not is_punch_mode() %} editable: true, eventDragStart: function(event, jsEvent, ui, view) { window.hidePopover = true; @@ -203,6 +204,7 @@ }, eventResize: changeHandler, {% endif %} + {% endif %} /* slotDuration: '00:30:00', // TODO make me configurable */ diff --git a/tests/Controller/TimesheetTeamControllerTest.php b/tests/Controller/TimesheetTeamControllerTest.php index d761cabf..88666542 100644 --- a/tests/Controller/TimesheetTeamControllerTest.php +++ b/tests/Controller/TimesheetTeamControllerTest.php @@ -120,9 +120,9 @@ class TimesheetTeamControllerTest extends ControllerBaseTest $this->request($client, '/team/timesheet/create'); $this->assertTrue($client->getResponse()->isSuccessful()); - $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form(); + $form = $client->getCrawler()->filter('form[name=timesheet_admin_edit_form]')->form(); $client->submit($form, [ - 'timesheet_edit_form' => [ + 'timesheet_admin_edit_form' => [ 'description' => 'Testing is fun!', 'project' => 1, 'activity' => 1, @@ -170,9 +170,9 @@ class TimesheetTeamControllerTest extends ControllerBaseTest 'Could not find link to documentation' ); - $form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form(); + $form = $client->getCrawler()->filter('form[name=timesheet_admin_edit_form]')->form(); $client->submit($form, [ - 'timesheet_edit_form' => [ + 'timesheet_admin_edit_form' => [ 'description' => 'foo-bar', 'tags' => 'foo,bar, testing, hello world,,', 'user' => $teamlead->getId() diff --git a/tests/Twig/TimesheetConfigExtensionTest.php b/tests/Twig/TimesheetConfigExtensionTest.php index 158c5158..86b2ff16 100644 --- a/tests/Twig/TimesheetConfigExtensionTest.php +++ b/tests/Twig/TimesheetConfigExtensionTest.php @@ -25,8 +25,9 @@ class TimesheetConfigExtensionTest extends TestCase $config = new TimesheetConfiguration($loader, ['mode' => 'duration_only']); $sut = new TimesheetConfigExtension($config); $filters = $sut->getFunctions(); - $this->assertCount(1, $filters); + $this->assertCount(2, $filters); $this->assertEquals('is_duration_only', $filters[0]->getName()); + $this->assertEquals('is_punch_mode', $filters[1]->getName()); } public function testIsDurationOnly() @@ -35,6 +36,7 @@ class TimesheetConfigExtensionTest extends TestCase $config = new TimesheetConfiguration($loader, ['mode' => 'duration_only']); $sut = new TimesheetConfigExtension($config); $this->assertTrue($sut->isDurationOnly()); + $this->assertFalse($sut->isPunchInOut()); } public function testIsNotDurationOnly() @@ -43,5 +45,15 @@ class TimesheetConfigExtensionTest extends TestCase $config = new TimesheetConfiguration($loader, ['mode' => 'default']); $sut = new TimesheetConfigExtension($config); $this->assertFalse($sut->isDurationOnly()); + $this->assertFalse($sut->isPunchInOut()); + } + + public function testIsPunchInOut() + { + $loader = $this->getMockBuilder(ConfigLoaderInterface::class)->getMock(); + $config = new TimesheetConfiguration($loader, ['mode' => 'punch']); + $sut = new TimesheetConfigExtension($config); + $this->assertFalse($sut->isDurationOnly()); + $this->assertTrue($sut->isPunchInOut()); } } diff --git a/translations/messages.sv.xliff b/translations/messages.sv.xliff index 5c83228b..2a2af808 100644 --- a/translations/messages.sv.xliff +++ b/translations/messages.sv.xliff @@ -628,10 +628,6 @@ För närvarande har %user% användare %records% tidsrekord som räknas upp till ROLE_USER Användare - - ROLE_CUSTOMER - Kund -