home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / ticketsmith / attach.php < prev    next >
Encoding:
PHP Script  |  2004-01-31  |  5.7 KB  |  169 lines

  1. <?php
  2.  
  3. if (!$canEdit) {
  4.     $AppUI->redirect( "m=public&a=access_denied" );
  5. }
  6.  
  7. $ticket = dPgetParam( $_GET, 'ticket', '');
  8.  
  9. $titleBlock = new CTitleBlock( 'Link Ticket', 'gconf-app-icon.php', $m, "$m.$a");
  10. $titleBlock->addCrumb( "?m=ticketsmith", "tickets list" );
  11. $titleBlock->show();
  12.  
  13. require("./modules/ticketsmith/config.inc.php");
  14. require("./modules/ticketsmith/common.inc.php");
  15.  
  16. $app_root = $AppUI->getConfig( 'base_url' );
  17.  
  18. /* setup table & database field stuff */
  19. $fields = array("headings" => array("Link", "Author", "Subject", "Date", 
  20.                                     "Followup", "Status", "Priority", "Owner"),
  21.  
  22.                 "columns"  => array("ticket", "author", "subject", "timestamp", 
  23.                                     "activity", "type", "priority", "assignment"),
  24.  
  25.                 "types"    => array("doattach", "email", "normal", "open_date", 
  26.                                     "activity_date", "normal", "priority_view", "user"),
  27.                               
  28.                 "aligns"   => array("center", "left", "left", "left", "left", 
  29.                                     "center", "center", "center"));
  30.  
  31. /* set up defaults for viewing */
  32. $type = @$type ? $type : "Open";
  33. $column = @$column ? $column : "priority";
  34. $direction = @$direction ? $direction : "DESC";
  35. $offset = @$offset ? $offset : 0;
  36. $limit = @$limit ? $limit : $CONFIG["view_rows"];
  37.  
  38.  
  39.  
  40. /* count tickets */
  41. $query = "SELECT COUNT(*) FROM tickets WHERE parent = '0' and ticket != $ticket";
  42. if ($type != 'All') {
  43.     $query .= " AND type = '$type'";
  44. }
  45. $ticket_count = query2result($query);
  46.  
  47. /* paging controls */
  48. if (($offset + $limit) < $ticket_count) {
  49.     $page_string = ($offset + 1) . " to " . ($offset + $limit) . " of $ticket_count";
  50. }
  51. else {
  52.     $page_string = ($offset + 1) . " to $ticket_count of $ticket_count";
  53. }
  54.  
  55. /* start table */
  56. $title = "Assign ticket to parent";
  57. ?>
  58. <table class="tbl" width="100%">
  59. <tr>
  60.     <td colspan="<?php echo count( $fields["headings"] );?>" align="center">
  61.         <table width="100%" border="0" cellspacing="1" cellpadding="1">
  62.         <tr>
  63.             <td width="33%"></td>
  64.             <td width="34%" align="center"><strong><?php echo $AppUI->_($title);?></strong></td>
  65.             <td width="33%" align="right" valign="middle">
  66. <?php
  67.  
  68. if ($ticket_count > $limit) {
  69.     if ($offset - $limit >= 0) {
  70.         print("<a href=index.php?m=ticketsmith&type=$type&column=$column&direction=$direction&offset=" . ($offset - $limit) . "><img src=modules/ticketsmith/images/ltwt.gif border=0></a> | \n");
  71.     }
  72.     print("$page_string\n");
  73.     if ($offset + $limit < $ticket_count) {
  74.         print(" | <a href=index.php?m=ticketsmith&type=$type&column=$column&direction=$direction&offset=" . ($offset + $limit) . "><img src=modules/ticketsmith/images/rtwt.gif border=0></a>\n");
  75.     }
  76. }
  77. ?>
  78.  
  79.             </td>
  80.         </tr>
  81.         </table>
  82.     </td>
  83. </tr>
  84. <?php
  85. /* form query */
  86. $select_fields= join(", ", $fields["columns"]);
  87. $query = "SELECT $select_fields FROM tickets WHERE ";
  88. if ($type == "My") {
  89.     $query .= "type = 'Open' AND (assignment = '$user_cookie' OR assignment = '0') AND ";
  90. }
  91. elseif ($type != "All") {
  92.     $query .= "type = '$type' AND ";
  93. }
  94. $query .= "ticket != $ticket AND ";
  95. $query .= "parent = '0' ORDER BY " . urlencode($column) . " $direction LIMIT $offset, $limit";
  96.  
  97. /* do query */
  98. $result = do_query($query);
  99. $parent_count = number_rows($result);
  100.  
  101. /* output tickets */
  102. if ($parent_count) {
  103.     print("<tr>\n");
  104.     for ($loop = 0; $loop < count($fields["headings"]); $loop++) {
  105.         print("<td  align=" . $fields["aligns"][$loop] . ">");
  106.         print("<a href=index.php?m=ticketsmith&type=$type");
  107.         print("&column=" . $fields["columns"][$loop]);
  108.         if ($column != $fields["columns"][$loop]) {
  109.             $new_direction = "ASC";
  110.         }
  111.         else {
  112.             if ($direction == "ASC") {
  113.                 $new_direction = "DESC";
  114.             }
  115.             else {
  116.                 $new_direction == "ASC";
  117.             }
  118.         }
  119.         print("&direction=$new_direction");
  120.         print("><b>" . $AppUI->_($fields["headings"][$loop]) . "</b></a></td>\n");
  121.     }
  122.     print("</tr>\n");
  123.     while ($row = result2hash($result)) {
  124.         print("<tr height=25>\n");
  125.         for ($loop = 0; $loop < count($fields["headings"]); $loop++) {
  126.             print("<td  bgcolor=white align=" . $fields["aligns"][$loop] . ">\n");
  127.             print(format_field($row[$fields["columns"][$loop]], $fields["types"][$loop], $ticket) . "\n");
  128.             print("</td>\n");
  129.         }
  130.         print("</tr>\n");
  131.     }
  132. }
  133.  else {
  134.     print("<tr height=25>\n");
  135.     print("<td align=center colspan=" . count($fields["headings"]) . ">\n");
  136.     print($AppUI->_('There are no')." ");
  137.     print($type == "All" ? "" : strtolower($AppUI->_($type)) . " ");
  138.     print($AppUI->_('tickets').".\n");
  139.     print("</td>\n");
  140.     print("</tr>\n");
  141. }
  142.  
  143. /* output action links */
  144. print("<tr>\n");
  145. print("<td><br></td>\n");
  146. print("<td colspan=" . (count($fields["headings"]) - 1) . " align=right>\n");
  147. print("<table width=100% border=0 cellspacing=0 cellpadding=0>\n");
  148. print("<tr height=25><td align=left>");
  149. $types = array("My","Open","Closed","Deleted","All");
  150. for ($loop = 0; $loop < count($types); $loop++) {
  151.     $toggles[] = "<a href=index.php?m=ticketsmith&type=" . $types[$loop] . ">" . $AppUI->_($types[$loop]) . "</a>";
  152. }
  153. print(join(" | ", $toggles));
  154. print(" ".$AppUI->_('Tickets')."</td>\n");
  155. if ($type == "Deleted" && $parent_count) {
  156.     print("<td align=center><a href=index.php?m=ticketsmith&type=Deleted&action=expunge>".$AppUI->_('Expunge Deleted')."</a></td>");
  157. }
  158. print("<td align=right><a href=index.php?m=ticketsmith&a=search>".$AppUI->_('Search')."</a> |
  159. <a href=index.php?m=ticketsmith&type=$type>".$AppUI->_('Back to top')."</a></td></tr>\n");
  160. print("</table>\n");
  161. print("</td>\n");
  162. print("</tr>\n");    
  163.  
  164. /* end table */
  165. print("</table>\n");
  166.  
  167. /* end page */
  168. ?>
  169.