actmeasure.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. Doo::loadModel('measure');
  3. /**
  4. * Description of Users
  5. *
  6. * @author zongheng
  7. */
  8. class actMeasure
  9. {
  10. private $__mmeasure;
  11. function __construct()
  12. {
  13. $this->__mmeasure = new Measure();
  14. }
  15. public function insertMeasure($uid, $pid, $stid, $pmname)
  16. {
  17. if (!isset($uid))
  18. return FALSE;
  19. $this->__mmeasure->uid = filter_var($uid, FILTER_VALIDATE_INT);
  20. $this->__mmeasure->pid = filter_var($pid, FILTER_VALIDATE_INT);
  21. $this->__mmeasure->stid = filter_var($stid, FILTER_VALIDATE_INT);
  22. $this->__mmeasure->pmname = filter_var($pmname, FILTER_SANITIZE_STRING);
  23. $this->__mmeasure->intime = time();
  24. return $this->__mmeasure->insert();
  25. }
  26. public function getAllbyStid($stid)
  27. {
  28. if (!$stid)
  29. return FALSE;
  30. return $this->__mmeasure->find(array('where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  31. }
  32. public function getRowUser($uid)
  33. {
  34. return $this->__mmeasure->find(array('where' => 'uid=?', 'param' => array($uid), 'asArray' => TRUE));
  35. }
  36. public function getRowUser2($uid)
  37. {
  38. return $this->__mmeasure->find(array('where' => 'uid=?', 'param' => array($uid), 'asc' => 'convert(pmname using gbk)', 'asArray' => TRUE));
  39. }
  40. public function getGroupProject($uid)
  41. {
  42. return $this->__mmeasure->find(array('where' => 'uid=?', 'param' => array($uid), 'groupby' => 'pid', 'asArray' => TRUE));
  43. }
  44. public function getRowUserStid($uid)
  45. {
  46. return $this->__mmeasure->find(array('where' => 'uid=?', 'param' => array($uid), 'groupby' => 'stid', 'asArray' => TRUE));
  47. }
  48. public function getPmidRow($uid)
  49. {
  50. return $this->__mmeasure->find(array('where' => 'uid=?', 'param' => array($uid), 'asArray' => TRUE));
  51. }
  52. public function getRowBy($stid)
  53. {
  54. if (!$stid)
  55. return FALSE;
  56. return $this->__mmeasure->find(array('where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  57. }
  58. public function getRowByPmid($pmid)
  59. {
  60. if (!$pmid)
  61. return FALSE;
  62. return $this->__mmeasure->getOne(array('where' => 'pmid=?', 'param' => array($pmid), 'asArray' => TRUE));
  63. }
  64. public function getRowByPids($pid)
  65. {
  66. if (!$pid)
  67. return FALSE;
  68. return $this->__mmeasure->find(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  69. }
  70. public function getRowByPid($pid)
  71. {
  72. if (!$pid)
  73. return FALSE;
  74. return $this->__mmeasure->getOne(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  75. }
  76. public function getRowsByPid($pid)
  77. {
  78. if (!$pid)
  79. return FALSE;
  80. return $this->__mmeasure->find(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  81. }
  82. public function getCountByUid($uid, $pid)
  83. {
  84. if (!$uid)
  85. return FALSE;
  86. return $this->__mmeasure->count(array('where' => 'uid=? and pid=?', 'param' => array($uid, $pid), 'asArray' => TRUE));
  87. }
  88. public function getMearsureCount($pid)
  89. {
  90. return $this->__mmeasure->count(array('where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE));
  91. }
  92. public function getTotalWithPid($pid)
  93. {
  94. if (!$pid)
  95. return FALSE;
  96. return $this->__mmeasure->getOne(array('select' => 'sum(contracttotal) as total', 'where' => 'pid=?', 'param' => array($pid), 'asArray' => TRUE))['total'];
  97. }
  98. public function getRowWithUidGroupByPid($uid)
  99. {
  100. return $this->__mmeasure->find(array('select' => 'pid', 'where' => 'uid=?', 'param' => array($uid), 'groupby' => 'pid', 'asArray' => TRUE));
  101. }
  102. public function updateCon($pmid, $con)
  103. {
  104. $this->__mmeasure->contracttotal = $con;
  105. return $this->__mmeasure->update(array('where' => 'pmid=?', 'param' => array($pmid)));
  106. }
  107. public function getTotal($stid)
  108. {
  109. if (!$stid)
  110. return FALSE;
  111. return $this->__mmeasure->getOne(array('select' => 'sum(contracttotal) as total', 'where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  112. }
  113. public function getCountMeasure($stid)
  114. {
  115. return $this->__mmeasure->count(array('where' => 'stid=?', 'param' => array($stid)));
  116. }
  117. public function getAll()
  118. {
  119. return $this->__mmeasure->find(array('asArray' => TRUE));
  120. }
  121. public function getRowPmid($pmid)
  122. {
  123. return $this->__mmeasure->find(array('where' => 'pmid=?', 'param' => array($pmid), 'asArray' => TRUE));
  124. }
  125. public function getAllbyStidSum($stid)
  126. {
  127. if (!$stid)
  128. return FALSE;
  129. return $this->__mmeasure->find(array('select' => 'sum(contracttotal) as contracttotal', 'where' => 'stid=?', 'param' => array($stid), 'asArray' => TRUE));
  130. }
  131. public function updateName($pmid, $pmname)
  132. {
  133. $this->__mmeasure->pmname = $pmname;
  134. return $this->__mmeasure->update(array('where' => 'pmid=?', 'param' => array($pmid)));
  135. }
  136. public function getCountPmid($pmid)
  137. {
  138. return $this->__mmeasure->count(array('where' => 'pmid=?', 'param' => array($pmid)));
  139. }
  140. public function del($pmid)
  141. {
  142. return $this->__mmeasure->delete(array('where' => 'pmid=?', 'param' => array($pmid)));
  143. }
  144. public function updateChangeDecimalNum($pmid,$dnum)
  145. {
  146. $this->__mmeasure->pmid = $pmid;
  147. $this->__mmeasure->cdecimalnum = $dnum;
  148. return $this->__mmeasure->update();
  149. }
  150. }