1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
<?php
// site_types.php - Page to list/add/edit site types
//
// SiT (Support Incident Tracker) - Support call tracking system
// Copyright (C) 2010-2014 The Support Incident Tracker Project
// Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
//
// This software may be used and distributed according to the terms
// of the GNU General Public License, incorporated herein by reference.
//
// Author: Paul Heaney <paul[at]sitracker.org>
//
require ('core.php');
$permission = PERM_SITE_TYPES;
require (APPLICATION_LIBPATH . 'functions.inc.php');
// This page requires authentication
require (APPLICATION_LIBPATH . 'auth.inc.php');
require (APPLICATION_LIBPATH . 'sitform.inc.php');
$title = $strSiteTypes;
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
$mode = clean_fixed_list($_REQUEST['mode'], array('','new','edit'));
if (empty($mode))
{
echo "<h2>".icon('edit', 32)." {$strSiteTypes}</h2>";
plugin_do('site_types');
$sql = "SELECT * FROM `{$dbSiteTypes}` ORDER BY typename";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
if (mysql_num_rows($result) > 0)
{
echo "<table class='maintable'>";
echo "<tr><th>{$strSiteType}</th><th>{$strActions}</th></tr>";
$shade = 'shade1';
while ($obj = mysql_fetch_object($result))
{
echo "<tr class='{$shade}'><td>{$obj->typename}</td>";
echo "<td><a href='{$_SERVER['PHP_SELF']}?mode=edit&typeid={$obj->typeid}'>{$strEdit}</a></td></tr>";
if ($shade == 'shade1') $shade = 'shade2';
else $shade = 'shade1';
}
echo "</table>";
}
else
{
user_alert($strNoRecords, E_USER_NOTICE);
}
echo "<p align='center'><a href='{$_SERVER['PHP_SELF']}?mode=new'>{$strNewSiteType}</a></p>";
}
elseif ($mode == 'new')
{
$form = new Form("sitetypes", $strNew, $dbSiteTypes, "insert", $strNewSiteType);
$form->setReturnURLFailure($_SERVER['PHP_SELF']);
$form->setReturnURLSuccess($_SERVER['PHP_SELF']);
$c1 = new Cell();
$c1->setIsHeader(TRUE);
$label = new Label($strSiteType);
$c1->addComponent($label);
$c2 = new Cell();
$sle = new SingleLineEntry("typename", 30, "typename", "", true);
$sle->setLabel($label);
$c2->addComponent($sle);
$r = new Row();
$r->addComponent($c1);
$r->addComponent($c2);
$form->addRow($r);
$hr = new HiddenRow();
$hr->addComponent(new HiddenEntry("mode", "", "new"));
$form->addRow($hr);
$form->run();
}
elseif ($mode == 'edit')
{
$typeid = clean_int($_REQUEST['typeid']);
$sql = "SELECT typename FROM `{$dbSiteTypes}` WHERE typeid = {$typeid}";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
if (mysql_num_rows($result) > 0)
{
list($typename) = mysql_fetch_row($result);
}
$form = new Form("sitetypes", $strSave, $dbSiteTypes, "update", $strEditSiteType);
$form->setReturnURLFailure($_SERVER['PHP_SELF']);
$form->setReturnURLSuccess($_SERVER['PHP_SELF']);
$c1 = new Cell();
$c1->setIsHeader(TRUE);
$label = new Label($strSiteType);
$c1->addComponent($label);
$c2 = new Cell();
$sle = new SingleLineEntry("typename", 30, "typename", $typename, true);
$sle->setLabel($label);
$c2->addComponent($sle);
$r = new Row();
$r->addComponent($c1);
$r->addComponent($c2);
$form->addRow($r);
$hr = new HiddenRow();
$hr->addComponent(new HiddenEntry("mode", "", "edit"));
$hr->addComponent(new HiddenEntry("typeid", "", $typeid));
$form->addRow($hr);
$form->setKey("typeid", $typeid);
$form->run();
}
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
?>
|