123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- //CHARGEMENT DE LA PAGE
- function init_plugin_employee(){
- switch($.urlParam('page')){
- case 'sheet.employee':
- employee_employee_contract_search();
- break;
- default:
- break;
- }
- $('#employees').sortable_table({
- onSort : employee_search
- });
- }
- function init_setting_global_employee(){
- employee_employee_work_time_search()
- }
- //Enregistrement des configurations
- function employee_setting_save(){
- $.action({
- action: 'employee_setting_save',
- fields: $('#employee-setting-form').toJson()
- },function(){
- $.message('success','Enregistré');
- });
- }
- /** FICHE EMPLOYé **/
- //Récuperation d'une liste fiche employé dans le tableau #employees
- function employee_search(callback,exportMode){
- var box = new FilterBox('#filters');
- if(exportMode) $('.btn-export').addClass('btn-preloader');
- $('#employees').fill({
- action:'employee_search',
- filters: box.filters(),
- sort: $('#employees').sortable_table('get'),
- export: !exportMode ? false : exportMode
- },function(response){
- $('.results-count span').text(response.pagination.total);
- if(callback!=null) callback();
- });
- }
- //Ajout ou modification fiche employé
- function employee_save(callback,noMessage){
- var data = $('#employee-form').toJson();
- data.hardware = [];
- $('.btn-save').addClass('btn-preloader');
- $('.hardware:checked').each(function(){
- data.hardware.push($(this).attr('data-id'));
- });
- $.action(data,function(r){
- $('#employee-form').attr('data-id',r.id);
- $.urlParam('id',r.id);
- if(noMessage===false || !noMessage) $.message('success','Enregistré');
- if(callback) callback();
- });
- }
- //Suppression fiche employé
- function employee_delete(element){
- if(!confirm('Êtes vous sûr de vouloir supprimer cet item ?')) return;
- var line = $(element).closest('.item-line');
- $.action({
- action: 'employee_delete',
- id: line.attr('data-id')
- },function(r){
- line.remove();
- $.message('info','Item supprimé');
- });
- }
- /** TEMPS DE TRAVAIL EMPLOYé **/
- //Récuperation d'une liste temps de travail employé dans le tableau #employeeworktimes
- function employee_employee_work_time_search(callback){
- $('#employee-work-times').fill({
- action:'employee_employee_work_time_search'
- },function(response){
- if(callback!=null) callback();
- });
- }
- //Ajout ou modification temps de travail employé
- function employee_employee_work_time_save(){
- var data = $('#employee-work-time-form').toJson();
- $.action(data,function(r){
- $('#employee-work-time-form').attr('data-id','');
- employee_employee_work_time_search();
- $('#employee-work-time-form').attr('data-id',r.id);
- $.urlParam('id',r.id);
- $.message('success','Enregistré');
- });
- }
- //Récuperation ou edition temps de travail employé
- function employee_employee_work_time_edit(element){
- var line = $(element).closest('.item-line');
- $.action({
- action: 'employee_employee_work_time_edit',
- id: line.attr('data-id')
- },function(r){
- $('#employee-work-time-form').fromJson(r);
- init_components('#employee-work-time-form');
- $('#employee-work-time-form').attr('data-id',r.id);
- });
- }
- //Suppression temps de travail employé
- function employee_employee_work_time_delete(element){
- if(!confirm('Êtes vous sûr de vouloir supprimer cet item ?')) return;
- var line = $(element).closest('.item-line');
- $.action({
- action: 'employee_employee_work_time_delete',
- id: line.attr('data-id')
- },function(r){
- line.remove();
- $.message('info','Item supprimé');
- });
- }
- /** CONTRAT EMPLOYé **/
- //Récuperation d'une liste contrat employé dans le tableau #employeecontracts
- function employee_employee_contract_search(callback){
- var id = $.urlParam('id');
- if(!id) return;
- $('#employee-contracts').fill({
- action:'employee_employee_contract_search',
- employee : id
- },function(response){
- if(callback!=null) callback();
- });
- }
- function employee_employee_contract_edit(element){
- $('#contractModal').clear().modal('show');
- var data = {action : 'employee_employee_contract_edit'};
- if(element) data.id = $(element).closest('tr').attr('data-id');
- $.action(data,function(r){
- $('#contractModal').fromJson(r);
- $('#contractModal').attr('data-id',r.id);
- });
- }
- //Ajout ou modification contrat employé
- function employee_employee_contract_save(){
- var saveContract = function(){
- var data = $('#contractModal').toJson();
- data.action='employee_employee_contract_save';
- data.employee = $.urlParam('id');
- data.id = $('#contractModal').attr('data-id');
- $.action(data,function(r){
- employee_employee_contract_search();
- $('#contractModal').modal('hide');
- $.message('success','Enregistré');
- });
- }
- if(!$.urlParam('id')){
- employee_save(function(){saveContract()},true);
- }else{
- saveContract();
- }
- }
- //Suppression contrat employé
- function employee_employee_contract_delete(element){
- if(!confirm('Êtes vous sûr de vouloir supprimer cet item ?')) return;
- var line = $(element).closest('.item-line');
- $.action({
- action: 'employee_employee_contract_delete',
- id: line.attr('data-id')
- },function(r){
- line.remove();
- $.message('info','Item supprimé');
- });
- }
|