LDay = function(size, date) {
this.doom = new LDivElement( '', 'normal', 20, '0px solid #FFF', '', '', '', '2px', 0, 0, size-2, size, '');
if ( (date.getDay())%7==0 || (date.getDay())%7==6 ) {
this.doom.setInnerHTML(['S','D'][(date.getDay()+1)%7]);
this.doom.style.backgroundColor = '#FFE771';
}
else
this.doom.setInnerHTML(date.getDate());
}
LMois = function( controller, index_mois, topSize, size, date_debut ) {
this.controller = controller;
this.date_debut = date_debut;
this.date_fin = new LDate(date_debut.toFullString());
this.mois = index_mois;
this.topSize = topSize;
this.size = size;
this.tabDay = new Array();
this.tab_mois = [ 'janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre' ];
this.doom = new LDivElement( '', '', 22, '0px solid #000', '', '', '', '0px', 0, 0, topSize+size, 0, '');
this.entete = new LDivElement( '', 'bigger overflow', 22, '', '0px 0px 1px 0px', 'solid solid dotted solid', '#FFF #FFF #FC0 #FFF', '0px', 0, 0, topSize, 0, '');
this.button = new LDivElement( '', '', 23, '0px solid #000', '', '', '', '3px', topSize/2-14, 0, 27, 0, '');
this.entete.appendChild_(this.button);
this.doom.appendChild_(this.entete);
this.getMonth = function() {
return this.mois;
}
this.addDay = function(day) {
day.doom.setTop(this.topSize);
this.doom.appendChild_(day.doom);
}
this.update = function() {
this.doom.setWidth(this.tabDay.length*(this.size-1)+1);
this.entete.setWidth(this.tabDay.length*(this.size-1));
this.button.setLeft(Math.max((this.tabDay.length*(this.size-1)-172)/2,0));
this.button.setWidth(Math.min(this.tabDay.length*(this.size-1), 172));
if (this.tabDay.length > 12) {
this.button.setBackground('url('+GLO_IMG_REP+GLO_IMG_MOIS+') 0px 2px no-repeat');
this.button.setInnerHTML(this.tab_mois[this.mois].firstUpper() + ' ' + this.date_debut.getFullYear());
this.button.style.cursor = 'pointer';
Event.setevent.call(this.button, 'click', function() {
planningController.moisClicked(this, this.button.top+1, this.button.left);
}.bind(this));
}
else {
this.button.style.background = '';
this.button.style.cursor = '';
if ( this.tabDay.length > 7 )
this.button.setInnerHTML(this.tab_mois[this.mois].firstUpper() + ' ' + this.date_debut.getFullYear());
else
this.button.setInnerHTML('');
}
}
this.updateDays = function() {
for (var i=0; i < this.tabDay.length; i++) {
this.tabDay[i].doom.setLeft(i*(this.size-1));
}
}
this.insertLastDay = function(day) {
day.doom.setLeft(this.tabDay.length*(this.size-1)); //On insère le jour en question par desuss le dernier jour actuellement en place
this.tabDay.push(day);
this.addDay(day);
}
this.insertFirstDay = function(day) {
day.doom.setLeft(0);
this.tabDay.unshift(day);
this.addDay(day);
}
this.removeLastDay = function() {
this.doom.removeChild_(this.tabDay.pop().doom);
if (this.tabDay.length == 0) {
this.controller.removeLastMonth();
}
else {
this.doom.setLeft(this.doom.getLeft()+this.size-1);
this.update();
}
}
this.removeFirstDay = function() {
this.doom.removeChild_(this.tabDay.shift().doom);
if (this.tabDay.length == 0) {
this.controller.removeFirstMonth();
}
else {
for (var i=0; i < this.tabDay.length; i++) {
this.tabDay[i].doom.setLeft(this.tabDay[i].doom.getLeft()-this.size+1);
}
this.update();
}
}
this.decale = function(value) {
this.doom.setLeft(this.doom.getLeft() + value*(this.size-1));
}
}
LCalendar = function(row, col, size, date_debut) {
this.date_debut = date_debut;
this.row = row;
this.col = col;
this.size = size;
this.doom = new LDivElement( '', 'calendar', 10, '0px solid #000', '', '', '', '0px', 0, 0, 0, (size-1)*col+1, '');
this.addLigne = function(salarie) {
var html = '';
var line = '<ul on'+mybro.getMouseEnterLabel()+'="pc.ulO.call(this, '+salarie.indice+', arguments[0]);">';
var top_ = (this.row == 0)?'top':'';
for (var j=0; j < this.col; j++) {
var left_ = (j == 0)?'left':'';
line += '<li class="'+top_+' '+left_+'"><ul>';
line += '<li id="'+salarie.indice+'|0|'+j+'" />';
line += '<li id="'+salarie.indice+'|1|'+j+'" />';
line += '</ul></li>';
}
line += '</ul>';
html += line;
this.doom.innerHTML += html;
this.row++;
this.doom.setHeight((this.size-1)*this.doom.childNodes.length+2);
}
this.remLigne = function(position) {
this.doom.removeChild(this.doom.childNodes[position]);
if ( position == 0 && this.doom.firstChild) { //Et s'il reste une ligne à l'écran !!
for (var i=0; i < this.doom.firstChild.childNodes.length; i++) {
this.doom.firstChild.childNodes[i].className += ' top'; //+= parce que le premier LI a déjà un 'left' dans sa classe
}
}
this.doom.setHeight((this.size-1)*this.doom.childNodes.length+2);
}
}
LEntete = function(topSize) {
this.col = 31;
this.topSize = topSize;
this.size = 20;
this.doom = new LDivElement( '', 'overflow', 20, '0px solid #000', '', '', '', '0px', 0, 0, topSize+this.size, (this.size-1)*this.col+1, '');
this.tabMois = new Array();
var mois_temp = -1;
this.date_debut = controller.getDateInitialePlanning();
var date = new LDate(this.date_debut.toFullString());
for (var i=0; i < this.col; i++) {
if ( date.getMonth() != mois_temp ) {
if ( this.tabMois.getLast() ) {
this.doom.appendChild_(this.tabMois.getLast().doom);
this.tabMois.getLast().doom.setBorder('', '0px 1px 0px 0px', 'solid dotted solid solid', '#FFF #FC0 #FFF #FFF');
this.tabMois.getLast().update();
}
mois_temp = date.getMonth();
var mois = new LMois( this, mois_temp, topSize, this.size, new LDate(date.toFullString()));
mois.doom.setLeft(i*(this.size-1));
this.tabMois.push( mois );
var day = new LDay(this.size, mois.date_fin);
this.tabMois.getLast().insertLastDay( day );
date.addJours(1);
i++;
}
mois.date_fin.addJours(1);
var day = new LDay(this.size, mois.date_fin);
this.tabMois.getLast().insertLastDay( day );
date.addJours(1);
}
this.doom.appendChild_(this.tabMois.getLast().doom);
this.tabMois.getLast().update();
this.goLeft = function() {
if ( this.tabMois.getFirst().date_debut.getDate() == 1 ) {
this.insertFirstMonth();
}
else {
this.tabMois.getFirst().date_debut.addJours(-1);
var day = new LDay(this.size, this.tabMois.getFirst().date_debut);
this.tabMois.getFirst().insertFirstDay(day);
}
controller.addJoursPlanning(-1);
this.tabMois.getFirst().update();
this.tabMois.getFirst().updateDays();
this.decaleMois(1);
this.tabMois.getLast().date_fin.addJours(-1);
this.tabMois.getLast().removeLastDay();
this.tabMois.getLast().doom.setBorder('0px solid #000', '', '', '');
this.offset--;
comptesController.updatePastilles();
if ( mybro.fast ) {
planningController.resetCalendrier();
}
}
this.offset = GLO_NB_JOURS;
this.goRight = function() {
var moisNextDay = this.tabMois.getLast().date_fin.addJours(1).getMonth();
this.tabMois.getLast().date_fin.addJours(-1);
if ( this.tabMois.getLast().date_fin.getMonth() != moisNextDay ) {
this.insertLastMonth();
}
else {
var day = new LDay(this.size, this.tabMois.getLast().date_fin.addJours(1));
this.tabMois.getLast().insertLastDay(day);
}
controller.addJoursPlanning(1);
this.tabMois.getLast().decale(-1);
this.tabMois.getLast().update();
this.decaleMois(-1);
this.tabMois.getFirst().date_debut.addJours(1);
this.tabMois.getFirst().removeFirstDay();
if (this.tabMois.length > 1)
this.tabMois[this.tabMois.length-2].doom.setBorder('', '0px 1px 0px 0px', 'solid dotted solid solid', '#FFF #FC0 #FFF #FFF');
this.offset++;
comptesController.updatePastilles();
if ( mybro.fast ) {
planningController.resetCalendrier();
}
}
this.decaleMois = function(value) {
for (var i=0; i < this.tabMois.length; i++) {
if ( this.tabMois[i] != this.tabMois.getFirst() && this.tabMois[i] != this.tabMois.getLast() )
this.tabMois[i].decale(value);
}
}
this.insertFirstMonth = function() {
var index_month = this.tabMois.getFirst().date_debut.addJours(-1).getMonth();
this.tabMois.getFirst().date_debut.addJours(1);
var mois = new LMois( this, index_month, this.topSize, this.size, (new LDate(this.tabMois.getFirst().date_debut.toFullString())).addJours(-1) );
mois.doom.setLeft(0);
this.tabMois.unshift( mois );
this.doom.appendChild_(mois.doom);
mois.doom.setBorder('', '0px 1px 0px 0px', 'solid dotted solid solid', '#FFF #FC0 #FFF #FFF');
var day = new LDay(this.size, mois.date_fin);
this.tabMois.getFirst().insertLastDay( day );
}
this.insertLastMonth = function() {
var index_month = this.tabMois.getLast().date_fin.addJours(1).getMonth();
this.tabMois.getLast().date_fin.addJours(-1);
var mois = new LMois( this, index_month, this.topSize, this.size, (new LDate(this.tabMois.getLast().date_fin.toFullString())).addJours(1) );
mois.doom.setLeft(this.col*(this.size-1));
this.tabMois.push( mois );
this.doom.appendChild_(mois.doom);
var day = new LDay(this.size, mois.date_fin);
this.tabMois.getLast().insertLastDay( day );
}
this.removeLastMonth = function() {
var month = this.tabMois.pop();
Util.collector.emptyChildNodes(month.doom);
this.doom.removeChild_(month.doom);
}
this.removeFirstMonth = function() {
var month = this.tabMois.shift()
Util.collector.emptyChildNodes(month.doom);
this.doom.removeChild_(month.doom);
}
this.initScroll = function() {
planningController.closeSelector();
this.blnScroll = true;
this.nbScroll = 31;
if ( !mybro.fast ) {
Effect.show.call(viewGrillePlanning.childNodes.grisage);
}
}
this.startScrollingRight = function() {
this.initScroll();
this.scrollRight();
}
this.scrollRight = function() {
if ( this.blnScroll && this.nbScroll > 0 ) {
this.goRight();
Util.delay(function() {
this.scrollRight();
}.bind(this), 20, 'scrollPlanningTimer');
this.nbScroll--;
}
}
this.startScrollingLeft = function() {
this.initScroll();
this.scrollLeft();
}
this.scrollLeft = function() {
if ( this.blnScroll && this.nbScroll > 0 ) {
this.goLeft();
Util.delay(function() {
this.scrollLeft();
}.bind(this), 20, 'scrollPlanningTimer');
this.nbScroll--;
}
}
this.stopScrolling = function() {
if ( this.blnScroll ) {
this.blnScroll = false;
this.nbScroll = 0;
Util.clearTimeout('scrollPlanningTimer');
Util.clearTimeout('soldesTimer');
controller.pool.abortAll();
salariesController.checkSalariesPresents();
Effect.show.call(viewGrillePlanning.childNodes.grisage);
if ( controller.getDateInitialePlanning() <= planningController.dateInitialeConges || controller.getDateFinalePlanning() >= planningController.dateFinaleConges || !mybro.fast ) {
this.offset = GLO_NB_JOURS;
controller.resetBornesConges();
congesController.loadConges();
salariesController.initJoursChomes();
}
salariesController.reloadSoldes( function() {
planningController.setEventCalendrier();
Effect.hide.call(viewGrillePlanning.childNodes.grisage);
});
}
}
}
planningController = function() {
this.size = 20;
this.col = GLO_NB_JOURS;
this.getOffsetTop = function() {
return Math.max(comptesController.getNbComptes()*20 + 60, 180);
}
this.getDateInitiale = function() {
return controller.getDateInitialePlanning();
}
this.getDateFinale = function() {
return controller.getDateFinalePlanning();
}
this.viewPlanning = viewPlanning;
this.playSoundOver = function() {
controller.playSound('over');
}
this.getViewSalarie = function(value) {
return this.viewPlanning.body.salaries.tabViewSalaries[value];
}
this.addCongeALL = function(li, compte) {
var tabInfos = this.getLiInfos(li);
var salarie = tabInfos[0];
var date = tabInfos[1];
date.duree = 'ALL';
var conge =  new Conge( compte, salarie, date, +1);
salarie.insertConge(conge, +1);
var k = Date.dateDiff(controller.getDateInitialePlanning(), date);
var hash = salariesController.hashConges;
var offset = viewEntetePlanning.entete.offset;
var i = salariesController.tabSalaries.getIndex(salarie);
if ( !hash[k+offset] )
hash[k+offset] = new Array();
if ( !hash[k+offset][i] )
hash[k+offset][i] = new Array();
if ( !hash[k+offset][i][0] )
hash[k+offset][i][0] = new Array();
hash[k+offset][i][0][0] = conge;
salarie.addJoursSaisis(compte, date, 1);
this.resetLigneFromLi(li);
}
this.addCongeDEMI = function(li, compte) {
var tabInfos = this.getLiInfos(li);
var salarie = tabInfos[0];
var date = tabInfos[1]; //La date est déjà au bon format, AM ou PM selon le LI cliqué
var conge =  new Conge( compte, salarie, date, +1);
salarie.insertConge(conge, +0.5);
var k = Date.dateDiff(controller.getDateInitialePlanning(), date);
var hash = salariesController.hashConges;
var offset = viewEntetePlanning.entete.offset;
var i = salariesController.tabSalaries.getIndex(salarie);
if ( !hash[k+offset] )
hash[k+offset] = new Array();
if ( !hash[k+offset][i] )
hash[k+offset][i] = new Array();
if ( !hash[k+offset][i][0] )
hash[k+offset][i][0] = new Array();
hash[k+offset][i][0][(date.duree=='AM')?1:2] = conge;
salarie.addJoursSaisis(compte, date, 0.5);
this.resetLigneFromLi(li);
}
this.remCongeDEMI = function(li, conge) {
var tabInfos = this.getLiInfos(li);
var salarie = tabInfos[0];
var date = tabInfos[1]; //La date est déjà au bon format, AM ou PM selon le LI cliqué
var compte = conge.compte;
var congeEnvoye =  new Conge( compte, salarie, date, -1);
salarie.insertConge(congeEnvoye, -0.5);
var k = Date.dateDiff(controller.getDateInitialePlanning(), date);
var hash = salariesController.hashConges;
var offset = viewEntetePlanning.entete.offset;
var i = salariesController.tabSalaries.getIndex(salarie);
if ( !hash[k+offset] )
hash[k+offset] = new Array();
if ( !hash[k+offset][i] )
hash[k+offset][i] = new Array();
if ( !hash[k+offset][i][0] )
hash[k+GLO_NB_JOURS][i][0] = new Array();
if ( conge.dateConge.duree == 'ALL' ) {
hash[k+offset][i][0][0] = null;
conge.dateConge.duree = (date.duree=='AM')?'PM':'AM';
hash[k+offset][i][0][(conge.dateConge.duree=='AM')?1:2] = conge;
}
else { //C'était un congé demi, on doit simplement le virer
hash[k+offset][i][0][(conge.dateConge.duree=='AM')?1:2] = null;
}
salarie.addJoursSaisis(compte, date, -0.5);
compte.out();
this.resetLigneFromLi(li);
}
this.compteActif = Undefined;
this.ulOver = function(index, e) {
var evt = e||event;
if ( !evt.relatedTarget || evt.relatedTarget.nodeName == 'DIV' || ( evt.relatedTarget.nodeName == 'LI' && evt.relatedTarget.parentNode.parentNode.parentNode != this && evt.relatedTarget.parentNode != this ) ) {
planningController.planningActif = true;
salariesController.setActiveSalarie(salariesController.tabSalaries[index]);
for (var i=0; i < comptesController.tabComptes.length; i++)
comptesController.tabComptes[i].out();
comptesController.mode.getCompteSaisie(salariesController.getActiveSalarie()).over();
}
}
this.ulO = this.ulOver;
this.getLiInfos = function(li) {
var id = li.id.split('|');
var jour = new LDate( this.getDateInitiale().toFullString(), (id[1]==0)?'AM':'PM' )
jour.addJours(parseInt(id[2]));
var salarie = salariesController.tabSalaries[id[0]];
return [salarie, jour];
}
this.resetCalendrier = function() {
var div = viewGrillePlanning.calendar.doom;
for (var i=0; i < div.childNodes.length; i++) {
var salarie = div.childNodes[i];
var indice = salarie.firstChild.firstChild.firstChild.id.split('|')[0];
for (var j=0; j < salarie.childNodes.length; j++) {
this.resetCase(indice, salarie, j);
}
}
}
this.setEventCalendrier = function() {
var div = viewGrillePlanning.calendar.doom;
for (var i=0; i < div.childNodes.length; i++) {
var salarie = div.childNodes[i];
var indice = salarie.firstChild.firstChild.firstChild.id.split('|')[0];
for (var j=0; j < salarie.childNodes.length; j++) {
this.setEventCase(indice, salarie, j);
}
}
}
this.resetLigne = function(indice, viewSalariePlanning) {
for (var j=0; j < viewSalariePlanning.childNodes.length; j++)
this.resetCase(indice, viewSalariePlanning, j);
}
this.resetLigneFromLi = function(li) {
var id = li.id.split('|');
this.resetLigne(parseInt(id[0]), li.parentNode.parentNode.parentNode); //Le UL (Ligne) contenant ce LI
this.setEventLigne(parseInt(id[0]), li.parentNode.parentNode.parentNode);
}
this.setEventLigne = function(indice, viewSalariePlanning) {
for (var j=0; j < viewSalariePlanning.childNodes.length; j++)
this.setEventCase(indice, viewSalariePlanning, j);
}
this.resetCase = function(indice, viewSalariePlanning, jour) {
var journee = viewSalariePlanning.childNodes[jour];
var matin = journee.firstChild.firstChild;
var aprem = matin.nextSibling;
var salarie = salariesController.tabSalaries[indice];
var compte = comptesController.mode.getCompteSaisie(salarie);
matin.style.backgroundColor = '#FFF';
aprem.style.backgroundColor = '#FFF';
journee.conge = null;
matin.conge = null;
aprem.conge = null;
var hash = salariesController.hashConges;
var offset = viewEntetePlanning.entete.offset;
jour += offset;
if ( hash[jour] && hash[jour][indice] ) {
if ( hash[jour][indice][1] ) { //S'il y a des TP, on les affecte
journee.conge = hash[jour][indice][1][0];
matin.conge = hash[jour][indice][1][1];
aprem.conge = hash[jour][indice][1][2];
}
if ( hash[jour][indice][0] ) { //S'il y a des Congés, ils écrasent les TP
journee.conge = hash[jour][indice][0][0] || journee.conge; //Si pas de congé en journée, on garde le TP
matin.conge = hash[jour][indice][0][1] || matin.conge; //Si pas de congé le matin, on garde le TP
aprem.conge = hash[jour][indice][0][2] || aprem.conge; //Si pas de congé l'aprem, on garde le TP
}
}
if ( journee.conge ) { //D'abord la journée
matin.style.backgroundColor = journee.conge.compte.getColor();
aprem.style.backgroundColor = journee.conge.compte.getColor();
}
if ( matin.conge ) // Puis les demi journées qui peuvent écraser en couleur les TP de la journée par ex
matin.style.backgroundColor = matin.conge.compte.getColor();
if ( aprem.conge )
aprem.style.backgroundColor = aprem.conge.compte.getColor();
}
this.setEventCase = function(indice, viewSalariePlanning, jour) {
var journee = viewSalariePlanning.childNodes[jour];
var matin = journee.firstChild.firstChild;
var aprem = matin.nextSibling;
var salarie = salariesController.tabSalaries[indice];
var compte = comptesController.mode.getCompteSaisie(salarie);
matin.style.cursor = 'default';
aprem.style.cursor = 'default';
matin.onmouseover = function() {};
matin.onmouseout = function() {};
matin.onclick = function() {};
aprem.onmouseover = function() {};
aprem.onmouseout = function() {};
aprem.onclick = function() {};
journee.onmouseover = function() {};
journee.onmouseout = function() {};
if ( !journee.conge && !matin.conge && !aprem.conge ) {
if ( compte != Undefined && compte != undefined ) {
if ( salarie.getSolde(3, compte.numero).getJours() >= 1 ) {
this.saisieALL(journee, matin, aprem, compte);
}
if ( salarie.getSolde(3, compte.numero).getJours() < 1 && salarie.getSolde(3, compte.numero).getJours() >= 0.5 ) {
if ( comptesController.mode == modeManuel ) {
if ( compte.isCreditAuto() )
this.saisieALL(journee, matin, aprem, compte);
else
this.saisieALLmessage(journee, matin, aprem, compte, 'Le compte va être débiteur');
}
else { //Mode auto, saisie en demi journée et pas de message
this.saisieDEMI(matin, compte);
this.saisieDEMI(aprem, compte);
}
}
if ( salarie.getSolde(3, compte.numero).getJours() < 0.5 ) {
if ( compte.isCreditAuto() )
this.saisieALL(journee, matin, aprem, compte);
else
this.saisieALLmessage(journee, matin, aprem, compte, 'Le compte va être débiteur');
}
}
else { //Pas de compte de saisie, message
this.messageOnly(journee, 'Solde insuffisant<br>Passez en mode manuel');
}
}
else { //Un ou plusieurs congés ou TP
if ( journee.conge ) {
if ( journee.conge.typeOf() != 'jourChome' ) {
this.corrDEMI(matin, journee.conge);
this.corrDEMI(aprem, journee.conge);
}
else { //C'est un SA, DI, Férié ou TP
if ( !matin.conge && !aprem.conge ) {
if ( compte != Undefined && compte != undefined && compte.isCalendaire() ) {
if ( salarie.getSolde(3, compte.numero).getJours() < 1 ) {
if ( compte.isCreditAuto() )
this.saisieALL(journee, matin, aprem, compte);
else
this.saisieALLmessage(journee, matin, aprem, compte, 'Le compte va être débiteur');
}
else {
this.saisieALL(journee, matin, aprem, compte);
}
}
else {
}
}
else { //Il y a en plus un vrai congé en demi journée (AM, PM ou les deux)
if ( matin.conge && !aprem.conge ) {
this.corrDEMI(matin, matin.conge);
if ( compte != Undefined && compte != undefined && compte.isCalendaire() ) {
if ( salarie.getSolde(3, compte.numero).getJours() < 0.5 ) {
if ( compte.isCreditAuto() )
this.saisieDEMI(aprem, compte);
else
this.saisieDEMImessage(aprem, compte, 'Le compte va être débiteur');
}
else {
this.saisieDEMI(aprem, compte);
}
}
else {
}
}
if ( !matin.conge && aprem.conge ) {
this.corrDEMI(aprem, aprem.conge);
if ( compte != Undefined && compte != undefined && compte.isCalendaire() ) {
if ( salarie.getSolde(3, compte.numero).getJours() < 0.5 ) {
if ( compte.isCreditAuto() )
this.saisieDEMI(matin, compte);
else
this.saisieDEMImessage(matin, compte, 'Le compte va être débiteur');
}
else {
this.saisieDEMI(matin, compte);
}
}
else {
}
}
if ( matin.conge && aprem.conge ) {
this.corrDEMI(matin, matin.conge);
this.corrDEMI(aprem, aprem.conge);
}
}
}
}
else { //pas journée entière
if ( matin.conge ) {
if ( matin.conge.typeOf() != 'jourChome' ) {
this.corrDEMI(matin, matin.conge);
}
else { //Sinon, TP ou SA DI FE
if ( compte != Undefined && compte != undefined && compte.isCalendaire() ) {
if ( salarie.getSolde(3, compte.numero).getJours() < 0.5 ) {
if ( compte.isCreditAuto() )
this.saisieDEMI(matin, compte);
else
this.saisieDEMImessage(matin, compte, 'Le compte va être débiteur');
}
else {
this.saisieDEMI(matin, compte);
}
}
else {
}
}
}
else { //Pas de congé le matin, on peut donc saisir
if ( compte != Undefined && compte != undefined ) {
if ( salarie.getSolde(3, compte.numero).getJours() >= 0.5 ) {
this.saisieDEMI(matin, compte);
}
else { //Solde inférieur à 0.5, c'est qu'on est en mode manuel, car en mode auto, le compte n'aurait pas été sélectionné
if ( compte.isCreditAuto() )
this.saisieDEMI(matin, compte);
else
this.saisieDEMImessage(matin, compte, 'Le compte va être débiteur');
}
}
else { //Pas de compte de saisie, message
this.messageOnly(matin, 'Solde insuffisant<br>Passez en mode manuel');
}
}
if ( aprem.conge ) {
if ( aprem.conge.typeOf() != 'jourChome' ) {
this.corrDEMI(aprem, aprem.conge);
}
else { //Sinon, TP ou SA DI FE
if ( compte != Undefined && compte != undefined && compte.isCalendaire() ) {
if ( salarie.getSolde(3, compte.numero).getJours() < 0.5 ) {
if ( compte.isCreditAuto() )
this.saisieDEMI(aprem, compte);
else
this.saisieDEMImessage(aprem, compte, 'Le compte va être débiteur');
}
else {
this.saisieDEMI(aprem, compte);
}
}
else {
}
}
}
else { //Pas de congé l'aprem, on peut donc saisir
if ( compte != Undefined && compte != undefined ) {
if ( salarie.getSolde(3, compte.numero).getJours() >= 0.5 ) {
this.saisieDEMI(aprem, compte);
}
else { //Solde inférieur à 0.5, c'est qu'on est en mode manuel, car en mode auto, le compte n'aurait pas été sélectionné
if ( compte.isCreditAuto() )
this.saisieDEMI(aprem, compte);
else
this.saisieDEMImessage(aprem, compte, 'Le compte va être débiteur');
}
}
else { //Pas de compte de saisie, message
this.messageOnly(aprem, 'Solde insuffisant<br>Passez en mode manuel');
}
}
}
}
}
this.saisieALL = function(journee, matin, aprem, compte) {
matin.style.cursor = 'pointer';
aprem.style.cursor = 'pointer';
var AMbckColor = matin.style.backgroundColor;
var PMbckColor = aprem.style.backgroundColor;
journee.onmouseover = function() {
matin.style.backgroundColor = compte.getColor();
aprem.style.backgroundColor = compte.getColor();
}
journee.onmouseout = function() {
matin.style.backgroundColor = AMbckColor;
aprem.style.backgroundColor = PMbckColor;
}
matin.onclick = function() {
planningController.addCongeALL(this, compte);
}
aprem.onclick = function() {
planningController.addCongeALL(this, compte);
}
}
this.saisieALLmessage = function(journee, matin, aprem, compte, message) {
matin.style.cursor = 'pointer';
aprem.style.cursor = 'pointer';
var AMbckColor = matin.style.backgroundColor;
var PMbckColor = aprem.style.backgroundColor;
journee.onmouseover = function() {
matin.style.backgroundColor = compte.getColor();
aprem.style.backgroundColor = compte.getColor();
planningController.showMsg(message);
}
journee.onmouseout = function() {
matin.style.backgroundColor = AMbckColor;
aprem.style.backgroundColor = PMbckColor;
planningController.hideMsg();
}
matin.onclick = function() {
planningController.addCongeALL(this, compte);
planningController.hideMsg();
}
aprem.onclick = function() {
planningController.addCongeALL(this, compte);
planningController.hideMsg();
}
}
this.saisieDEMI = function(AMouPM, compte) {
AMouPM.style.cursor = 'pointer';
var bckColor = AMouPM.style.backgroundColor;
AMouPM.onmouseover = function() {
AMouPM.style.backgroundColor = compte.getColor();
}
AMouPM.onmouseout = function() {
AMouPM.style.backgroundColor = bckColor;
}
AMouPM.onclick = function() {
planningController.addCongeDEMI(this, compte);
}
}
this.saisieDEMImessage = function(AMouPM, compte, message) {
AMouPM.style.cursor = 'pointer';
var bckColor = AMouPM.style.backgroundColor;
AMouPM.onmouseover = function() {
AMouPM.style.backgroundColor = compte.getColor();
planningController.showMsg(message);
}
AMouPM.onmouseout = function() {
AMouPM.style.backgroundColor = bckColor;
planningController.hideMsg();
}
AMouPM.onclick = function() {
planningController.addCongeDEMI(this, compte);
planningController.hideMsg();
}
}
this.messageOnly = function(AMouPMouALL, message) {
AMouPMouALL.onmouseover = function() {
planningController.showMsg(message);
}
AMouPMouALL.onmouseout = function() {
planningController.hideMsg();
}
}
this.corrDEMI = function(AMouPM, conge) {
AMouPM.style.cursor = 'pointer';
AMouPM.onmouseover = function() {
comptesController.mode.getCompteSaisie(salariesController.getActiveSalarie()).out();
conge.compte.over();
mybro.setOpacity(AMouPM, 0.3);
}
AMouPM.onmouseout = function() {
conge.compte.out();
comptesController.mode.getCompteSaisie(salariesController.getActiveSalarie()).over();
mybro.setOpacity(AMouPM, 1);
}
AMouPM.onclick = function() {
mybro.setOpacity(AMouPM, 1);
planningController.remCongeDEMI(this, conge);
comptesController.mode.getCompteSaisie(salariesController.getActiveSalarie()).over();
}
}
this.showMsg = function(value) {
if ( viewPlanning.childNodes.message.innerHTML != value || !viewPlanning.childNodes.message.shown ) {
viewPlanning.childNodes.message.setInnerHTML(value);
Effect.show.call(viewPlanning.childNodes.message);
viewPlanning.childNodes.message.setOpacity(1);
}
}
this.hideMsg = function() {
Effect.fadeTo.call(viewPlanning.childNodes.message, 0, 200, true);
viewPlanning.childNodes.message.shown = false;
}
this.selectorOpened = false;
this.moisClicked = function(mois, top, left) {
( this.selectorOpened ) ? this.closeSelector() : this.openSelector(mois, top, left);
}
this.openSelector = function(mois, top, left) {
mois.doom.className = 'overflow';
this.viewMoisSelector = new viewMoisSelector(mois);
this.viewMoisSelector.body.setTop(top-38);
this.viewMoisSelector.body.setLeft(left+28);
mois.entete.appendChild_(this.viewMoisSelector.body);
this.viewMoisSelector.body.setVisible(true);
this.selectorOpened = true;
}
this.closeSelector = function() {
if ( this.viewMoisSelector ) {
this.viewMoisSelector.body.setVisible(false);
this.viewMoisSelector.body.parentNode.parentNode.className = '';
Util.collector.emptyChildNodes(this.viewMoisSelector.body);
if ( this.viewMoisSelector.body.parentNode )
this.viewMoisSelector.body.parentNode.removeChild_(this.viewMoisSelector.body);
delete(this.viewMoisSelector.body);
delete(this.viewMoisSelector);
this.selectorOpened = false;
}
}
}
Salarie = function(id, nom, prenom, dt_arr, dt_dep, profil, matricule, nbj_travaille_prec, nbj_travaille_encours, nbj_absence) {
Observable.call(this);
this.tabSoldes = new TabSoldes();
this.tabConges = new TabConges(this);
this.tabJoursChomes = new Array();
this.id = id;
this.matricule = matricule;
this.nom = nom;
Observable.call(this.nom);
this.prenom = prenom;
Observable.call(this.prenom);
this.dt_arr = new LDate(dt_arr);
Observable.call(this.dt_arr);
this.dt_dep = (dt_dep=='')?new UndefinedObject():new LDate(dt_dep);
Observable.call(this.dt_dep);
this.profil = profil;
this.profil_temp = this.profil;
this.nbj_travaille_prec = nbj_travaille_prec;
this.nbj_travaille_encours = nbj_travaille_encours;
this.nbj_absence = nbj_absence;
this.mail = '';
this.dateFinaleSoldes = new UndefinedObject();
this.dateDernierConge = new UndefinedObject();
this.setDateFinaleSoldes = function(date) {
this.dateFinaleSoldes.switchObservers(date);
this.dateFinaleSoldes = date;
this.dateFinaleSoldes.notifyObservers();
this.dateDernierConge = new LDate(date.getTime());
}
this.getDateFinaleSoldes = function() {
return this.dateFinaleSoldes;
}
this.setPrenom = function(value) {
this.prenom = value;
this.notifyObservers();
}
this.setNom = function(value) {
this.nom = value;
this.notifyObservers();
}
this.setMatricule = function(value) {
this.matricule = value;
this.notifyObservers();
}
this.setArrivee = function(value) {
if ( value != '' ) {
this.dt_arr = new LDate(value);
this.notifyObservers();
}
}
this.setDepart = function(value) {
if ( value != '' ) {
this.dt_dep = new LDate(value);
}
else {
this.dt_dep = new UndefinedObject();
}
this.notifyObservers();
}
this.isActif = function() {
return ( Date.dateDiff(Date.today, this.dt_dep) >= 0 || this.dt_dep.isUndefined )?true:false;
}
this.isPresent = function() {
return ( ( Date.dateDiff(controller.getDateInitialePlanning(), this.dt_dep) >= 0 || this.dt_dep.isUndefined ) && Date.dateDiff(this.dt_arr, controller.getDateFinalePlanning()) >= 0  ) ? true : false;
}
this.setProfil = function(value) {
this.profil = value;
this.profil_temp = value;
this.notifyObservers();
}
this.resetGetLibelle = function() {
this.getLibelle = function() {
return this.nom + ' ' + this.prenom;
}
}
this.resetGetLibelle();
this.getNom = function() {
return this.nom;
}
this.getPrenom = function() {
return this.prenom;
}
this.toString = function() {
return 'Salarie';
}
this.setActif = function(bln) {
this.actif = bln;
this.notifyObservers();
}
this.initSoldes = function() {
var dtDebutSolde = new LDate(controller.getDateDebutSoldes().toFullString());
controller.pool.newHttpRequest('server.asp?obj=compte&req=getSoldeJoursSaisisDroitsUser&dtmDebut='+dtDebutSolde.toFullString()+'&dtmFin='+controller.getDateFinSoldes().toFullString()+'&iUser='+this.id+'&intService='+LOC_ID_SERVICE, {
onSuccess: this.initSoldes_.bind(this)
});
}
this.initSoldes_ = function() {
this.loadSoldes.apply(this, [ arguments[0], 0 ]);
this.loadSoldes.apply(this, [ arguments[1], 1 ]);
var date = new LDate(arguments[2][1][0][0]);
Observable.call(date);
this.setDateFinaleSoldes(date);
this.loadSoldes.apply(this, [ arguments[2][0], 2 ]);
this.loadEstimationAu();
salariesController.soldesLoaded++;
salariesController.ifAllSoldesLoaded();
}
this.reloadSoldes = function() {
var dtDebutSolde = new LDate(controller.getDateDebutSoldes().toFullString());
controller.pool.newHttpRequest('server.asp?obj=compte&req=getSoldeJoursSaisisDroitsUser&dtmDebut='+dtDebutSolde.toFullString()+'&dtmFin='+controller.getDateFinSoldes().toFullString()+'&iUser='+this.id+'&intService='+LOC_ID_SERVICE, {
onSuccess: this.initSoldes_.bind(this)
});
for (var i=0; i < this.tabSoldes.tabSoldes.length; i++) {
for (var j=0; j < this.tabSoldes.tabSoldes[i].length; j++) {
if ( this.tabSoldes.tabSoldes[i][j] ) {
this.tabSoldes.tabSoldes[i][j].setJours(0);
}
}
}
}
this.switchSoldes = function(oldActiveSalarie) {
for (var i=0; i < 4; i++) {
for (var j=0; j < comptesController.getNbComptes(); j++) {
var k = parseInt(comptesController.tabComptes[j].numero);
oldActiveSalarie.getSolde(i,k).switchObservers(this.getSolde(i,k));
}
}
}
this.loadSoldes = function(soldes, colonne) {
for (var i=0; i < soldes.length; i++) {
var value = soldes[i][1];
var numero_compte = soldes[i][0];
if ( colonne != 0 || value != 0 || numero_compte > 999 ) {
var compte = comptesController.getCompteByNumber(numero_compte);
if ( !compte ) {
controller.pool.newHttpRequest('server.asp?obj=compte&req=getCompteTableau&intNumeroCompte='+numero_compte, {
onSuccess: comptesController.addComptes.bind(comptesController),
async: false
});
}
this.tabSoldes.tabSoldes[colonne][numero_compte].addJours(value);
}
}
}
this.loadEstimationAu = function() {
for (var i=0; i < comptesController.getNbComptes(); i++) {
var j = parseInt(comptesController.tabComptes[i].numero);
if ( this.getSolde(0,j) ) {
this.getSolde(3, j).setJours( Math.round((this.getSolde(0,j).getJours() - this.getSolde(1,j).getJours() + this.getSolde(2,j).getJours())*100, 2)/100);
}
}
}
this.getSolde = function(col, row) {
return this.tabSoldes.getSolde(col,row);
}
this.addConge = function(numeroCompte, date, duree, nbJours) {
this.tabConges.addConge(numeroCompte, date, duree, nbJours);
}
this.insertConge = function(conge, nbJours) {
var oldSalarieSelectionnePlanning = salariesController.salarieSelectionnePlanning;
salariesController.salarieSelectionnePlanning = this;
Aide.unregister(oldSalarieSelectionnePlanning.vuePlanning);
this.vuePlanning.setAidePlanning();
salariesController.setActiveSalarie(this);
oldSalarieSelectionnePlanning.notifyObservers();
controller.pool.newHttpRequest('server.asp?obj=planning&req=insCompEcritures&iUser='+this.id+'&iCompte='+conge.compte.numero+'&sLibelleCompte='+conge.compte.libelle+'&fNbj='+nbJours+'&dComptable='+conge.dateConge.toFullString()+'&sDuree='+conge.dateConge.duree+'&iCalendaire='+conge.compte.calendaire+'&iCompteAccorde='+conge.compte.contrePartieAccorde+'&iCompteConso='+conge.compte.contrePartieConso, {
noRed: true
});
}
this.addJoursSaisis = function(compte, date, value) {
if (date.toFullString() == controller.getDateDebutSoldes().toFullString()) {
this.getSolde(0, compte.numero).addJours(-value);
this.getSolde(0, compte.numero).blink();
}
else {
this.getSolde(1, compte.numero).addJours(value);
this.getSolde(1, compte.numero).blink();
}
if ( compte.isCreditAuto() ) {
if (date.toFullString() == controller.getDateDebutSoldes().toFullString())
this.getSolde(0, compte.numero).addJours(value);
else
this.getSolde(2, compte.numero).addJours(value);
}
this.loadEstimationAu();
comptesController.mode.setCompteSaisie(comptesController.mode.getCompteSaisie(this), this);
}
this.initJoursChomes = function(date1, date2) {
controller.pool.newHttpRequest('server.asp?obj=planning&req=getPlanningBaseUser&dtmDebut='+date1.toFullString()+'&dtmFin='+date2.toFullString()+'&iUser='+this.id, {
onSuccess: this.initJoursChomes_.bind(this)
});
}
this.initJoursChomes_ = function() {
for (var i=0; i < arguments.length; i++) {
this.tabJoursChomes.push( new Conge( Undefined, this, new LDate( arguments[i][0], arguments[i][1] ), +1) );
}
salariesController.tryInitHashAndPlanning();
}
this.getInfosJoursTravailles = function() {
controller.pool.newHttpRequest('server.asp?obj=user&req=getInfosJoursTravailles&dArrivee='+this.dt_arr.toFullString()+'&dDepart='+this.dt_dep.toFullString()+'&iUser='+this.id, {
onSuccess: this.getInfosJoursTravailles_.bind(this),
async: false
});
}
this.getInfosJoursTravailles_ = function(nbj_travaille_prec, nbj_travaille_encours, nbj_absence) {
this.nbj_travaille_prec = nbj_travaille_prec;
this.nbj_travaille_encours = nbj_travaille_encours;
this.nbj_absence = nbj_absence;
}
this.get_nbj_travaille_prec = function() {
return this.nbj_travaille_prec;
}
this.get_nbj_travaille_encours = function() {
return this.nbj_travaille_encours;
}
this.get_nbj_absence = function() {
return this.nbj_absence;
}
}
SalarieActif = function() {
Observable.call(this);
this.getLibelle = function() {
return salariesController.getActiveSalarie().getLibelle();
}
}
function salariesController() {
this.activeSalarie = new UndefinedObject();
this.salarieActif = new SalarieActif();
this.getSalarieActif = function() {
return this.salarieActif;
}
this.soldesLoaded = 0;
this.tabSalaries = new Array();
this.hashConges = new Array();
this.salariesLoaded = false;
this.loadSalaries = function() {
controller.pool.newHttpRequest('server.asp?obj=user&req=getAllUsers', {
onSuccess: function() {
salariesController.loadSalaries_.apply(salariesController, arguments);
salariesController.reloadSoldes( function() {
congesController.loadConges();
salariesController.initJoursChomes();
});
}
});
}
this.loadSalaries_ = function() {
for (var i=0; i < arguments.length; i++) {
var salarie = new Salarie(arguments[i][0], arguments[i][1], arguments[i][2], arguments[i][3], arguments[i][4], arguments[i][5], arguments[i][6], arguments[i][7], arguments[i][8], arguments[i][9]);
salarie.indice = this.tabSalaries.push(salarie)-1; //La salarié mémorise son indice dans le tableau
if ( salarie.isPresent() )
controller.addViewSalarie(salarie);
}
this.setActiveSalarie(viewBodyPlanning.childNodes.salaries.tabViewSalaries[0].observed);
this.salarieSelectionnePlanning = viewBodyPlanning.childNodes.salaries.tabViewSalaries[0].observed;
this.salarieSelectionnePlanning.vuePlanning.setAidePlanning();
this.activeSalarieSoldes = viewBodyPlanning.childNodes.salaries.tabViewSalaries[0].observed;
this.salariesLoaded = true;
}
this.setActiveSalarie = function(salarie) {
salarie.setActif(true);
if ( this.activeSalarie != salarie ) {
var oldSalarie = this.activeSalarie;
this.activeSalarie = salarie;
oldSalarie.setActif(false);
this.activeSalarie.notifyObservers();
this.salarieActif.notifyObservers();
oldSalarie.switchObservers(this.activeSalarie);
this.activeSalarie.switchSoldes(oldSalarie);
}
}
this.getActiveSalarie = function() {
return this.activeSalarie;
}
this.setActiveSalarieSoldes = function(salarie) {
this.activeSalarieSoldes = salarie;
}
this.getSolde = function(col, row) {
return this.getActiveSalarie().getSolde(col, row);
}
/*this.openSelector = function() {
if (!this.selector) {
this.selector = new salariesSelector(this);
this.controller.bind(this.selector);
}
this.selector.update();
this.selector.doom.setVisible(true);
this.selectorOpened = true;
}*/
/*this.closeSelector = function() {
this.selector.doom.setVisible(false);
this.selectorOpened = false;
}*/
this.getTabSalaries = function() {
return this.tabSalaries;
}
/*this.getTabComptes = function() {
return this.controller.getTabComptes();
}*/
/*this.getNbComptes = function() {
return this.controller.getNbComptes();
}*/
/*this.getCompteByNumber = function(value) {
return this.controller.getCompteByNumber(value);
}*/
/*this.getNumeroCompte = function(index) {
return this.controller.getNumeroCompte(index);
}*/
this.getNbSalaries = function() {
return this.tabSalaries.length;
}
this.getNbSalariesPresents = function() {
var i = 0;
for (var j=0; j < this.tabSalaries.length; j++) {
if ( this.tabSalaries[j].isPresent() )
i++;
}
return i;
}
this.getTabViewSoldes = function() {
return controller.getTabViewSoldes();
}
this.reloadSoldes = function( andAfter ) {
this.andAfter = function() {};
if ( andAfter ) {
this.andAfter = andAfter;
}
this.soldesLoaded = 0;
for ( var i=0; i < this.tabSalaries.length; i++ ) {
this.tabSalaries[i].reloadSoldes();
}
}
this.ifAllSoldesLoaded = function() {
if (this.soldesLoaded == this.tabSalaries.length) {
controller.dateInitialePlanning.notifyObservers();
controller.dateFinalePlanning.notifyObservers();
this.calculeComptesSaisieAuto();
this.andAfter();
}
}
this.getSalarieById = function(value) {
for (var i=0; i < this.tabSalaries.length; i++) {
if ( this.tabSalaries[i].id == value )
return this.tabSalaries[i];
}
return new UndefinedObject();
}
this.getSalarieByOrder = function(value) {
return this.tabSalaries[value];
}
this.initJoursChomes = function() {
for (var i=0; i < this.tabSalaries.length; i++) {
this.tabSalaries[i].initJoursChomes(planningController.dateInitialeConges, planningController.dateFinaleConges);
}
}
this.tryInitHashAndPlanning = function() {
this.count = (this.count+1||1);
if (this.count==this.tabSalaries.length+1) { //Le +1 est pour les congés, 1 seule requête pour tous les salariés
this.initHash();
planningController.resetCalendrier();
planningController.setEventCalendrier();
Effect.hide.call(viewGrillePlanning.childNodes.grisage);
this.count = 0;
}
}
this.initHash = function() {
this.hashConges = new Array();
for (var i=0; i < this.tabSalaries.length; i++) {
var salarie = this.tabSalaries[i];
var tabJours = Array.concat(salarie.tabConges.tabConges, salarie.tabJoursChomes);
for (var j=0; j < tabJours.length; j++) {
var k = Date.dateDiff(controller.getDateInitialePlanning(), tabJours[j].dateConge);
var l = ( tabJours[j].typeOf() != 'jourChome' ) ? 0 : 1;
var m = ( tabJours[j].dateConge.duree == 'AM' ) ? 1 : ( ( tabJours[j].dateConge.duree == 'PM' ) ? 2 : 0 );
if ( !this.hashConges[k+GLO_NB_JOURS] )
this.hashConges[k+GLO_NB_JOURS] = new Array();
if ( !this.hashConges[k+GLO_NB_JOURS][i] )
this.hashConges[k+GLO_NB_JOURS][i] = new Array();
if ( !this.hashConges[k+GLO_NB_JOURS][i][l] )
this.hashConges[k+GLO_NB_JOURS][i][l] = new Array();
this.hashConges[k+GLO_NB_JOURS][i][l][m] = tabJours[j];
}
}
}
this.resetConges = function() {
for (var i=0; i < this.tabSalaries.length; i++) {
this.tabSalaries[i].tabConges.tabConges = new Array();
this.tabSalaries[i].tabJoursChomes = new Array();
}
}
this.addTabSoldes = function( compte ) {
for (var i=0; i < this.tabSalaries.length; i++) {
this.tabSalaries[i].tabSoldes.addSolde(compte, 0, 0);
this.tabSalaries[i].tabSoldes.addSolde(compte, 1, 0);
this.tabSalaries[i].tabSoldes.addSolde(compte, 2, 0);
this.tabSalaries[i].tabSoldes.addSolde(compte, 3, 0);
}
}
this.calculeComptesSaisieAuto = function() {
for (var i=0; i < this.tabSalaries.length; i++) {
comptesController.mode.setCompteSaisie(comptesController.mode.getCompteSaisie(this.tabSalaries[i]), this.tabSalaries[i]);
}
}
this.checkSalariesPresents = function() {
for (var i=0; i < this.tabSalaries.length; i++) {
if ( !this.tabSalaries[i].isPresent() ) {
viewBodyPlanning.childNodes.salaries.remViewSalarie(this.tabSalaries[i]);
if ( this.tabSalaries[i] == this.getActiveSalarie() ) {
var undefinedSalarie =  new UndefinedObject();
if ( viewBodyPlanning.childNodes.salaries.tabViewSalaries[0] ) {
this.setActiveSalarie(viewBodyPlanning.childNodes.salaries.tabViewSalaries[0].observed);
salariesController.salarieSelectionnePlanning = viewBodyPlanning.childNodes.salaries.tabViewSalaries[0].observed;
viewBodyPlanning.childNodes.salaries.tabViewSalaries[0].setAidePlanning();
}
else {
this.setActiveSalarie(undefinedSalarie);
salariesController.salarieSelectionnePlanning = undefinedSalarie;
}
}
}
else { //Ce salarié doit être présent dans le planning, on crée sa ligne si elle n'existe pas déjà
var blnFound = false;
for (var j=0; j < viewBodyPlanning.childNodes.salaries.tabViewSalaries.length; j++) {
if ( viewBodyPlanning.childNodes.salaries.tabViewSalaries[j].observed == this.tabSalaries[i] ) {
blnFound = true;
break;
}
}
if ( !blnFound ) {
viewBodyPlanning.childNodes.salaries.addViewSalarie(this.tabSalaries[i]);
planningController.resetLigne(i, viewGrillePlanning.calendar.doom.lastChild);
planningController.setEventLigne(i, viewGrillePlanning.calendar.doom.lastChild);
}
}
}
}
}
Compte = function(numero, libelle, contre_partie_accorde, contre_partie_conso, numero_affichage, debut_acq, fin_acq, nb_jours, debut_conso, fin_conso, calendaire, pastille) {
Observable.call(this);
this.view = null;
this.numero = numero;
this.libelle = libelle;
this.numeroAffichage = numero_affichage;
this.contrePartieAccorde = contre_partie_accorde;
this.contrePartieConso = contre_partie_conso;
this.debutAcq = new LDate(debut_acq);
this.finAcq = new LDate(fin_acq);
this.nbJours = nb_jours;
this.debutConso = new LDate(debut_conso);
this.finConso = new LDate(fin_conso);
this.calendaire = calendaire; //0 ou 1 selon que le compte est calendaire ou pas
this.pastille = pastille||comptesController.calculePastille(this);
this.isCalendaire = function() {
return this.calendaire;
}
this.isRecurrent = function() {
return debut_acq;
}
this.isCreditAuto = function() {
return ( this.numero == this.contrePartieConso );
}
this.getLibelle = function() {
return this.libelle;
}
this.getPastille = function() {
return this.pastille;
}
this.setPastille = function(pastille) {
this.pastille = pastille;
this.notifyObservers();
}
this.getColor = function() {
return GLO_COL_CPT[this.pastille];
}
this.getBackgroundColor = function() {
return this.backgroundColor||this.color||'#FFF';
}
this.setBackground = function( color ) {
this.backgroundColor = color;
this.notifyObservers();
}
this.over = function() {
this.isOver = true;
this.notifyObservers();
}
this.out = function() {
this.isOver = false;
this.notifyObservers();
}
this.grise = function() {
this.isGris = true;
this.notifyObservers();
}
this.degrise = function() {
this.isGris = false;
this.notifyObservers();
}
this.outDelayed = function() {
this.isOver = false;
setTimeout( function() {
this.notifyObservers();
}.bind(this), 50);
}
}
function comptesController() {
this.tabComptes = new Array();
this.comptesLoaded = false;
this.compteActif = Undefined;
this.getNbComptes = function() {
return this.tabComptes.length;
}
this.getCompteByNumber = function(value) {
for (var i=0; i < this.tabComptes.length; i++) {
if ( this.tabComptes[i].numero == value ) {
return this.tabComptes[i];
}
}
return null;
}
this.calculePastille = function(compte) {
var pastille = compte.pastille;
if ( compte.numero >= 100 && compte.numero < 300 ) {
var datePlanning = controller.getDateInitialePlanning();
if ( compte.finConso < datePlanning )
pastille = 'ROUGE';
else { //Sinon
if ( compte.debutConso <= datePlanning )
pastille = 'ORANGE';
else { //Sinon, c'est que c'est A+1
pastille = 'JAUNE';
}
}
}
if ( compte.numero >= 300 && compte.numero < 600 ) {
var datePlanning = controller.getDateInitialePlanning();
if ( compte.debutConso <= datePlanning )
pastille = 'VERT';
else {
pastille = 'PISTACHE';
}
}
return pastille;
}
/*this.getTabComptes = function() {
return this.tabComptes;
}*/
this.setAllBackground = function( color ) {
for (var i=0; i < this.tabComptes.length; i++) {
this.tabComptes[i].setBackground(color);
}
}
this.addComptes = function() {
for (var i=0; i < arguments.length; i++)
this.addCompte.apply(this, arguments[i]);
}
this.addCompte = function() {
if ( !this.getCompteByNumber(arguments[0]) ) {
var compte = new Compte(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8], arguments[9], arguments[12], arguments[13]);
this.insertCompte(compte);
viewComptes.addViewCompte(compte);
for (var j=0; j < salariesController.tabSalaries.length; j++) {
salariesController.tabSalaries[j].tabSoldes.addSolde( compte, 0, 0);
salariesController.tabSalaries[j].tabSoldes.addSolde( compte, 1, 0);
salariesController.tabSalaries[j].tabSoldes.addSolde( compte, 2, 0);
salariesController.tabSalaries[j].tabSoldes.addSolde( compte, 3, 0);
}
viewSoldes.tabViewSoldes[0].addViewSolde(salariesController.activeSalarie.tabSoldes.tabSoldes[0][compte.numero]);
viewSoldes.tabViewSoldes[1].addViewSolde(salariesController.activeSalarie.tabSoldes.tabSoldes[1][compte.numero]);
viewSoldes.tabViewSoldes[2].addViewSolde(salariesController.activeSalarie.tabSoldes.tabSoldes[2][compte.numero]);
viewSoldes.tabViewSoldes[3].addViewSolde(salariesController.activeSalarie.tabSoldes.tabSoldes[3][compte.numero]);
}
}
this.delCompte = function(iCompte) {
var compte = this.getCompteByNumber(iCompte);
viewComptes.remViewCompte(compte);
}
this.insertCompte = function(compte) {
var position = 0;
for (var i=0; i < this.tabComptes.length; i++) {
if ( this.tabComptes[i].numeroAffichage > compte.numeroAffichage )
break;
position++;
}
this.tabComptes.insert(compte, position);
}
this.updatePastilles = function() {
for (var i=0; i < this.tabComptes.length; i++) {
this.tabComptes[i].setPastille(this.calculePastille(this.tabComptes[i]));
this.tabComptes[i].notifyObservers();
}
}
/*this.addViewCompte = function(compte) {
controller.mesSoldesController.addViewCompte(compte);
controller.setHeightPaveDroit();
}*/
this.mode = modeAuto;
}
modeAuto = {
mouseoverView: function() {
this.compte.isOver = true;
this.childNodes.pastille.setBackground('url('+GLO_IMG_REP+this.compte.getPastille()+'_actif.gif) 0px 2px #FFF no-repeat');
this.childNodes.txt.setBackgroundColor('#FEC900');
},
mouseoutView: function() {
this.compte.isOver = false;
this.childNodes.pastille.setBackground('url('+GLO_IMG_REP+this.compte.getPastille()+'_sortie.gif) 0px 2px #FFF no-repeat');
this.childNodes.txt.setBackgroundColor('#FFF');
},
mousedownView: function() {
this.childNodes.pastille.setBackground('url('+GLO_IMG_REP+this.compte.getPastille()+'_enfonce.gif) 0px 2px #FFF no-repeat');
this.childNodes.txt.setBackgroundColor('#FF8200');
comptesController.mode.switchMode();
comptesController.mode.setCompteSaisie(this.compte);
planningController.resetCalendrier();
planningController.setEventCalendrier();
},
mouseupView: function() {
},
switchMode: function() {
comptesController.mode = modeManuel;
},
getCompteSaisie: function(salarie) {
return salarie.compteSaisie;
},
setCompteSaisie: function(compte, salarie) {
compte = compte||Undefined;
salarie.compteSaisie = Undefined;
var tabEstimationAu = salarie.tabSoldes.tabEstimationAu;
for (var i=0; i < comptesController.getNbComptes(); i++) {
if ( salarie.getSolde(3, parseInt(comptesController.tabComptes[i].numero)).getJours() >= 0.5 ) {
salarie.compteSaisie = comptesController.tabComptes[i];
break;
}
}
if ( salarie.compteSaisie != compte ) {
compte.out();
}
}
}
modeManuel = {
mouseoverView: function() {
this.compte.isOver = true;
},
mouseoutView: function() {
this.compte.isOver = false;
},
mousedownView: function() {
if ( this.compte == comptesController.mode.compteSaisie ) {
comptesController.mode.compteSaisie.observers[0].childNodes.pastille.setBackground('url('+GLO_IMG_REP+comptesController.mode.compteSaisie.getPastille()+'_sortie.gif) 0px 2px #FFF no-repeat');
comptesController.mode.compteSaisie.observers[0].childNodes.txt.setBackgroundColor('#FFF');
this.childNodes.pastille.setBackground('url('+GLO_IMG_REP+this.compte.getPastille()+'_actif.gif) 0px 2px #FFF no-repeat');
this.childNodes.txt.setBackgroundColor('#FEC900');
for (var i=0; i < comptesController.getNbComptes(); i++) {
comptesController.tabComptes[i].degrise();
}
comptesController.mode.switchMode();
planningController.resetCalendrier();
planningController.setEventCalendrier();
}
},
mouseupView: function() {
},
switchMode: function() {
comptesController.mode = modeAuto;
},
getCompteSaisie: function() {
return this.compteSaisie;
},
setCompteSaisie: function(compte) {
for (var i=0; i < comptesController.getNbComptes(); i++) {
comptesController.tabComptes[i].grise();
}
compte.degrise();
this.compteSaisie = compte;
}
}
TabSoldes = function() {
Observable.call(this);
this.tabSoldes = new Array();
this.tabSoldeAu = new Array();
this.tabJoursSaisis = new Array();
this.tabDroits = new Array();
this.tabEstimationAu = new Array();
this.tabSoldes.push(this.tabSoldeAu, this.tabJoursSaisis, this.tabDroits, this.tabEstimationAu);
this.addSolde = function(compte, offset, value) {
var solde = new Solde(compte, value);
this.tabSoldes[offset][compte.numero] = solde;
}
this.getSolde = function(col, row) {
return this.tabSoldes[col][row]||Undefined;
}
}
Solde = function(compte, value) {
Observable.call(this);
this.compte = compte;
this.nb = parseFloat(value);
this.getJours = function() {
return this.nb;
}
this.setJours = function(value) {
this.nb = parseFloat(value);
this.notifyObservers();
}
this.addJours = function(value) {
this.setJours( this.nb + value );
}
this.afficheDetailEcritures = function(salarie, compte) { //A partir du 3ème argument, ce sont les écritures
var detail = $A(arguments); detail.shift(); detail.shift(); //ON vire le salarie et le compte
var html = 'Compte '+compte.getLibelle()+' pour '+salarie.getLibelle()+'<br><br>';
html += '<table id="detail"><tr><th>Date</th><th>Libellé</th><th>Débit</th><th>Crédit</th></tr>';
var debit = 0;
var credit = 0;
for (var i=0; i < detail.length; i++) {
html += '<tr><td>'+detail[i][1]+'</td><td>'+detail[i][2]+'</td><td align="right">'+(detail[i][3]==0?'-':detail[i][3])+'</td><td align="right">'+(detail[i][4]==0?'-':detail[i][4])+'</td></tr>';
debit += detail[i][3];
credit += detail[i][4];
}
html += '<tr><td colspan="2" align="right" class="big">Solde</td><td colspan="2" align="right" class="big">'+Math.round((credit-debit)*100)/100+'</td></tr>';
html += '</table>';
viewPopUp.childNodes.titre.setInnerHTML('Historique des écritures');
viewPopUp.affiche(html);
viewPopUp.body.setTop(120);
viewPopUp.body.setLeft(236+this.parentNode.getLeft()+mainView.childNodes.paveGauche.getWidth());
Aide.unregister(viewPopUp.body);
Aide.register(viewPopUp.body, 'accueil', 'soldeau', false, {
options: {
$date_debut_soldes: controller.getDateDebutSoldes().toString()
}
});
Effect.show.call(viewPopUp.body);
}
this.afficheDetailAbsences = function(salarie, compte) { //A partir du 3ème argument, ce sont les écritures
var detail = $A(arguments); detail.shift(); detail.shift(); //ON vire le salarie et le compte
var html = 'Compte '+compte.getLibelle()+' pour '+salarie.getLibelle()+'<br><br>';
html += '<table id="detail"><tr><th>Date</th><th>Libellé</th><th>Débit</th><th>Crédit</th></tr>';
var debit = 0;
for (var i=0; i < detail.length; i++) {
if ( detail[i][3] == compte.numero ) {
var nbJours = detail[i][2];
if ( nbJours != 0 ) {
var libelle = 'Journée prise';
if ( nbJours == 0.5 ) //Demi journée positive
libelle = 'Demi journée prise';
if ( nbJours == -0.5 ) //Demi journée enlevée
libelle = 'Demi journée annulée';
if ( nbJours == -1 ) //Demi journée enlevée
libelle = 'Journée annulée';
html += '<tr><td>'+detail[i][1]+'</td><td>'+libelle+'</td><td align="right">'+detail[i][2]+'</td><td align="right">-</td></tr>';
debit += detail[i][2];
}
}
}
html += '<tr><td colspan="2" align="right" class="big">Solde</td><td colspan="2" align="right" class="big">'+(-debit)+'</td></tr>';
html += '</table>';
viewPopUp.childNodes.titre.setInnerHTML('Congés ou absences pris');
viewPopUp.affiche(html);
viewPopUp.body.setTop(120);
viewPopUp.body.setLeft(236+this.parentNode.getLeft()+mainView.childNodes.paveGauche.getWidth());
Aide.unregister(viewPopUp.body);
Aide.register(viewPopUp.body, 'accueil', 'jourssaisis', false, {
options: {
$date_debut_soldes: controller.getDateDebutSoldes().toString()
}
});
Effect.show.call(viewPopUp.body);
}
this.blink = function() {
this.observers[0].blink();
}
}
/*soldesController = function() {
Observable.call(this);
}*/
mesSoldesController = function() {
this.size = 20;
/*this.getNbComptes = function() {
return this.controller.getNbComptes();
}*/
/*this.getDateInitiale = function() {
return controller.getDateDebutSoldes();
}*/
/*this.getDateFinale = function() {
return controller.getDateFinaleSoldes();
}*/
/*this.getDateInitialePlanning = function() {
return controller.getDateInitialePlanning();
}*/
/*this.getDateFinalePlanning = function() {
return controller.getDateFinalePlanning();
}*/
/*this.getActiveSalarie = function() {
return this.controller.getActiveSalarie();
}*/
/*this.getActiveSalarieId = function() {
return this.controller.getActiveSalarie().id;
}*/
/*this.getTabViewComptes = function() {
return this.viewComptes.tabView;
}*/
/*this.getTabViewSoldes = function() {
return this.viewSoldes.tabViewSoldes;
}*/
/*this.getNumeroCompte = function(value) {
return this.controller.getTabComptes()[value].numero;
}*/
/*this.salarieSoldesClicked = function() {
( this.selectorOpened ) ? this.closeSelector() : this.openSelector();
}*/
/*this.openSelector = function() {
viewSalariesSelector.build();
viewSalariesSelector.update();
viewSalariesSelector.body.setVisible(true);
this.selectorOpened = true;
}*/
/*this.closeSelector = function() {
viewSalariesSelector.body.setVisible(false);
this.selectorOpened = false;
}*/
/*this.getViewSalarie = function() {
return this.viewSalarie;
}*/
/*this.addViewCompte = function(compte) {
viewComptes.addViewCompte(compte);
}*/
this.orderByNumeroAffichage = function() {
for (var i=0; i < viewSoldes.tabViewSoldes.length; i++) {
var tbl_temp = new Array();
for (var j=0; j < viewSoldes.tabViewSoldes[i].length; j++)
tbl_temp[viewSoldes.tabViewSoldes[i].tabView[j].solde.compte.numeroAffichage] = viewSoldes.tabViewSoldes[i].tabView[j];
viewSoldes.tabViewSoldes[i].tabView = new Array();
for (var j=0; j < tbl_temp.length; j++) {
if ( tbl_temp[j] )
viewSoldes.tabViewSoldes[i].tabView.push(tbl_temp[j]);
}
}
}
}
Aide = new Object();
Aide.observers = new Array();
Aide.register = function(el, node, att, sync, params) {
el.isAide = true;
Event.addevent.call(el, 'mouseover', function() {});
Event.addevent.call(el, 'mouseout', function() {});
Aide.observers.push([el, node, att, sync, params]);
}
Aide.unregister = function(el) {
if ( el.isAide ) {
Aide.observers.each( function(obs, i) {
if ( obs[0] == el ) {
Aide.observers.splice(i, 1);
el.isAide = false;
return ;
}
});
}
}
function aideController() {
this.aides = {};
this.setTitre = function(texte) {
viewAide.childNodes.titre.setInnerHTML(texte);
}
this.setTexte = function(texte) {
viewAide.childNodes.texte.setInnerHTML(texte);
}
this.setAide = function(node, att, sync, params, el) {
var options = undefined;
if ( params ) {
options = params.options;
}
if ( !this.aides[node+att] ) {
if ( params ) {
if ( params.toDoBefore ) {
params.toDoBefore.call(el);
}
}
this.nodeAtt = node+att;
controller.pool.newHttpRequest('server.asp?obj=aide&sNode='+node+'&req='+att, {
onSuccess: this.setAide_.bind(this, el, this.nodeAtt, sync, options)
});
}
else { //L'aide est déjà chargée en local
if ( this.nodeAtt != node+att ) {
if ( params ) {
if ( params.toDoBefore ) {
params.toDoBefore.call(el);
}
}
this.nodeAtt = node+att;
this.setAide_(el, this.nodeAtt, sync, options, this.aides[this.nodeAtt]);
}
else { //C'est celle qui est déjà affichée, mais on doit la mettre à jour s'il y a des options locales uniquement
if ( params && !params.toDoBefore ) {
this.setAide_(el, this.nodeAtt, sync, options, this.aides[this.nodeAtt]);
}
}
}
}
this.setAide_ = function(el, nodeAtt, sync, options, tabAide) {
this.setTitre(this.replaceText(tabAide[0], options, el));
this.setTexte(this.replaceText(tabAide[1], options, el));
if ( !this.aides[nodeAtt] ) {
this.aides[nodeAtt] = [ tabAide[0], tabAide[1], tabAide[2] ];
}
}
this.replaceText = function(texte, options, el) {
if ( !options )
return texte;
else {//Il y a des options
if ( texte.indexOf('$') != -1 ) {
for (var i in options) {
var reg = new RegExp('(\\'+i+')', 'g');
if ( typeof(options[i]) == 'function' && !options.constructor.prototype[i] ) { //Il ne faut pas exécuter les méthodes qu'on a rajouté sur les Object dont options fait partie
texte = texte.replace(reg, options[i].call(el));
}
else
texte = texte.replace(reg, options[i]);
}
return texte;
}
else //Sinon on retourne le texte brut
return texte;
}
}
this.reset = function() {
this.setAide(viewAideModule, viewAideAttribut);
}
this.start = function() {
setInterval( function() {
if ( Mouse.e ) {
var el = Mouse.e.LTarget;
var tabEl = [el];
while ( el = el.parentNode ) {
tabEl.push(el);
}
for (var i=0; i < tabEl.length; i++) {
for (var j=0; j < Aide.observers.length; j++) {
if ( tabEl[i] == Aide.observers[j][0] ) {
var node = Aide.observers[j][1];
var att = Aide.observers[j][2];
var sync = Aide.observers[j][3];
var params = Aide.observers[j][4];
this.setAide(node, att, sync, params, tabEl[i]);
return true;
}
}
}
this.reset();
}
}.bind(this), 500);
this.reset();
}
}
TabConges = function(salarie) {
this.salarie = salarie;
this.tabConges = new Array();
this.addConge = function(numeroCompte, date, duree, nbJours) {
var journee = new Array();
for (var i=0; i < this.tabConges.length; i++) {
if ( this.tabConges[i] && this.tabConges[i].dateConge.toFullString() == date ) {
journee[(this.tabConges[i].dateConge.duree=='AM'?1:(this.tabConges[i].dateConge.duree=='PM'?2:0))] = this.tabConges[i];
journee[(this.tabConges[i].dateConge.duree=='AM'?1:(this.tabConges[i].dateConge.duree=='PM'?2:0))].indice = i;
}
}
var compte = comptesController.getCompteByNumber(numeroCompte);
if ( !compte ) {
controller.pool.newHttpRequest('server.asp?obj=compte&req=getCompteTableau&intNumeroCompte='+numeroCompte, {
onSuccess: comptesController.addComptes.bind(comptesController),
async: false
});
}
if ( journee.length == 0 ) {
if ( nbJours > 0 ) {
var conge = new Conge( comptesController.getCompteByNumber(numeroCompte), this.salarie, new LDate( date, duree), Math.abs(nbJours)/nbJours);
this.tabConges.push(conge);
}
else { //Ici on a une correction en premier, ce n'est pas normal
alert(this.salarie.getLibelle(), date, 'Congé négatif avant congé positif\n'+nbJours+' sur le compte '+numeroCompte);
}
}
if ( journee.length > 0 ) {
if ( journee[0] ) {
if ( nbJours < 0 ) {
if ( duree == 'AM' )
journee[0].dateConge.duree = 'PM';
if ( duree == 'PM' )
journee[0].dateConge.duree = 'AM';
if ( duree != 'AM' && duree != 'PM' )
alert(this.salarie.getLibelle(), date, 'Congé négatif ALL impossible');
}
else
alert(this.salarie.getLibelle(), date, 'Congé positif alors que congé ALL déjà présent')
}
else { //Le congé n'est pas homogène sur toute la journée, c'est donc soit AM, soit PM soit les deux
if ( journee[1] && !journee[2] ) {
if ( (duree == 'AM' && nbJours < 0) || (duree == 'PM' && nbJours > 0) ) {
if ( duree == 'AM' && nbJours < 0 ) {
this.tabConges.splice(journee[1].indice, 1);
}
if ( duree == 'PM' && nbJours > 0 ) {
var conge = new Conge( comptesController.getCompteByNumber(numeroCompte), this.salarie, new LDate( date, duree), Math.abs(nbJours)/nbJours);
this.tabConges.push(conge);
}
}
else
alert(this.salarie.getLibelle(), date, 'Congé autre que négatif AM ou positif PM');
}
if ( !journee[1] && journee[2] ) {
if ( (duree == 'PM' && nbJours < 0) || (duree == 'AM' && nbJours > 0) ) {
if ( duree == 'PM' && nbJours < 0 )
this.tabConges.splice(journee[2].indice, 1);
if ( duree == 'AM' && nbJours > 0 ) {
var conge = new Conge( comptesController.getCompteByNumber(numeroCompte), this.salarie, new LDate( date, duree), Math.abs(nbJours)/nbJours);
this.tabConges.push(conge);
}
}
else
alert(this.salarie.getLibelle(), date, 'Congé autre que négatif PM ou positif AM');
}
if ( journee[1] && journee[2] ) {
if ( ( duree=='AM' || duree=='PM' ) && nbJours < 0 ) {
this.tabConges.splice(journee[(duree=='AM')?1:2].indice,1);
}
else
alert(this.salarie.getLibelle(), date, 'Congé autre que négatif AM ou néagtif PM');
}
}
}
}
}
Conge = function(compte, salarie, date, signe) {
Observable.call(this);
this.compte = compte;
this.salarie = salarie;
this.dateConge = date;
this.signe = signe;
this.typeOf = function() {
if ( this.compte == Undefined )
return 'jourChome';
else {
return 'conge';
}
}
}
congesController = function() {
Observable.call(this);
this.loadConges = function() {
controller.pool.newHttpRequest('server.asp?obj=planning&req=getPlanning&dtmDebut='+planningController.dateInitialeConges.toFullString()+'&dtmFin='+planningController.dateFinaleConges.toFullString()+'&intService='+LOC_ID_SERVICE, {
onSuccess: this.loadConges_.bind(this)
});
}
this.loadConges_ = function() {
for (var i=0; i < arguments.length; i++) {
var id = arguments[i][0];
var numeroCompte = arguments[i][3];
var nbJours = arguments[i][5];
var duree = arguments[i][6];
var date = arguments[i][7];
salariesController.getSalarieById(parseInt(id)).addConge(numeroCompte, date, duree, nbJours);
}
salariesController.tryInitHashAndPlanning();
}
}
function uneDemiCaseListing(numJour, iUser, blnJC) { //blnJC indique si on veut une case blanche ou jaune
this.NumeroDuJour = Math.ceil(numJour/2);
var left = 10 * (numJour - 1) ;
if(numJour % 2 != 0){
var sStyle = 'dotted dotted dotted solid';
var sDuree = 'AM';
}
else { //Divisible par 2 donc PM
var sStyle = 'dotted solid solid solid';
var sDuree = 'PM';
}
this.iName = iUser+'_'+this.NumeroDuJour+'_'+sDuree;
this.html = new LDivElement( this.iName, (blnJC == 1?'caseTP':'caseNormal'), 65, '', '0px 1px 0px 0px', sStyle, '#FF8200 #FF8200 #FF8200 #FF8200', '0px', 0, left, 22, 10, '', { token: 1});
}
function uneDemiCaseHistorique(numJour, iUser, blnJC) {
uneDemiCaseListing.call(this, numJour, iUser, blnJC);
this.html.setLeft(10 * (numJour - 1) + 180);
this.html.setBorder('', '1px '+this.html.border.borderWidthRight+'px 1px '+this.html.border.borderWidthLeft+'px', 'solid '+this.html.border.borderStyleRight+' solid '+this.html.border.borderStyleLeft, '#FF8200 '+this.html.border.borderColorRight+' #FF8200 '+this.html.border.borderColorLeft);
if ( numJour == 1 ) {
this.html.setLeft(10 * (numJour - 1) + 179);
this.html.setWidth(11);
this.html.setBorder('', '1px '+this.html.border.borderWidthRight+'px 1px 1px', 'solid '+this.html.border.borderStyleRight+' solid solid', '#FF8200 '+this.html.border.borderColorRight+' #FF8200 #FF8200');
}
}
function uneDemiCaseSaisie(numJour, iUser, blnJC) {
uneDemiCaseListing.call(this, numJour, iUser, blnJC);
this.html.setBorder('', this.html.border.borderWidthTop+'px '+this.html.border.borderWidthRight+'px 1px '+this.html.border.borderWidthLeft+'px', this.html.border.borderStyleTop+' '+this.html.border.borderStyleRight+' solid '+this.html.border.borderStyleLeft, this.html.border.borderColorTop+' '+this.html.border.borderColorRight+' #FF8200 '+this.html.border.borderColorLeft);
this.html.className += ' pointer';
this.html.setTop(20);
this.html.setLeft(10 * (numJour - 1) + 174);
if ( numJour == 1 ) {
this.html.setLeft(10 * (numJour - 1) + 173);
this.html.setWidth(11);
this.html.setBorder('', this.html.border.borderWidthTop+'px '+this.html.border.borderWidthRight+'px 1px 1px', this.html.border.borderStyleTop+' '+this.html.border.borderStyleRight+' solid solid', this.html.border.borderColorTop+' '+this.html.border.borderColorRight+' #FF8200 #FF8200');
}
this.isJC = blnJC;
Event.setevent.call(this.html, 'click', function() {
Effect.show.call($('div_semaine_type_ok'));
if ( this.isJC ) {
this.html.className = 'caseNormal pointer';
this.isJC = false;
}
else { //Sinon, on le met
this.html.className = 'caseTP pointer';
this.isJC = true;
}
/*if(this.EtatDuJour == 1) {
this.EtatDuJour = 0;
}
else{
this.EtatDuJour = 1;
}*/
}.bind(this));
}
function unJour(numJour,iUser){
if(iUser == 'id'){
var left = 190 + 20 * (numJour - 1);
switch (numJour){
case 1:
var sTexte = 'L';
break;
case 2:
var sTexte = 'M';
break;
case 3:
var sTexte = 'M';
break;
case 4:
var sTexte = 'J';
break;
case 5:
var sTexte = 'V';
break;
case 6:
var sTexte = 'S';
break;
case 7:
var sTexte = 'D';
break;
}
}
else{
var left = 190 + 20 * (numJour - 1);
var sTexte = Date.getInfo('addJours', -Date.today.getDay() + numJour - 1, 'getDate');
}
if(numJour == 1)
sBorder = '0px 1px 0px 1px'
else
sBorder = '0px 1px 0px 0px'
this.html = new LDivElement('','orangeEnteteCaseSalarie enteteFicheSalarie', 65, '', sBorder, 'solid solid solid solid', '#FF8200 #FF8200 #FF8200 #FF8200', '0px', 0,left, 20, 20,sTexte, { token: 1});
}
function unJourEntete(numJour) {
var tabJour = ['L', 'M', 'M', 'J', 'V', 'S', 'D'];
this.html = new LDivElement('','orangeEnteteCaseSalarie enteteFicheSalarie', 65, '1px solid #FF8200', '', '', '', '2px', 0, 20*numJour+153, 20, 21, tabJour[numJour-1], { token: 1});
}
function viewSemaineTypeListing(salarie, dDebut, type) {
if ( dDebut )
this.date_debut = new LDate(dDebut);
else
this.date_debut = new LDate();
this.date_debut.addJours(-this.date_debut.getDay()+1);
this.html = new LDivElement( '', type!='histo'?'pointer':'', 65, '0px solid #000', '', '', '', '0px', 0, 0, 20, 160, '', { token: 2});
adminController.adminFicheSalaries.getTempsPartiels(salarie, this.date_debut.toFullString(), (new LDate(this.date_debut.toFullString())).addJours(7).toFullString(), function(salarie, tabTP) {
for (var i=0; i < 14; i++) {
if ( i > 0 && i%2==0 )
this.date_debut.addJours(1);
var blnJC = false;
for (var j=0; j < tabTP.length; j++) {
var jc = tabTP[j];
if ( jc.dateConge.toFullString() == this.date_debut.toFullString() && ( jc.dateConge.duree == 'ALL' || ( jc.dateConge.duree == 'AM' && i%2==0 ) || ( jc.dateConge.duree == 'PM' && i%2!=0 ) ) ) {
blnJC = true;
break;
}
}
if ( type == 'listing' )
var newDemiCase = new uneDemiCaseListing(i+1, salarie.id, blnJC);
if ( type == 'histo' )
var newDemiCase = new uneDemiCaseHistorique(i+1, salarie.id, blnJC);
if ( type == 'saisie' ) {
var newDemiCase = new uneDemiCaseSaisie(i+1, salarie.id, blnJC);
this.tabCases.push(newDemiCase);
}
this.html.appendChild_(newDemiCase.html);
}
}.bind(this, salarie));
}
function viewSemaineTypeHistorique(salarie, listingTP, indice) {
viewSemaineTypeListing.call(this, salarie, listingTP[3], 'histo');
this.html = new LDivElement('', '', 65, '0px solid #000', '', '', '', '0px', 0, 0, 22, 340, '', { token: 1});
var dDebut = listingTP[3];
var dFin = listingTP[4];
if ( indice == 0 ) {
this.efface = new LDivElement('', 'cursor', 65, '0px solid #000', '', '', '', '0px', 2, 320, 20, 20, '', { token: 1});
this.efface.setBackground('url('+GLO_IMG_REP+GLO_IMG_DEL+') 2px 1px #FFF no-repeat');
Event.setevent.call(this.efface, 'click', function (salarie, dDebut) {
adminController.adminFicheSalaries.delTempsPartiels(salarie, dDebut);
}.bind(this, salarie, dDebut));
this.html.appendChild_(this.efface);
}
if ( dFin == '' ) {
dDebut = 'à partir du '+dDebut;
dFin = '';
}
else { //Sinon, période
dDebut = 'du '+dDebut;
dFin = ' au '+dFin;
}
this.debut = new LDivElement( '', 'normal', 65, '', '1px 0px 1px 0px', 'solid dotted solid dotted', '#FF8000 #FF8000 #FF8000 #FF8000', '2px', 0, 0, 22, 160, dDebut, { token: 1}); //160 pour pouvoir déborder sur dFin si pas de dFin !
this.fin = new LDivElement( '', 'normal', 65, '', '1px 0px 1px 0px', 'solid dotted solid dotted', '#FF8000 #FF8000 #FF8000 #FF8000', '2px', 0, 88, 22, 91, dFin, { token: 1});
this.html.appendChild_(this.debut,this.fin);
}
function viewSemaineTypeSaisie(salarie, dateDebut, dateMini) {
viewSemaineTypeListing.call(this, salarie, dateDebut.toFullString(), 'saisie');
this.html = new LDivElement('', '', 65, '0px solid #000', '', '', '', '0px', 12, 18, 42, 332, '', { token: 1});
this.tabCases = [];
this.libelle_mois = new LDivElement( '', 'bold right', 185, '0px solid #000', '', '', '', '2px', 20, -10, 20, 180, '', { token: 1});
this.libelle_mois.date_debut = dateDebut;
this.libelle_mois.date_debut.addJours(-this.libelle_mois.date_debut.getDay()+1);
this.libelle_mois.update = function() {
this.setInnerHTML( 'à partir du '+this.date_debut.getDate()+' '+monthText[this.date_debut.getMonth()]+' '+this.date_debut.getFullYear() );
}
this.libelle_mois.update();
this.html.appendChild_(this.libelle_mois);
this.prec = new LDivElement('', 'bold cursor center', 75, '1px solid #FFF', '', '', '', '2px', 0, 156, 20, 17, '&lt;', { token: 1});
this.suiv = new LDivElement('', 'bold cursor center', 75, '1px solid #FFF', '', '', '', '2px', 0, 314, 20, 17, '&gt;', { token: 1});
Event.setevent.call(this.prec, 'click', function() {
if ( !dateMini || dateMini < this.libelle_mois.date_debut ) {
this.libelle_mois.date_debut.addJours(-7);
this.libelle_mois.update();
}
else { //On dit que c'est pas possible
alert("Il n\'est pas possible de saisir une nouvelle semaine type débutant avant la dernière semaine type saisie");
}
}.bind(this));
Event.setevent.call(this.suiv, 'click', function() {
this.libelle_mois.date_debut.addJours(7);
this.libelle_mois.update();
}.bind(this));
this.html.appendChild_(this.prec, this.suiv);
this.lundi = new unJourEntete(1);
this.mardi = new unJourEntete(2);
this.mercredi = new unJourEntete(3);
this.jeudi = new unJourEntete(4);
this.vendredi = new unJourEntete(5);
this.samedi = new unJourEntete(6);
this.dimanche = new unJourEntete(7);
this.html.appendChild_(this.lundi.html,this.mardi.html,this.mercredi.html,this.jeudi.html,this.vendredi.html,this.samedi.html,this.dimanche.html);
this.ok = new LDivElement( 'div_semaine_type_ok', 'cursor hidden', 65, '0px solid #000', '', '', '', '0px', 22, 316, 20, 20, '', { token: 1});
this.ok.setBackground('url('+GLO_IMG_REP+GLO_IMG_SAVE+') 0px 0px #FFF no-repeat');
Event.setevent.call(this.ok, 'click', function() {
adminController.adminFicheSalaries.addTempsPartiels( this, this.libelle_mois.date_debut.toFullString(), salarie );
}.bind(this));
this.html.appendChild_(this.ok);
}
function viewEnteteSalarie() {
var sClasse = 'center big white';
var sImg = 'entete_salaries_admin.gif';
this.html = new LDivElement('', '', 30, '0px solid #000', '', '', '', '0px', 0, 0, 26, 726, '');
this.nom = new LDivElement( '', sClasse, 30, '1px solid #900', '', '', '', '5px', 0, 0, 26, 111, 'Nom');
this.prenom = new LDivElement( '', sClasse, 30, '1px solid #900',  '', '', '', '5px', 0, 110, 26, 111, 'Prénom');
this.date_arrivee = new LDivElement( '', sClasse, 30, '1px solid #900',  '', '', '', '0px', 0, 220, 26, 101, 'Date d\'arrivée (JJ/MM/AAAA)');
this.profil = new LDivElement( '',sClasse, 30, '1px solid #900',  '', '', '', '5px', 0, 320, 26, 147, 'Profil');
this.semaine_type = new LDivElement( '',sClasse, 30, '1px solid #900',  '', '', '', '5px', 0, 466, 26, 140, 'Semaine de travail');
this.date_depart = new LDivElement( '',sClasse, 30, '1px solid #900',  '', '', '', '0px', 0, 605, 26, 102, 'Date de départ (JJ/MM/AAAA)');
this.html.appendChild_(this.nom, this.prenom, this.date_arrivee, this.profil, this.semaine_type, this.date_depart);
this.nom.setBackground('url('+GLO_IMG_REP+sImg+') 0px 0px transparent repeat-x');
this.prenom.setBackground('url('+GLO_IMG_REP+sImg+') 0px 0px transparent repeat-x');
this.date_arrivee.setBackground('url('+GLO_IMG_REP+sImg+') 0px 0px transparent repeat-x');
this.profil.setBackground('url('+GLO_IMG_REP+sImg+') 0px 0px transparent repeat-x');
this.semaine_type.setBackground('url('+GLO_IMG_REP+sImg+') 0px 0px transparent repeat-x');
this.date_depart.setBackground('url('+GLO_IMG_REP+sImg+') 0px 0px transparent repeat-x');
}
function viewLigneSalarie(salarie, indice) {
this.salarie = salarie;
var sClasse = 'editable caseFicheSalarie ';
var sClasseNonEditable = 'caseFicheSalarie overflow';
var sPaddingTop = '2px';
this.html = new LDivElement( '', 'normal overflow', 30+(100-indice), '0px solid #FF8200', '', '', '', '0px', 0, 0, 22, 726, '', { token: 1});
this.nom = new LDivElement( 'div_nom_'+this.salarie.id, sClasse, 35, '1px solid #FF8200', '', '', '', sPaddingTop, 0, 0, 22, 111, '', { token: 1});
Observer.call(this.nom);
this.prenom = new LDivElement( '', sClasse, 35, '1px solid #FF8200',  '', '', '', sPaddingTop, 0, 110, 22, 111, '', { token: 1});
Observer.call(this.prenom);
this.date_arrivee = new LDivElement( '', sClasse, 35, '1px solid #FF8200',  '', '', '', sPaddingTop, 0, 220, 22, 101, '', { token: 1});
Observer.call(this.date_arrivee);
this.profil = new LDivElement( '',sClasseNonEditable, 35, '1px solid #FF8200',  '', '', '', sPaddingTop, 0, 320 , 22, 147,'', { token: 1});
this.semaine_type = new LDivElement( '',sClasseNonEditable, 35, '1px solid #FF8200',  '', '', '', sPaddingTop, 0, 466, 22, 140,'', { token: 1});
this.date_depart = new LDivElement( '',sClasse, 35, '1px solid #FF8200',  '', '', '', sPaddingTop, 0, 605, 22, 100, '', { token: 1});
Observer.call(this.date_depart);
this.ok = new LDivElement( 'ok_'+this.salarie.id,'hidden', 35, '',  '', '', '', sPaddingTop, 0, 707, 20, 20,'<img class=cursor src="'+GLO_IMG_REP+GLO_IMG_SAVE+'" onClick="adminController.adminFicheSalaries.click('+this.salarie.id+','+indice+')";>', { token: 1});
selectProfilFactory(adminController.adminFicheSalaries.tabViewProfil, this.profil, this.salarie.profil, this.salarie.id);
Aide.register(this.profil, 'admin', 'salariesprofil');
Aide.register(this.semaine_type, 'admin', 'salariessemainetype');
Aide.register(this.date_depart, 'admin', 'salariesddepart');
this.semaine_type.update = function() {
Util.collector.emptyChildNodes(this.semaine_type);
this.semaine_type.setInnerHTML('');
var uneSemaineType = new viewSemaineTypeListing(this.salarie, null, 'listing');
Event.setevent.call(uneSemaineType.html, 'click', function(salarie) {
Effect.hide.call(viewPopUp.body);
viewPopUp.body.setTop(142);
viewPopUp.body.setLeft(235+mainView.childNodes.paveGauche.getWidth());
adminController.adminFicheSalaries.buildTempsPartiels(salarie);
}.bind(uneSemaineType, this.salarie));
this.semaine_type.appendChild_(uneSemaineType.html);
}.bind(this);
this.semaine_type.update();
this.salarie.updateSemaineType = function() {
this.semaine_type.update();
}.bind(this);
[ this.nom, this.prenom, this.date_arrivee, this.date_depart ].each( function(el, i) {
el.update = function() {
( !this.edition ) ? this.setInnerHTML(this.observed[this.keyAtt].toFullString()) : null;
}
}); 
this.update = function() {
this.nom.update(); this.prenom.update(); this.date_arrivee.update(); this.date_depart.update(); 
}
this.quitteModeEdition = function() {
this.nom.edition = false;
this.prenom.edition = false;
this.date_arrivee.edition = false;
this.date_depart.edition = false;
Effect.hide.call(this.ok);
this.update();
}
this.setModeDisquette = function() {
[ this.nom, this.prenom, this.date_arrivee, this.date_depart ].each( function(indice, el, i) {
el.edit = function(el, indice) {
if ( !el.edition ) {
el.edition = true;
el.setInnerHTML('<input type="text" autocomplete="off" class="InputNormal" maxlength="30" value="'+el.observed[el.keyAtt].toFullString()+'">');
el.firstChild.focus();
el.firstChild.onkeyup = function() {
if ( this.nom.firstChild.value!='' && this.prenom.firstChild.value!='' && this.date_arrivee.firstChild.value!='') {
Effect.show.call(this.ok);
}
else {//Sinon on cache la disquette éventuellement montrée précédemment
Effect.hide.call(this.ok);
}
}.bind(this)
}
}.bind(this, el, indice)
}.bind(this, indice));
this.nom.edit();
this.prenom.edit();
this.date_arrivee.edit();
this.date_depart.edit();
this.profil.update = function(iProfil) {
this.salarie.profil_temp = iProfil;
}.bind(this)
}
this.profil.update = function(indice, iProfil) {
this.salarie.profil_temp = iProfil;
adminController.adminFicheSalaries.updUser(this);
}.bind(this, indice)
Event.setevent.call(this.nom, 'click', function() {
this.edit();
});
Event.setevent.call(this.prenom, 'click', function() {
this.edit();
});
Event.setevent.call(this.date_arrivee, 'click', function() {
this.edit();
});
Event.setevent.call(this.date_depart, 'click', function() {
this.edit();
});
[ this.nom, this.prenom, this.date_arrivee, this.date_depart ].each( function(indice, el, i) {
el.edit = function(el, indice) {
if ( !el.edition ) {
el.edition = true;
el.setInnerHTML('<input type="text" autocomplete="off" class="InputNormal" maxlength="30" value="'+el.observed[el.keyAtt].toFullString()+'">');
el.firstChild.focus();
el.firstChild.onblur = function(el, indice) {
if ( el.firstChild.value != el.observed[el.keyAtt].toFullString() ) {
adminController.adminFicheSalaries.updUser(this);
}
else { //Sinon on se contente de revenir en mode normal
el.edition = false;
el.update();
}
}.bind(this, el, indice)
}
}.bind(this, el, indice)
}.bind(this, indice));
[ this.nom, this.prenom, this.date_arrivee, this.date_depart ].each( function(el, i) {
Event.setevent.call(el, 'mouseover', function() {
this.style.background = '#FFF';
this.style.cursor = 'text';
this.style.color = '#CCC';
});
Event.setevent.call(el, 'mouseout', function() {
this.style.background = '#FE9';
this.style.cursor = 'auto';
this.style.color = '#900';
});
});
this.nom.keyAtt = 'nom';
this.nom.observes(salarie);
this.prenom.keyAtt = 'prenom';
this.prenom.observes(salarie);
this.date_arrivee.keyAtt = 'dt_arr';
this.date_arrivee.observes(salarie);
this.date_depart.keyAtt = 'dt_dep';
this.date_depart.observes(salarie);
this.html.appendChild_(this.nom,this.prenom,this.date_arrivee,this.profil,this.semaine_type,this.date_depart,this.ok);
}
function selectProfilFactory(tabProfil,sProfil,iProfil,id) {
var tmpHTML = '';
tmpHTML +=  '<select id="iProfil_'+id+'" class="menuDeroulant" onChange="this.parentNode.update(this.options[this.selectedIndex].value);">';
for (var i=0; i < tabProfil.length; i++) {
var id_profil = tabProfil[i][0];
var libelle_profil = tabProfil[i][1];
sSelected = ' ';
if(iProfil == id_profil){
sSelected = 'selected';
}
tmpHTML += '<option value="'+id_profil+'" '+sSelected+'>'+libelle_profil+'</option>';
}
tmpHTML += '</select>';
sProfil.setInnerHTML(tmpHTML);
setTimeout( function() {
replace_select( this.firstChild, '0px solid #FE9', 'select_fleche.gif', '#00F');
}.bind(sProfil), 0);
}
/* -------------------------------CONTROLLER--------------------------- */
function adminFicheSalaries() {
this.tabViewSalarie = new Array();
this.date_jour = new LDate();
this.affiche = function() {
controller.pool.newHttpRequest('server.asp?obj=user&req=getFichesSalaries&intService='+LOC_ID_SERVICE, {
onSuccess: this.getListeSalaries_.bind(this)
});
}
this.getListeSalaries_ = function() {
var enteteSalarie = new viewEnteteSalarie();
viewAdmin.childNodes.content.appendChild_(enteteSalarie.html);
this.tabViewProfil = new Array();
for (var i=0; i < arguments[0].length; i++) {
this.tabViewProfil.push(arguments[0][i]);
}
if (salariesController.salariesLoaded){
this.top = 10;
for (var i=0; i < salariesController.tabSalaries.length; i++) {
var salarie = salariesController.tabSalaries[i];
if ( salarie.isActif() ) {
var ligneSalarie = new viewLigneSalarie(salarie, this.tabViewSalarie.length);
ligneSalarie.update();
ligneSalarie.html.setTop(this.top += 21);
viewAdmin.childNodes.content.appendChild_(ligneSalarie.html);
this.tabViewSalarie.push(ligneSalarie);
}
}
}
var salarie = new Salarie(100000000+Util.random(1000), '', '', '', '', 0, '', 0, 0, 0);
var texteNouveau = new LDivElement( '', 'normal', 65, '0px solid #000', '', '', '', '2px 0px 2px 0px', this.top+=41, 0, 20, 150, 'Nouveau salarié', { token: 1});
viewAdmin.childNodes.content.appendChild_(texteNouveau);
var newLigne = new viewLigneSalarie(salarie, this.tabViewSalarie.length);
newLigne.setModeDisquette();
newLigne.html.setTop(this.top += 21);
viewAdmin.childNodes.content.appendChild_(newLigne.html);
setTimeout( function(salarie) {
$('div_select_iProfil_'+salarie.id).selectOption(0);
}.bind(this, salarie), 100); //Le délai devrait être suffisant
this.tabViewSalarie.push(newLigne);
salarie.getLibelle = function() {
return this.nom.firstChild.value + ' ' + this.prenom.firstChild.value;
}.bind(newLigne);
var lien = new LDivElement( 'lien_partis', 'normal pointer underline', 65, '0px solid #000', '', '', '', '2px 0px 2px 0px', this.top+=41, 0, 20, 150, 'Montrer les salariés partis', { token: 1});
lien.top = this.top;
Event.setevent.call(lien, 'click', function(lien) {
if ( lien.clicked ) {
this.masqueSalariesPartis();
lien.setInnerHTML('Montrer les salariés partis');
lien.clicked = false;
}
else {//Fois impaire où on clic sur le lien
this.afficheSalariesPartis();
lien.setInnerHTML('Masquer les salariés partis');
lien.clicked = true;
}
}.bind(this, lien));
viewAdmin.childNodes.content.appendChild_(lien);
this.afficheSalariesPartis = function() {
var j = this.tabViewSalarie.length;
for (var i=0; i < salariesController.tabSalaries.length; i++) {
var salarie = salariesController.tabSalaries[i];
if ( !salarie.isActif() ) {
var ligneSalarie = new viewLigneSalarie(salarie, this.tabViewSalarie.length);
ligneSalarie.update();
ligneSalarie.html.setTop(this.top += 21);
viewAdmin.childNodes.content.appendChild_(ligneSalarie.html);
this.tabViewSalarie.push(ligneSalarie);
}
}
this.afficheSalariesPartis = function() {
for (var i=j; i < this.tabViewSalarie.length; i++) {
this.tabViewSalarie[i].html.style.display = 'block';
}
}
this.masqueSalariesPartis = function() {
for (var i=j; i < this.tabViewSalarie.length; i++) {
this.tabViewSalarie[i].html.style.display = 'none';
}
}
}
if ( this.andAfter ) {
this.andAfter();
this.andAfter = function() {}
}
}
this.getTempsPartiels = function(salarie, dtDebut, dtFin, andAfter) {//On envoie une fonction a exécuter une fois que le TP est récupéré
var tabTP = [];
controller.pool.newHttpRequest('server.asp?obj=user&req=getTempsPartiels&iUser='+salarie.id+'&dtDebut='+dtDebut+'&dtFin='+dtFin, {
onSuccess: function() {
var tabTP = [];
for (var i=0; i < arguments.length; i++)
tabTP.push( new Conge( Undefined, this, new LDate( arguments[i][0], arguments[i][1] ), +1) );
andAfter(tabTP);
}.bind(salarie)
});
}
this.buildTempsPartiels = function(salarie) {
viewPopUp.childNodes.titre.setInnerHTML('Semaine de travail pour '+salarie.getLibelle());
viewPopUp.affiche('');
Effect.show.call(viewPopUp.body);
controller.pool.newHttpRequest('server.asp?obj=user&req=getListeTempsPartiels&iUser='+salarie.id, {
onSuccess: function() {
if ( arguments[0][1] != '' ) {
var historique = new LDivElement( '', 'big', 65, '0px solid #000', '', '', '', '0px', 70, 12, 40, 340, 'Historique', { token: 1});
for (var i=0; i < arguments.length; i++) {
var newViewSemaineType = new viewSemaineTypeHistorique(this, arguments[i], i);
newViewSemaineType.html.setTop(21*i+14);
historique.appendChild_(newViewSemaineType.html);
}
historique.setHeight(21*arguments.length+35); //35px pour que ça fasse de la marge en bas
viewPopUp.childNodes.content.appendChild_(historique);
}
if ( arguments[0][1] != '' ) {
var dDebut = new LDate(arguments[0][3]);
var dMini = new LDate(arguments[0][3]); //La date mini est la date début du dernier historique
if ( dDebut < (new LDate()) ) //Si elle est plus petite, on prend la date de jour comme référence
dDebut = new LDate();
}
else { //Si pas d'historique, alors c'est la date du jour et il n'y a pas de limite basse
var dDebut = new LDate();
var dMini = false;
}
var newViewSemaineType = new viewSemaineTypeSaisie(this, dDebut, dMini);
viewPopUp.childNodes.content.appendChild_(newViewSemaineType.html);
viewPopUp.resize();
Aide.unregister(viewPopUp.body);
Aide.register(viewPopUp.body, 'admin', 'salariessemainetype');
Effect.show.call(viewPopUp.body);
}.bind(salarie)
});
}
this.delTempsPartiels = function(salarie, dDebut) {
controller.pool.newHttpRequest('server.asp?obj=user&req=delTempsPartiels&iUser='+salarie.id+'&dDebut='+dDebut, {
onSuccess: this.delTempsPartiels_.bind(this, salarie),
noRed: true
});
}
this.delTempsPartiels_ = function(salarie){
salarie.updateSemaineType();
this.buildTempsPartiels(salarie);
}
this.addTempsPartiels = function( viewSaisie, dDebutTP , salarie){
var sChaine = [];
for (var i=0; i < viewSaisie.tabCases.length; i++) {
if ( ( 0 <= i && i <= 9 && viewSaisie.tabCases[i].isJC ) || ( ( i >= 10 ) && !viewSaisie.tabCases[i].isJC ) ) {
var j = i + 2; //pour tous les jours du L au S, on déclae de 2 demi cases vers la droite
if ( i >= 12 )
j = i - 12;
sChaine.push(viewSaisie.tabCases[j].iName);
}
}
controller.pool.newHttpRequest('server.asp?obj=user&req=insTP&iUser='+salarie.id+'&dDebut='+dDebutTP+'&sChaine='+sChaine.join(','), {
onSuccess: this.addTempsPartiels_.bind(this, salarie),
noRed: true
});
}
this.addTempsPartiels_ = function(salarie) {
salarie.updateSemaineType();
this.buildTempsPartiels(salarie);
}
this.click = function(iNumeroSalarie, indice){
var viewSalarie = this.tabViewSalarie[indice];
var nom = ( viewSalarie.nom.edition ) ? viewSalarie.nom.firstChild.value : viewSalarie.nom.innerHTML;
var prenom = ( viewSalarie.prenom.edition ) ? viewSalarie.prenom.firstChild.value : viewSalarie.prenom.innerHTML;
var date_arrivee = ( viewSalarie.date_arrivee.edition ) ? viewSalarie.date_arrivee.firstChild.value : viewSalarie.date_arrivee.innerHTML;
var date_depart = ( viewSalarie.date_depart.edition ) ? viewSalarie.date_depart.firstChild.value : viewSalarie.date_depart.innerHTML;
if ( checkDateFinish(date_arrivee) && checkDateFinish(date_depart) ) {
controller.pool.newHttpRequest('server.asp?obj=user&req=insUser&iUser='+viewSalarie.salarie.id+'&sNom='+escape(nom)+'&sPrenom='+escape(prenom)+'&dArrivee='+date_arrivee+'&dDepart='+date_depart+'&iService='+LOC_ID_SERVICE+'&iProfil='+viewSalarie.salarie.profil_temp, {
onSuccess: this.insUser_.bind(this, viewSalarie),
noRed: true
});
}
}
this.updUser = function(viewSalarie) {
var nom = ( viewSalarie.nom.edition ) ? viewSalarie.nom.firstChild.value : viewSalarie.nom.innerHTML;
var prenom = ( viewSalarie.prenom.edition ) ? viewSalarie.prenom.firstChild.value : viewSalarie.prenom.innerHTML;
var date_arrivee = ( viewSalarie.date_arrivee.edition ) ? viewSalarie.date_arrivee.firstChild.value : viewSalarie.date_arrivee.innerHTML;
var date_depart = ( viewSalarie.date_depart.edition ) ? viewSalarie.date_depart.firstChild.value : viewSalarie.date_depart.innerHTML;
controller.pool.newHttpRequest('server.asp?obj=user&req=updUser&sNom='+escape(nom)+'&sPrenom='+escape(prenom)+'&dArrivee='+date_arrivee+'&dDepart='+date_depart+'&iProfil='+viewSalarie.salarie.profil_temp+'&iUser='+viewSalarie.salarie.id, {
onSuccess: this.updUser_.bind(this, viewSalarie),
noRed: true
});
}
this.updUser_ = function(viewSalarie){
var salarie = viewSalarie.salarie;
var nom = ( viewSalarie.nom.edition ) ? viewSalarie.nom.firstChild.value : viewSalarie.nom.innerHTML;
var prenom = ( viewSalarie.prenom.edition ) ? viewSalarie.prenom.firstChild.value : viewSalarie.prenom.innerHTML;
var date_arrivee = ( viewSalarie.date_arrivee.edition ) ? viewSalarie.date_arrivee.firstChild.value : viewSalarie.date_arrivee.innerHTML;
var date_depart = ( viewSalarie.date_depart.edition ) ? viewSalarie.date_depart.firstChild.value : viewSalarie.date_depart.innerHTML;
salarie.setNom(nom);
salarie.setPrenom(prenom);
salarie.setArrivee(date_arrivee);
salarie.setDepart(date_depart);
salarie.setProfil(salarie.profil_temp);
viewSalarie.quitteModeEdition();
controller.showLabel('Information enregistrée');
}
this.insUser_ = function(viewSalarie){
var salarie = viewSalarie.salarie;
salarie.id = arguments[1][0];
salarie.resetGetLibelle();
var nom = ( viewSalarie.nom.edition ) ? viewSalarie.nom.firstChild.value : viewSalarie.nom.innerHTML;
var prenom = ( viewSalarie.prenom.edition ) ? viewSalarie.prenom.firstChild.value : viewSalarie.prenom.innerHTML;
var date_arrivee = ( viewSalarie.date_arrivee.edition ) ? viewSalarie.date_arrivee.firstChild.value : viewSalarie.date_arrivee.innerHTML;
var date_depart = ( viewSalarie.date_depart.edition ) ? viewSalarie.date_depart.firstChild.value : viewSalarie.date_depart.innerHTML;
salarie.setNom(nom);
salarie.setPrenom(prenom);
salarie.setArrivee(date_arrivee);
salarie.setDepart(date_depart);
salarie.setProfil(salarie.profil_temp);
salarie.indice = salariesController.tabSalaries.push(salarie)-1; //Le salarié mémorise son indice dans le tableau
controller.addViewSalarie(salarie);
for (var i=0; i < comptesController.tabComptes.length; i++) {
salarie.tabSoldes.addSolde( comptesController.tabComptes[i], 0, 0);
salarie.tabSoldes.addSolde( comptesController.tabComptes[i], 1, 0);
salarie.tabSoldes.addSolde( comptesController.tabComptes[i], 2, 0);
salarie.tabSoldes.addSolde( comptesController.tabComptes[i], 3, 0);
}
controller.showLabel('Salarié enregistré');
viewAdmin.reset(0);
adminController.adminFicheSalaries.affiche();
}
}
function viewUneLigneCompte(top, iCompte, sCompte, iUser, strSI, strJP, strJA, strSF) {
this.html = new LDivElement( '', 'pointer chiffre bold', 30, '', '0px 0px 1px 0px', 'dotted dotted dotted dotted', '#FF8000 #FF8000 #FF8000 #FF8000', '0px', top, 120, 15, 600, '');
this.Compte = new LDivElement( '', '', 30, '0px solid #000', '', '', '', '0px', 0, 0, 15,  200, sCompte);
this.SI = new LDivElement( '', 'right', 30, '0px solid #000', '', '', '', '0px', 0, 200, 15, 100, strSI);
this.JP = new LDivElement( '', 'right', 30, '0px solid #000', '', '', '', '0px', 0, 300, 15, 100, strJP);
this.JA = new LDivElement( '', 'right', 30, '0px solid #000', '', '', '', '0px', 0, 400, 15, 100, strJA);
this.SF = new LDivElement( '', 'right', 30, '0px solid #000', '', '', '', '0px', 0, 500, 15, 100, strSF)
this.html.appendChild_(this.Compte, this.SI, this.JP, this.JA, this.SF);
Event.setevent.call(this.html, 'click', function() {
viewPopUp.body.setTop(152);//this.getTop()+120-viewAdmin.childNodes.content.scrollTop);
viewPopUp.body.setLeft(this.getLeft()+250);
adminController.adminConsulter.ligneClicked(iUser,iCompte);
});
Event.setevent.call(this.html, 'mouseover',function(){
this.setBackgroundColor('#FF8200');
});
Event.setevent.call(this.html, 'mouseout',function(){
this.setBackgroundColor('#FFFFFF');
});
}
function adminConsulter() {
this.dDebut = new LDate();
this.dFin = new LDate();
this.affiche = function(dDebut, dFin) {
if (!dDebut || !dFin) {
var dToDate = new LDate();
this.dDebut = dToDate.getFirstInMonth();
this.dFin = this.dDebut.getLastInMonth();
this.dDebut.addMois(-1);
}
else { //Si l'utilisateur a changé les dates et fait un nouvel affichage, alors on prend ses dates
this.dDebut = new LDate(dDebut);
this.dFin = new LDate(dFin);
}
if (this.dDebut <= this.dFin) {
controller.pool.newHttpRequest('server.asp?obj=admin&req=getConsulter&intService='+LOC_ID_SERVICE+'&dtmDebut='+this.dDebut.toFullString()+'&dtmFin='+this.dFin.toFullString(), {
onSuccess: this.getConsulter_.bind(this)
});
}
else
alert("La date de fin est antérieure à la date de début.");
adminController.getAide('Consulter');
}
this.getConsulter_ = function() {
this.html = new LDivElement('', '', 30, '0px solid #000', '', '', '', '0px', 0, 0, 70, 726, '');
this.entete = new LDivElement('', 'libelle center ', 30, '0px solid #000', '', '', '', '4px', 0, 0, 36, 720, 'Période du <input type="text" id="dDebut" name="dDebut" size=12 class="Input" value="'+this.dDebut.toFullString()+'"> au <input type="text" id="dFin" size=12 class="Input" value="'+this.dFin.toFullString()+'"> <img onClick="adminController.adminConsulter.affiche($(\'dDebut\').value, $(\'dFin\').value);" style="cursor:pointer; position: relative; top: 8px;" src="'+GLO_IMG_REP+GLO_IMG_AFF+'">');
this.enteteSI = new LDivElement('', 'libelle center ', 30, '0px solid #000', '', '', '', '4px', 50, 320, 20, 100, 'Solde initial');
this.enteteJP = new LDivElement('', 'libelle center ', 30, '0px solid #000', '', '', '', '4px', 50, 420, 20, 100, 'Jours pris');
this.enteteJA = new LDivElement('', 'libelle center ', 30, '0px solid #000', '', '', '', '4px', 50, 520, 20, 100, 'Jours acquis');
this.enteteSF = new LDivElement('', 'libelle center ', 30, '0px solid #000', '', '', '', '4px', 50, 620, 20, 100, 'Solde final');
this.html.appendChild_(this.entete, this.enteteSI, this.enteteJP, this.enteteJA, this.enteteSF);
var top = 50;
for (var i=0; i < arguments[0].length; i++) {
top += 17;
var strEnteteSalarie = new LDivElement('', 'libelle activeCaseSalarie', 30, '', '0px 0px 1px 0px', 'solid solid solid solid', '#900 #900 #900 #900', '0px', top, 0 , 15,  720, arguments[0][i][1]+' '+arguments[0][i][2]);
this.html.appendChild_(strEnteteSalarie);
for (var j=0; j < arguments[1].length; j++) {
if(arguments[0][i][0] == arguments[1][j][0]){
top += 17;
this.uneLigneCompte = new viewUneLigneCompte(top,arguments[1][j][1],arguments[1][j][2],arguments[1][j][0],arguments[1][j][3],arguments[1][j][4],arguments[1][j][5],arguments[1][j][6]);
this.html.appendChild_(this.uneLigneCompte.html);
}
}
}
this.html.setHeight(top+20);
viewAdmin.reset(0);
viewAdmin.childNodes.content.appendChild_(this.html);
}
this.ligneClicked = function(iUser,iCompte){
var dFin = $('dFin').value;
var dtmFin = new LDate(dFin);
controller.pool.newHttpRequest('server.asp?obj=admin&req=getListeDetails&iCompte='+iCompte+'&iUser='+iUser+'&dtmFin='+dtmFin.toFullString(), {
onSuccess: this.getListeDetails_.bind(this)
});
}
this.getListeDetails_ = function(){
var sTitre = 'Détail des écritures';//'Détail du compte '+arguments[0][0]+' entre le '+this.dDebut.toFullString()+' et le '+this.dFin.toFullString();
if(arguments[1].length != 0){
var tmp = '<table width=340>';
tmp += '<tr class="normal center bold"><td width=70 class=bas_table>Date</td><td width=170 class=bas_table>Libellé</td><td width=50 class=bas_table>Débit</td><td width=50 class=bas_table>Crédit</td></tr>';
var fSolde = 0;
for (var j=0; j < arguments[1].length; j++) {
tmp += '<tr class="small"><td class=bas_table>'+arguments[1][j][3]+'</td><td class=bas_table>'+arguments[1][j][2]+'</td><td class="right bas_table">'+arguments[1][j][0]+'</td><td class="right bas_table">'+arguments[1][j][1]+'</td></tr>';
fSolde = eval(fSolde) + eval(arguments[1][j][1]) - eval(arguments[1][j][0]);
}
var strSolde = 'Solde';
if(fSolde < 0)
strSolde += ' (débiteur)';
tmp += '<tr class="small bold"><td colspan=2 class="left bas_table">'+strSolde+'</td><td colspan=2 class="right bas_table">'+Math.round(fSolde*100)/100+'</td></tr>';
tmp += '</table>';
}
else
var tmp = 'Aucune écriture pour ce compte entre les deux dates';
viewPopUp.childNodes.titre.setInnerHTML(sTitre);
viewPopUp.affiche(tmp);
Aide.unregister(viewPopUp.body);
Aide.register(viewPopUp.body, 'admin', 'consulter');
Effect.show.call(viewPopUp.body);
}
}
function viewLigneSalariesActifs() {
var tmp = '<select id=iUser name=iUser class=menuDeroulant_200>';
for (var i=0; i < salariesController.tabSalaries.length; i++) {
var salarie = salariesController.tabSalaries[i];
if ( salarie.isActif() ) {
tmp += '<option value='+salarie.id+'>'+salarie.nom+' '+salarie.prenom+'</option>';
}
}
tmp += '</select>';
return tmp;
}
function viewLigneComptes(tabComptes) {
var tmp = '<select id=iCompte name=iCompte class=menuDeroulant_200>';
for (var i=0; i < tabComptes.length; i++) {
var numero_compte = tabComptes[i][0];
var libelle_compte = tabComptes[i][1];
var contrepartie_compte = tabComptes[i][2];
tmp += '<option value="'+numero_compte+'|'+contrepartie_compte+'">'+libelle_compte+'</option>';
}
tmp += '</select>';
return tmp;
}
viewLibelle=function(controller){
var tmp = '<input type="text" id="sLibelle" class="Input" name="sLibelle" style="width: 200px;">';
return tmp;
}
viewCredit =function(){
var tmp = '<input type="text" id="fNbj" class="Input" name="fNbj" style="width: 200px;">';
return tmp;
}
adminAdministrer = function() {
this.affiche = function() {
controller.pool.newHttpRequest('server.asp?obj=admin&req=getListeSalariesActifs&intService='+LOC_ID_SERVICE, {
onSuccess: this.getListeSalariesActifs_.bind(this)
});
adminController.getAide('Administrer');
}
this.getListeSalariesActifs_ = function() {
var sSelectSalaries = viewLigneSalariesActifs();
var sSelectComptes = viewLigneComptes(arguments[1]);
var sInputCredit = viewCredit();
var sInputLibelle = viewLibelle();
var tmp = '<table border=0 width=450 style=padding-top:50px;>';
tmp += '<tr><td class="big right" style=padding-left:160px;width:350px;>Un salarié</td><td width=100px>'+sSelectSalaries+'</td></tr>';
tmp += '<tr><td class="big right" style=padding-left:160px;width:350px;>Un compte</td><td>'+sSelectComptes+'</td></tr>';
tmp += '<tr><td class="big right" style=padding-left:160px;width:350px;>Un libellé</td><td>'+sInputLibelle+'</td></tr>';
tmp += '<tr><td class="big right" style=padding-left:160px;width:350px;>Un crédit</td><td>'+sInputCredit+'</td></tr>';
tmp += '<tr><td></td><td><img onClick="adminController.adminAdministrer.insertion();" style="cursor:pointer;" src="'+GLO_IMG_REP+GLO_IMG_ENREGISTRER+'"></td></tr>';
tmp += '</table>';
viewAdmin.childNodes.content.setInnerHTML(tmp);
}
this.insertion = function(){
var iUser = $("iUser").value;
var iComptes = $("iCompte").value;
var aComptes = iComptes.split("|");
var iCompte = aComptes[0];
var iContrepartie = aComptes[1];
var fNbj = $("fNbj").value;
var sLibelle = $("sLibelle").value;
controller.pool.newHttpRequest('server.asp?obj=admin&req=insAttribuerDroits&iUser='+iUser+'&iCompte='+iCompte+'&sLibelle='+escape(sLibelle)+'&fNbj='+fNbj+'&iContrepartie='+iContrepartie, {
onSuccess: this.insertion_.bind(this, iUser),
noRed: true
});
}
this.insertion_ = function(iUser) {
if(arguments.length > 1)
alert(arguments[1]);
else{
$("fNbj").value = '';
$("sLibelle").value = '';
controller.showLabel('Insertion réussie');
}
}
}
function adminParametrer() {
this.iNbDeCouleurs = GLO_NB_COL_CPT;
this.iCompteChangeColor = 0;
this.menu = '';
this.reset_color = function( ){
}
this.affiche = function( value ) {
this.menu = value;
switch(value){
case 'valeurs_parametres' :
controller.pool.newHttpRequest('server.asp?obj=admin&req=getParametres&intService='+LOC_ID_SERVICE, {
onSuccess: this.getParametres_.bind(this)
});
break;
case 'comptes_absence' :
controller.pool.newHttpRequest('server.asp?obj=admin&req=getComptesSociete&intService='+LOC_ID_SERVICE, {
onSuccess: this.getComptesSociete_.bind(this)
});
break;
case 'profils_comptes' :
controller.pool.newHttpRequest('server.asp?obj=admin&req=getProfilsSociete&intService='+LOC_ID_SERVICE, {
onSuccess: this.getProfilsSociete_.bind(this)
});
break;
}
}
this.suppression = function(value, type) {
if(type == "compte") {
controller.pool.newHttpRequest('server.asp?obj=compte&req=delCompte&iCompte='+escape(value), {
onSuccess: this.delete_.bind(this, value),
noRed: true
});
}
if(type == "profil") {
controller.pool.newHttpRequest('server.asp?obj=admin&req=delProfil&iProfil='+escape(value), {
onSuccess: this.delete_.bind(this, value),
noRed: true
});
}
}
this.getParametres_ = function(){
var tmp = '<table border="0" width="728" style="padding-top: 30px; padding-left: 5px;">';
tmp += '<tr><td class="big bold right" width=250>Mail / login</td><td width=200><input type=texte id=STR_LOGIN style=width:202px;></td><td id="error_STR_LOGIN" class="red"><a class="lien" onClick=adminController.adminParametrer.modifier("motdepasse");>modifier mot de passe</a></td></tr>';
tmp += '<tr><td class="big bold right">Nom</td><td><input type=texte id=STR_NOM style=width:202px;></td><td id="error_STR_NOM" class="red"></td></tr>';
tmp += '<tr><td class="big bold right">Prénom</td><td><input type=texte id=STR_PRENOM style=width:202px;></td><td id="error_STR_PRENOM" class="red"></td></tr>';
tmp += '<tr><td class="big bold right">Nom de la société</td><td><input type=texte id=STR_SOCIETE style=width:202px;></td><td id="error_STR_SOCIETE" class="red"></td></tr>';
tmp += '<tr><td class="big bold right bas_table">Adresse de la société</td><td class="bas_table"><textarea id=STR_ADRESSE cols=22 rows=3></textarea></td><td id="error_STR_ADRESSE" class="red"></td></tr>';
tmp += '<tr><td class="big bold right">Adresse email de l\'expert comptable</td><td><input type=texte id=STR_MAIL_COMPTABLE style=width:202px;></td><td id="error_STR_MAIL_COMPTABLE" class="red"></td></tr>';
tmp += '<tr><td class="big bold right">Jour d\'envoi du mail (xx du mois)</td><td><input type=texte id=INT_JOUR_PAIE style=width:202px; onKeyDown=adminController.adminParametrer.verifNumber(event);></td><td id="error_INT_JOUR_PAIE" class="red"></td></tr>';
tmp += '<tr><td class="big bold right">Date de début d\'utilisation</td><td><input type=texte id=DTM_DEMARRAGE style=width:202px; readonly></td><td id="error_DTM_DEMARRAGE" class="red"><a class="lien" onClick=adminController.adminParametrer.modifier("date");>modifier</a></td></tr>';
tmp += '<tr><td></td><td><img onClick=adminController.adminParametrer.click(); style=cursor:pointer; src='+GLO_IMG_REP+GLO_IMG_ENREGISTRER+'></td><td></td></tr>';
tmp += '</table>';
viewAdmin.reset(1);
viewAdmin.childNodes.content.setInnerHTML(tmp);
this.tabParametres = arguments;
for(var i = 0; i < this.tabParametres.length; i++){
if($(this.tabParametres[i][0]))
$(this.tabParametres[i][0]).value = this.tabParametres[i][2];
}
}
this.getComptesSociete_ = function(){
var tmp = '<table border=0 width=500 style=padding-top:30px;padding-left:5px;>';
tmp += '<tr class="big center bold"><td class="bas_table" width=150>Comptes</td><td class="bas_table" width=200>Période d\'acquisition</td><td class="bas_table" width=50>n-1</td><td class="bas_table" width=50>n</td><td class="bas_table" width=50>n+1</td></tr>';
for (var i = 0; i < arguments[0].length; i++) {
var sLibelle = arguments[0][i][1];
var dDebut = arguments[0][i][3];
var dFin = arguments[0][i][4];
if ( arguments[0][i][0] >= 100 && arguments[0][i][0] < 300 ) { //CP
var sCouleurEnCours = '<img src="'+GLO_IMG_REP+'ORANGE'+'_sortie.gif">';
var sCouleurSuivante = '<img src="'+GLO_IMG_REP+'JAUNE'+'_sortie.gif">';
var sCouleurPrecedente = '<img src="'+GLO_IMG_REP+'ROUGE'+'_sortie.gif">';
}
else { //RTT
var sCouleurEnCours = '<img src="'+GLO_IMG_REP+'VERT'+'_sortie.gif">';
var sCouleurSuivante = '<img src="'+GLO_IMG_REP+'PISTACHE'+'_sortie.gif">';
var sCouleurPrecedente = '<img src="'+GLO_IMG_REP+'VERT'+'_sortie.gif">';
}
tmp += '<tr class="small"><td class="bas_table">'+sLibelle+'</td><td class="bas_table center">'+dDebut+' - '+dFin+'</td><td class="bas_table center">'+sCouleurPrecedente+'</td><td class="bas_table center">'+sCouleurEnCours+'</td><td class="bas_table center">'+sCouleurSuivante+'</td></tr>';
}
tmp += '</table>';
tmp += '<table border=0 width=500 style=padding-top:20px;padding-left:5px;>';
tmp += '<tr class="big center bold"><td class="bas_table" width=150>Comptes</td><td class="bas_table" width=200>Type</td><td class="bas_table" width=50>n°</td><td class="bas_table" width=50>&nbsp;</td><td class="bas_table" width=50>&nbsp;</td></tr>';
for(var i = 0; i < arguments[1].length; i++){
var iCompte = arguments[1][i][0];
var sLibelle = arguments[1][i][1];
var iAffichage = arguments[1][i][2];
var sCouleur = arguments[1][i][3];
var sDelete = arguments[1][i][4];
var iContrepartie = arguments[1][i][5];
var sImgCouleur = '<img id=color_'+iCompte+' class=cursor src='+GLO_IMG_REP+sCouleur+'_actif.gif'+' onClick=adminController.adminParametrer.ClickPalette('+iCompte+');>';
var sImgDelete = '<img class=cursor src='+GLO_IMG_REP+GLO_IMG_DEL+' onClick=adminController.adminParametrer.suppression('+iCompte+',"compte");>';
if(iCompte != iContrepartie)
var sAuto = 'II';
else
var sAuto = 'III';
tmp += '<tr class="small"><td class="bas_table">'+sLibelle+'</td><td class="bas_table center">'+sAuto+'</td><td class="bas_table normal center">'+iAffichage+'</td><td class="bas_table center">'+sImgCouleur+'</td><td class="bas_table center">'+sImgDelete+'</td></tr>';
}
var sPalette = '<img class=cursor id=color_0 src='+GLO_IMG_REP+GLO_IMG_ACTIF+' onClick=adminController.adminParametrer.ClickPalette(0);>';
var sImgAjout = '<img class=cursor src='+GLO_IMG_REP+GLO_IMG_SAVE+' onClick=adminController.adminParametrer.click();>';
tmp += '<tr class="small"><td class="bas_table"><input type=hidden id=sCode value=DIVERS><input type=texte style=width:130px class=small id=sCompte></td><td class="bas_table center"><select id=cContrepartie class=small><option value=0>II : crédit manuel</option><option value=1 selected>III : crédit auto</option></select></td><td class="bas_table normal center">&nbsp;</td><td class="bas_table center">'+sPalette+'</td><td class="bas_table center">'+sImgAjout+'</td></tr>';
tmp += '</table>';
tmp += '<br><br>';
viewAdmin.reset(1);
viewAdmin.childNodes.content.setInnerHTML(tmp);
}
this.getProfilsSociete_ = function(){
var tmp = '<table width=550 style=padding-top:50px;>';
tmp += '<tr class="big center bold"><td class=bas_table>Libellé</td><td class=bas_table>CP</td><td class=bas_table>RTT</td><td></td></tr>';
for(var i = 0; i < arguments.length; i++){
var sDel = '';
if(arguments[i][6] == 1)
sDel = '<img style=cursor:pointer; src='+GLO_IMG_REP+GLO_IMG_DEL+' onClick=adminController.adminParametrer.suppression('+arguments[i][5]+',"profil");>';
tmp += '<tr class="normal"><td class="bas_table">'+arguments[i][0]+'</td><td class="center bas_table">'+arguments[i][1]+'</td><td class="center bas_table">'+arguments[i][2]+'</td><td>'+sDel+'</td></tr>';
}
tmp += '<tr><td class="bas_table normal">&nbsp;</td><td class="bas_table center normal"><input type="hidden" id=iCP value='+arguments[0][3]+'><input type="texte" id=fCP size=4 class=Input></td><td class="bas_table center normal"><input type="hidden" id=iRTT value='+arguments[0][4]+'><input type="texte" id=fRTT size=4 class=Input></td><td></td></tr>';
tmp += '<tr><td colspan=4 class=center><img style=cursor:pointer; src='+GLO_IMG_REP+GLO_IMG_ENREGISTRER+' onClick=adminController.adminParametrer.click();></td></tr>';
tmp += '</table>';
viewAdmin.reset(1);
viewAdmin.childNodes.content.setInnerHTML(tmp);
}
this.ClickPalette = function( iCompte ){
var tmp = '';
tmp += '<div style="position:relative;float:left;margin:20px;width:80px""><img id=ssolde class=cursor src='+GLO_IMG_REP+'ssolde_actif.gif onClick=adminController.adminParametrer.ChangeColor('+iCompte+',"SSOLDE")></div>';
tmp += '<div style="position:relative;float:left;margin:20px;width:80px"><img id=divers class=cursor src='+GLO_IMG_REP+'divers_actif.gif onClick=adminController.adminParametrer.ChangeColor('+iCompte+',"DIVERS")></div>';
tmp += '<div style="position:relative;float:left;margin:20px;width:80px"><img id=maladie class=cursor src='+GLO_IMG_REP+'maladie_actif.gif onClick=adminController.adminParametrer.ChangeColor('+iCompte+',"MALADIE")></div>';
tmp += '<div style="position:relative;float:left;margin:20px;width:80px"><img id=marron class=cursor src='+GLO_IMG_REP+'marron_actif.gif onClick=adminController.adminParametrer.ChangeColor('+iCompte+',"MARRON")></div>';
tmp += '<div style="position:relative;float:left;margin:20px;width:80px"><img id=brun class=cursor src='+GLO_IMG_REP+'brun_actif.gif onClick=adminController.adminParametrer.ChangeColor('+iCompte+',"BRUN")></div>';
tmp += '<div style="position:relative;float:left;margin:20px;width:80px"><img id=gris class=cursor src='+GLO_IMG_REP+'gris_actif.gif onClick=adminController.adminParametrer.ChangeColor('+iCompte+',"GRIS")></div>';
viewPopUp.childNodes.titre.setInnerHTML('Sélectionnez une couleur');
viewPopUp.affiche(tmp);
viewPopUp.body.setTop(117);
viewPopUp.body.setLeft(354+mainView.childNodes.paveGauche.getWidth());
Aide.unregister(viewPopUp.body);
Aide.register(viewPopUp.body, 'admin', 'parametrercomptes');
Effect.show.call(viewPopUp.body);
}
this.ChangeColor = function( iCompte, sColor) {
if(iCompte != 0) {
controller.pool.newHttpRequest('server.asp?obj=admin&req=updColor&iCompte='+escape(iCompte)+'&sColor='+escape(sColor), {
onSuccess: this.ChangeColor_.bind(this, iCompte, sColor),
noRed: true
});
}
else { //Soit c'est le nouveau compte
$('sCode').value = sColor;
Effect.hide.call(viewPopUp.body);
$('color_0').src = GLO_IMG_REP+sColor+'_actif.gif';
}
}
this.ChangeColor_ = function(iCompte, sColor) {
Effect.hide.call(viewPopUp.body);
$('color_'+iCompte).src = GLO_IMG_REP+sColor+'_actif.gif';
comptesController.getCompteByNumber(iCompte).setPastille(sColor);
planningController.resetCalendrier();
}
this.click = function(){
switch (this.menu){
case 'valeurs_parametres' :
for(var i = 0; i < this.tabParametres.length; i++){
if($(this.tabParametres[i][0])){
sValeur = $(this.tabParametres[i][0]).value;
sCode = this.tabParametres[i][0];
var reg=new RegExp("(\n)", "g");
sValeur = sValeur.replace(reg,"<br>");
if (sValeur != this.tabParametres[i][2]){
controller.pool.newHttpRequest('server.asp?obj=inscription&req=getAlerte&sCode='+escape(sCode)+'&sValeur='+escape(sValeur), {
onSuccess: function(sCode, sValeur, LOC_ID_SERVICE, msg) { //msg vient du serveur
if ( msg != '' ) {
$("error_"+sCode).innerHTML = msg;
}
else {//Sinon c'est que c'est OK, on peut enregistrer
controller.pool.newHttpRequest('server.asp?obj=admin&req=updParametre&sCode='+escape(sCode)+'&iSociete='+LOC_ID_SERVICE+'&sValeur='+escape(sValeur), {
onSuccess: this.click_.bind(this),
noRed: true
});
}
}.bind(this, sCode, sValeur, LOC_ID_SERVICE)
});
}
}
}
break;
case 'comptes_absence' :
var sCode = $('sCode').value;
var sCompte = $('sCompte').value;
var cContrepartie = $('cContrepartie').value;
if(sCompte.length != 0) {
controller.pool.newHttpRequest('server.asp?obj=admin&req=insNewCompte&sCode='+escape(sCode)+'&sCompte='+escape(sCompte)+'&cContrepartie='+escape(cContrepartie)+'&intService='+LOC_ID_SERVICE, {
onSuccess: this.click_.bind(this),
noRed: true
});
}
else
alert("Vous n\'avez pas saisi de libellé pour le compte : "+sCompte);
break;
case 'profils_comptes' :
var fCP = $('fCP').value;
var fRTT = $('fRTT').value;
var iCP = $('iCP').value;
var iRTT = $('iRTT').value;
if(fCP.length == 0)
fCP = 0;
if(fRTT.length == 0)
fRTT = 0;
var sChaine = iCP+"_CP_"+fCP+"|"+iRTT+"_RTT_"+fRTT ;
controller.pool.newHttpRequest('server.asp?obj=compte&req=insNewProfil&sChaine='+escape(sChaine)+'&intService='+LOC_ID_SERVICE, {
onSuccess: this.click_.bind(this),
noRed: true
});
break;
}
}
this.click_ = function(){
if( this.menu == 'comptes_absence') {
comptesController.addCompte.apply(comptesController, arguments[0]);
controller.showLabel('Compte créé');
}
if( this.menu == 'valeurs_parametres') {
controller.showLabel('Paramètre enregistré');
for (var i=0; i < this.tabParametres.length; i++) {
if ( this.tabParametres[i][0] == arguments[0][0] ) {
this.tabParametres[i][2] = arguments[0][2];
break;
}
if ( arguments[0][0] == 'STR_SOCIETE' ) {
viewTitre.childNodes.societe.setInnerHTML(arguments[0][2]);
}
}
}
if( this.menu == 'profils_comptes') {
controller.showLabel('Profil enregistré');
}
if(this.menu != 'valeurs_parametres') {
this.affiche(this.menu);
}
}
this.delete_ = function(value){
viewAdmin.reset(1);
viewAdmin.childNodes.content.setInnerHTML('');
if(this.menu == 'comptes_absence'){
controller.showLabel('Compte supprimé');
comptesController.delCompte(value);
}
if(this.menu == 'profils_comptes'){
controller.showLabel('Profil supprimé');
}
this.affiche(this.menu);
}
this.modifier = function( action ){
switch(action){
case 'motdepasse' :
var sTitre = 'Modifier votre mot de passe';
var sHTML = '<table border=0 width=300px>';
sHTML += '<tr><td width=200px class=normal>Votre ancien mot de passe</td><td width=100px><input type="password" id="oldPWD" size="10" class="Input"></td></tr>';
sHTML += '<tr><td width=200px class=normal>Votre nouveau mot de passe</td><td width=100px><input type="password" id="newPWD1" size="10" class="Input"></td></tr>';
sHTML += '<tr><td width=200px class=normal>Confirmez votre nouveau mot de passe</td><td width=100px><input type="password" id="newPWD2" size="10" class="Input"></td></tr>';
sHTML += '<tr><td colspan=2 align=center><img onClick=adminController.adminParametrer.saveModif("motdepasse"); style=cursor:pointer; src='+GLO_IMG_REP+GLO_IMG_ENREGISTRER+'></td></tr>';
sHTML += '</table>';
var iTop = 176;
break;
case 'date' :
var sTitre = 'Modifier la date de début d\'utilisation';
var sHTML = '<table border=0 width=300px>';
sHTML += '<tr><td width=200px class=normal>La nouvelle date</td><td width=100px><input type="text" id="newDate" size="10" class="Input" onKeyPress="return checkKey(this, event);" onKeyUp="checkDateTemp(this.value, this);"></td></tr>';
sHTML += '<tr><td colspan=2 align=center><img onClick=adminController.adminParametrer.saveModif("date"); style=cursor:pointer; src='+GLO_IMG_REP+GLO_IMG_ENREGISTRER+'></td></tr>';
sHTML += '</table>';
var iTop = 264;
break;
}
viewPopUp.body.setTop(iTop-viewAdmin.childNodes.content.scrollTop);
viewPopUp.body.setLeft(240+mainView.childNodes.paveGauche.getWidth());
viewPopUp.childNodes.titre.setInnerHTML(sTitre);
viewPopUp.affiche(sHTML);
Aide.unregister(viewPopUp.body);
Aide.register(viewPopUp.body, 'admin', 'parametrergeneraux');
Effect.show.call(viewPopUp.body);
}
this.saveModif = function( action ){
switch(action){
case 'motdepasse' :
var oldPWD = $('oldPWD').value;
var newPWD1 = $('newPWD1').value;
var newPWD2 = $('newPWD2').value;
controller.pool.newHttpRequest('server.asp?obj=admin&req=updPassword&sCode=STR_PWD&iSociete='+LOC_ID_SERVICE+'&sOldPwd='+escape(oldPWD)+'&sNewPwd1='+escape(newPWD1)+'&sNewPwd2='+escape(newPWD2), {
onSuccess: this.saveModif_.bind(this),
noRed: true
});
break;
case 'date' :
var sValeur = $('newDate').value;
controller.pool.newHttpRequest('server.asp?obj=admin&req=updParametre&sCode=DTM_DEMARRAGE&iSociete='+LOC_ID_SERVICE+'&sValeur='+escape(sValeur), {
onSuccess: this.saveModif_.bind(this),
noRed: true
});
$('DTM_DEMARRAGE').value = sValeur;
break;
}
}
this.saveModif_ = function() {
Effect.hide.call(viewPopUp.body);
controller.showLabel('Modification enregistrée');
}
this.verifNumber = function(e) {
}
}
function adminController() {
this.action = 0;
this.adminFicheSalaries = new adminFicheSalaries();
this.adminConsulter = new adminConsulter();
this.adminAdministrer = new adminAdministrer();
this.adminParametrer = new adminParametrer();
this.boutonClicked = function(BoutonClique,NomDeLaVue,NomDuController){
var controlleur = this[NomDuController];
controlleur.affiche();
this.getAide(BoutonClique);
}
this.getAide = function(req){
/*viewAideAdmin.childNodes.titre.setInnerHTML('');
viewAideAdmin.childNodes.texte.setInnerHTML('');
viewAideAdmin.childNodes.action.setInnerHTML('');*/
/*controller.pool.newHttpRequest('server.asp?obj=aide&req='+req+'&sNode=admin', {
onSuccess: this.getAide_.bind(this)
});*/
}
this.getAide_ = function(){
viewAideAdmin.childNodes.titre.setInnerHTML(arguments[0][0]);
viewAideAdmin.childNodes.texte.setInnerHTML(arguments[0][1]);
}
}
viewAideAdmin = {
body: new LDivElement( '', 'white', 10, '0px solid #FFC000', '', '', '', '0px', mybro.getWindowHeight() - 226, 14, 128, 730, '<img style="position: absolute; top: 0px; right: 8px; z-index: 20;" src="'+GLO_IMG_REP+'interrogation_carre.gif" />'),
childNodes: {
titre: new LDivElement( '', 'pink bigger', 10, '', '1px 1px 0px 1px', 'solid solid solid solid', '#FFC000 #FFC000 #000 #FFC000', '0px 0px 0px 4px', 6, 0, 20, 730, ''),
texte: new LDivElement( '', 'left normal auto', 10, '', '0px 1px 1px 1px', 'solid solid solid solid', '#000 #FFC000 #FFC000 #FFC000', '4px', 26, 0, 100, 730, '')
}
}
viewAideAdmin.setPosition = function( value ){
}
function viewMoisSelector(mois) {
this.body = new LDivElement( 'div_mois', 'hidden', 22, '', '0px 3px 3px 3px', 'solid solid solid solid', '#FFF #FFF #FFF #FFF', '2px', 0, 0, 10, 116, '');
this.body.style.backgroundColor = '#FFEFBD';
var index = mois.mois;
var tabMois = mois.tab_mois.concat(mois.tab_mois).concat(mois.tab_mois);
var date_debut = new LDate(mois.date_debut.toFullString());
date_debut.addMois(-2);
this.body.setHeight(160+4);
for (var i=0; i < 8; i++) {
var lmois = new LDivElement( 'div_mois_'+i, 'pointer big left', 10, '1px solid #FFEFBD', '', '', '', '3px', 0, 0, 20, 110, tabMois[index+12-2+i].firstUpper() + ' ' + date_debut.getFullYear());
this.body.appendChild_(lmois);
lmois.setTop( i*20 + Math.floor((Math.max(0,i-1)+9)/10)); //Calcul barbare pour obtenir +1 à partir de i=2
Event.setevent.call(lmois, 'mouseover', function() {
this.setBorder('1px solid #900');
});
Event.setevent.call(lmois, 'mouseout', function() {
this.setBorder('1px solid #FFEFBD');
});
Event.setevent.call(lmois, 'mouseup', function() {
this.setBorder('1px solid #FFEFBD');
});
date_debut.addMois(1);
if ( i == 2 ) {
Event.setevent.call(lmois, 'click', function() {
planningController.closeSelector();
});
}
else {
Event.setevent.call(lmois, 'click', function(i) {
planningController.closeSelector();
controller.addJoursPlanning(31*(i-2));
salariesController.checkSalariesPresents();
viewEntetePlanning.reset();
}.bind(this, i));
}
}
}
viewSoldes = {
body: new LDivElement( '', 'big', 10, '0px solid #000', '', '', '', '0px', 42, 142, 2, 280, ''),
childNodes: {
tabSoldeAu: new LDivElement( '', '', 10, '0px solid #000', '', '', '', '0px', 0, 0, 0, 70, ''),
tabJoursSaisis: new LDivElement( '', '', 10, '0px solid #000', '', '', '', '0px', 0, 70, 0, 70, ''),
tabDroits: new LDivElement( '', '', 10, '0px solid #000', '', '', '', '0px', 0, 140, 0, 70, ''),
tabEstimationAu: new LDivElement( '', '', 10, '0px solid #000', '', '', '', '0px', 0, 210, 0, 70, '')
}
}
Aide.register(viewSoldes.childNodes.tabSoldeAu, 'accueil', 'soldeau', false, {
options: {
$date_debut_soldes: function() { return controller.getDateDebutSoldes().toString(); }
}
});
Aide.register(viewSoldes.childNodes.tabJoursSaisis, 'accueil', 'jourssaisis', false, {
options: {
$date_debut_soldes: function() { return controller.getDateDebutSoldes().toString(); }
}
});
Aide.register(viewSoldes.childNodes.tabDroits, 'accueil', 'droits', false, {
options: {
$date_debut_soldes: function() { return controller.getDateDebutSoldes().toString(); },
$date_fin_soldes: function() { return controller.getDateFinaleSoldes().toMonthString(); }
}
});
Aide.register(viewSoldes.childNodes.tabEstimationAu, 'accueil', 'estimation', false, {
options: {
$date_fin_soldes: function() { return controller.getDateFinaleSoldes().toMonthString(); }
}
});
function viewSoldeFactory() {
var viewSolde = new LDivElement( '', 'right', 10, '', '1px 1px 1px 0px', 'solid solid dotted solid', '#FFF #FFF #FC0 #FFF', '2px 10px 2px 0px', 0, 0, 20, 70, '');
return viewSolde;
}
viewSoldes.tabViewSoldes = new Array(viewSoldes.childNodes.tabSoldeAu, viewSoldes.childNodes.tabJoursSaisis, viewSoldes.childNodes.tabDroits, viewSoldes.childNodes.tabEstimationAu);
viewSoldes.childNodes.each( function(el, elName) {
el.tabView = new Array();
el.addViewSolde = function(solde) {
var posInsertion = 0;
for (var i=0; i < el.tabView.length; i++) {
if ( solde.compte.numeroAffichage < el.tabView[i].solde.compte.numeroAffichage ) {
posInsertion = i;
for (var j=i; j < el.tabView.length; j++) {
el.tabView[j].setTop((j+1)*20);
}
break;
}
posInsertion++;
}
var vSolde = viewSoldeFactory();//(this.controller, solde, this.col, posInsertion*20);
vSolde.setTop(posInsertion*20);
Observer.call(vSolde);
if ( elName != 'tabJoursSaisis' ) { //Pour les jours saisis, on doit afficher en négatif
vSolde.update = function(observed) {
this.setInnerHTML((observed.getJours()==0)?'-':observed.getJours());
}
}
else { //Jours saisis
vSolde.update = function(observed) {
this.setInnerHTML((observed.getJours()==0)?'-':(-observed.getJours()));
}
}
vSolde.blink = function() {
this.times = (this.times-1)||7;
if ( this.times > 1 ) {
if ( this.times%2==0 )
this.setBackgroundColor('#FFF');
else
this.setBackgroundColor('#FF8200');
this.blinkTimer = setTimeout(function() {
this.blink();
}.bind(this), 80);
}
else {
this.setBackgroundColor('#FFF');
clearTimeout(this.blinkTimer);
this.times = 8;
}
}
if ( elName == 'tabSoldeAu' || elName == 'tabJoursSaisis'  ) {
Event.setevent.call(vSolde, 'mousemove', function() {
if ( this.observed.getJours() != 0 ) {
vSolde.style.cursor = 'pointer';
mainView.childNodes.curseur.setTop(mybro.getMouseY()+12);
mainView.childNodes.curseur.setLeft(mybro.getMouseX()+12);
Effect.show.call(mainView.childNodes.curseur);
}
});
Event.setevent.call(vSolde, 'mouseout', function() {
vSolde.style.cursor = 'default';
Effect.hide.call(mainView.childNodes.curseur);
});
Event.setevent.call(vSolde, 'click', function() {
if ( this.observed.getJours() != 0 ) {
if ( elName == 'tabSoldeAu' ) {
controller.pool.newHttpRequest('server.asp?obj=compte&req=getDetailEcritures&iUser='+salariesController.getActiveSalarie().id+'&iCompte='+this.observed.compte.numero+'&dateSolde='+controller.getDateDebutSoldes().toFullString(), {
onSuccess: this.observed.afficheDetailEcritures.bind(this, salariesController.getActiveSalarie(), this.observed.compte)
});
}
if ( elName == 'tabJoursSaisis' ) {
var dtmDebut = new LDate(controller.getDateDebutSoldes().toFullString());
controller.pool.newHttpRequest('server.asp?obj=admin&req=getListeAbsences&iUser='+salariesController.getActiveSalarie().id+'&dtmDebut='+dtmDebut.addJours(1).toFullString()+'&dtmFin='+controller.getDateFinaleSoldes().getLastInMonth().toFullString(), {
onSuccess: this.observed.afficheDetailAbsences.bind(this, salariesController.getActiveSalarie(), this.observed.compte)
});
}
}
});
}
vSolde.observes(solde);
vSolde.solde = solde;
el.appendChild_(vSolde);
el.tabView.insert(vSolde,posInsertion);
el.setHeight(el.tabView.length*20);
viewSoldes.body.setHeight(el.tabView.length*20);
}.bind(this)
});
viewComptes = {
body: new LDivElement( '', '', 10, '0px solid #000', '', '', '', '0px', 42, 0, 0, 142, ''),
childNodes: {}
}
function viewCompteFactory(compte) {
var viewCompte = {
body: new LDivElement( '', '', 10, '0px solid #000', '', '', '', '0px', 0, 0, 20, 140, ''),
childNodes: {
pastille: new LDivElement( '', 'pointer', 10, '0px solid #000', '', '', '', '0px', 0, 0, 20, 20, ''),
txt: new LDivElement( '', 'big left pointer', 10, '1px solid #FFF', '', '', '', '3px', 0, 20, 20, 120, '<nobr>'+(compte.getLibelle().length>18?(compte.getLibelle().substr(0,17)+'.'):compte.getLibelle())+'</nobr>')
}
}
if (compte.isRecurrent()) {
Aide.register(viewCompte.body, 'accueil', 'comptesrecurrent', false, {
options: {
$libelle_compte: compte.getLibelle(),
$nb_jour: compte.nbJours,
$date_debut_ac: compte.debutAcq,
$date_fin_ac: compte.finAcq,
$date_debut_conso: compte.debutConso,
$date_fin_conso: compte.finConso
}
});
}
else {//Compte sans période d'acquisition
if (compte.isCreditAuto()) {
Aide.register(viewCompte.body, 'accueil', 'comptescreditauto', false, {
options: {
$libelle_compte: compte.getLibelle()
}
});
}
else { //Notion de débit/crédit pour ce compte
Aide.register(viewCompte.body, 'accueil', 'comptesdebitcredit', false, {
options: {
$libelle_compte: compte.getLibelle()
}
});
}
}
viewCompte.childNodes.pastille.setBackground('url('+GLO_IMG_REP+compte.getPastille()+'_sortie.gif) 0px 2px #FFF no-repeat');
Observer.call(viewCompte);
viewCompte.update = function(observed) {
if ( this.compte.isOver ) {
comptesController.mode.mouseoverView.call(this);
}
else {
comptesController.mode.mouseoutView.call(this);
}
if ( this.compte.isGris ) {
this.body.setOpacity(0.2);
this.childNodes.txt.className = 'big left';
this.childNodes.pastille.className = '';
}
else {
this.body.setOpacity(1);
this.childNodes.txt.className = 'big left pointer';
this.childNodes.pastille.className = 'pointer';
}
}
Event.setevent.call(viewCompte.childNodes.pastille, 'mouseover', function() {
comptesController.mode.mouseoverView.call(this);
}.bind(viewCompte));
Event.setevent.call(viewCompte.childNodes.pastille, 'mouseout', function() {
comptesController.mode.mouseoutView.call(this);
}.bind(viewCompte));
Event.setevent.call(viewCompte.childNodes.pastille, 'mousedown', function() {
comptesController.mode.mousedownView.call(this);
}.bind(viewCompte));
Event.setevent.call(viewCompte.childNodes.pastille, 'mouseup', function() {
comptesController.mode.mouseupView.call(this);
}.bind(viewCompte));
Event.setevent.call(viewCompte.childNodes.txt, 'mouseover', function() {
comptesController.mode.mouseoverView.call(this);
}.bind(viewCompte));
Event.setevent.call(viewCompte.childNodes.txt, 'mouseout', function() {
comptesController.mode.mouseoutView.call(this);
}.bind(viewCompte));
Event.setevent.call(viewCompte.childNodes.txt, 'mousedown', function() {
comptesController.mode.mousedownView.call(this);
}.bind(viewCompte));
Event.setevent.call(viewCompte.childNodes.txt, 'mouseup', function() {
comptesController.mode.mouseupView.call(this);
}.bind(viewCompte));
viewCompte.compte = compte;
compte.viewCompte = viewCompte;
viewCompte.observes(compte);
return viewCompte;
}
viewComptes.tabView = new Array();
viewComptes.addViewCompte = function(compte) {
var viewComte_ = viewCompteFactory(compte);
var position = 0;
for (var i=0; i < this.tabView.length; i++) {
if ( this.tabView[i].compte.numeroAffichage > compte.numeroAffichage )
break;
position++;
}
this.tabView.insert(viewComte_, position);
for (var i=0; i < this.tabView.length; i++) {
this.tabView[i].body.setTop(i*20);
}
processNode(viewComte_, viewComptes.body);
this.body.setHeight(this.tabView.length*20);
viewMesSoldes.body.setHeight(46+this.tabView.length*20);
viewPlanning.body.setTop( planningController.getOffsetTop() );
controller.setHeightPaveDroit();
}
viewComptes.remViewCompte = function(compte) {
compte.viewCompte.body.setInnerHTML('');
}
viewTitres = {
body: new LDivElement( '', '', 10, '0px solid #000', '', '', '', '0px', 0, 144, 160, 280, ''),
childNodes: {
soldeAu: new LDivElement( '', 'center big', 10, '0px solid #000', '', '', '', '6px', 0, 0, 40, 66, ''),
joursSaisis: new LDivElement( '', 'center big', 10, '0px solid #000', '', '', '', '6px', 0, 70, 40, 66, ''),
droits: new LDivElement( '', 'center big', 10, '0px solid #000', '', '', '', '6px', 0, 140, 40, 66, ''),
estimationAu: new LDivElement( '', 'center big', 10, '0px solid #000', '', '', '', '6px', 0, 210, 40, 66, '')
}
}
viewTitres.childNodes.soldeAu.setBackground('url('+GLO_IMG_REP+GLO_IMG_TITRE_SOLDE+') 0px 0px #FFF no-repeat');
viewTitres.childNodes.joursSaisis.setBackground('url('+GLO_IMG_REP+GLO_IMG_TITRE_SOLDE+') 0px 0px #FFF no-repeat');
viewTitres.childNodes.droits.setBackground('url('+GLO_IMG_REP+GLO_IMG_TITRE_SOLDE+') 0px 0px #FFF no-repeat');
viewTitres.childNodes.estimationAu.setBackground('url('+GLO_IMG_REP+GLO_IMG_TITRE_SOLDE+') 0px 0px #FFF no-repeat');
Observer.call(viewTitres);
viewTitres.update = function() {
this.childNodes.soldeAu.setTextNode('Solde au '+controller.getDateDebutSoldes().toString());
this.childNodes.joursSaisis.setTextNode('Jours saisis');
this.childNodes.droits.setTextNode('Droits à acquérir');
this.childNodes.estimationAu.setTextNode('Solde fin '+controller.getDateFinaleSoldes().toMonthString());
}
Aide.register(viewTitres.childNodes.soldeAu, 'accueil', 'soldeau', false, {
options: {
$date_debut_soldes: function() { return controller.getDateDebutSoldes().toString(); }
}
});
Aide.register(viewTitres.childNodes.joursSaisis, 'accueil', 'jourssaisis', false, {
options: {
$date_debut_soldes: function() { return controller.getDateDebutSoldes().toString(); }
}
});
Aide.register(viewTitres.childNodes.droits, 'accueil', 'droits', false, {
options: {
$date_debut_soldes: function() { return controller.getDateDebutSoldes().toString(); },
$date_fin_soldes: function() { return controller.getDateFinaleSoldes().toMonthString(); }
}
});
Aide.register(viewTitres.childNodes.estimationAu, 'accueil', 'estimation', false, {
options: {
$date_fin_soldes: function() { return controller.getDateFinaleSoldes().toMonthString(); }
}
});
viewMesSoldes = {
body: new LDivElement( '', 'left overflow', 10, '0px solid #000', '', '', '', '2px', 12, 14, 46, 424, ''),
childNodes: {
salarie: new LDivElement( '', 'salarie', 10, '0px solid #FFC000', '', '', '', '3px 0px 3px 24px', 0, 0, 39, 139, ''),
titres: viewTitres,
comptes: viewComptes,
soldes: viewSoldes
}
}
viewMesSoldes.childNodes.salarie.setBackground('url('+GLO_IMG_REP+GLO_IMG_SAL+') 0px 0px #FFF no-repeat');
Observer.call(viewMesSoldes.childNodes.salarie);
viewMesSoldes.childNodes.salarie.update = function(observed) {
this.setInnerHTML( '<b>' + observed.getNom() + '</b>' + '<br>' + observed.getPrenom() );
}
Aide.register(viewMesSoldes.childNodes.salarie, 'accueil', 'salarie', false, {
options: {
$libelle_salarie: function() { return this.observed.getLibelle(); },
$mois_precedent: Date.getInfo('addMois', -1, 'toMonthText'),
$mois_courant: Date.today.toMonthText(),
$fin_mois_courant: Date.today.toMonthText(),
$nb_jours_travailles_mois_precedent: function() { return this.observed.get_nbj_travaille_prec(); },
$nb_jours_travailles_mois_courant: function() { return this.observed.get_nbj_travaille_encours(); },
$nb_jours_absence_debut_annee: function() { return this.observed.get_nbj_absence(); }
},
toDoBefore: function() {
this.observed.getInfosJoursTravailles();
}
});
viewSousMenus = {
body: new LDivElement( '', 'left white hidden', 80, '0px solid #000', '', '', '', '0px', 32, 14, 20, 730, ''),
childNodes: {
parametres: new LDivElement( '', 'sous_menus pointer center normal', 85, '', '', '', '', '2px', 0, 0, 20, 242, 'Les paramètres généraux'),
comptes: new LDivElement( '', 'sous_menus pointer center normal', 85, '','', '', '', '2px', 0, 244, 20, 242, 'Le plan de comptes'),
profils: new LDivElement( '', 'sous_menus pointer center normal', 85, '', '', '', '', '2px', 0, 488, 20, 242, 'Les profils')
}
}
Event.setevent.call(viewSousMenus.childNodes.parametres, 'click', function() {
resetAllButThisOneSousMenus(this);
adminController.adminParametrer.affiche('valeurs_parametres');
viewAideModule = 'admin';
viewAideAttribut = 'parametrergeneraux';
adminController.getAide('parametres');
});
Event.setevent.call(viewSousMenus.childNodes.comptes, 'click', function() {
resetAllButThisOneSousMenus(this);
adminController.adminParametrer.affiche('comptes_absence');
viewAideModule = 'admin';
viewAideAttribut = 'parametrercomptes';
adminController.getAide('comptes');
});
Event.setevent.call(viewSousMenus.childNodes.profils, 'click', function() {
resetAllButThisOneSousMenus(this);
adminController.adminParametrer.affiche('profils_comptes');
viewAideModule = 'admin';
viewAideAttribut = 'parametrerprofils';
adminController.getAide('profils');
});
function resetAllButThisOneSousMenus(module) {
viewSousMenus.childNodes.parametres.style.backgroundColor = '#FC7';
viewSousMenus.childNodes.comptes.style.backgroundColor = '#FC7';
viewSousMenus.childNodes.profils.style.backgroundColor = '#FC7';
module.style.backgroundColor = '#FF8000';
}
viewMenus = {
body: new LDivElement( '', 'left white', 80, '0px solid #000', '', '', '', '0px', 0, 14, 30, 730, ''),
childNodes: {
salaries: new LDivElement( '', 'menus pointer center big', 85, '0px solid #000', '', '', '', '8px', 0, 0, 30, 182, 'Salariés'),
consulter: new LDivElement( '', 'menus pointer center big', 85, '0px solid #000','', '', '', '8px', 0, 184, 30, 182, 'Consulter'),
attribuer: new LDivElement( '', 'menus pointer center big', 85, '0px solid #000', '', '', '', '8px', 0, 368, 30, 182, 'Attribuer des droits'),
parametrer: new LDivElement( '', 'menus pointer center big', 85, '0px solid #000', '', '', '', '8px', 0, 552, 30, 182, 'Paramétrer')
}
}
Event.setevent.call(viewMenus.childNodes.salaries, 'click', function() {
viewAdmin.reset(0);
resetAllButThisOne(this);
adminController.adminFicheSalaries.affiche();
viewAideModule = 'admin';
viewAideAttribut = 'salaries';
});
Event.setevent.call(viewMenus.childNodes.consulter, 'click', function() {
viewAdmin.reset(0);
resetAllButThisOne(this);
adminController.adminConsulter.affiche();
viewAideModule = 'admin';
viewAideAttribut = 'consulter';
});
Event.setevent.call(viewMenus.childNodes.attribuer, 'click', function() {
viewAdmin.reset(0);
resetAllButThisOne(this);
adminController.adminAdministrer.affiche();
viewAideModule = 'admin';
viewAideAttribut = 'attribuer';
});
Event.setevent.call(viewMenus.childNodes.parametrer, 'click', function(e) {
viewAdmin.reset(1);
resetAllButThisOne(this);
adminController.adminParametrer.affiche();
viewSousMenus.childNodes.parametres.onclick(e);
});
function resetAllButThisOne(module) {
viewMenus.childNodes.salaries.style.backgroundColor = '#FE9';
viewMenus.childNodes.consulter.style.backgroundColor = '#FE9';
viewMenus.childNodes.attribuer.style.backgroundColor = '#FE9';
viewMenus.childNodes.parametrer.style.backgroundColor = '#FE9';
module.style.backgroundColor = '#FFC000';
}
viewAdmin = {
body: new LDivElement( 'viewAdmin', 'left white hidden', 10, '0px solid #FFF', '', '', '', '0px', 64, 0, 0, 760, ''),
childNodes: {
menu: viewMenus,
sousmenus:viewSousMenus,
content: new LDivElement( '', 'white auto', 10, '0px solid #000', '', '', '', '0px', 54, 14, mybro.getWindowHeight() - 280, 746, ''),
aide: viewAideAdmin
}
}
viewAdmin.reset = function( value ) {
Util.collector.emptyChildNodes(viewAdmin.childNodes.content);
viewAdmin.childNodes.content.setInnerHTML('');
if (value == 0)
Effect.hide.call(viewSousMenus.body);
else
Effect.show.call(viewSousMenus.body);
}
viewPopUp = {
body: new LDivElement( '', 'hidden', 15, '0px solid #FFC000', '', '', '', '0px', 0, 0, 187, 388, ''),
childNodes: {
titre: new LDivElement( '', 'bigger center move', 20, '0px solid #000', '', '', '', '0px', 12, 7, 23, 374, '-'),
backTop: new LDivElement( '', '', 15, '0px solid #000', '', '', '', '0px', 0, 0, 35, 388, ''),
back: new LDivElement( '', '', 15, '0px solid #000', '', '', '', '0px', 35, 0, 150, 388, ''),
backBottom: new LDivElement( '', '', 15, '0px solid #000', '', '', '', '0px', 0, 0, 23, 388, ''),
content: new LDivElement( '', 'white left normal auto', 15, '0px solid #000', '', '', '', '4px', 35, 8, 150, 367, '-')
}
}
viewPopUp.childNodes.backBottom.style.top = 'auto';
viewPopUp.childNodes.backBottom.style.bottom = 0+'px';
var html = '';
html += '<img class="aide cursor" onclick="viewPopUp.close();" style="z-index: 25; top: 10px; right: 16px;" src="'+GLO_IMG_REP+GLO_IMG_POP[1]+'" />';
viewPopUp.body.setInnerHTML(html);
viewPopUp.childNodes.backTop.setPNGBackground('url('+GLO_IMG_REP+GLO_IMG_POP[0]+') 0px 0px no-repeat');
viewPopUp.childNodes.back.setPNGBackground('url('+GLO_IMG_REP+GLO_IMG_POP[3]+') 0px 0px repeat-y');
viewPopUp.childNodes.backBottom.setPNGBackground('url('+GLO_IMG_REP+GLO_IMG_POP[2]+') 0px 0px no-repeat');
Event.setevent.call(viewPopUp.childNodes.titre, 'mousedown', function(e) {
this.pointerX = mybro.getRelativeMouseX(this, Mouse.e)+7;
this.pointerY = mybro.getRelativeMouseY(this, Mouse.e)+12;
Event.setevent.call(lbody, 'mousemove', function(e) {
viewPopUp.body.setLeft( mybro.getMouseX(Mouse.e) - viewPopUp.childNodes.titre.pointerX );
viewPopUp.body.setTop( mybro.getMouseY(Mouse.e) - viewPopUp.childNodes.titre.pointerY );
});
});
Event.setevent.call(viewPopUp.childNodes.titre, 'mouseup', function(e) {
Event.setevent.call(lbody, 'mousemove', function(e) {});
});
viewPopUp.affiche = function(html) {
this.childNodes.content.setInnerHTML(html);
this.resize();
}
viewPopUp.resize = function() {
this.body.setHeight(150+58);
this.childNodes.content.setHeight(150);
this.childNodes.back.setHeight(150);
this.childNodes.back.firstChild.setHeight(150);
if ( parseInt(this.childNodes.content.scrollHeight) >= 150 ) {
var height = Math.min(400, parseInt(this.childNodes.content.scrollHeight));
this.body.setHeight(height+58);
this.childNodes.content.setHeight(height);
this.childNodes.back.setHeight(height);
this.childNodes.back.firstChild.setHeight(height);
}
}
viewPopUp.close = function() {
this.childNodes.content.setInnerHTML('');
Effect.hide.call(viewPopUp.body);
}
viewTitre = {
body: new LDivElement( '', 'left white', 10, '', '0px 1px 1px 1px', 'solid solid solid solid', '#000 #FF8200 #FF8200 #FF8200', '5px 5px 5px 22px', 0, (mybro.getWindowWidth()-782)/2, 64, 762, ''),
childNodes: {
admin: viewAdmin,
label: new LDivElement( 'div_label', 'big hidden', 9999, '0px solid #000', '', '', '', '2px 2px 2px 4px', 0, 0, 17, 200, 'Paramètres enregistrés'),
red: new LDivElement( 'div_connexion', 'hidden center', 9999, '', '', '', '', '1px 0px 0px 0px', 2, 0, 17, 17, ''),
green: new LDivElement( 'div_ecriture', 'hidden', 9999, '', '', '', '', '0px', 2, 0, 20, 20, ''),
btnDeconnexion: new LDivElement( '', 'pointer right', 10, '0px solid #000', '', '', '', '0px', 36, 0, 22, 29, ''),
btnAdmin: new LDivElement( '', 'pointer right', 10, '0px solid #000', '', '', '', '0px', 36, 0, 22, 52, ''),
societe: new LDivElement( '', 'bigger center', 9999, '0px solid #000', '', '', '', '0px', 28, 310, 20, 140, LOC_NOM_SERVICE)
}
}
viewTitre.childNodes.label.setBackground('url('+GLO_IMG_REP+GLO_IMG_LABEL+') 0px 0px #FFF no-repeat');
viewTitre.childNodes.label.style.top = 'auto';
viewTitre.childNodes.label.style.left = 'auto';
viewTitre.childNodes.label.style.right = 108+'px';
viewTitre.childNodes.label.style.bottom = 5+'px';
viewTitre.childNodes.red.setBackground('url('+GLO_IMG_REP+GLO_IMG_RED+') 0px 0px #FFF no-repeat');
viewTitre.childNodes.red.style.left = 'auto';
viewTitre.childNodes.red.style.right = 11+'px';
viewTitre.childNodes.green.setBackground('url('+GLO_IMG_REP+GLO_IMG_GREEN+') 0px 0px #FFF no-repeat');
viewTitre.childNodes.green.style.left = 'auto';
viewTitre.childNodes.green.style.right = 31+'px';
viewTitre.body.setBackground('url('+GLO_IMG_REP+GLO_IMG_LOGO+') 10px 5px #FFF no-repeat');
viewTitre.childNodes.btnAdmin.glo_img_admin = GLO_IMG_GESTION;
viewTitre.childNodes.btnAdmin.setBackground('url('+GLO_IMG_REP+viewTitre.childNodes.btnAdmin.glo_img_admin[0]+') 0px 0px no-repeat');
Event.setevent.call(viewTitre.childNodes.btnAdmin, 'mouseover', function() {
this.setBackground('url('+GLO_IMG_REP+viewTitre.childNodes.btnAdmin.glo_img_admin[1]+') 0px 0px no-repeat');
});
Event.setevent.call(viewTitre.childNodes.btnAdmin, 'mouseout', function() {
this.setBackground('url('+GLO_IMG_REP+viewTitre.childNodes.btnAdmin.glo_img_admin[0]+') 0px 0px no-repeat');
});
Event.setevent.call(viewTitre.childNodes.btnAdmin, 'mousedown', function() {
this.setBackground('url('+GLO_IMG_REP+viewTitre.childNodes.btnAdmin.glo_img_admin[2]+') 0px 0px no-repeat');
});
Event.setevent.call(viewTitre.childNodes.btnAdmin, 'mouseup', function() {
this.setBackground('url('+GLO_IMG_REP+viewTitre.childNodes.btnAdmin.glo_img_admin[1]+') 0px 0px no-repeat');
});
viewTitre.childNodes.btnAdmin.style.left = 'auto';
viewTitre.childNodes.btnAdmin.style.right = 45+'px';
viewTitre.childNodes.btnDeconnexion.setBackground('url('+GLO_IMG_REP+GLO_IMG_DECON[0]+') 0px 0px no-repeat');
Event.setevent.call(viewTitre.childNodes.btnDeconnexion, 'mouseover', function() {
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_DECON[1]+') 0px 0px no-repeat');
});
Event.setevent.call(viewTitre.childNodes.btnDeconnexion, 'mouseout', function() {
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_DECON[0]+') 0px 0px no-repeat');
});
Event.setevent.call(viewTitre.childNodes.btnDeconnexion, 'mousedown', function() {
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_DECON[2]+') 0px 0px no-repeat');
});
Event.setevent.call(viewTitre.childNodes.btnDeconnexion, 'mouseup', function() {
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_DECON[1]+') 0px 0px no-repeat');
});
viewTitre.childNodes.btnDeconnexion.style.left = 'auto';
viewTitre.childNodes.btnDeconnexion.style.right = 11+'px';
Aide.register(viewTitre.childNodes.btnAdmin, 'accueil', 'btnadmin');
Aide.register(viewTitre.childNodes.btnDeconnexion, 'accueil', 'btndeco');
Event.setevent.call(viewTitre.childNodes.btnAdmin, 'click', function() {
if ( !this.moving ) {
var dist = Math.round(Math.max((mybro.getWindowHeight()-6) - 64, 0) / 20);
if ( this.down ) {
this.move = function(value, n) {
viewTitre.body.setHeight(64+value);
mainView.childNodes.content.body.setTop(66+value);
viewAdmin.body.setHeight(Math.max(0,64+value-96));
if ( value >= dist ) {
setTimeout(function(value, n) {
this.move(value, n);
}.bind(this, value-n, n), 0);
}
else { //Sinon, on est arrivé en haut
this.down = false;
viewTitre.childNodes.btnAdmin.glo_img_admin = GLO_IMG_GESTION;
viewTitre.childNodes.btnAdmin.setBackground('url('+GLO_IMG_REP+viewTitre.childNodes.btnAdmin.glo_img_admin[0]+') 0px 0px no-repeat');
viewAide = viewAideAccueil;
viewAideModule = 'accueil';
viewAideAttribut = 'default';
controller.setHeightPaveDroit();
}
}
salariesController.checkSalariesPresents();
controller.resetBornesConges();
salariesController.reloadSoldes( function() {
congesController.loadConges();
salariesController.initJoursChomes();
});
this.move(20*dist, dist);
}
else { //S'il est en haut, on le baisse
this.move = function(value, n) {
viewTitre.body.setHeight(64+value);
mainView.childNodes.content.body.setTop(66+value);
viewAdmin.body.setHeight(Math.max(0,64+value-96));
if ( value <= 19 * dist ) {
setTimeout(function(value, n) {
this.move(value, n);
}.bind(this, n+value, n), 0);
}
else {
viewTitre.body.setHeight(mybro.getWindowHeight()-2);
mainView.childNodes.content.body.setTop(mybro.getWindowHeight());
viewAdmin.body.setHeight(Math.max(0,mybro.getWindowHeight()-2-96));
this.down = true;
viewTitre.childNodes.btnAdmin.glo_img_admin = GLO_IMG_PLANNING;
viewTitre.childNodes.btnAdmin.setBackground('url('+GLO_IMG_REP+viewTitre.childNodes.btnAdmin.glo_img_admin[0]+') 0px 0px no-repeat');
viewAide = viewAideAdmin;
viewAideModule = 'admin';
viewAideAttribut = 'salaries';
}
}
Log.log('clic_admin', '<service>'+LOC_ID_SERVICE+'</service>');
this.afficheAdmin(function(dist) {
mainView.childNodes.paveDroit.firstChild.style.height = 0+'px';
mainView.childNodes.paveDroit.style.overflow = 'hidden';
setTimeout( function(dist) {
mainView.childNodes.paveDroit.style.overflow = 'auto';
this.move(dist, dist);
}.bind(this, dist), 0);
}.bind(this, dist));
}
}
});
viewTitre.childNodes.btnAdmin.afficheAdmin = function(andAfter) {
Effect.show.call(viewAdmin.body);
viewAdmin.reset(0);
resetAllButThisOne(viewMenus.childNodes.salaries);
adminController.adminFicheSalaries.andAfter = andAfter;
adminController.adminFicheSalaries.affiche();
}
Event.setevent.call(viewTitre.childNodes.btnDeconnexion, 'click', function() {
location.href = 'deconnexion.asp';
});
viewAideAccueil = {
body: new LDivElement( '', '', 10, '0px solid #FFC000', '', '', '', '0px', 4, 0, 176, 294, ''),
childNodes: {
titre: new LDivElement( '', 'pink bigger', 10, '', '1px 1px 0px 1px', 'solid solid solid solid', '#FFC000 #FFC000 #FFC000 #FFC000', '1px', 10, 0, 20, 294, ''),
texte: new LDivElement( '', 'left normal', 10, '', '0px 1px 1px 1px', 'solid solid solid solid', '#FFC000 #FFC000 #FFC000 #FFC000', '4px', 30, 0, 146, 294, '')
}
}
viewAideAccueil.body.style.left = 'auto';
viewAideAccueil.body.style.right = 14+'px';
var html = '';
html += '<img class="aide" style="top: 10px; left: 0px;" src="'+GLO_IMG_REP+GLO_IMG_AIDE[0]+'" />';
html += '<img class="aide" style="top: 10px; right: 0px;" src="'+GLO_IMG_REP+GLO_IMG_AIDE[1]+'" />';
html += '<img class="aide" style="top: 2px; right: 8px;" src="'+GLO_IMG_REP+GLO_IMG_AIDE[2]+'" />';
html += '<img class="aide" style="bottom: 0px; left: 0px;" src="'+GLO_IMG_REP+GLO_IMG_AIDE[3]+'" />';
html += '<img class="aide" style="bottom: 0px; right: 0px;" src="'+GLO_IMG_REP+GLO_IMG_AIDE[4]+'" />';
viewAideAccueil.body.setInnerHTML(html);
viewEntetePlanning = {
body: new LDivElement( '', 'overflow', 20, '0px solid #000', '', '', '', '3px', 10, 152, 50, 590, ''),
childNodes: {
leftArrow: new LDivElement( '', 'pointer', 24, '0px solid #000', '', '', '', '0px', 1, 3, 25, 25, ''),
rightArrow: new LDivElement( '', 'pointer', 24, '0px solid #000', '', '', '', '0px', 3, 0, 25, 25, '')
}
}
viewGrillePlanning = {
body: new LDivElement( '', '', 10, '0px solid #000', '', '', '', '0px', 0, 142, 0, 590, '<img src="include/img/planning_botright_blanc.gif" style="position: absolute; bottom: '+mybro.getCompatibleOffsetBackgroundImage(1)+'px; right: 0px;z-index: 20;">'),
childNodes: {
grisage: new LDivElement( '', 'white', 10, '0px solid #000', '', '', '', '0px', 0, 0, 0, 0, '')
}
}
viewGrillePlanning.childNodes.grisage.style.width = '100%';
viewGrillePlanning.childNodes.grisage.style.height = '100%';
viewGrillePlanning.childNodes.grisage.setOpacity(0.5);
Event.setevent.call(viewGrillePlanning.body, mybro.getMouseEnterLabel(), function(e) {
planningController.planningActif = true;
});
Event.setevent.call(viewGrillePlanning.body, mybro.getMouseLeaveLabel(), function(e) {
if ( (!Mouse.e.relatedTarget) || Mouse.e.relatedTarget.nodeName != 'LI' ) {
planningController.planningActif = false;
salariesController.setActiveSalarie(salariesController.salarieSelectionnePlanning);
for (var i=0; i < comptesController.tabComptes.length; i++)
comptesController.tabComptes[i].out();
}
});
viewGrillePlanning.body.onmousewheel = function(e) {
mainView.childNodes.paveDroit.scrollTop -= event.wheelDelta/2;
viewGrillePlanning.body.setTop(-mainView.childNodes.paveDroit.scrollTop);
viewBodyPlanning.childNodes.salaries.body.setTop(-mainView.childNodes.paveDroit.scrollTop);
}
viewBodyPlanning = {
body: new LDivElement( '', '', 10, '0px solid #000', '', '', '', '3px', 59, 10, 0, 143+589, ''),
childNodes: {
salaries: {
body: new LDivElement( '', '', 10, '0px solid #000', '', '', '', '3px', 0, 0, 0, 143, ''),
childNodes: {}
},
grille: viewGrillePlanning
}
}
Aide.register(viewBodyPlanning.childNodes.salaries.body, 'accueil', 'blocsalaries');
function viewSalariePlanningFactory(salarie) {
var viewSalariePlanning = new LDivElement( '', 'pointer left big', 10, '1px solid #FFE771', '', '', '', '2px 2px 2px 6px', 0, 0, 20, 143, '');
/*viewSalariePlanning.semaineType = new LDivElement( '', 'pointer', 10, '', '', '', '', '0px', 0, 0, 15, 15, '');
viewSalariePlanning.semaineType.style.left = 'auto';
viewSalariePlanning.semaineType.style.right = 2+'px';
viewSalariePlanning.semaineType.setBackground('url('+GLO_IMG_REP+GLO_IMG_CAL+') 0px 0px no-repeat'); */
/*var setTop_ = viewSalariePlanning.setTop;
viewSalariePlanning.setTop = function(value) {
setTop_.call(this, value);
this.semaineType.setTop(value+3);
}*/
salarie.vuePlanning = viewSalariePlanning;
viewSalariePlanning.setAidePlanning = function() {
Aide.register(this, 'accueil', 'salarie', false, {
options: {
$libelle_salarie: salarie.getLibelle(),
$mois_precedent: Date.getInfo('addMois', -1, 'toMonthText'),
$mois_courant: Date.today.toMonthText(),
$fin_mois_courant: Date.today.toMonthText(),
$nb_jours_travailles_mois_precedent: salarie.get_nbj_travaille_prec.bind(salarie),
$nb_jours_travailles_mois_courant: salarie.get_nbj_travaille_encours.bind(salarie),
$nb_jours_absence_debut_annee: salarie.get_nbj_absence.bind(salarie)
},
toDoBefore: function() {
this.observed.getInfosJoursTravailles();
}
});
}
Event.setevent.call(viewSalariePlanning, 'click', function() {
Aide.unregister(salariesController.salarieSelectionnePlanning.vuePlanning);
salariesController.salarieSelectionnePlanning = salarie;
salarie.vuePlanning.setAidePlanning();
salariesController.setActiveSalarie(salarie);
});
Event.setevent.call(viewSalariePlanning, 'mouseover', function() {
if ( salarie != salariesController.getActiveSalarie() ) {
this.setBackgroundColor('#FC0');
}
});
Event.setevent.call(viewSalariePlanning, 'mouseout', function() {
this.update(salarie);
});
return viewSalariePlanning;
}
viewPlanning = {
body: new LDivElement( '', 'overflow', 10, '0px solid #000', '', '', '', '3px', 180, 4, 71, 163+589, ''),
childNodes: {
entete: viewEntetePlanning,
body: viewBodyPlanning,
message: new LDivElement( '', 'hidden big left', 20, '0px solid #000', '', '', '', '3px 0px 0px 5px', 10, 10, 41, 134, '')
}
}
viewPlanning.childNodes.message.setBackground('url('+GLO_IMG_REP+GLO_IMG_MSG+') 0px 0px no-repeat');
Aide.register(viewPlanning.body, 'accueil', 'planning');
viewEntetePlanning.body.setBackground('url('+GLO_IMG_REP+GLO_IMG_FOND+') 0px 0px no-repeat');
viewEntetePlanning.childNodes.leftArrow.setBackground('url('+GLO_IMG_REP+GLO_IMG_FL_G+'_1.gif) 0px 0px no-repeat');
viewEntetePlanning.childNodes.rightArrow.setBackground('url('+GLO_IMG_REP+GLO_IMG_FL_D+'_1.gif) 0px 0px no-repeat');
viewEntetePlanning.childNodes.rightArrow.style.left = 'auto';
viewEntetePlanning.childNodes.rightArrow.style.right = 3+'px';
/*----------FLECHE GAUCHE-------------*/
Event.setevent.call(viewEntetePlanning.childNodes.leftArrow, 'mouseover', function() {
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_FL_G+'_2.gif) 0px 0px no-repeat');
});
Event.setevent.call(viewEntetePlanning.childNodes.leftArrow, 'mouseout', function() {
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_FL_G+'_1.gif) 0px 0px no-repeat');
viewEntetePlanning.entete.stopScrolling();
});
Event.setevent.call(viewEntetePlanning.childNodes.leftArrow, 'mousedown', function() {
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_FL_G+'_3.gif) 0px 0px no-repeat');
viewEntetePlanning.entete.startScrollingLeft();
});
Event.setevent.call(viewEntetePlanning.childNodes.leftArrow, 'mouseup', function() {
viewEntetePlanning.entete.stopScrolling();
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_FL_G+'_1.gif) 0px 0px no-repeat');
});
/*----------FLECHE DROITE-------------*/
Event.setevent.call(viewEntetePlanning.childNodes.rightArrow, 'mouseover', function() {
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_FL_D+'_2.gif) 0px 0px no-repeat');
});
Event.setevent.call(viewEntetePlanning.childNodes.rightArrow, 'mouseout', function() {
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_FL_D+'_1.gif) 0px 0px no-repeat');
viewEntetePlanning.entete.stopScrolling();
});
Event.setevent.call(viewEntetePlanning.childNodes.rightArrow, 'mousedown', function() {
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_FL_D+'_3.gif) 0px 0px no-repeat');
viewEntetePlanning.entete.startScrollingRight();
});
Event.setevent.call(viewEntetePlanning.childNodes.rightArrow, 'mouseup', function() {
viewEntetePlanning.entete.stopScrolling();
this.setBackground('url('+GLO_IMG_REP+GLO_IMG_FL_D+'_1.gif) 0px 0px no-repeat');
});
viewEntetePlanning.init = function() {
this.entete = new LEntete(32); //32 c'est la hauteur des lignes, pas le nombre de jours !!
this.body.appendChild_(this.entete.doom);
}
viewEntetePlanning.reset = function() {
Util.collector.emptyChildNodes(this.entete.doom);
this.body.removeChild_(this.entete.doom);
this.init();
comptesController.updatePastilles();
controller.resetBornesConges();
Effect.show.call(viewGrillePlanning.childNodes.grisage);
salariesController.reloadSoldes( function() {
congesController.loadConges();
salariesController.initJoursChomes();
});
}
var coins = '<img src="include/img/planning_topleft_blanc.gif" style="position: absolute; top: 0px; left: 0px; z-index: 20;">';
coins += '<img src="include/img/planning_botleft_blanc.gif" style="position: absolute; bottom: '+mybro.getCompatibleOffsetBackgroundImage(1)+'px; left: 0px; z-index: 20;">';
viewBodyPlanning.childNodes.salaries.body.addInnerHTML(coins);
viewBodyPlanning.childNodes.salaries.tabViewSalaries = new Array();
viewBodyPlanning.childNodes.salaries.addViewSalarie = function(salarie) {
var vSalarie = viewSalariePlanningFactory(salarie);//new viewSalariePlanning(this.controller, salarie, this.tabViewSalaries.length*(this.controller.size-1));
vSalarie.setTop(this.tabViewSalaries.length*19);
StaticObserver.call(vSalarie);
vSalarie.update = function(observed) {
if ( observed == salariesController.getActiveSalarie() ) {
if ( planningController.planningActif  )
this.setBackgroundColor('#FC0');
else //Sinon, orange
this.setBackgroundColor('#FF8200');
}
else { //Sinon, transparent
this.setBackgroundColor('transparent');
}
this.setInnerHTML(observed.getLibelle());
}
vSalarie.observes(salarie);
this.tabViewSalaries.push(vSalarie);
viewBodyPlanning.childNodes.salaries.body.appendChild_(vSalarie);
/*viewBodyPlanning.childNodes.salaries.body.appendChild(vSalarie.semaineType);*/
viewPlanning.body.setHeight(70+this.tabViewSalaries.length*19);
viewPlanning.childNodes.body.body.setHeight(this.tabViewSalaries.length*19+1);
this.body.setHeight(this.tabViewSalaries.length*19+1);
viewGrillePlanning.addLigne(salarie);
}
viewBodyPlanning.childNodes.salaries.remViewSalarie = function(salarie) {
for (var i=0; i < this.tabViewSalaries.length; i++) {
if ( this.tabViewSalaries[i].observed == salarie ) {
var vSalarie = this.tabViewSalaries[i];
viewBodyPlanning.childNodes.salaries.body.removeChild_(vSalarie);
/*viewBodyPlanning.childNodes.salaries.body.removeChild(vSalarie.semaineType);*/
var position = this.tabViewSalaries.remove(vSalarie);
viewPlanning.body.setHeight(70+this.tabViewSalaries.length*19);
viewPlanning.childNodes.body.body.setHeight(this.tabViewSalaries.length*19+1);
this.body.setHeight(this.tabViewSalaries.length*19+1);
viewGrillePlanning.remLigne(position);
i--;
}
else { //On met à jour la position de la vue courante
this.tabViewSalaries[i].setTop(i*19);
}
}
}
viewGrillePlanning.init = function() {
this.calendar = new LCalendar(0, 31, 20, controller.getDateInitialePlanning());
this.body.appendChild_(this.calendar.doom);
this.addLigne = function(salarie) {
this.calendar.addLigne(salarie);
this.body.setHeight(viewBodyPlanning.childNodes.salaries.tabViewSalaries.length*19+1);
}
this.remLigne = function(position) {
this.calendar.remLigne(position);
this.body.setHeight(viewBodyPlanning.childNodes.salaries.tabViewSalaries.length*19+1);
}
}
viewPlanning.tabLigneSalarie = new Array();
mainView = {
body: document.body,
childNodes: {
error: new LDivElement( '', 'fond hidden', 50, '1px solid #000', '', '', '', '4px', 0, 0, 500, 600, ''),
popup: viewPopUp,
curseur: new LDivElement( '', 'hidden', 50, '0px solid #000', '', '', '', '0px', 0, 0, 14, 14, ''),
paveGauche: new LDivElement( '', 'white', 10, '', '0px 1px 0px 0px', 'solid solid solid solid', '#000 #FF8200 #000 #000', '0px', 0, 0, mybro.getWindowHeight(), Math.max( (mybro.getWindowWidth()-786)/2, 0), ''),
titre: viewTitre,
content: {
body: new LDivElement( '', 'white', 10, '', '1px 1px 0px 1px', 'solid solid solid solid', '#FF8200 #FF8200 #000 #FF8200', '0px', 66, (mybro.getWindowWidth()-782)/2, mybro.getWindowHeight() - 66, 762, ''),
childNodes: {
messoldes: viewMesSoldes,
aide: viewAideAccueil,
planning: viewPlanning,
msgnav: mybro.getMessageNav()
}
},
paveDroit: new LDivElement( '', 'white auto', 10, '', '0px 0px 0px 1px', 'solid solid solid solid', '#000 #000 #000 #FF8200', '0px', 0, (mybro.getWindowWidth()+746)/2, mybro.getWindowHeight(), Math.max((mybro.getWindowWidth()-786)/2+19, 0), '<div style="height: 0px; width: 100%;" />')
}
}
var viewAide = viewAideAccueil;
var viewAideModule = 'accueil';
var viewAideAttribut = 'default';
mainView.childNodes.curseur.setBackground('url('+GLO_IMG_REP+GLO_IMG_CUR+') 0px 0px no-repeat');
mainView.childNodes.paveDroit.onscroll = function(e) {
viewGrillePlanning.body.setTop(-this.scrollTop);
viewBodyPlanning.childNodes.salaries.body.setTop(-this.scrollTop);
}
function processNode(node, parentNode) {
if ( node.typeOf == 'LDivElement' ) {
parentNode.appendChild_(node);
}
else { //Sinon, c'est un objet contenant un noeud principal et un ensemble de noeuds enfants
parentNode.appendChild_(node.body);
node.childNodes.each( function(childNode, i) {
processNode(childNode, node.body);
});
}
}
mainView.childNodes.content.childNodes.msgnav.style.top = 'auto';
mainView.childNodes.content.childNodes.msgnav.style.bottom = 0+'px';
mainView.childNodes.content.childNodes.msgnav.style.visibility = 'visible';
function retourServer(view_) {
var view = view_;
this.setView = function(view_) {
view = view_;
}
this.display = function(texte, auto) {
view.setInnerHTML(texte.substring(0, 20));
Effect.show.call(view);
if ( auto ) {
Util.delay( function() {
this.hide();
}.bind(this), 500, 'msgServerTimer');
}
}
this.hide = function() {
view.hide();
view.setInnerHTML('');
}
}
mainController = function() {
Controller.call(this);
/*this.getNbComptes = function() {
return this.comptesController.tabComptes.length;
}*/
/*this.getNumeroCompte = function(value) {
return this.getTabComptes()[value].numero;
}*/
this.dateInitialePlanning = new LDate();
Observable.call(this.dateInitialePlanning);
this.getDateInitialePlanning = function() {
return this.dateInitialePlanning;
}
this.dateFinalePlanning = new LDate(this.dateInitialePlanning.toFullString());
this.dateFinalePlanning.addJours(GLO_NB_JOURS-1);
Observable.call(this.dateFinalePlanning);
this.getDateFinalePlanning = function() {
return this.dateFinalePlanning;
}
this.dateInitialeSoldes = Date.today; //Elle ne change pas pendant toute la session
Observable.call(this.dateInitialeSoldes);
this.getDateInitialeSoldes = function() {
return this.dateInitialeSoldes;
}
this.getDateFinaleSoldes = function() {
return ( salariesController.getActiveSalarie().getDateFinaleSoldes() > this.getDateFinalePlanning() ) ? salariesController.getActiveSalarie().getDateFinaleSoldes() : this.getDateFinalePlanning();
}
this.getDateDebutSoldes = function() {
return ( this.dateInitialeSoldes > this.dateInitialePlanning ) ? this.dateInitialePlanning : this.dateInitialeSoldes;
}
this.getDateFinSoldes = function() {
return this.dateFinalePlanning;
}
this.addJoursPlanning = function(value) {
this.dateInitialePlanning.addJours(value);
this.dateFinalePlanning.addJours(value);
this.dateInitialePlanning.notifyObservers();
this.dateFinalePlanning.notifyObservers();
}
/*this.getActiveSalarie = function() {
return this.salariesController.getActiveSalarie();
}*/
/*if(LOC_INIT == 0)
this.connexion();*/
this.resetBornesConges = function() {
planningController.dateInitialeConges = new LDate(this.dateInitialePlanning.toFullString());
planningController.dateFinaleConges = new LDate(this.dateFinalePlanning.toFullString());
planningController.dateInitialeConges.addJours(-GLO_NB_JOURS);
planningController.dateFinaleConges.addJours(GLO_NB_JOURS);
salariesController.resetConges();
}
this.addViewSalarie = function(salarie) {
viewBodyPlanning.childNodes.salaries.addViewSalarie(salarie);
this.setHeightPaveDroit();
}
this.setHeightPaveDroit = function() {
mainView.childNodes.paveDroit.firstChild.style.height = ( 120 + Math.max(comptesController.getNbComptes()*20,140) + 60 + salariesController.getNbSalariesPresents()*20 ) + 'px';
}
/*this.connexion = function(){
controller.inscriptionController.doom.show();
this.pool.newHttpRequest(this.inscriptionController, 'init', 'GET', null, true, 'server.asp?obj=user&req=getAllUsers&intService='+LOC_ID_SERVICE, 'HTML', 0);
}*/
this.showLabel = function(text) {
viewTitre.childNodes.label.setInnerHTML(text);
viewTitre.childNodes.label.setOpacity(1);
Effect.show.call(viewTitre.childNodes.label);
setTimeout(function() {
Effect.fadeTo.call(viewTitre.childNodes.label, 0, 500, true);
}, 1500);
}
this.displayError = function(text) {
mainView.childNodes.error.setInnerHTML('<a nohref onclick="Effect.hide.call(mainView.childNodes.error);">Fermer</a><br><br>'+text+'<br><br><a nohref onclick="Effect.hide.call(mainView.childNodes.error);">Fermer</a>');
Effect.show.call(mainView.childNodes.error);
}
}
var planningController = new planningController();
var aideController = new aideController();
var comptesController = new comptesController();
var salariesController = new salariesController();
var congesController = new congesController();
var mesSoldesController = new mesSoldesController();
var adminController = new adminController();
var pc = planningController;
var controller = new mainController();
viewEntetePlanning.init();
viewGrillePlanning.init();
aideController.start();
viewTitres.observes(controller.getDateDebutSoldes());
viewTitres.observes(controller.getDateFinaleSoldes());
viewMesSoldes.childNodes.salarie.observes(salariesController.getActiveSalarie());
/*------------------------Construction graphique---------------------*/
mainView.childNodes.each( function(childNode, i) {
processNode(childNode, mainView.body);
});
document.body.removeChild($('div_load'));
mainView.body.style.backgroundColor = '#FFC000';
/*------------------------Construction logique---------------------*/
setTimeout(function() {
controller.resetBornesConges();
salariesController.loadSalaries();
}, 0);
window.onresize = function() {
mainView.childNodes.paveGauche.setHeight(mybro.getWindowHeight());
mainView.childNodes.paveDroit.setHeight(mybro.getWindowHeight());
mainView.childNodes.content.body.setHeight(mybro.getWindowHeight()-66);
mainView.childNodes.paveGauche.setWidth(Math.max( (mybro.getWindowWidth()-786)/2, 0));
mainView.childNodes.paveDroit.setWidth(Math.max( (mybro.getWindowWidth()-786)/2+19, 0));
viewTitre.body.setLeft((mybro.getWindowWidth()-782)/2);
mainView.childNodes.content.body.setLeft((mybro.getWindowWidth()-782)/2);
mainView.childNodes.paveDroit.setLeft((mybro.getWindowWidth()+746)/2);
viewAdmin.childNodes.content.setHeight(mybro.getWindowHeight() - 280);
viewAdmin.childNodes.aide.body.setTop(mybro.getWindowHeight() - 226);
viewAdmin.body.setHeight(Math.max(0,mybro.getWindowHeight()-2-96));
if ( viewTitre.childNodes.btnAdmin.down ) {
viewTitre.body.setHeight(mybro.getWindowHeight()-2);
mainView.childNodes.content.body.setTop(mybro.getWindowHeight());
}
}
window.token = 1;
