actmeasure.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. Doo::loadModel('measure');
  3. /**
  4. * Description of Users
  5. *
  6. * @author zongheng
  7. */
  8. class actMeasure {
  9. private $__mmeasure;
  10. function __construct() {
  11. $this->__mmeasure = new Measure();
  12. }
  13. public function insertMeasure($uid, $pid, $stid, $pmname) {
  14. if (!isset($uid))
  15. return FALSE;
  16. $this->__mmeasure->uid = filter_var($uid, FILTER_VALIDATE_INT);
  17. $this->__mmeasure->pid = filter_var($pid, FILTER_VALIDATE_INT);
  18. $this->__mmeasure->stid = filter_var($stid, FILTER_VALIDATE_INT);
  19. $this->__mmeasure->pmname = filter_var($pmname, FILTER_SANITIZE_STRING);
  20. return $this->__mmeasure->insert();
  21. }
  22. public function getAllbyStid($stid) {
  23. if (!$stid)
  24. return FALSE;
  25. return $this->__mmeasure->find(array('where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  26. }
  27. public function getRowUser($uid) {
  28. return $this->__mmeasure->find(array('where' => 'uid=?', 'param' => array($uid), 'asArray' => TRUE));
  29. }
  30. public function getGroupProject($uid) {
  31. return $this->__mmeasure->find(array('where' => 'uid=?', 'param' => array($uid), 'groupby' => 'pid', 'asArray' => TRUE));
  32. }
  33. public function getRowUserStid($uid) {
  34. return $this->__mmeasure->find(array('where' => 'uid=?', 'param' => array($uid), 'groupby' => 'stid', 'asArray' => TRUE));
  35. }
  36. public function getPmidRow($uid) {
  37. return $this->__mmeasure->find(array('where' => 'uid=?', 'param' => array($uid), 'asArray' => TRUE));
  38. }
  39. public function getRowBy($stid) {
  40. if (!$stid)
  41. return FALSE;
  42. return $this->__mmeasure->find(array('where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  43. }
  44. public function getRowByPmid($pmid) {
  45. if (!$pmid)
  46. return FALSE;
  47. return $this->__mmeasure->getOne(array('where' => 'pmid=?', 'param' => array($pmid), 'asArray' => TRUE));
  48. }
  49. public function getRowByPids($pid) {
  50. if (!$pid)
  51. return FALSE;
  52. return $this->__mmeasure->find(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  53. }
  54. public function getRowByPid($pid) {
  55. if (!$pid)
  56. return FALSE;
  57. return $this->__mmeasure->getOne(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  58. }
  59. public function getRowsByPid($pid) {
  60. if (!$pid)
  61. return FALSE;
  62. return $this->__mmeasure->find(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  63. }
  64. public function getCountByUid($uid, $pid) {
  65. if (!$uid)
  66. return FALSE;
  67. return $this->__mmeasure->count(array('where' => 'uid=? and pid=?', 'param' => array($uid, $pid), 'asArray' => TRUE));
  68. }
  69. public function getMearsureCount($pid) {
  70. return $this->__mmeasure->count(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  71. }
  72. public function getTotalWithPid($pid) {
  73. if (!$pid)
  74. return FALSE;
  75. return $this->__mmeasure->getOne(array('select' => 'sum(contracttotal) as total', 'where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE))['total'];
  76. }
  77. public function getRowWithUidGroupByPid($uid) {
  78. return $this->__mmeasure->find(array('select' => 'pid', 'where' => 'uid=?', 'param' => array($uid), 'groupby' => 'pid', 'asArray' => TRUE));
  79. }
  80. public function updateCon($pmid, $con) {
  81. $this->__mmeasure->contracttotal = $con;
  82. return $this->__mmeasure->update(array('where' => 'pmid=?', 'param' => array($pmid)));
  83. }
  84. public function getTotal($stid) {
  85. if (!$stid)
  86. return FALSE;
  87. return $this->__mmeasure->getOne(array('select' => 'sum(contracttotal) as total', 'where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  88. }
  89. public function getCountMeasure($stid) {
  90. return $this->__mmeasure->count(array('where' => 'stid=?', 'param' => array($stid)));
  91. }
  92. public function getAll() {
  93. return $this->__mmeasure->find(array('asArray' => TRUE));
  94. }
  95. public function getRowPmid($pmid) {
  96. return $this->__mmeasure->find(array('where' => 'pmid=?', 'param' => array($pmid), 'asArray' => TRUE));
  97. }
  98. public function getAllbyStidSum($stid) {
  99. if (!$stid)
  100. return FALSE;
  101. return $this->__mmeasure->find(array('select' => 'sum(contracttotal) as contracttotal', 'where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  102. }
  103. public function updateName($pmid, $pmname) {
  104. $this->__mmeasure->pmname = $pmname;
  105. return $this->__mmeasure->update(array('where' => 'pmid=?', 'param' => array($pmid)));
  106. }
  107. }