<?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: admin1.php,v 1.6 2001/01/16 21:56:53 rschader Exp $ */
$phpgw_info["flags"]["enable_nextmatchs_class"] = "True";
$phpgw_info["flags"]["currentapp"] = "timetrack";
include("../header.inc.php");
if($mode == "accept"){
if($loc_id){
$phpgw->db->query("update locations set location_name='$loc_name' "
. "where location_id='$loc_id'");
}
}
if($mode == "add"){
$phpgw->db->query("insert into locations (location_name) VALUES ('Edit this')");
$mode="edit";
$phpgw->db->query("select location_id from locations where location_name='Edit this'");
$phpgw->db->next_record();
$loc_id = $phpgw->db->f("location_id");
}
if($mode == "delete"){
if ($loc_id){
if(! $confirm){
$phpgw->db->query("select location_name from locations where location_id='$loc_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 location ?");
echo '<br>' . $phpgw->db->f("location_name");
echo '<td></tr><tr><td>';
echo '<a href="' . $phpgw->link() . '">' . lang("No") . '</a></td><td>';
echo '<a href="' . $phpgw->link("","loc_id=$loc_id&mode=delete&confirm=true")
. '">' . lang("Yes") . "</a>";
echo '</td></tr></table></center>';
} else { //we have loc_id and confirm
$phpgw->db->query("delete from locations where location_id='$loc_id'");
}
}
}
echo "<p><center><h3>" . lang("Locations Table") . "</h3><table border=0 width=65%>"
. "<tr bgcolor=" . $phpgw_info["theme"]["th_bg"] . "><th>" . lang("Location ID") . "</th><th>"
. lang("Location") . "</th><th> " . lang("Edit") . " </th> <th> "
. lang("Delete") . " </th></tr>";
$phpgw->db->query("select * from locations");
while ($phpgw->db->next_record()) {
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$location_id = $phpgw->db->f("location_id");
$location_name = $phpgw->db->f("location_name");
if(($mode == "edit") && ($loc_id == $location_id)){
$location_name = '<form method=POST action="'
. $phpgw->link("","loc_id=" . $location_id . "&mode=accept")
. '"><input name="loc_name" value="' . $location_name . '">'
. '</form>';
}
echo "<tr valign=\"center\" bgcolor=$tr_color><td>$location_id</td><td>";
echo $location_name
. "</td><td width=5%><a href=\"" . $phpgw->link("",
"loc_id=" . $location_id . "&mode=edit") . "\"> " . lang("Edit") . " </a></td>";
echo "<td width=8%><a href=\"" . $phpgw->link("",
"loc_id=" . $location_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();