Setelah login saya selalu ingin melihat daftar pekerjaan yang masih 'pending' untuk itu saya selalu memanggil function settodo untuk mempersiapkan list yang harus di kerjakan.
Begini saya buatnya.
di buat di todos_controller.php
function settodo(){
$this->layout = 'blank';
App::import('Model', 'Project');
$tmpProject = new Project();
$this->set('entry',$tmpProject->findAll("valuation_date = '0000-00-00'",array('id','engagement_code')));
App::import('Model', 'Todo');
$tmpTodo = new Todo();
// erase all the list.
$tmpTodo->query('delete from todos');
arch project without valuation date
$entry=$tmpProject->findAll("valuation_date = '0000-00-00'",array('id','engagement_code'),null,null) ;
foreach ($entry as $e){
$tmpTodo->save(array('id' => '', 'notes'=> 'Project '.$e['Project']['engagement_code'].' has no valuation date', 'url' => '/projects/view/'.$e['Project']['id'],'role_id'=>'3'));
}
arch projects without leaders
$entry=$tmpProject->findAll("leader_id = '1'",array('id','engagement_code'),null,null);
foreach ($entry as $e){
$tmpTodo->save(array('id' => '', 'notes'=> 'Project '.$e['Project']['engagement_code'].' has no leaders assigned', 'url' => '/projects/view/'.$e['Project']['id']));
}
arch projects without piccalc
$entry=$tmpProject->findAll("leader_id <> '1' and piccalc_id = '1'",array('id','engagement_code'),null,null);
foreach ($entry as $e){
$tmpTodo->save(array('id' => '', 'notes'=> 'Project '.$e['Project']['engagement_code'].' has no p.i.c of calculation assigned', 'url' => '/projects/view/'.$e['Project']['id']));
}
arch projects without picprop
$entry=$tmpProject->findAll("leader_id <> '1' and picprop_id = '1'",array('id','engagement_code'),null,null);
foreach ($entry as $e){
$tmpTodo->save(array('id' => '', 'notes'=> 'Project '.$e['Project']['engagement_code'].' has no p.i.c of proposal assigned', 'url' => '/projects/view/'.$e['Project']['id']));
}
arch projects without proposed fee
$entry=$tmpProject->findAll("proposed_fee = 0",array('id','engagement_code'),null,null);
foreach ($entry as $e){
$tmpTodo->save(array('id' => '', 'notes'=> 'Project '.$e['Project']['engagement_code'].' dont have proposed fee', 'url' => '/projects/view/'.$e['Project']['id']));
}
unset($tmpProject);
unset($tmpTodo);
$this->redirect(array('action'=>'index'));
}
0 komentar:
Posting Komentar