Last active
August 29, 2015 14:22
-
-
Save makamo/f995a9b5c8a93aca35b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public function generate() | |
{ | |
//Generation des paies | |
if ($this->request->is(array('post', 'put'))) { | |
$paies = $this->request->data; | |
foreach ($paies as $key => $paie) { | |
$paie = $this->Paies->get($paie['id']); | |
$periodeDate = Periode::getStartAndEndDate($paie->week, $paie->year); | |
// Trouver les rapports journaliers pour le contrat choisi, la foreuse choisie et entre les dates sélectionnées | |
$employee_rjs = TableRegistry::get('employees_rjs'); | |
/** @var \App\Model\Table\EmployeesRjsTable $employee_rjs */ | |
$rjQuery = $employee_rjs->find("listEmployeeTravail", $periodeDate)->select(['id']); | |
$employeesRjsIds = $rjQuery->extract('id')->toArray(); | |
$tasksRjsQuery = TableRegistry::get('TasksRjs')->find(); | |
$tasksRjsQuery->matching('EmployeesRjs', function ($q) use ($employeesRjsIds) { | |
return $q->where(['EmployeesRjs.id IN' => $employeesRjsIds]); | |
}); | |
foreach ($tasksRjsQuery as $tache) { | |
$paie_heure['paie_heures'][]= [ | |
'date' => $tache->rapport_journalier->date->toDateString(), | |
'equipement_id'=> $tache->rapport_journalier->foreuse->equipement_id, | |
'qte '=> $tache->qte, | |
'type '=> $tache->type, | |
'fonction_id'=> $tache->fonction_id, | |
'task_id'=> $tache->task_id | |
]; | |
$this->Paies->patchEntity($paie,$paie_heure,[ | |
'associated' => ['Paies.PaieHeures'] | |
]); | |
debug($paie); | |
if($this->Paies->save($paie, [ | |
'associated' => [ | |
'PaieAutres', | |
'PaieHeures', | |
] | |
])){ | |
$this->Flash->success("Tous les paies sont générer"); | |
}else{ | |
$this->Flash->error("Tous les paies sont générer"); | |
} | |
// die(); | |
} | |
} | |
// $this->Flash->success("Tous les paies sont générer"); | |
//return $this->redirect(Router::url(['_name' => 'paieList', $paie->week, $paie->year])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this to check for validation errors: