From fea3495098009325242fcf508a8298c3fd1efb36 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Wed, 22 May 2019 22:28:29 +0200 Subject: [PATCH] lock exported timesheets (#798) --- .scrutinizer.yml | 2 +- UPGRADING.md | 5 +- assets/js/plugins/KimaiAjaxModalForm.js | 10 ++- config/packages/kimai.yaml | 4 +- public/build/app.js | 2 +- public/build/manifest.json | 2 +- src/API/TimesheetController.php | 48 +++++++++++ src/Command/CreateReleaseCommand.php | 2 + src/Command/KimaiImporterCommand.php | 1 + src/Command/ResetCommand.php | 5 ++ src/Twig/Extensions.php | 1 + src/Voter/TimesheetVoter.php | 40 +++++++-- templates/export/index.html.twig | 81 +++++++++---------- templates/macros/widgets.html.twig | 10 ++- templates/timesheet-team/edit.html.twig | 3 + templates/timesheet/edit.html.twig | 3 + tests/API/TimesheetControllerTest.php | 76 +++++++++++++++++ .../SqliteSessionInitSubscriberTest.php | 77 ++++++++++++++++++ tests/Voter/AbstractVoterTest.php | 4 +- tests/Voter/TimesheetVoterTest.php | 61 +++++++++++++- translations/flashmessages.de.xliff | 8 ++ translations/flashmessages.en.xliff | 8 ++ 22 files changed, 386 insertions(+), 67 deletions(-) create mode 100644 tests/Doctrine/SqliteSessionInitSubscriberTest.php diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 150b79fb1f..b16e2c3573 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -35,6 +35,6 @@ filter: - 'vendor/' build_failure_conditions: - - 'project.metric("scrutinizer.quality", < 9.30)' + - 'project.metric("scrutinizer.quality", < 9.0)' - 'project.metric("scrutinizer.test_coverage", < 0.9)' - 'project.metric_change("scrutinizer.test_coverage", < -0.01)' \ No newline at end of file diff --git a/UPGRADING.md b/UPGRADING.md index 81277fbd49..c22ac8ee73 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -22,11 +22,12 @@ And make sure to **create a backup before you start**. Follow the normal update and database migration process (see above). -### Apply necessary changes to your `local.yaml`: +### Apply necessary changes to your local.yaml: -New permissions are available: +New permissions are available. If you configured custom permissions in `local.yaml`, you have to add those, otherwise you can't use the new features: - `view_tag` - view all tags - `delete_tag` - delete tags +- `edit_exported_timesheet` - allows to edit records which were exported ### BC BREAKS diff --git a/assets/js/plugins/KimaiAjaxModalForm.js b/assets/js/plugins/KimaiAjaxModalForm.js index 9141ea16e2..6dc66cd9c6 100644 --- a/assets/js/plugins/KimaiAjaxModalForm.js +++ b/assets/js/plugins/KimaiAjaxModalForm.js @@ -52,7 +52,10 @@ export default class KimaiAjaxModalForm extends KimaiClickHandlerReducedInTableR // the modal that we use to render the form in let formIdentifier = '#remote_form_modal .modal-content form'; + // if any of these is found in a response, the form will be re-displayed let flashErrorIdentifier = 'div.alert-error'; + // messages to show above the form + let flashMessageIdentifier = 'div.alert'; let form = jQuery(formIdentifier); let remoteModal = jQuery('#remote_form_modal'); @@ -88,10 +91,9 @@ export default class KimaiAjaxModalForm extends KimaiClickHandlerReducedInTableR } // show error flash messages - if (jQuery(html).find(flashErrorIdentifier).length > 0) { - jQuery('#remote_form_modal .modal-body').prepend( - jQuery(html).find(flashErrorIdentifier) - ); + let flashMessages = jQuery(html).find(flashMessageIdentifier); + if (flashMessages.length > 0) { + jQuery('#remote_form_modal .modal-body').prepend(flashMessages); } // ----------------------------------------------------------------------- diff --git a/config/packages/kimai.yaml b/config/packages/kimai.yaml index 19bc1e1f29..521d131a91 100644 --- a/config/packages/kimai.yaml +++ b/config/packages/kimai.yaml @@ -101,8 +101,8 @@ kimai: # adding single permissions to user roles, extending the definition from "sets" ("role name" = [array of "permissions"]) ROLE_USER: [] ROLE_TEAMLEAD: [view_invoice_template,create_invoice_template,edit_invoice_template,view_rate_own_timesheet,view_rate_other_timesheet,hourly-rate_own_profile] - ROLE_ADMIN: [hourly-rate_own_profile] - ROLE_SUPER_ADMIN: [hourly-rate_own_profile,hourly-rate_other_profile,delete_own_profile,roles_own_profile,system_information,system_actions,system_configuration,plugins] + ROLE_ADMIN: [hourly-rate_own_profile,edit_exported_timesheet] + ROLE_SUPER_ADMIN: [hourly-rate_own_profile,hourly-rate_other_profile,delete_own_profile,roles_own_profile,system_information,system_actions,system_configuration,plugins,edit_exported_timesheet] # -------------------------------------------------------------------------------- diff --git a/public/build/app.js b/public/build/app.js index 6ec4ef2c0a..ff6040b254 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")),s()(t).find("div.alert-error").length>0&&s()("#remote_form_modal .modal-body").prepend(s()(t).find("div.alert-error"));var r=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=r}),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;nviewHandler->handle($view); } + + /** + * Switch the export state of a timesheet record to (un-)lock it + * + * @SWG\Response( + * response=200, + * description="Switches the exported state on the record and therefor locks / unlocks it for further updates. Needs edit_export_*_timesheet permission.", + * @SWG\Schema(ref="#/definitions/TimesheetEntity") + * ) + * @SWG\Parameter( + * name="id", + * in="path", + * type="integer", + * description="Timesheet record ID to switch export state", + * required=true, + * ) + * + * @Security("is_granted('edit_export_own_timesheet') or is_granted('edit_export_other_timesheet')") + * + * @param int $id + * @return Response + */ + public function exportAction($id) + { + /** @var Timesheet $timesheet */ + $timesheet = $this->repository->find($id); + + if (null === $timesheet) { + throw new NotFoundException(); + } + + if (!$this->isGranted('edit_export', $timesheet)) { + throw new AccessDeniedHttpException( + sprintf('You are not allowed to %s this timesheet', ($timesheet->isExported() ? 'unlock' : 'lock')) + ); + } + + $timesheet->setExported(!$timesheet->isExported()); + + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->persist($timesheet); + $entityManager->flush(); + + $view = new View($timesheet, 200); + $view->getContext()->setGroups(['Default', 'Entity', 'Timesheet']); + + return $this->viewHandler->handle($view); + } } diff --git a/src/Command/CreateReleaseCommand.php b/src/Command/CreateReleaseCommand.php index 363d544178..971d213e85 100644 --- a/src/Command/CreateReleaseCommand.php +++ b/src/Command/CreateReleaseCommand.php @@ -18,6 +18,8 @@ /** * Command used to create a release package with pre-installed composer, SQLite database and user. + * + * @codeCoverageIgnore */ class CreateReleaseCommand extends Command { diff --git a/src/Command/KimaiImporterCommand.php b/src/Command/KimaiImporterCommand.php index c4115135c3..9b19f4e30b 100644 --- a/src/Command/KimaiImporterCommand.php +++ b/src/Command/KimaiImporterCommand.php @@ -37,6 +37,7 @@ * Command used to import data from a Kimai v1 installation. * Getting help in improving this script would be fantastic, it currently only handles the most basic use-cases. * + * This command is way to messy and complex to be tested ... so we use something, which I actually don't like: * @codeCoverageIgnore */ class KimaiImporterCommand extends Command diff --git a/src/Command/ResetCommand.php b/src/Command/ResetCommand.php index bbae57323c..43465fa81d 100644 --- a/src/Command/ResetCommand.php +++ b/src/Command/ResetCommand.php @@ -19,6 +19,11 @@ /** * Command used to execute all the basic application bootstrapping AFTER "composer install" was executed. + * + * This command is NOT used during runtime and only meant for developers on their local machines. + * I am too lazy to think about how this could be tested ... and this is one of the rare edge cases where I don't + * feel like it is necessary, so I "cheat" with: + * @codeCoverageIgnore */ class ResetCommand extends Command { diff --git a/src/Twig/Extensions.php b/src/Twig/Extensions.php index bbda63ab28..356ce83287 100644 --- a/src/Twig/Extensions.php +++ b/src/Twig/Extensions.php @@ -93,6 +93,7 @@ class Extensions extends AbstractExtension 'debug' => 'far fa-file-alt', 'profile-stats' => 'far fa-chart-bar', 'profile' => 'fas fa-user-edit', + 'warning' => 'fas fa-exclamation-triangle', ]; /** diff --git a/src/Voter/TimesheetVoter.php b/src/Voter/TimesheetVoter.php index 95ce5ce905..cc6f6696ed 100644 --- a/src/Voter/TimesheetVoter.php +++ b/src/Voter/TimesheetVoter.php @@ -85,12 +85,24 @@ protected function voteOnAttribute($attribute, $subject, TokenInterface $token) $permission .= $attribute; break; + case self::EDIT: + if (!$this->canEdit($user, $subject)) { + return false; + } + $permission .= $attribute; + break; + + case self::DELETE: + if (!$this->canDelete($user, $subject)) { + return false; + } + $permission .= $attribute; + break; + case self::VIEW_RATE: case self::EDIT_RATE: case self::STOP: - case self::EDIT: case self::VIEW: - case self::DELETE: case self::EXPORT: case self::EDIT_EXPORT: $permission .= $attribute; @@ -114,11 +126,7 @@ protected function voteOnAttribute($attribute, $subject, TokenInterface $token) return $this->hasRolePermission($user, $permission); } - /** - * @param Timesheet $timesheet - * @return bool - */ - protected function canStart(Timesheet $timesheet) + protected function canStart(Timesheet $timesheet): bool { // possible improvements for the future: // we could check the amount of active entries (maybe slow) @@ -142,4 +150,22 @@ protected function canStart(Timesheet $timesheet) return true; } + + protected function canEdit(User $user, Timesheet $timesheet): bool + { + if ($timesheet->isExported() && !$this->hasRolePermission($user, 'edit_exported_timesheet')) { + return false; + } + + return true; + } + + protected function canDelete(User $user, Timesheet $timesheet): bool + { + if ($timesheet->isExported() && !$this->hasRolePermission($user, 'edit_exported_timesheet')) { + return false; + } + + return true; + } } diff --git a/templates/export/index.html.twig b/templates/export/index.html.twig index a77288a972..162caa95cb 100644 --- a/templates/export/index.html.twig +++ b/templates/export/index.html.twig @@ -119,42 +119,56 @@ {{ parent() }}