-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_aoi.php
136 lines (119 loc) · 3.07 KB
/
save_aoi.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* Submitted from curr_user_aois.php, updates table aoi.
*
* @package swgap
*/
session_start();
require("pr_config.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>User page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="StyleSheet" href="styles/popups.css" type="text/css" />
<link rel="stylesheet" href="styles/custom-theme/jquery-ui-1.8.6.custom.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script>
<script type="text/javascript" src="javascript/jquery-ui-1.8.6.custom.min.js" ></script>
<style type="text/css">
/* <![CDATA[ */
.bld {font-weight: bold;}
.ui-widget {font-size: 11px;}
button {width: 100px;
margin: 10px;}
/* ]]> */
</style>
<script language="javascript" type="text/javascript">
/* <![CDATA[ */
$(document).ready(function() {
$("button").button();
$("#sv").click(function(evt) {
evt.preventDefault();
save_aoi();
});
$("#dl").click(function(evt) {
evt.preventDefault();
delete_aoi();
});
$("#can").click(function(evt) {
evt.preventDefault();
go_back();
});
});
function ajax_req(){
var aoiname = $("#aoiname").val();
var del = $("#del").val();
var desc = $("#desc").val();
//alert(aoiname + del + desc);
$.ajax({
type: "POST",
url: "save_aoi_ajax.php",
data: { aoiname: aoiname, del: del, desc: desc },
dataType: "json",
success: function(data){
if(data.success){
if(opener.document.forms.fm4){
opener.document.forms.fm4.submit();
} else {
$(window).attr("location", "curr_user_aois.php");
}
}
}
});
}
function save_aoi(){
if(document.forms[0].desc.value.length == 0){
alert('must enter a description')
} else{
document.forms[0].del.value = '';
ajax_req();
}
}
function delete_aoi(){
document.forms[0].del.value = 'delete';
ajax_req();
}
/*
function go_back(){
opener.document.forms.fm4.submit();
}*/
function go_back(){
if(opener.document.forms.fm4){
opener.document.forms.fm4.submit();
} else {
$(window).attr("location", "curr_user_aois.php");
}
}
/* ]]> */
</script>
</head>
<body >
<?php
pg_connect($pg_connect);
$user = $_SESSION['username'];
$aoi_name = $_POST['aoi_name'];
$type = $_POST['type'];
$aoi_name_saved = $_POST['aoi_name_saved'];
if (isset($_POST['aoi_name_saved_cb'])){
$aoi_name_saved = $_POST['aoi_name_saved_cb'];
}
if ($type == 'selected') {
$aoi_name = $aoi_name_saved;
}
$query = "select description from aoi where name = '{$aoi_name}'";
$result = pg_query($query);
$row = pg_fetch_array($result);
?>
<form method="post" action="save_aoi.php" target="_self">
<input type="hidden" name="aoi_name" id="aoiname" value="<?php echo $aoi_name; ?>" />
<input type="hidden" name="del" id="del" />
<div>
AOI name:<input type="text" size="25" maxlength="50" name="desc" id="desc" value="<?php echo $row[0]; ?>"/>
</div>
<button id="sv">Save</button>
<button id="dl">Delete</button>
<button id="can">Cancel</button>
</form>
</body>
</html>