HolidayController.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class HolidayController extends DooController {
  6. public $staff;
  7. public static $NEW = 0;
  8. public static $NEW2 = 0;
  9. function __construct() {
  10. if(isset($_COOKIE["staff"])){
  11. if(!empty($_COOKIE["staff"])){
  12. Doo::loadModel ( 'staff' );
  13. $staff = new staff ();
  14. $this->staff=$staff->getUserByIdList($_COOKIE["staff"]);
  15. self::$NEW= $this->getReceiptCount();
  16. self::$NEW2= $this->getExeCount();
  17. include './protected/controller/ReceiptController.php';
  18. ReceiptController::$NEW=self::$NEW;
  19. ReceiptController::$NEW2=self::$NEW2;
  20. return "/";
  21. }
  22. }
  23. Doo::loadCore ( 'uri/DooUriRouter' );
  24. $router = new DooUriRouter ();
  25. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  26. if($routeRs['1']!="login"){
  27. header ( 'Content-Type:text/html;charset=utf-8' );
  28. @header ( "Location: /login" );
  29. }
  30. }
  31. public function myList(){
  32. $data ['memu'] = 'holiday';
  33. $data ['holidaymenu'] = 'mylist';
  34. $data ['staff'] = $this->staff;
  35. $this->render ( "/holiday-myList", $data );
  36. }
  37. private function getReceiptCount(){
  38. $status=2;
  39. $year=date('Y');
  40. Doo::loadModel('receipt');
  41. $receipt=new receipt();
  42. $dateCondition=" and Year(date) =".$year;
  43. $approvalCondition=' and nowStaff like "%'.$this->staff[0]['sid'].'%" ';
  44. $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  45. return count($receiptList);
  46. }
  47. private function getExeCount(){
  48. Doo::loadModel('receipt');
  49. $receipt=new receipt();
  50. $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  51. return count($receiptList);
  52. }
  53. }
  54. ?>