compteur d'un jour donné
327493
private Counter getDayCounterAtDate(Date day) {
		final Counter dayCounter = createDayCounterAtDate(day);
		try {
			dayCounter.readFromFile();
		} catch (final IOException e) {
			// lecture échouée, tant pis
			// (on n'interrompt pas tout un rapport juste pour un des fichiers illisible)
			LOG.info("read of a counter file failed: " + dayCounter.getName(), e);
		}
		return dayCounter;
	}
435530
public function ajouter()
    {
        $authentifie = new archiAuthentification();
        $formulaire = new formGenerator();
        if ($authentifie->estConnecte()) {
            $tabForm=$this->getAdresseFields();
            $this->connexionBdd->getLock(array('historiqueAdresse'));
            $errors = $formulaire->getArrayFromPost($tabForm); // recupere les donnees POST suivant les champs de tabForm , tabForm est passé en référence, il contient donc les valeurs des champs a la sortie de la fonction
            $this->nettoieCoordonneesAdresse($tabForm); // permet de garder l'id de la rue, quartier, sousQuartier le plus bas dans la hierarchie , a partir duquel on peut retrouver le reste

            if (count($errors)==0) {
            // on regarde si l'adresse existe deja parmis les adresses valides (non "archivees")
                $sql = "SELECT ha1.idAdresse as idAdresse
						FROM historiqueAdresse ha1, historiqueAdresse ha2
						WHERE ha2.idAdresse = ha1.idAdresse
						AND ha1.idRue='".$tabForm['rue']['value']."'
								AND ha1.idSousQuartier='".$tabForm['sousQuartier']['value']."'
										AND ha1.idQuartier='".$tabForm['quartier']['value']."'
												AND ha1.idVille='".$tabForm['ville']['value']."'
														AND ha1.idPays='".$tabForm['pays']['value']."'
																AND ha1.numero = '".$tabForm['numero']['value']."'
																		AND ha1.date='".$tabForm['date']['value']."'
																				AND ha1.idIndicatif='".$tabForm['indicatif']['value']."'
																						GROUP BY ha1.idAdresse, ha1.idHistoriqueAdresse
																						HAVING ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse)";

                //debug($sql);

                $resCheckExist=$this->connexionBdd->requete($sql);

                if (mysql_num_rows($resCheckExist)>1) {
                    echo "plusieurs adresse existe concernant cette adresse, pas d'ajout, veuillez prevenir l'administrateur.<br>";
                } elseif (mysql_num_rows($resCheckExist)==1) {
                    echo "l'adresse existe deja dans la base";
                    // recuperation de l'id existant
                    $fetchAdresseExistante=mysql_fetch_array($resCheckExist);
                } else {
                    // ajout
                    // recherche du nouvel idAdresse
                    $resIdAdresse = $this->connexionBdd->requete("select max(idAdresse) as maxIdAdresse from historiqueAdresse");
                    $nouvelIdAdresse=0;
                    if (mysql_num_rows($resIdAdresse)>0) {
                        $fetchNouvelIdAdresse = mysql_fetch_array($resIdAdresse);
                        $nouvelIdAdresse = $fetchNouvelIdAdresse["maxIdAdresse"] + 1;
                    }

                    $sql = "INSERT INTO historiqueAdresse (idUtilisateur,idAdresse,date,description,nom,idRue,numero,idQuartier,idSousQuartier,idPays,idVille) VALUES (
							'".$authentifie->getIdUtilisateur()."',
							'".$nouvelIdAdresse."',
							\"".$this->date->toBdd($tabForm['date']['value'])."\",
							\"".$tabForm['description']['value']."\",
							\"".$tabForm['nom']['value']."\",
							'".$tabForm['rue']['value']."',
							'".$tabForm['numero']['value']."',
							'".$tabForm['quartier']['value']."',
							'".$tabForm['sousQuartier']['value']."',
							'".$tabForm['pays']['value']."',
							'".$tabForm['ville']['value']."'
							)";

                    $this->connexionBdd->requete($sql);

                    $cache = new cacheObject();
                    $cache->refreshCache();
                }
            } else {
                echo $this->afficheFormulaire($tabForm);
            }




            $this->connexionBdd->freeLock(array('historiqueAdresse'));
        } else {
            echo "erreur : Vous devez etre authentifié pour faire un ajout<br>";
        }
    }
1098513
static function ajouter_argument_balise($element, $p) {

		// Toujours un parametre 0 vide s'il n'existe pas.
		if (!isset($p->param[0][0])) {
			if (!isset($p->param[0])) {
				$p->param[0] = array();
			}
			$p->param[0][0] = '';
		}

		$zero = array_shift($p->param[0]);
		array_unshift($p->param[0], $element);
		array_unshift($p->param[0], $zero);

		return $p;
	}
956912
public function bootDatatable($route = '/datatable/{token}')
    {

        // gestion de la navifgation Ajax
        Route::get($route, function($token) {

            try{
                $request = request();

                // chargement de l'objet
                $table = FrenchFrogs\Table\Table\Table::load($token);

                // configuration de la navigation
                $table->setItemsPerPage(Input::get('length'));
                $table->setPageFromItemsOffset(Input::get('start'));
                $table->setRenderer(new FrenchFrogs\Table\Renderer\Remote());

                // gestion des reccherches
                foreach(request()->get('columns') as $c) {
                    if ($c['searchable'] == "true" && $c['search']['value'] != '') {
                        $table->getColumn($c['name'])->getStrainer()->call($table, $c['search']['value']);
                    }
                }

                // gestion de la recherche globale
                $search = $request->get('search');
                if (!empty($search['value']) ) {
                    $table->search($search['value']);
                }

                // gestion du tri
                $order = $request->get('order');
                if (!empty($order)) {

                    if ($table->isSourceQueryBuilder()) {
                        $table->getSource()->orders = [];
                    }

                    foreach($order as $o) {
                        extract($o);
                        $table->getColumnByIndex($column)->order($dir);
                    }
                }

                // recuperation des données
                $data = [];
                foreach($table->render() as $row){
                    $data[] = array_values($row);
                }

                return response()->json(['data' => $data, 'draw' => Input::get('draw'), 'recordsFiltered' => $table->getItemsTotal(), 'recordsTotal' => $table->getItemsTotal()]);

            }catch (\Exception $e) {
                //Si on catch une erreur on renvoi une reponse json avec le code 500
                return response()->json(['error' => $e->getMessage()],500);
            }

        })->name('datatable');


        /**
         * Gestion de l'export CSV
         */
        Route::get($route . '/export', function($token) {
            $table = FrenchFrogs\Table\Table\Table::load($token);
            $table->setItemsPerPage(5000);
            $table->toCsv();
        })->name('datatable-export');


        /**
         * Gestion de l'edition en remote
         *
         */
        Route::post($route, function($token) {
            $request = request();
            $table = FrenchFrogs\Table\Table\Table::load($token);
            return $table->getColumn($request->get('column'))->remoteProcess($request->get('id'), $request->get('value'));
        });

    }
709837
public function set_joursferies($year)
    {
        $this->joursferies = [];
        $this->joursferies["${year}0101"] = true;
        $this->joursferies["${year}0501"] = true;
        $this->joursferies["${year}0508"] = true;
        $this->joursferies["${year}0714"] = true;
        $this->joursferies["${year}0815"] = true;
        $this->joursferies["${year}1101"] = true;
        $this->joursferies["${year}1111"] = true;
        $this->joursferies["${year}1225"] = true;
        
        //Timestamp du dimanche de paques
        $this->ts_easter = self::get_easter_date($year);
        
        //Lundi de paques
        $ts_feriers = $this->ts_easter + 1 * self::$TIME2SEC['d'];
        $aaaammdd_ferie = date('Ymd', $ts_feriers);
        $this->joursferies["$aaaammdd_ferie"] = true;
        
        //Jeudi de l'Ascension
        $ts_feriers = $this->ts_easter + 39 * self::$TIME2SEC['d'];
        $aaaammdd_ferie = date('Ymd', $ts_feriers);
        $this->joursferies["$aaaammdd_ferie"] = true;
        
        //Lundi de Pentecote
        $ts_feriers = $this->ts_easter + 50 * self::$TIME2SEC['d'];
        $aaaammdd_ferie = date('Ymd', $ts_feriers);
        $this->joursferies["$aaaammdd_ferie"] = true;
        
        return $this;
    }
605053
function Menu(arg,opt) {
        
        if ($.isPlainObject(arg) || Array.isArray(arg)) { opt = arg; arg = null; }
        
        /**
         * Conteneur du menu contextuel
         */
        if (!arg) arg = document.createElement('ul');
        
        if (arg) this.container = $(arg)[0];
        /**
         * Tableau d'objets MenuItem définissant la liste des éléments du menu
         */
        this.list = [];
        /**
         * Liste des séparateurs d'éléments
         */
        this.dividers = [];
        
        this.keyboardCtrls = new KeyboardCtrls(this);
        
        if (opt) this.set(opt); 
    }
1183453
public function getActiveSliderPages()
    {
        $em = $this->serviceLocator->get('doctrine.entitymanager.orm_default');
        $today = new \DateTime("now");
        //$today->format('Y-m-d H:i:s');
        $today = $today->format('Y-m-d') . ' 23:59:59';

        // Page active with a startDate before today (or without startDate)
        // and closeDate after today (or without closeDate)
        $query = $em->createQuery(
            'SELECT p FROM PlaygroundCms\Entity\Page p
                WHERE (p.publicationDate <= :date OR p.publicationDate IS NULL)
                AND (p.closeDate >= :date OR p.closeDate IS NULL)
                AND p.active = 1 AND p.pushHome = true
                ORDER BY p.publicationDate DESC'
        );
        $query->setParameter('date', $today);
        $pages = $query->getResult();

        // Je les classe par date de publication (date comme clé dans le tableau afin de pouvoir merger les objets
        // de type article avec le même procédé en les classant naturellement par date asc ou desc
        $arrayPages = array();
        foreach ($pages as $page) {
            if ($page->getPublicationDate()) {
                $key = $page->getPublicationDate()->format('Ymd');
                $key .= $page->getUpdatedAt()->format('Ymd').'-'.$page->getId();
            } else {
                $key = $page->getUpdatedAt()->format('Ymd');
                $key .= $page->getUpdatedAt()->format('Ymd').'-'.$page->getId();
            }

            $arrayPages[$key] = $page;
        }

        return $arrayPages;
    }
1222995
public function activation($token,$newsletter_id)
    {
        // Activate the email on the website
        $user = $this->subscription->activate($token);

        if(!$user)
        {
            alert()->danger('Le jeton ne correspond pas ou à expiré');

            return redirect('/');
        }

        $newsletter = $this->newsletter->find($newsletter_id);

        if(!$newsletter)
        {
            alert()->danger('Cette newsletter n\'existe pas');

            return redirect('/');
        }

        //Subscribe to mailjet
        $this->worker->setList($newsletter->list_id);
        $result = $this->worker->subscribeEmailToList($user->email);

        if(!$result){

            alert()->danger('Problème');

            return redirect('/');
        }

        alert()->success('Vous êtes maintenant abonné à la newsletter');

        return redirect('/');
    }
395751
def weekday_tomorrow(self, date_from=None, date_format=None):
		
		# date de demain que sur les jours de semaine
		return self.delta(days=1, date_from=date_from, date_format=date_format, days_range=[1, 2, 3, 4, 5])
515228
def weekend_tomorrow(self, date_from=None, date_format=None):
		
		# date de demain que sur les jours de week-end
		return self.delta(days=1, date_from=date_from, date_format=date_format, days_range=[6, 7])
289025
function task () {
  run = true;
  var item = messages.shift();
  if (!item) {
    run = false;

  // 書き込み
  } else if ('message' in item) {
    if (output_) {
      write(item);
    } else {
      task();
    }

  // パスの変更
  } else if (item.path) {
    p_ = path.resolve(p_, item.path);
    task();

  // 出力のコントロール
  } else if ('output' in item) {
    output_ = item.output;
    task();

  } else {
    task();
  }
}
1050446
public static void main(String[] args) {
		log("starting");

		// jnlp prefix to fix:
		// http://stackoverflow.com/questions/19400725/with-java-update-7-45-the-system-properties-no-more-set-from-jnlp-tag-property
		// https://bugs.openjdk.java.net/browse/JDK-8023821
		for (final Object property : Collections.list(System.getProperties().keys())) {
			final String name = String.valueOf(property);
			if (name.startsWith(JnlpPage.JNLP_PREFIX)) {
				final String value = System.getProperty(name);
				System.setProperty(name.substring(JnlpPage.JNLP_PREFIX.length()), value);
			}
		}

		initLookAndFeel();
		// une touche bleu-clair pour avoir une teinte moins grisatre
		UIManager.put("control", new Color(225, 225, 250));

		ShadowPopupFactory.install();
		MSwingUtilities.initEscapeClosesDialogs();
		// on définit le répertoire courant, car par exemple dans JavaWebStart il n'est pas bon par défaut
		System.setProperty("user.dir", System.getProperty("user.home"));

		Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
			@Override
			public void uncaughtException(Thread t, Throwable e) {
				MSwingUtilities.showException(e);
			}
		});

		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				try {
					// affichage de la frame dans le thread AWT
					showFrame();
				} catch (final Throwable t) { // NOPMD
					MSwingUtilities.showException(t);
					exit();
				}
			}
		});
	}
208531
public function init()
    {
        if ( $this->lat0 == 0 ) {
            $this->lat0 = 90; //$this->lat0 ca
        }

        /* Place parameters in static storage for common use
          ------------------------------------------------- */
        $this->temp = $this->b / $this->a;
        $this->es = 1.0 - pow( $this->temp, 2 ); // devait etre dans tmerc.js mais n y est pas donc je commente sinon retour de valeurs nulles 
        $this->e = sqrt( $this->es );
        $this->e0 = Common::e0fn( $this->es );
        $this->e1 = Common::e1fn( $this->es );
        $this->e2 = Common::e2fn( $this->es );
        $this->e3 = Common::e3fn( $this->es );
        $this->ml0 = Common::mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 ); //si que des zeros le calcul ne se fait pas
        //if (!$this->ml0) {$this->ml0=0;}
    }
1364681
private Path<?> buildPropertyPathForAnyType(Root<T> root, String stringPath) {
		
		// Si la racine est nulle
		if(root == null) return null;
		
		// Si la chaine est vide
		if(stringPath == null || stringPath.trim().length() == 0) return null;
		
		// Le Path à retournet
		Path<?> path = null;
		
		// On splitte sur le séparateur de champs
		String[] hierarchicalPaths = stringPath.trim().split("\\.");
		
		// Obtention du premier chemin
		path = root.get(hierarchicalPaths[0]);
		
		// Si la taille est > 1
		if(hierarchicalPaths.length > 1) {

			// Parcours
			for (int i = 1; i < hierarchicalPaths.length; i++) {
				
				// Le chemin
				String unitPath = hierarchicalPaths[i];
				
				// Si le path est vide ou est une suite d'espace
				if(unitPath == null || unitPath.trim().length() == 0) continue;
				
				// Acces à la ppt
				path = path.get(unitPath.trim());
			}
		}
		
		// On retourne le Path
		return path;
	}
259726
public function afficher($id)
    {
        $html = '';
        $formulaire = new formGenerator();
        if ($formulaire->estChiffre($id) == 1) {
            $sql = 'SELECT p.nom as nom, p.prenom as prenom,  m.nom as metier,  p.idPersonne as idPersonne,  p.dateNaissance as dateNaissance,  p.dateDeces as dateDeces,  p.description as description
                    FROM personne p
                    LEFT JOIN metier m ON m.idMetier = p.idMetier
                    WHERE p.idPersonne='.$id.' LIMIT 1';
            $rep = $this->connexionBdd->requete($sql);
            if (mysql_num_rows($rep) == 1) {
                $res = mysql_fetch_object($rep);

                $t = new Template('modules/archi/templates/');
                $t->set_filenames((array('pe'=>'personne.tpl')));

                $e = new archiEvenement();

                $t->assign_vars(
                    array(
                        'prenom' => $res->prenom,
                        'nom'    => $res->nom,
                        'metier' => $res->metier,
                        'dateNaissance'=> $this->date->toFrench($res->dateNaissance),
                        'dateDeces'    => $this->date->toFrench($res->dateDeces),
                        'description'  => $res->description,
                        'urlAjout'     => $this->creerUrl('ajouterPersonne'),
                        'evenementLies'=> $e->afficherListe(array( 'selection' => 'personne',  'id' => $res->idPersonne))
                    )
                );

                ob_start();
                $t->pparse('pe');
                $html .= ob_get_contents();
                ob_end_clean();
            } else {
                $html .= 'ERREUR aucun résultat !';
            }
        } else {
            $html .= 'ERREUR mauvais ID!';
        }
        return $html;
    }
1222699
function BoxScrollCtrl($window, $document, $interval, $timeout, $scope, boxesScrollServices) {
		var ctrl = this;
		ctrl.reItems;
		ctrl.ngelt; // le composant lui meme
		ctrl.elt; // le composant lui meme
		ctrl.infos = null;

		ctrl.removeEventListeners = removeEventListeners; // gestion des events
		ctrl.addEventListeners = addEventListeners; // gestion des events
		ctrl.updateInfos = updateInfos; // met a jours les infos 
		ctrl.updateTotal = updateTotal;
		ctrl.updateLimit = updateLimit;
		ctrl.updateBegin = updateBegin;
		ctrl.updateSize = updateSize;
		ctrl.getInnerLimit = getInnerLimit;
		ctrl.getEltArea = getEltArea;
		ctrl.getScrollbarArea = getScrollbarArea;

		/**
		 * Retourne la limit pour les calcul interne, cad le nombre d'items vraiment visible
		 * @returns {Number|type.ngLimit|boxesscrollL#1.BoxScrollCtrl.$scope.ngLimit}
		 */
		function getInnerLimit() {
			var items = getItems();
			var notInDeck = 0;
			if (items.length) {
				do {
					notInDeck = notInDeck + 1;
					var cont = false;
					var item = items[items.length - notInDeck];
					if (item) {
						var area = getArea(item);
						if (ctrl.horizontal) {
							cont = area.right > getEltArea().right;
						} else {
							cont = area.bottom > getEltArea().bottom;
						}
						if (!cont) {
							notInDeck--;
						}
					}
				} while (cont);
			} else {
				notInDeck = 1;
			}
			var fix = ($scope.ngLimit - items.length) + notInDeck;
			return $scope.max ? $scope.ngLimit : $scope.ngLimit - fix;
		}
		var hasFocus = false;
		/**
		 * Ajoute et Supprime tous les handlers
		 */
		function addEventListeners() {
			ctrl.ngelt.on('wheel', wheelOnElt);
			ctrl.ngelt.on('computegrabbersizes', ctrl.updateSize);
//			ctrl.elt.addEventListener("wheel", function (event) {
//				boxesScrollServices.execAndApplyIfScrollable($scope, this, wheel, [event]);
//			}, {passive: true, capture: true});
			ctrl.ngsb.on("mouseout", mouseoutOnSb);
			ctrl.ngsb.on("mousedown", mousedownOnSb); // sur le mousedown, si dans le grabber, on init le mode drag, sinon on inc/dec les pages tant que l'on est appuyé
			ctrl.ngsb.on("mouseup", mouseup);  // on stop l'inc/dec des pages
			ctrl.ngsb.on("click", boxesScrollServices.stopEvent); // desactive la propagation entre autrepour eviter la fermeture des popup
			ctrl.ngelt.on("mousemove", mousemoveOnElt); // on définit la couleur du grabber
			if (!ctrl.ngelt.css('display') !== 'none') { // si c'est une popup, le resize de l'ecran ne joue pas
				ng.element($window).on("resize", updateSize);
			}
			$document.on("mousedown", mousedownOnDoc);
			$document.on("keydown", keydownOnOnDoc);
			$document.on("scroll", invalidSizes);
		}
		function removeEventListeners() {
			ctrl.ngelt.off('wheel', wheelOnElt);
			ctrl.ngelt.off('computegrabbersizes', ctrl.updateSize);
			ctrl.ngsb.off("mouseout", mouseoutOnSb);
			ctrl.ngsb.off("mousedown", mousedownOnSb);
			ctrl.ngsb.off("mouseup", mouseup);
			ctrl.ngsb.off("click", boxesScrollServices.stopEvent);
			ctrl.ngelt.off("mousemove", mousemoveOnElt);
			ng.element($window).off("resize", updateSize);
			$document.off("mousedown", mousedownOnDoc);
			$document.off("keydown", keydownOnOnDoc);
			$document.off("scroll", invalidSizes);
		}
		function invalidSizes(event) {
			ctrl.getScrollbarArea().invalid = true;
			ctrl.getEltArea().invalid = true;
		}
		function keydownOnOnDoc(event) {
			if (!$scope.allowKeynav || !hasFocus || event.which < 33 || event.which > 40)
				return;
			boxesScrollServices.execAndApplyIfScrollable($scope, this, keydown, [event]);
		};
		function mousedownOnDoc(event) {
			hasFocus = ctrl.elt.contains(event.target);
		}
		function mousemoveOnElt(event) {
			boxesScrollServices.execAndApplyIfScrollable($scope, this, mousemove, [event]);
		}
		function mousedownOnSb(event) {
			hasFocus = true;
			boxesScrollServices.execAndApplyIfScrollable($scope, this, mousedown, [event]);
		}
		function mouseoutOnSb(event) {
			if (!isDragMode()) {
				hideScrollbar(SHOWSB_TIMEOUT);
			}
		}
		function wheelOnElt(event) {
			boxesScrollServices.execAndApplyIfScrollable($scope, this, wheel, [event]);
		}
		/**
		 * begin, limit ou total on changés
		 */
		var infosTimer;
		function updateInfos() {
			if (infosTimer) {
				$timeout.cancel(infosTimer);
			}
			ctrl.infos = null;
			if (!isNaN($scope.ngBegin) && !isNaN($scope.ngLimit) && !isNaN($scope.total) && $scope.total > 1) {
				var from = $scope.total ? $scope.ngBegin + 1 : 0;
				var to = $scope.ngBegin + boxesScrollServices.minXmax(0, ctrl.getInnerLimit(), $scope.total);
				ctrl.infos = "[" + from + "-" + to + "]/" + $scope.total;
				infosTimer = $timeout(function (c) {
					c.infos = null;
				}, $scope.showInfoDelay || 1000, true, ctrl);
			}
		}
		/**
		 * Le nombre d'items a changé
		 * On repositionne le grabber en 0
		 * Si pas d'items, grabber = 100%
		 * Sinon on set limit a 1, ce qui va lancer le processus updateLimit->adjustLimit
		 */
		function updateTotal() {
			$scope.ngBegin = 0;
			moveGrabber(getGrabberOffsetPercentFromBegin($scope.ngBegin));
			adjustLimit();
			updateGrabberSizes();
			updateInfos();
		}
		/**
		 * La limit a ete mis a jour
		 */
		function updateLimit() {
			moveGrabber(getGrabberOffsetPercentFromBegin($scope.ngBegin));
			adjustLimit();
			updateGrabberSizes();
			updateInfos();
		}
		/**
		 * begin a ete mis a jour
		 */
		function updateBegin() {
			moveGrabber(getGrabberOffsetPercentFromBegin($scope.ngBegin));
			adjustLimit();
//			updateGrabberSizes();
			updateInfos();
		}
		/**
		 * La fenetre a ete redimentionn�
		 */
		var resizeTimer = null;
		function updateSize() {
			if (resizeTimer) {
				$timeout.cancel(resizeTimer);
			}
			if ($scope.ngLimit > 2) {
				resizeTimer = $timeout(function (s) {
					adjustLimit();
					updateGrabberSizes();
				}, 200, true, $scope);
			} else {
				adjustLimit();
				updateGrabberSizes();
			}
		}
		/**
		 * Gere les differents rendus de la scrollbar.
		 * Si on passe au dessus du trigger
		 * Mousemove(!drag) and mouseup
		 * @param {type} event
		 * @returns {undefined}
		 */
		function manageScrollbarRender(event) {
			if (modeTimer) {
				$timeout.cancel(modeTimer);
			}
			var m = boxesScrollServices.getMousePosition(event);
			if (isTriggerOver(m)) { // la souris est au dessus du declencheur
				showScrollbar();
			}
			if (isScrollbarVisible()) {
				if (isScrollbarOver(m)) { // la souris est au dessus de la scrollbar
					showScrollbar();
					if (compareGrabberAndMousePosition(m) === 0) { // la souris est au dessus du curseur
						showScrollbar('hover');
					}
				} else {
					hideScrollbar(SHOWSB_TIMEOUT);
				}
			}
		}
		/**
		 * Gere la navigation clavier
		 * @param {type} event
		 */
		function keydown(event) {
			var inc = 0;
			if (ctrl.horizontal) {
				if (event.which === 37) { // LEFT
					inc = -1;
				} else if (event.which === 39) { // RIGHT
					inc = 1;
				}
			} else {
				var innerLimit = ctrl.getInnerLimit();
				if (event.which === 38) { // UP
					inc = -1;
				} else if (event.which === 40) { // DOWN
					inc = 1;
				} else if (event.which === 33) { // PAGEUP
					inc = -innerLimit;
				} else if (event.which === 34) { // PAGEDOWN
					inc = innerLimit;
				} else if (event.which === 35) { // END
					inc = $scope.total - $scope.ngBegin - innerLimit;
				} else if (event.which === 36) { // HOME
					inc = -$scope.ngBegin;
				}
			}
			if (inc !== 0) {
				boxesScrollServices.stopEvent(event);
				$scope.ngBegin = $scope.ngBegin + inc;
			}
		}
		/**
		 * la souris bouge au dessus de la scrollbar
		 * @param {jqEvent} event
		 */
		function mousemove(event) {
			if (!isDragMode()) {
				manageScrollbarRender(event);
			}
		}
		var downData = {timer: null, scope: null, inc: 0, end: 0};
		var offsetMouse;
		function mousedown(event) {
			var m = boxesScrollServices.getMousePosition(event);
			boxesScrollServices.stopEvent(event);
			var pos = compareGrabberAndMousePosition(m);
			if (!isNaN(pos)) { // dans la scrollbar
				if (pos === 0) { // on a click sur le curseur passage en mode drag
					offsetMouse = getOffsetMouseFromGrabber(m);
					showScrollbar('drag');
					document.addEventListener('mousemove', dragHandler, false);
					document.addEventListener("mouseup", endDrag, false);
				} else {
					var innerLimit = ctrl.getInnerLimit();
					$scope.ngBegin = $scope.ngBegin + (innerLimit * pos); // next or previous page
					downData.scope = $scope;
					downData.inc = pos; // vaut 1 ou -1
					downData.end = getBeginFromPercent(getGrabberOffsetPercentFromMousePosition(m, 0));
					if (pos < 0) {
						downData.end -= innerLimit;
					}
					downData.timer = $interval(function (data) {
						var next = data.scope.ngBegin + (innerLimit * data.inc); // next or previous page;
						if (next * data.inc > data.end * data.inc) {
							$interval.cancel(data.timer);
							return;
						}
						data.scope.ngBegin = next;
					}, 300, 0, true, downData);
				}
			}
		}
		function mouseup(event) {
			if (downData.timer) {
				$interval.cancel(downData.timer);
			}
		}
		function endDrag(event) {
			offsetMouse = 0;
			document.removeEventListener('mousemove', dragHandler);
			document.removeEventListener('mouseup', endDrag);
			boxesScrollServices.execAndApplyIfScrollable($scope, this, manageScrollbarRender, [event]); // 
		}
		function dragHandler(event) {
			boxesScrollServices.stopEvent(event);
			var m = boxesScrollServices.getMousePosition(event);
			var percent = getGrabberOffsetPercentFromMousePosition(m, offsetMouse);
			var begin = getBeginFromPercent(percent);
			if (begin <= $scope.total - ctrl.getInnerLimit()) {
				$scope.ngBegin = begin;
			}
		}
		var wheelData = {timer: null, begin: null};
		function wheel(event) {
			boxesScrollServices.stopEvent(event);
			hideScrollbar();
			wheelData.begin = manageWheelHandler(event, wheelData.begin || $scope.ngBegin);
//			moveGrabber(getGrabberOffsetPercentFromBegin(wheelData.begin));
//			if (!wheelData.timer) {
//				$scope.ngBegin = wheelData.begin;
//				wheelData.timer = $timeout(function (scope, data) {
//					scope.ngBegin = data.begin;
//					data.timer = null;
//					data.begin = null;
//				}, 60, true, $scope, wheelData);
//			}
			$scope.ngBegin = wheelData.begin;
			wheelData.begin = null;
		}
		function manageWheelHandler(event, begin) {
			var evt = event.originalEvent || event;
			return boxesScrollServices.minXmax(0, begin + ((evt.deltaY < 0) ? -SCROLLBY : SCROLLBY), $scope.total - ctrl.getInnerLimit());
		}
		function getGrabberOffsetPercentFromBegin(begin) {
			return begin * 100 / $scope.total;
		}
		function getGrabberOffsetPercentFromMousePosition(m, offset) {
			var grabberOffsetPercent;
			var rect = getTriggerArea();
			var grabberOffsetPixel;
			var onePercent;
			if (ctrl.horizontal) {
				onePercent = rect.width / 100;
				grabberOffsetPixel = m.x - rect.left - offset;
			} else {
				onePercent = rect.height / 100;
				grabberOffsetPixel = m.y - rect.top - offset;
			}
			grabberOffsetPercent = grabberOffsetPixel / onePercent;
			return boxesScrollServices.minXmax(0, grabberOffsetPercent, 100 - getGrabberSizePercentFromScopeValues());
		}
		/**
		 * Est on en mode drag&drop
		 */
		function isDragMode() {
			return ctrl.ngsb.attr('mode') === 'drag';
		}
		function isScrollbarVisible() {
			return ctrl.ngsb.attr('mode') !== 'hidden';
		}
		function showScrollbar(mode) {
			ctrl.ngsb.attr('mode', mode || null);
		}
		var modeTimer;
		function hideScrollbar(defer) {
			if (isScrollbarVisible()) {
				if (modeTimer) {
					$timeout.cancel(modeTimer);
				}
				if (defer) {
					ctrl.ngsb.attr('mode', null);
					modeTimer = $timeout(function () {
						ctrl.ngsb.attr('mode', 'hidden');
					}, defer);
				} else {
					ctrl.ngsb.attr('mode', 'hidden');
				}
			}
		}
		/**
		 * La souris est elle au dessus de la scrollbar
		 * @param {MouseCoordonates} m
		 * @returns {Boolean}
		 */
		function isScrollbarOver(m) {
			return document.elementFromPoint(m.x, m.y) === ctrl.sb;
		}
		/**
		 * 
		 * @param {MouseCoordonates} m
		 * @returns {Boolean}
		 */
		function isTriggerOver(m) {
			var result = false;
			if (document.elementFromPoint(m.x, m.y) === ctrl.elt) {
				if (ctrl.horizontal) {
					result = m.y >= getTriggerArea().top; // on est au dessus de la scrollbar trigger
				} else {
					result = m.x >= getTriggerArea().left; // on est au dessus de la scrollbar trigger
				}
			}
			return result;
		}
		/**
		 * La souris est elle avant le grabber (-1), apres le grabber (1) sur le grabber (0), pas au dessus NaN
		 * @param {type} m
		 * @returns {Number}
		 */
		function compareGrabberAndMousePosition(m) {
			if (isScrollbarOver(m)) {
				if (ctrl.horizontal) {
					var start = getScrollbarArea().left + getGrabberOffsetPixelFromPercent(getGrabberOffsetPercentFromBegin($scope.ngBegin));
					if (m.x < start)
						return -1;
					var end = start + getGrabberSizePixelFromPercent(getGrabberSizePercentFromScopeValues());
					if (m.x > end)
						return 1;
					if (m.x >= start && m.x <= end)
						return 0;
				} else {
					var start = getScrollbarArea().top + getGrabberOffsetPixelFromPercent(getGrabberOffsetPercentFromBegin($scope.ngBegin));
					if (m.y < start)
						return -1;
					var end = start + getGrabberSizePixelFromPercent(getGrabberSizePercentFromScopeValues());
					if (m.y > end)
						return 1;
					if (m.y >= start && m.y <= end)
						return 0;
				}
			}
			return Number.NaN;
		}
		function getOffsetMouseFromGrabber(m) {
			var result = 0;
			if (ctrl.horizontal) {
				var start = getTriggerArea().left + getGrabberOffsetPixelFromPercent(getGrabberOffsetPercentFromBegin($scope.ngBegin));
				result = m.x - start;
			} else {
				var start = getTriggerArea().top + getGrabberOffsetPixelFromPercent(getGrabberOffsetPercentFromBegin($scope.ngBegin));
				result = m.y - start;
			}
			return result;
		}
		function adjustLimit() {
			var items = getItems(); // il y en a au moins un
			computeDirectionIfNeeded(items);
			if ($scope.max) {
				$scope.ngLimit = $scope.max;
			} else if ($scope.total) {
				var nbItems = items.length;
				if (nbItems) {
					var firstItem = items[0];
					var lastItem = items[nbItems - 1];
					var containerSize = ctrl.horizontal ?
							  getArea(lastItem).right - getArea(firstItem).left :
							  getArea(lastItem).bottom - getArea(firstItem).top;
					var offset = getOffsetPixelContainerBeforeItem(firstItem); // on ignore les éléments avant
					var empty = getHeightArea() - offset - containerSize; // zone non remplie
					var inc = 0;
					var average = containerSize / nbItems;
					if (average) { // protect div par 0
						var floatValue = empty / average;
						inc = floatValue < 0 ? Math.ceil(floatValue) : Math.ceil(floatValue); // on veut en voir une de plus
						if (inc === floatValue) { // on tombe pile poil, on rajoute un, pour tjs avoir un de plus
							inc++;
						}
					}
					var max = $scope.total - $scope.ngBegin;
					if (inc !== -1) { // si un depasse on laisse
						var newLimit = boxesScrollServices.minXmax(1, $scope.ngLimit + inc, max + 1);
						if (newLimit !== $scope.ngLimit) {
							$scope.ngLimit = newLimit;
						}
					}
				}
			}
		}
		function computeDirectionIfNeeded(items) {
			if (ctrl.ngelt.is('box-scroll') || ctrl.ngelt.attr('box-scroll') !== undefined) {
				if (!ctrl.ngelt.hasClass('vertical') && !ctrl.ngelt.hasClass('horizontal') && items.length) {
					var inlineDisplays = ['table-cell'];
					var display = ng.element(items[0]).css('display');
					ctrl.ngelt.removeClass('horizontal');
					ctrl.ngelt.removeClass('vertical');
					var inlineElt = display.indexOf('inline') !== -1;
					if (inlineElt || inlineDisplays.indexOf(display) !== -1) {
						if (inlineElt) {
							ctrl.ngelt.css('display', 'flex');
						}
						ctrl.ngelt.addClass('horizontal');
						ctrl.horizontal = true;
					} else {
						ctrl.ngelt.addClass('vertical');
						ctrl.horizontal = false;
					}
				}
			}
		}
		function getItems() {
			var items = ctrl.ngelt.find("[ng-repeat]");
			var result = [];
			items.each(function (idx, item) {
				var ngRepeat = ng.element(item).attr('ng-repeat');
				if (ngRepeat.match(ctrl.reItems)) {
					result.push(item);
				}
			});
			return result;
		}
		/**
		 * Calcul la taille des grabbers 
		 */
		function updateGrabberSizes() {
			if (ctrl.horizontal !== undefined) {
				var bgSizeElt = ctrl.ngelt.css('background-size');
				var bgSizeSb = ctrl.ngsb.css('background-size');

				var grabbersizePixel = '100%';
				if(getInnerLimit() !== $scope.total) {
					grabbersizePixel = getGrabberSizePixelFromPercent(getGrabberSizePercentFromScopeValues())+'px';
				}

				if (ctrl.horizontal) {
					bgSizeElt = bgSizeElt.replace(/.*\s+/, grabbersizePixel + ' ');
					bgSizeSb = bgSizeSb.replace(/.*\s+/, grabbersizePixel + ' ');
				} else {
					bgSizeElt = bgSizeElt.replace(/px\s+\d+(\.\d+)*.*/, 'px ' + grabbersizePixel);
					bgSizeSb = bgSizeSb.replace(/px\s+\d+(\.\d+)*.*/, 'px ' + grabbersizePixel);
				}
				ctrl.ngelt.css({'background-size': bgSizeElt});
				ctrl.ngsb.css({'background-size': bgSizeSb});
			}
		}
		/**
		 * Corrige et déplace le curseur
		 * @param {number} percent
		 */
		function moveGrabber(percent) {
			var offset = 0;
			if (percent && $scope.total) {
				var grabberSizePercent = getGrabberSizePercentFromScopeValues();
				var grabberOffsetPercent = boxesScrollServices.minXmax(0, percent, 100 - grabberSizePercent);
				offset = getGrabberOffsetPixelFromPercent(grabberOffsetPercent);
				var grabberSize = getGrabberSizePixelFromPercent(grabberSizePercent);
				if (offset >= getHeightArea() - grabberSize) {
					offset = getHeightArea() - grabberSize;
				}
			}
			if (ctrl.horizontal) {
				ctrl.ngelt.css({'background-position': offset + 'px bottom'});
				ctrl.ngsb.css({'background-position': offset + 'px bottom'});
			} else {
				ctrl.ngelt.css({'background-position': 'right ' + offset + 'px'});
				ctrl.ngsb.css({'background-position': 'right ' + offset + 'px'});
			}
		}
		/**
		 * Calcul ngBegin à partir de la position du curseur
		 * @param {number} percent : la position en % du curseur, son offset
		 */
		function getBeginFromPercent(percent) {
			return Math.round(percent * $scope.total / 100);
		}
		/**
		 * Calcul la position du curseur en px
		 * @param {type} percentOffset
		 * @returns {Number}
		 */
		function getGrabberOffsetPixelFromPercent(percentOffset) {
			var sbLenght = getHeightArea(); // Longueur de la scrollbar
			var grabberOffsetPixel = sbLenght * percentOffset / 100;
			return Math.max(grabberOffsetPixel, 0);
		}
		/**
		 * Retourne la taille en pourcent du grabber en fonction de ngLimit et total
		 * @returns {Number}
		 */
		function getGrabberSizePercentFromScopeValues() {
			if ($scope.total) {
				return Math.min((($scope.max || ctrl.getInnerLimit()) / $scope.total) * 100, 100);
			}
			return 100;
		}
		/**
		 * Calcul la hauteur du grabber
		 * @param {type} percentSize
		 * @returns {Number}
		 */
		function getGrabberSizePixelFromPercent(percentSize) {
			return Math.max(getHeightArea() * percentSize / 100, GRABBERMIN);
		}
		/**
		 * Retourne l'offset en pixel avant l'item
		 * Typiquement la taille du header dans un tableau 
		 * @param {HtmlElement} item
		 * @returns {number}
		 */
		function getOffsetPixelContainerBeforeItem(item) {
			if (ctrl.horizontal) {
				return getArea(item).left - getEltArea().left;
			} else {
				return getArea(item).top - getEltArea().top;
			}
		}
		/**
		 * Retourne la hauteur utile 
		 * @returns {number}
		 */
		function getHeightArea() {
			return ctrl.horizontal ? getEltArea().width : getEltArea().height;
		}
		/**
		 * Retourne la zone correspondante à l'indicateur de position de la scrollbar, permet aussi de faire apparaitre la scrollbar au survol
		 * @return {Rectangle}
		 */
		var triggerArea = getNullArea();
		function getTriggerArea() {
			if (triggerArea.invalid) {
				var clientRect = ctrl.elt.getClientRects();
				if (clientRect && clientRect.length) {
					var rect = clientRect[0];
					if (rect) {
						// zone de la scrollbar
						var bgSize = ctrl.ngelt.css('background-size');
						if (ctrl.horizontal) {
							var m = bgSize.match(/\D*\d+\D*(\d+)\D*/);
							var s = m.length > 0 ? parseInt(m[1]) : 4;
							triggerArea = {
								left: rect.left, right: rect.right,
								width: rect.width, height: s,
								top: rect.bottom - s, bottom: rect.bottom
							};
						} else {
							var m = bgSize.match(/\D*(\d+)\D*\d+\D*/);
							var s = m.length > 0 ? parseInt(m[1]) : 4;
							triggerArea = {
								left: rect.right - s, right: rect.right,
								width: s, height: rect.height,
								top: rect.top, bottom: rect.bottom
							};
						}
					}
				}
			}
			return triggerArea;
		}
		/**
		 * Retourne la zone correspondante à la scrollbar
		 * @return {Rectangle}
		 */
		var sbArea = getNullArea();
		function getScrollbarArea() {
			if (sbArea.invalid) {
				sbArea = getArea(ctrl.sb, true);
			}
			return sbArea;
		}
		/**
		 * Retourne la zone correspondante à la directive
		 * @return {Rectangle}
		 */
		var eltArea = getNullArea();
		function getEltArea() {
			if (eltArea.invalid) {
				eltArea = getArea(ctrl.elt, true);
			}
			return eltArea;
		}
		/**
		 * Retourne la zone correspondante à l'element html en argument
		 * @param {HTMLElement} elt
		 * @param {boolean} validation
		 * @return {Rectangle}
		 */
		function getArea(elt, validation) {
			var clientRect = elt.getClientRects();
			if (clientRect && clientRect.length) {
				var rect = clientRect[0];
				if (rect) {
					rect.invalid = validation && !isElementInViewport(rect);
					return rect;
				}
			}
			return getNullArea();
		}
		function isElementInViewport(rect) {
			if (ctrl.horizontal) {
				return rect.left >= 0 && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
			} else {
				return rect.top >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight);
			}
		}
		/**
		 * Retourne un rectangle de valeurs 0
		 * @return {Rectangle}
		 */
		function getNullArea() {
			return {left: 0, right: 0, width: 0, height: 0, top: 0, bottom: 0, invalid: true};
		}
	}
150507
public function on($first, $comp = '=', $second = null)
    {
        if (is_null($this->join)) {
            throw new QueryBuilderException(
                'La clause intérieure rejoindre est dèja initialisé.',
                E_ERROR
            );
        }

        if (!$this->isComporaisonOperator($comp)) {
            $second = $comp;
        }

        if (count(explode('.', $first)) == 2) {
            $first = $this->getPrefix().$first;
        }

        if (count(explode('.', $second)) == 2) {
            $second = $this->getPrefix().$second;
        }

        if (!preg_match('/on/i', $this->join)) {
            $this->join .= ' on `' . $first . '` ' . $comp . ' `' . $second . '`';
        } else {
            $this->join .= ' and `' . $first . '` ' . $comp . ' `' . $second . '`';
        }

        return $this;
    }