PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/base/widgets/workload/class.php

https://gitlab.com/nexxuz/phpBMS
PHP | 268 lines | 160 code | 69 blank | 39 comment | 19 complexity | 7b448bc4aebedcb58a2c1db9482a3caf MD5 | raw file
  1. <?php
  2. /*
  3. $Rev: 311 $ | $LastChangedBy: brieb $
  4. $LastChangedDate: 2007-10-02 19:51:27 -0600 (Tue, 02 Oct 2007) $
  5. +-------------------------------------------------------------------------+
  6. | Copyright (c) 2004 - 2010, Kreotek LLC |
  7. | All rights reserved. |
  8. +-------------------------------------------------------------------------+
  9. | |
  10. | Redistribution and use in source and binary forms, with or without |
  11. | modification, are permitted provided that the following conditions are |
  12. | met: |
  13. | |
  14. | - Redistributions of source code must retain the above copyright |
  15. | notice, this list of conditions and the following disclaimer. |
  16. | |
  17. | - Redistributions in binary form must reproduce the above copyright |
  18. | notice, this list of conditions and the following disclaimer in the |
  19. | documentation and/or other materials provided with the distribution. |
  20. | |
  21. | - Neither the name of Kreotek LLC nor the names of its contributore may |
  22. | be used to endorse or promote products derived from this software |
  23. | without specific prior written permission. |
  24. | |
  25. | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
  26. | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
  27. | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
  28. | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
  29. | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
  30. | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
  31. | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
  32. | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
  33. | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
  34. | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
  35. | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
  36. | |
  37. +-------------------------------------------------------------------------+
  38. */
  39. class wdgta1aec114954b37c104747d4e851c728c extends widget{
  40. var $uuid ="wdgt:a1aec114-954b-37c1-0474-7d4e851c728c";
  41. var $type = "little";
  42. var $title = "Workload";
  43. var $jsIncludes = array('modules/base/widgets/workload/workload.js');
  44. var $cssIncludes = array('widgets/base/workload.css');
  45. var $phpbms;
  46. var $userid;
  47. var $useruuid;
  48. function displayMiddle(){
  49. global $phpbms;
  50. $this->phpbms = $phpbms;
  51. $this->userid = $_SESSION["userinfo"]["id"];
  52. $this->useruuid = $_SESSION["userinfo"]["uuid"];
  53. $this->showTasks("GivenAssignments");
  54. $this->showTasks("ReceivedAssignments");
  55. }//end function showMiddle
  56. function showTasks($type){
  57. $querystatement="
  58. SELECT
  59. id,
  60. type,
  61. subject,
  62. completed,
  63. if(enddate < CURDATE(),1,0) AS ispastdue,
  64. if(assignedtodate < CURDATE(),1,0) AS ispastassigneddate,
  65. startdate,
  66. enddate,
  67. assignedtodate,
  68. private,
  69. assignedbyid,
  70. assignedtoid,
  71. IF(assignedtodate IS NOT NULL, assignedtodate, IF((enddate IS NOT NULL && type = 'TS'), enddate, IF((startdate IS NOT NULL && type = 'EV'), startdate, CURDATE()))) AS xdate
  72. FROM
  73. notes
  74. WHERE";
  75. switch($type){
  76. case "ReceivedAssignments":
  77. $querystatement.="
  78. ((
  79. assignedtoid = '".$this->useruuid."'
  80. OR (
  81. type = 'TS'
  82. AND (assignedtoid = '' OR assignedtoid IS NULL)
  83. AND createdby = ".$this->userid."
  84. )
  85. )
  86. AND (
  87. completed = 0
  88. OR (
  89. completed = 1
  90. AND completeddate >= CURDATE()
  91. )
  92. )
  93. )";
  94. $title = "Assignments";
  95. $id = "AS";
  96. break;
  97. case "GivenAssignments":
  98. $querystatement.="
  99. (assignedbyid = '".$this->useruuid."'
  100. AND (completed = 0
  101. OR (completed = 1 AND completeddate >= CURDATE())
  102. ))";
  103. $title = "Delegations";
  104. $id = "DG";
  105. break;
  106. }//endswitch
  107. $querystatement.="AND (
  108. (startdate IS NULL AND enddate IS NULL AND assignedtodate IS NULL)
  109. OR (startdate IS NOT NULL AND startdate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY) AND enddate IS NULL AND assignedtodate IS NULL)
  110. OR (enddate IS NOT NULL AND enddate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY))
  111. OR (assignedtodate IS NOT NULL AND assignedtodate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY))
  112. )";
  113. $querystatement.=" ORDER BY
  114. importance DESC,
  115. xdate,
  116. subject";
  117. $queryresult = $this->db->query($querystatement);
  118. $numRows = $this->db->numRows($queryresult);
  119. ?>
  120. <h3 class="tasksLinks"><?php echo $title; if($numRows) {?> <span class="small">(<?php echo $numRows?>)</span><?php } ?></h3>
  121. <div class="tasksDivs">
  122. <div>
  123. <?php if($numRows){
  124. $linkStart = getAddEditFile($this->db,"tbld:a4cdd991-cf0a-916f-1240-49428ea1bdd1");
  125. $section["title"] = "Today";
  126. $section["date"] = mktime(0,0,0,date("m"),date("d"),date("Y"));
  127. while($therecord = $this->db->fetchArray($queryresult)) {
  128. $className="tasks";
  129. if($therecord["completed"])
  130. $className.=" complete";
  131. else if($therecord["ispastdue"] || $therecord["ispastassigneddate"])
  132. $className.=" pastDue";
  133. if($therecord["private"]) $className.=" private";
  134. $className.=" ".$therecord["type"];
  135. $checkBoxID = $id.$therecord["type"]."C".$therecord["id"];
  136. $link = $linkStart."?id=".$therecord["id"]."&amp;backurl=".APP_PATH."modules/base/snapshot.php";
  137. $rightSide = "";
  138. if($therecord["assignedtodate"])
  139. $rightSide .= "FUP: ".formatFromSQLDate($therecord["assignedtodate"])."<br />";
  140. switch($therecord["type"] ){
  141. case "TS":
  142. if($therecord["enddate"])
  143. $rightSide .= "Due: ".formatFromSQLDate($therecord["enddate"])."<br />";
  144. break;
  145. case "EV":
  146. $rightSide .= "Start: ".formatFromSQLDate($therecord["startdate"])."<br />";
  147. $rightSide .= "End: ".formatFromSQLDate($therecord["enddate"])."<br />";
  148. break;
  149. }//endswitch
  150. if(!$rightSide)
  151. $rightSide = "&nbsp;";
  152. $bottomInfo = "";
  153. switch($type){
  154. case "ReceivedAssignments":
  155. if($therecord["assignedbyid"])
  156. $bottomInfo = "Assigned By: ".htmlQuotes($this->phpbms->getUserName($therecord["assignedbyid"], true));
  157. break;
  158. case "GivenAssignments":
  159. $bottomInfo = "Assigned To: ".htmlQuotes($this->phpbms->getUserName($therecord["assignedtoid"], true));
  160. break;
  161. }//endswitch
  162. // Looking for grouping changes in headers (3 days, 4-7 days, > 7 days)
  163. $xdate = stringToDate($therecord["xdate"],"SQL") ;
  164. if($xdate > $section["date"]){
  165. while($xdate > $section["date"]){
  166. switch($section["title"]){
  167. case "Today":
  168. $section["title"] = "Soon";
  169. $section["date"] = mktime(0,0,0,date("m"),date("d")+7,date("Y"));
  170. break;
  171. case "Soon":
  172. $section["title"] = "Later";
  173. $section["date"] = mktime(0,0,0,1,1,2038);
  174. break;
  175. case "Later":
  176. //should never be here
  177. $section["date"] = $xdate;
  178. }//end switch
  179. }//endwhile
  180. ?><div class="taskSection"><?php echo $section["title"] ?></div><?php
  181. }//end if
  182. ?>
  183. <div id="<?php echo $id.$therecord["id"]?>" class="<?php echo $className?>">
  184. <span class="taskRight"><?php echo $rightSide ?></span>
  185. <input class="radiochecks taskChecks" id="<?php echo $checkBoxID?>" name="<?php echo $checkBoxID?>" type="checkbox" value="1" <?php if($therecord["completed"]) echo 'checked="checked"'?> align="middle" />
  186. <a href="<?php echo $link?>"><?php echo htmlQuotes($therecord["subject"])?></a>
  187. <?php if($bottomInfo){ ?>
  188. <p><?php echo $bottomInfo ?></p>
  189. <?php }//endif ?>
  190. </div>
  191. <?php }//endwhile
  192. } else { ?>
  193. <p class="small disabledtext">no <?php echo strtolower($title)?></p><?php
  194. }?>
  195. </div>
  196. </div> <?php
  197. }//end method showTasks
  198. }//end class workload
  199. ?>