home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / history / addedit.php next >
Encoding:
PHP Script  |  2003-12-03  |  3.3 KB  |  109 lines

  1. <?php /* $Id: addedit.php,v 1.4 2003/12/03 01:05:02 gregorerhardt Exp $ */
  2. $history_id = defVal( @$_GET["history_id"], 0);
  3.  
  4. /*
  5. // check permissions
  6. if (!$canEdit) {
  7.     $AppUI->redirect( "m=public&a=access_denied" );
  8. }
  9. */
  10.  
  11. $action = @$_REQUEST["action"];
  12. if($action) {
  13.     $history_description = $_POST["history_description"];
  14.     $history_project = $_POST["history_project"];
  15.     $userid = $AppUI->user_id;
  16.     
  17.     if( $action == "add" ) {
  18.         $sql = "INSERT INTO history (history_date, history_description, history_user, history_project) " .
  19.           "VALUES (now(), '$history_description', $userid, $history_project)";
  20.         $okMsg = "History added";
  21.     } else if ( $action == "update" ) {
  22.         $sql = "UPDATE history SET history_description = '$history_description', history_project = '$history_project' WHERE history_id = $history_id";
  23.         $okMsg = "History updated";
  24.     } else if ( $action == "del" ) {
  25.         $sql = "DELETE FROM history WHERE history_id = $history_id";
  26.         $okMsg = "History deleted";                
  27.     }
  28.     if(!db_exec($sql)) {
  29.         $AppUI->setMsg( db_error() );
  30.     } else {    
  31.         $AppUI->setMsg( $okMsg );
  32.     }
  33.     $AppUI->redirect();
  34. }
  35.  
  36. // pull the history
  37. $sql = "SELECT * FROM history WHERE history_id = $history_id";
  38. db_loadHash( $sql, $history );
  39.  
  40. ?>
  41.  
  42. <form name="AddEdit" method="post">                
  43. <table width="100%" border="0" cellpadding="0" cellspacing="1">
  44. <input name="action" type="hidden" value="<?php echo $history_id ? "update" : "add"  ?>">
  45. <tr>
  46.     <td><img src="./images/icons/tasks.gif" alt="" border="0"></td>
  47.     <td align="left" nowrap="nowrap" width="100%"><h1><?php echo $AppUI->_( $history_id ? 'Edit history' : 'New history' );?></h1></td>
  48. </tr>
  49. </table>
  50.  
  51. <table border="0" cellpadding="4" cellspacing="0" width="98%">
  52. <tr>
  53.     <td width="50%" align="right">
  54.         <a href="javascript:delIt()"><img align="absmiddle" src="./images/icons/trash.gif" width="16" height="16" alt="" border="0"><?php echo $AppUI->_('delete history');?></a>
  55.     </td>
  56. </tr>
  57. </table>
  58.  
  59. <table border="1" cellpadding="4" cellspacing="0" width="98%" class="std">
  60.     
  61. <script>
  62.     function delIt() {
  63.         AddEdit.action.value = "del";
  64.         AddEdit.submit();
  65.     }    
  66. </script>
  67.     
  68. <tr>
  69.     <td align="right" nowrap="nowrap"><?php echo $AppUI->_( 'Project' );?>:</td>
  70.     <td width="60%">
  71. <?php
  72. // pull the projects list
  73. $sql = "SELECT project_id,project_name FROM projects ORDER BY project_name";
  74. $projects = arrayMerge( array( 0 => '('.$AppUI->_('any').')' ), db_loadHashList( $sql ) );
  75. echo arraySelect( $projects, 'history_project', 'class="text"', $history["history_project"] );
  76. ?>
  77.     </td>
  78. </tr>
  79.     
  80. <tr>
  81.     <td align="right" nowrap="nowrap"><?php echo $AppUI->_( 'Description' );?>:</td>
  82.     <td width="60%">
  83.         <textarea name="history_description" class="textarea" cols="60" rows="5" wrap="virtual"><?php echo $history["history_description"];?></textarea>
  84.     </td>
  85. </tr>    
  86.         
  87. <table border="0" cellspacing="0" cellpadding="3" width="98%">
  88. <tr>
  89.     <td height="40" width="30%"> </td>
  90.     <td  height="40" width="35%" align="right">
  91.         <table>
  92.         <tr>
  93.             <td>
  94.                 <input class="button" type="button" name="cancel" value="<?php echo $AppUI->_('cancel'); ?>" onClick="javascript:if(confirm('Are you sure you want to cancel.')){location.href = '?<?php echo $AppUI->getPlace();?>';}">
  95.             </td>
  96.             <td>
  97.                 <input class="button" type="button" name="btnFuseAction" value="<?php echo $AppUI->_('save'); ?>" onClick="submit()">
  98.             </td>
  99.         </tr>
  100.         </table>
  101.     </td>
  102. </tr>
  103. </table>    
  104.     
  105. </table>
  106. </form>        
  107. </body>
  108. </html>
  109.