Subversion Repositories eFlore/Applications.del

Rev

Rev 2031 | Rev 2035 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2031 Rev 2033
Line 113... Line 113...
113
		if (isset($this->requete['where']['OR_SOUS_REQUETE']) && count($this->requete['where']['OR_SOUS_REQUETE']) > 0) {
113
		if (isset($this->requete['where']['OR_SOUS_REQUETE']) && count($this->requete['where']['OR_SOUS_REQUETE']) > 0) {
114
			$clauseWhereSousRequete = implode(' OR ', $this->requete['where']['OR_SOUS_REQUETE']);
114
			$clauseWhereSousRequete = implode(' OR ', $this->requete['where']['OR_SOUS_REQUETE']);
115
			$sousRequete = 'di.ce_observation IN '.
115
			$sousRequete = 'di.ce_observation IN '.
116
				"(SELECT id_observation FROM del_observation AS do WHERE $clauseWhereSousRequete ) ";
116
				"(SELECT id_observation FROM del_observation AS do WHERE $clauseWhereSousRequete ) ";
117
			$this->requete['where']['OR'][] = "( $sousRequete )";
117
			$this->requete['where']['OR'][] = "( $sousRequete )";
118
			unset($this->requete['join']['LEFT JOIN del_observation AS do ON (di.ce_observation = do.id_observation) ']);
118
			unset($this->requete['join'][$this->getSqlJointureObs()]);
119
		}
119
		}
Line 120... Line 120...
120
 
120
 
121
		if (isset($this->requete['where']['OR']) && count($this->requete['where']['OR']) > 0) {
121
		if (isset($this->requete['where']['OR']) && count($this->requete['where']['OR']) > 0) {
122
			$this->requete['where']['AND'][] = '('.implode(' OR ', $this->requete['where']['OR']).')';
122
			$this->requete['where']['AND'][] = '('.implode(' OR ', $this->requete['where']['OR']).')';
Line 380... Line 380...
380
		}
380
		}
381
	}
381
	}
Line 382... Line 382...
382
	
382
	
383
	private function ajouterJoinObsSiNecessaire() {
383
	private function ajouterJoinObsSiNecessaire() {
384
			if ($this->etreAppliImg()) {
384
			if ($this->etreAppliImg()) {
385
				$this->addJoin('INNER JOIN del_observation AS do ON (di.ce_observation = do.id_observation) ');
385
				$this->addJoin($this->getSqlJointureObs());
386
			}
386
			}
-
 
387
	}
-
 
388
	
-
 
389
	private function getSqlJointureObs() {
-
 
390
		return 'INNER JOIN del_observation AS do ON (di.ce_observation = do.id_observation) ';
Line 387... Line 391...
387
	}
391
	}
388
 
392
 
389
	public function ajouterConstrainteAppliObs() {
393
	public function ajouterConstrainteAppliObs() {
390
		$this->ajouterContrainteTagCel();
394
		$this->ajouterContrainteTagCel();
Line 461... Line 465...
461
							'AND do.nom_sel_nn IS NOT NULL'.
465
							'AND do.nom_sel_nn IS NOT NULL'.
462
						') '	
466
						') '	
463
					);
467
					);
464
			}	
468
			}	
Line 465... Line 469...
465
 
469
 
466
			if ($this->etreAppliImg()) {
-
 
467
				$this->addJoin('LEFT JOIN del_observation AS do ON (di.ce_observation = do.id_observation) ');
-
 
468
			}
470
			$this->ajouterJoinObsSiNecessaire();
469
		}
471
		}
Line 470... Line 472...
470
	}
472
	}
471
	
473
	
Line 494... Line 496...
494
		if (isset($this->parametres['masque.milieu'])) {
496
		if (isset($this->parametres['masque.milieu'])) {
495
			$milieu = $this->parametres['masque.milieu'];
497
			$milieu = $this->parametres['masque.milieu'];
496
			$milieuMotif = $this->bdd->proteger("%$milieu%");
498
			$milieuMotif = $this->bdd->proteger("%$milieu%");
497
			$this->addWhere('masque.milieu', "do.milieu LIKE $milieuMotif");
499
			$this->addWhere('masque.milieu', "do.milieu LIKE $milieuMotif");
Line 498... Line 500...
498
 
500
 
499
			if ($this->etreAppliImg()) {
-
 
500
				$this->addJoin('LEFT JOIN del_observation AS do ON (di.ce_observation = do.id_observation) ');
-
 
501
			}
501
			$this->ajouterJoinObsSiNecessaire();
502
		}
502
		}
Line 503... Line 503...
503
	}
503
	}
504
 
504
 
Line 555... Line 555...
555
 
555
 
556
				if ($this->etreAppliObs()) {
556
				if ($this->etreAppliObs()) {
557
					$this->addJoin('LEFT JOIN del_image AS di ON (di.ce_observation = do.id_observation) ');
557
					$this->addJoin('LEFT JOIN del_image AS di ON (di.ce_observation = do.id_observation) ');
558
				}
558
				}
559
			}
559
			}
560
			if ($this->etreAppliImg()) {
-
 
561
				$this->addJoin('LEFT JOIN del_observation AS do ON (di.ce_observation = do.id_observation) ');
-
 
562
			}
560
			$this->ajouterJoinObsSiNecessaire();
563
		}
561
		}
Line 564... Line 562...
564
	}
562
	}
565
 
563
 
Line 577... Line 575...
577
						'WHERE actif = 1 '.
575
						'WHERE actif = 1 '.
578
						'GROUP BY ce_image '.
576
						'GROUP BY ce_image '.
579
						"HAVING GROUP_CONCAT(DISTINCT tag_normalise ORDER BY tag_normalise) REGEXP $tagsMotif ";
577
						"HAVING GROUP_CONCAT(DISTINCT tag_normalise ORDER BY tag_normalise) REGEXP $tagsMotif ";
580
				}
578
				}
581
			} else {
579
			} else {
582
				// Si un seul tag est demandé il se trouve dans le OR
580
				// Si un seul tag est demandé il se trouve dans le OR dans le cas de la recherche
-
 
581
				// spécifique et dans le AND dans le cas de la recherche générale
-
 
582
				// WTF?
-
 
583
				$tag = "";
-
 
584
				if(isset($this->parametres['masque.tag_del']['OR'][0])) {
583
				$tag = $this->parametres['masque.tag_del']['OR'][0];
585
					$tag = $this->parametres['masque.tag_del']['OR'][0];
-
 
586
				} else if(isset($this->parametres['masque.tag_del']['AND'][0])) {
-
 
587
					$tag = $this->parametres['masque.tag_del']['AND'][0];
-
 
588
				}
-
 
589
				
584
				$sousRequete = 'SELECT ce_image '.
590
				$sousRequete = 'SELECT ce_image '.
585
						'FROM del_image_tag '.
591
						'FROM del_image_tag '.
586
						'WHERE actif = 1 '.
592
						'WHERE actif = 1 '.
587
						'AND tag_normalise LIKE '.$this->bdd->proteger($tag.'%');
593
						'AND tag_normalise LIKE '.$this->bdd->proteger($tag.'%');
588
			}
594
			}