-
Notifications
You must be signed in to change notification settings - Fork 0
/
crud_irp_devtypes.php
77 lines (67 loc) · 2.57 KB
/
crud_irp_devtypes.php
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
<?php
/*
crud_irp_devtypes - This file is part of remoteDBdiscovery.
remoteDBdiscovery 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.
remoteDBdiscovery is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--------
Copyright (c) 2017 Marco Sillano. All right reserved.
*/
$r=dirname(dirname(__FILE__));
include("$r/remoteDBdiscovery/libs/crudClass.php");
require_once ("$r/remoteDB/irp_commonSQL.php");
if (isset($_GET['kind'])){
$_POST = $_GET;
}
echo "<html><head>";
echo StyleSheet();
echo "</head><body>";
echo "<h1> Table <b>irp_devtypes</b>: <i>add/edit/delete records</i></h1>";
//--------------------------------------------------
//callback for show fields (view)
function crud_get_show($field, $value) {
$code = NULL;
// special cases
if ($field == 'ticon')
$code = "<A href='./../remoteDB/icons/$value' target='_blank' >$value</A>" ;
return $code;
}
// --------------------------------------------------
$crud = new crudClass('irp_devtypes','kind,ticon','kind' );// Initiate the class with table information
if (isset($_POST['submit'])){
$create_sql = $crud->create();//Fetch INSERT query
sql($create_sql);
}
if (isset($_POST['update'])){
$update_sql = $crud->update();//Fetch UPDATE query
sql($update_sql);
}
if (isset($_POST['delete'])){
$delete_sql = $crud->delete();//Fetch DELETE query
sql($delete_sql);
}
// -------------
if (isset($_POST['edit'])){
// edit
echo "<div class='note' align='right'>";
echo $crud->renderEditor();//Prepare data edit form
echo '</div>' ;
} else {
// or insert
echo "<div class='note' align='right'>";
echo $crud->create_form();//Prepare data entry form
echo '</div>';
}
// table
echo $crud->renderVertically(' ORDER BY kind');// SHOW data table
echo '<hr><center> <a href="javascript:history.go(-1)"><<< back </a> | <a href="discovery.html">discovery</a> </center><br>';
echo "</body></html>";
?>