Created
February 6, 2015 11:53
-
-
Save makamo/96b8dec40905e3736e85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Table; | |
use Core\Table\Table; | |
class EmployeeTable extends Table{ | |
protected $table = "TAB_Employe"; | |
private $validForeur = ["Runner","Runner/Seul","Runner/Foreman"]; | |
private $validHelper = ["Helper","Helper 2nd"]; | |
private $validForeman = ["Foreman"]; | |
private $validSuperviseur = ["Surintendant"]; | |
/** | |
* @param $id | |
* @return \App\Entity\EmployeeEntity | |
*/ | |
public function find($id){ | |
return $this->query("SELECT * FROM ". $this->table." WHERE Ref_Employe =".$id ,null, true); | |
} | |
/** | |
* Trouve tout les employee qui on travaillé sur un meme équipement durant la meme période de temps | |
* @param $equipements | |
* @param $start | |
* @param $end | |
* @param $quart | |
* @return array | |
*/ | |
public function findByEquipement($equipements,$start,$end,$quart){ | |
return $this->query("SELECT Ref_Employe ,EM_Nom ,EM_Prenom ,FC_Fonction FROM REQ_Nbheure".$quart." WHERE Ref_Equipement=".$equipements." AND RJ_Date>=#".$start."# AND RJ_Date<=#".$end."# GROUP BY Ref_Employe ,EM_Nom ,EM_Prenom ,FC_Fonction; | |
"); | |
} | |
/** | |
*Trouve tout les employee qui on travailler sur un meme contrat durant la meme période de temps | |
* @param $contrat | |
* @param $start | |
* @param $end | |
* @param $quart | |
* @return array | |
*/ | |
public function findByRapport($contrat,$start,$end,$quart){ | |
$query = $this->query("SELECT Ref_Employe ,EM_Nom ,EM_Prenom ,FC_Fonction FROM REQ_Nbheure" . $quart . " WHERE Ref_Contrat=" . $contrat . " AND RJ_Date>=#" . $start . "# AND RJ_Date<=#" . $end . "# GROUP BY Ref_Employe ,EM_Nom ,EM_Prenom ,FC_Fonction; | |
"); | |
//var_dump($query); | |
return $query; | |
} | |
/** | |
* Trouve tout les foreures | |
* @param $equipements | |
* @param $start | |
* @param $end | |
* @param $quart | |
* @return array | |
*/ | |
public function getForeureByEquipement($equipements,$start,$end,$quart){ | |
$foreures = []; | |
foreach($this->findByEquipement($equipements,$start,$end,$quart) as $employe){ | |
if(in_array($employe->fonction,$this->validForeur)){ | |
array_push($foreures,$employe); | |
} | |
} | |
return $foreures; | |
} | |
/** | |
* Trouve tout les helpers | |
* @param $equipements | |
* @param $start | |
* @param $end | |
* @param $quart | |
* @return array | |
*/ | |
public function getHelperByEquipement($equipements,$start,$end,$quart){ | |
$helpers=[]; | |
foreach($this->findByEquipement($equipements,$start,$end,$quart) as $employe){ | |
if(in_array($employe->fonction,$this->validHelper)){ | |
$helpers[] = $employe; | |
} | |
} | |
return $helpers; | |
} | |
/** | |
* Trouve tout les Superviseurs | |
* @param $contrat | |
* @param $start | |
* @param $end | |
* @param $quart | |
* @return array | |
*/ | |
public function getSuperviseurByContrat($contrat,$start,$end,$quart){ | |
$byRapport = $this->findByRapport($contrat, $start, $end, $quart); | |
var_dump("line 96",$byRapport); | |
foreach($byRapport as $employe){ | |
if(in_array($employe->fonction,$this->validSuperviseur)){ | |
break; | |
} | |
} | |
return $employe; | |
} | |
/** | |
* Trouve tout les foremans | |
* @param $contrat | |
* @param $start | |
* @param $end | |
* @param $quart | |
* @return array | |
*/ | |
public function getForemanByContrat($contrat,$start,$end,$quart){ | |
$foreman=[]; | |
$byRapport = $this->findByRapport($contrat, $start, $end, $quart); | |
var_dump("line 115",$byRapport); | |
foreach($byRapport as $employe){ | |
if(in_array($employe->fonction,$this->validForeman)){ | |
$foreman[] = $employe; | |
} | |
} | |
return $foreman; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment