-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7662 from lomamech/importPayrollConfigurationFrom…
…Excel Import payroll configuration from excel
- Loading branch information
Showing
16 changed files
with
2,156 additions
and
2,084 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
client/src/modules/multiple_payroll_indice/modals/import.modal.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<form name="ModalForm" bh-submit="$ctrl.submit(ModalForm)" novalidate> | ||
<div class="modal-header"> | ||
<ol class="headercrumb"> | ||
<li class="static" translate>TREE.MULTI_PAYROLL_INDICE</li> | ||
<li class="title" translate>FORM.INFO.IMPORT_PAYROLL_CONFIGURATION</li> | ||
</ol> | ||
</div> | ||
|
||
<div class="modal-body"> | ||
<div class="row"> | ||
<div class="col-sm-12"> | ||
<div class="form-group marginTop1ex" | ||
ng-class="{ 'has-error' : $ctrl.noSelectedFile }"> | ||
<label translate>FORM.LABELS.LOAD_FROM_FILE</label> | ||
<input | ||
id="import-input" | ||
accept=".csv" | ||
class="form-control" | ||
type="file" | ||
name="file" | ||
ng-model="$ctrl.file" | ||
ngf-select="$ctrl.select($ctrl.file)"> | ||
<div class="help-block" data-error-message ng-show="$ctrl.noSelectedFile"> | ||
<i class="fa fa-warning"></i> <span translate>FORM.INFO.NO_FILE_SELECTED</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button data-method="cancel" type="button" class="btn btn-default" ng-click="$ctrl.close()"> | ||
<span translate>FORM.BUTTONS.CANCEL</span> | ||
</button> | ||
|
||
<bh-loading-button disabled="!$ctrl.file" loading-state="ModalForm.$loading"> | ||
</bh-loading-button> | ||
</div> | ||
</form> |
59 changes: 59 additions & 0 deletions
59
client/src/modules/multiple_payroll_indice/modals/import.modal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
angular.module('bhima.controllers') | ||
.controller('MultiPayrollIndiceImportModalController', MultiPayrollIndiceImportModalController); | ||
|
||
MultiPayrollIndiceImportModalController.$inject = [ | ||
'data', 'NotifyService', '$uibModalInstance', 'Upload', '$state', 'LanguageService', | ||
]; | ||
|
||
function MultiPayrollIndiceImportModalController(data, Notify, Instance, Upload, $state, Language) { | ||
const vm = this; | ||
|
||
vm.close = Instance.close; | ||
vm.param = {}; | ||
vm.configuration = data; | ||
|
||
vm.select = (file) => { | ||
vm.noSelectedFile = !file; | ||
}; | ||
|
||
vm.submit = () => { | ||
// send data only when a file is selected | ||
if (!vm.file) { | ||
vm.noSelectedFile = true; | ||
return; | ||
} | ||
|
||
uploadFile(vm.file); | ||
}; | ||
|
||
/** | ||
* upload the file to server | ||
* @param {string} file - name of file to upload | ||
*/ | ||
function uploadFile(file) { | ||
vm.uploadState = 'uploading'; | ||
const params = { | ||
url : `/multiple_payroll_indice/upload/${vm.configuration.payroll_configuration_id}?lang=${Language.key}`, | ||
data : { file }, | ||
}; | ||
|
||
// upload the file to the server | ||
Upload.upload(params) | ||
.then(handleSuccess, Notify.handleError, handleProgress); | ||
|
||
// success upload handler | ||
function handleSuccess() { | ||
vm.uploadState = 'uploaded'; | ||
Notify.success('FORM.INFO.OPERATION_SUCCESS'); | ||
$state.go('multiple_payroll_indice', null, { reload : true }); | ||
Instance.close(); | ||
} | ||
|
||
// progress handler | ||
// @TODO : does this work ??? Is it necessary? | ||
function handleProgress(evt) { | ||
file.progress = Math.min(100, parseInt((100.0 * evt.loaded) / evt.total, 10)); | ||
vm.progressStyle = { width : String(file.progress).concat('%') }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.