Location: PHPKode > projects > Phpgw Time Tracking Add On App > timetrack/admin2.php
<?php
  /**************************************************************************\
  * phpgwtimetrack - phpGroupWare addon application                          *
  * http://phpgwtimetrack.sourceforge.net                                    *
  * Written by Robert Schader <hide@address.com>                         *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

  /* $Id: admin2.php,v 1.6 2001/01/16 21:56:53 rschader Exp $ */

  // For editing Status ID table, entries are
  // table name: job_status
  // fields: status_id, status_name

  $phpgw_info["flags"]["enable_nextmatchs_class"] = "True";
  $phpgw_info["flags"]["currentapp"] = "timetrack";
  include("../header.inc.php");

  if($mode == "accept"){
    if($stat_id){
	  $phpgw->db->query("update job_status set status_name='$stat_name' "
	    . "where status_id='$stat_id'");
	}
  }

  if($mode == "add"){
	$phpgw->db->query("insert into job_status (status_name) VALUES ('Edit Me')");
    $mode="edit";
	$phpgw->db->query("select status_id from job_status where status_name='Edit Me'");
	$phpgw->db->next_record();
	$stat_id = $phpgw->db->f("status_id");
  }
  
  if($mode == "delete"){
	  if ($stat_id){
		if(! $confirm){
		  $phpgw->db->query("select status_name from job_status where status_id='$stat_id'");
		  $phpgw->db->next_record();
		  echo '<center><table border=0 with=65%>';
		  echo '<tr colspan=2><td align=center>';
		  echo lang("Are you sure you want to delete this Status Code ?");
		  echo '<br>' . $phpgw->db->f("status_name");
		  echo '<td></tr><tr><td>';
	      echo '<a href="' . $phpgw->link() . '">' . lang("No") . '</a></td><td>';
	      echo '<a href="' . $phpgw->link("","stat_id=$stat_id&mode=delete&confirm=true")
		     . '">' . lang("Yes") . "</a>";
		  echo '</td></tr></table></center>';
	    } else { //we have stat_id and confirm
          $phpgw->db->query("delete from job_status where status_id='$stat_id'");
		}
	 }
  }

  echo "<p><center><h3>" . lang("Status ID Table") . "</h3><table border=0 width=65%>"
     . "<tr bgcolor=" . $phpgw_info["theme"]["th_bg"] . "><th>" . lang("Status ID") . "</th><th>"
     . lang("Status Name") . "</th><th> " . lang("Edit") . " </th> <th> "
     . lang("Delete") . " </th></tr>";

  $phpgw->db->query("select * from job_status");

  while ($phpgw->db->next_record()) {
    $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);

    $status_id  = $phpgw->db->f("status_id");
    $status_name = $phpgw->db->f("status_name");

	if(($mode == "edit") && ($stat_id == $status_id)){
	  $status_name = '<form method=POST action="' 
	     . $phpgw->link("","stat_id=" . $status_id . "&mode=accept")
	     . '"><input name="stat_name" value="' . $status_name . '">'
		 . '</form>';
	}

    echo "<tr valign=\"center\" bgcolor=$tr_color><td>$status_id</td><td>";
	echo $status_name
       . "</td><td width=5%><a href=\"" . $phpgw->link("",
         "stat_id=" . $status_id . "&mode=edit") . "\"> " . lang("Edit") . " </a></td>";

    echo  "<td width=8%><a href=\"" . $phpgw->link("",
          "stat_id=" . $status_id . "&mode=delete") . "\"> " . lang("Delete") . " </a> </td></tr>";
  }
  echo '<form method=POST action="' . $phpgw->link("",
  		"mode=add") . '">'
     . "<tr><td colspan=5><input type=\"submit\" value=\"" . lang("Add")
     . "\"></td></tr></form></table></center>";

  $phpgw->common->phpgw_footer();
Return current item: Phpgw Time Tracking Add On App