diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 94210cb..733a4f0 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -12,13 +12,17 @@ RUN apt-get install -y \ libjpeg62-turbo-dev \ libpng-dev \ libicu-dev \ + libzip-dev \ + zip \ && docker-php-ext-install -j$(nproc) iconv \ && docker-php-ext-configure gd --with-jpeg=/usr/include/ --with-freetype=/usr/include/ \ && docker-php-ext-install -j$(nproc) gd \ && docker-php-ext-install -j$(nproc) intl \ - && docker-php-ext-install -j$(nproc) pdo_mysql + && docker-php-ext-install -j$(nproc) pdo_mysql \ + && docker-php-ext-install zip RUN apt-get install -y git zip +RUN apt-get install mariadb-client -y RUN apt install nano diff --git a/README.md b/README.md index f556ba1..85f54e0 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,6 @@ - info@coaching4dogs.xx (kein Admin-Account) - benny@probuddy.de - timo@tbuddy.de - - tretslag@gmail.com \ No newline at end of file + - tretslag@gmail.com +- `docker exec -it pb-php /bin/bash` +- SELECT * FROM profile WHERE JSON_CONTAINS( `teams_js`, '{"team_id":"75"}' ); \ No newline at end of file diff --git a/src/client/app/js/app/core/Dict.js b/src/client/app/js/app/core/Dict.js index b6964a5..ba385ed 100644 --- a/src/client/app/js/app/core/Dict.js +++ b/src/client/app/js/app/core/Dict.js @@ -541,7 +541,8 @@ app.core.Dict = { "APPOINTMENT_CATEGORIES_MISSING_FOR_ADMIN" : "Deinem Gruppenprofil wurden keine Kategorien zugewiesen. Bitte benachrichtige den Gruppeninhaber.", "NOTE_NO_SERIAL_APPOINTMENT_EDITING_AFTER_PUBLISHING" : "Hinweis: Serientermine können nach ihrer Veröffentlichung nur noch einzelnd bearbeitet werden.", "STATS_REPORTING" : 'Reporting', - 'STATS_PLANNING' : 'Planung' + 'STATS_PLANNING' : 'Planung', + "DO_YOU_REALLY_WANT_TO_DELETE_THIS_CONTRACT" : "Möchtest Du diesen Vertrag wirklich löschen?", }, "en" : { } diff --git a/src/client/manager/js/app/components/appointments/AppointmentSelectTable.js b/src/client/manager/js/app/components/appointments/AppointmentSelectTable.js index 3fdd8c4..50fbedb 100644 --- a/src/client/manager/js/app/components/appointments/AppointmentSelectTable.js +++ b/src/client/manager/js/app/components/appointments/AppointmentSelectTable.js @@ -5,9 +5,33 @@ const AppointmentSelectTable = { var app = this.app, $container = $( this.container ); - this.render( { apps: appointments.getAll(), activeGroup : this.app.user.getActiveGroup() } ); + let date = new Date(); + let strFrom = ''; + date.setMonth(date.getMonth() - 3); + let dd = String(date.getDate()).padStart(2, '0'); + let mm = String(date.getMonth() + 1).padStart(2, '0'); //January is 0! + let yyyy = date.getFullYear(); + strFrom = yyyy + '-' + mm + '-' + dd; - $container.find( '.datatable' ).DataTable( { + date = new Date(); + let strTo = ''; + date.setMonth(date.getMonth() + 3); + dd = String(date.getDate()).padStart(2, '0'); + mm = String(date.getMonth() + 1).padStart(2, '0'); //January is 0! + yyyy = date.getFullYear(); + strTo = yyyy + '-' + mm + '-' + dd; + + let appointmentItems = appointments.getAll(); + + this.render( + { apps: appointmentItems, + activeGroup : this.app.user.getActiveGroup(), + strFrom: strFrom, + strTo: strTo + } + ); + + let table = $container.find( '.datatable' ).DataTable( { pageLength: 50, responsive: true, dom: '<"html5buttons"B>lTfgitp', @@ -78,6 +102,31 @@ const AppointmentSelectTable = { app.openInApp( '/#/appointment/' + $( this ).attr( 'data-appointment-id' ) + '/chat' ); e.stopPropagation(); }); + + $('input.dateStart').on('change', function() { + table.draw(); + }); + + $('input.dateEnd').on('change', function() { + table.draw(); + }); + + $.fn.dataTable.ext.search.push( + function(settings, searchData, index, rowData, counter) { + const dateFrom = $('input.dateStart').val(); + const dateTo = $('input.dateEnd').val(); + const item = appointmentItems[index]; + const startDate = item['start_dt']; + const strStartDate = startDate.date.substring(0,10); + + if (strStartDate >= dateFrom && strStartDate <= dateTo) { + return true; + } + return false; + } + ); + // Initial drawing needed to filter by date interval + table.draw(); }, getSelectedIds : function() diff --git a/src/client/manager/js/app/components/appointments/appointment-select-table.html b/src/client/manager/js/app/components/appointments/appointment-select-table.html index e18f43e..21812c8 100644 --- a/src/client/manager/js/app/components/appointments/appointment-select-table.html +++ b/src/client/manager/js/app/components/appointments/appointment-select-table.html @@ -1,4 +1,6 @@
| PLZ | Stadt | Offene Verrechnungen | +Aktiver Vertrag vorhanden | - <%= ui[ i ].member ? ui[ i ].member.getName() : '[gelöscht]' %> + <%= ui[ i ].member ? ui[ i ].member.getName() : '[gelöscht - nicht mehr Mitglied der Gruppe]' %> | <%= ui[ i ].member && ui[ i ].member.street ? ui[ i ].member.street : '---' %> @@ -30,9 +33,12 @@ | <%= ui[ i ].member && ui[ i ].member.city ? ui[ i ].member.city : '---' %> | -+ | <%= ui[ i ].count %> | ++ <%= ui[ i ].hasActiveContract ? 'ja' : 'nein' %> + | <% } %> diff --git a/src/client/manager/js/app/components/settings/AccessDataTable.js b/src/client/manager/js/app/components/settings/AccessDataTable.js index 0131ea9..ab34db3 100644 --- a/src/client/manager/js/app/components/settings/AccessDataTable.js +++ b/src/client/manager/js/app/components/settings/AccessDataTable.js @@ -36,7 +36,7 @@ const AccessDataTable = { }, }, buttons: [ - { extend: 'copy'}, + {extend: 'copy'}, {extend: 'csv'}, {extend: 'excel', title: 'Mitgliederliste'}, {extend: 'pdf', title: 'Mitgliederliste'}, diff --git a/src/client/manager/js/app/views/appointments/AppointmentList.js b/src/client/manager/js/app/views/appointments/AppointmentList.js index 5dee478..40e6a47 100644 --- a/src/client/manager/js/app/views/appointments/AppointmentList.js +++ b/src/client/manager/js/app/views/appointments/AppointmentList.js @@ -59,6 +59,8 @@ const AppointmentList = { } } + + let compAst = this.createComponent( 'appointment-select-table', $container.find( '[f-id="container-appointment-data-table"]' ).first().get( 0 ), diff --git a/src/client/manager/js/app/views/contract/ContractCharging.js b/src/client/manager/js/app/views/contract/ContractCharging.js index d3f9fd5..8ec54e1 100644 --- a/src/client/manager/js/app/views/contract/ContractCharging.js +++ b/src/client/manager/js/app/views/contract/ContractCharging.js @@ -16,6 +16,7 @@ const ContractCharging = { app = this.app, members = [], groupId = p.get( 'groupId' ), + profileIdsWithActiveContract = [], self = this; function getMemberById( mId ) @@ -30,7 +31,6 @@ const ContractCharging = { break; } } - return m; } @@ -56,49 +56,63 @@ const ContractCharging = { app.rpc.call( 'Contract', - 'getUnchargedProfileIds', + 'getList', { - teamId : groupId + teamId : groupId, + state : 'active' }, - function( res ) - { - let unchargedItems = [], - memberIdsInList = []; - if ( res && res.hasOwnProperty( 'data' ) && res.data.hasOwnProperty( 'unchargedProfileIds' ) ) - { - const up = res.data.unchargedProfileIds; - for( let upi = 0; upi < up.length; upi++ ) - { - memberIdsInList.push( +up[ upi ].profile_id ); - unchargedItems.push({ - member : getMemberById( up[ upi ].profile_id ), - count : up[ upi ].cnt - }); + function( res ) { + if (res && res.hasOwnProperty('data') && res.data.hasOwnProperty('contractData')) { + const cs = res.data.contractData; + for (let ci = 0; ci < cs.length; ci++) { + profileIdsWithActiveContract[cs[ci]['profile_id']] = 1; } } - for ( let mi = 0; mi < members.length; mi++ ) - { - if ( -1 === memberIdsInList.indexOf( +members[ mi ].id ) ) + app.rpc.call( + 'Contract', + 'getUnchargedProfileIds', { - unchargedItems.push({ - member : members[ mi ], - count : 0 - }); - } - } + teamId: groupId + }, + function (res) { + let unchargedItems = [], + memberIdsInList = []; + if (res && res.hasOwnProperty('data') && res.data.hasOwnProperty('unchargedProfileIds')) { + const up = res.data.unchargedProfileIds; + for (let upi = 0; upi < up.length; upi++) { + memberIdsInList.push(+up[upi].profile_id); + unchargedItems.push({ + member: getMemberById(up[upi].profile_id), + count: up[upi].cnt, + hasActiveContract: profileIdsWithActiveContract.hasOwnProperty(up[upi].profile_id) + }); + } + } - let st = self.createComponent( - 'contract-uncharged-member-data-table', - $container.find( '[f-id="container-contract-uncharged-member-table"]' ).first().get( 0 ), - { - unchargedItems : unchargedItems, - groupId : groupId - } - ); + for (let mi = 0; mi < members.length; mi++) { + if (-1 === memberIdsInList.indexOf(+members[mi].id)) { + unchargedItems.push({ + member: members[mi], + count: 0, + hasActiveContract: -1 !== profileIdsWithActiveContract.indexOf(+members[mi].id) + }); + } + } - $container.find( '.sk-loading' ).toggleClass( 'sk-loading' ); - }.bind ( this ) + let st = self.createComponent( + 'contract-uncharged-member-data-table', + $container.find('[f-id="container-contract-uncharged-member-table"]').first().get(0), + { + unchargedItems: unchargedItems, + groupId: groupId + } + ); + + $container.find('.sk-loading').toggleClass('sk-loading'); + }.bind(this) + ); + } ); } } diff --git a/src/client/manager/js/app/views/contract/ContractEdit.js b/src/client/manager/js/app/views/contract/ContractEdit.js index fcf97a9..f504ea0 100644 --- a/src/client/manager/js/app/views/contract/ContractEdit.js +++ b/src/client/manager/js/app/views/contract/ContractEdit.js @@ -21,8 +21,7 @@ const ContractEdit = { self = this; self.contract = null; - - this.render( { groupId : groupId } ); + self.contractIsDeletable = false; app.rpc.call( 'Contract', @@ -32,11 +31,16 @@ const ContractEdit = { }, function( res ) { - if ( res && res.hasOwnProperty( 'data' ) && res.data.hasOwnProperty( 'contractData' ) ) + if ( res && res.hasOwnProperty( 'data' )) { - self.contract = self.createInstance( 'Contract', res.data.contractData ); + if ( res.data.hasOwnProperty( 'contractData' ) ) { + self.contract = self.createInstance( 'Contract', res.data.contractData ); + } + if ( res.data.hasOwnProperty( 'contractIsDeletable' ) ) { + self.contractIsDeletable = res.data.contractIsDeletable; + } } - + this.render( { groupId : groupId, contractIsDeletable: self.contractIsDeletable } ); const $compContractForm = self.createComponent( 'contract-form', $container.find( '[f-id="container-contract-form"]' ).first().get( 0 ), @@ -89,10 +93,69 @@ const ContractEdit = { } }); + if (self.contractIsDeletable) { + $container.find( '[data-id="btnDeleteContract"]').click( function() + { + + let $modalRoot = $container.find( '[data-id="modal-confirm-delete-contract"]' ).first(); + $modalRoot.find( '[data-id="section-confirm-delete-contract"]' ).first().show(); + $modalRoot.find( '[data-id="section-loader"]' ).first().hide(); + $modalRoot.on( 'shown.bs.modal', function() + { + $modalRoot.find( '[data-id="btnDelete"]' ).first().off( "click" ); + $modalRoot.find( '[data-id="btnDelete"]' ).first().click( function() + { + $(this).off( "click" ); + + $modalRoot.find( '[data-id="section-confirm-delete-contract"]' ).first().hide(); + $modalRoot.find( '[data-id="section-loader"]' ).first().show(); + + app.rpc.call( + 'Contract', + 'delete', + { + contractId : contractId + }, + function( resp ) + { + if ( resp && resp.hasOwnProperty( 'code' ) && resp.code == 200 ) + { + app.UI.toastSuccess( 'Vertrag wurde erfolgreich gelöscht.', 'Vertrag gelöscht' ); + if ( redirectPath ) + { + app.redirect( redirectPath ); + } + else + { + app.redirect( 'contract/list/' + groupId ); + } + } + else + { + app.UI.toastError( 'Der Vertrag konnte nicht gelöscht werden, ' + + 'da er entweder mindestens eine verknüpfte Verrechnung oder bereits ' + + 'eine Einzahlung stattgefunden hat', + 'Fehler' ); + } + $modalRoot.modal( 'hide' ); + } + ); + }); + }); + $modalRoot.on( 'hidden.bs.modal', function() + { + $modalRoot.modal( 'dispose' ); + }); + $modalRoot.modal( 'show' ); + } + ); + } + $container.find( '.sk-loading' ).toggleClass( 'sk-loading' ); }.bind ( this ) ); + }, destroy : function() diff --git a/src/client/manager/js/app/views/contract/contract-edit.html b/src/client/manager/js/app/views/contract/contract-edit.html index 175c69c..63669f3 100644 --- a/src/client/manager/js/app/views/contract/contract-edit.html +++ b/src/client/manager/js/app/views/contract/contract-edit.html @@ -40,10 +40,62 @@ href="javascript:history.back()"> Abbrechen + <% if ( true === contractIsDeletable ) { %> + + <% } %> + + + \ No newline at end of file diff --git a/src/client/manager/js/app/views/contract/contract-master-data.html b/src/client/manager/js/app/views/contract/contract-master-data.html index 9cce9fb..95dd320 100644 --- a/src/client/manager/js/app/views/contract/contract-master-data.html +++ b/src/client/manager/js/app/views/contract/contract-master-data.html @@ -118,6 +118,49 @@ +
|---|