-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_common_entry.php
318 lines (272 loc) · 14.4 KB
/
config_common_entry.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<?php
require_once(__DIR__.'/source/main.php');
require_once(__DIR__.'/source/common_functions/common_list.php');
require_once(__DIR__.'/source/common_functions/common_check_action.php');
require_once(__DIR__.'/source/common_functions/common_security.php');
const LOCAL_STORED_PROC_NAME = 'config_form'; // Used to call stored procedures for the main record set of this script.
const LOCAL_BASE_TITLE = 'Common Forms'; // Title display, button labels, instruction inserts, etc.
const PRIMARY_DATA_CLASS = '\dc\application\CommonEntry';
// Save this record.
function action_save($database)
{
// Set up account info.
$access_obj = new \dc\stoeckl\status();
// Initialize main data class and populate it from
// post variables.
$primary_data_class = PRIMARY_DATA_CLASS;
$_main_data = new $primary_data_class();
$_main_data->populate_from_request();
// Call update stored procedure.
$database->set_sql('{call '.LOCAL_STORED_PROC_NAME.'_update(@param_id = ?,
@param_log_update_by = ?,
@param_log_update_ip = ?,
@param_label = ?,
@param_details = ?,
@param_title = ?,
@param_description = ?,
@param_main_sql_name = ?,
@param_main_object_name = ?,
@param_slug = ?,
@param_file_name = ?)}');
$params = array(array('<root><row id="'.$_main_data->get_id().'"/></root>', SQLSRV_PARAM_IN),
array($access_obj->get_id(), SQLSRV_PARAM_IN),
array($access_obj->get_ip(), SQLSRV_PARAM_IN),
array($_main_data->get_label(), SQLSRV_PARAM_IN),
array($_main_data->get_details(), SQLSRV_PARAM_IN),
array($_main_data->get_title(), SQLSRV_PARAM_IN),
array($_main_data->get_description(), SQLSRV_PARAM_IN),
array($_main_data->get_main_sql_name(), SQLSRV_PARAM_IN),
array($_main_data->get_main_object_name(), SQLSRV_PARAM_IN),
array($_main_data->get_slug(), SQLSRV_PARAM_IN),
array($_main_data->get_file_name(), SQLSRV_PARAM_IN));
$database->set_param_array($params);
$database->query_run();
// Repopulate main data object with results from merge query.
// We can use common data here because all we need
// is the ID for redirection.
$database->get_line_config()->set_class_name('\data\Common');
$_main_data = $database->get_line_object();
// Now that save operation has completed, reload page using ID from
// database. This ensures the ID is always up to date, even with a new
// or copied record.
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$_main_data->get_id());
}
// Verify user access.
common_security($yukon_database);
// Start page cache.
$page_obj = new \dc\cache\PageCache();
// Main navigaiton.
$obj_navigation_main = new class_navigation();
// Record navigation - also gets user record action requests.
$obj_navigation_rec = new \dc\recordnav\RecordNav();
// Apply user action request (if any). Depending on the
// action, the page may be reloaded with the same or
// another ID.
common_check_action($obj_navigation_rec->get_action(), NULL, $yukon_database);
// Initialize a blank main data object.
$primary_data_class = PRIMARY_DATA_CLASS;
$_main_data = new $primary_data_class();
// Populate from request so that we have an
// ID and KEY ID (if nessesary) to work with.
$_main_data->populate_from_request();
// Set up primary query with parameters and arguments.
$yukon_database->set_sql('{call '.LOCAL_STORED_PROC_NAME.'(@param_filter_id = ?,
@param_filter_id_key = ?)}');
$params = array(array($_main_data->get_id(), SQLSRV_PARAM_IN),
array($_main_data->get_id_key(), SQLSRV_PARAM_IN));
// Apply arguments and execute query.
$yukon_database->set_param_array($params);
$yukon_database->query_run();
// Get navigation record set and populate navigation object.
$yukon_database->get_line_config()->set_class_name('\dc\recordnav\RecordNav');
if($yukon_database->get_row_exists() === TRUE) $obj_navigation_rec = $yukon_database->get_line_object();
// Get primary data record set.
$yukon_database->get_next_result();
$yukon_database->get_line_config()->set_class_name(PRIMARY_DATA_CLASS);
if($yukon_database->get_row_exists() === TRUE) $_main_data = $yukon_database->get_line_object();
?>
<!DOCtype html>
<html lang="en">
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1" />
<title><?php echo APPLICATION_SETTINGS::NAME. ', '.LOCAL_BASE_TITLE; ?></title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="source/css/style.css" />
<link rel="stylesheet" href="source/css/print.css" media="print" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<!-- WYSIWYG Text boxes -->
<script type="text/javascript" src="source/javascript/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="source/javascript/tinymce/settings.js"></script>
</head>
<body>
<div id="container" class="container">
<?php echo $obj_navigation_main->generate_markup_nav(); ?>
<div class="page-header">
<h1><?php echo LOCAL_BASE_TITLE; ?></h1>
<p class="lead">This screen allows for adding and editing <?php echo LOCAL_BASE_TITLE; ?> records.</p>
<?php require(__DIR__.'/source/common_includes/revision_alert.php'); ?>
</div>
<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data">
<?php echo $obj_navigation_rec->generate_button_list(); ?>
<hr />
<?php require(__DIR__.'/source/common_includes/details_field.php'); ?>
<div class="form-group">
<label class="control-label col-sm-2" for="revision">Revision</label>
<div class="col-sm-10">
<p class="form-control-static">
<?php if(is_object($_main_data->get_create_time()))
{
?>
<a id="revision" href = "common_version_list.php?id=<?php echo $_main_data->get_id(); ?>"
data-toggle = ""
title = "View log for this record."
target = "_new"
><?php echo date(APPLICATION_SETTINGS::TIME_FORMAT, $_main_data->get_create_time()->getTimestamp()); ?></a>
<?php
}
else
{
?>
<span class="alert-success">New Record. Fill out form and save to create first revision.</span>
<?php
}
?>
</p>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Test Links</label>
<div class="col-sm-10">
<p class="form-control-static">
<?php if($_main_data->get_id() && $_main_data->get_id() != -1)
{
?>
<a id="test_link_entry" href = ".?id_form=<?php echo $_main_data->get_id(); ?>&id=-1"
data-toggle = ""
title = "Test entry form."
target = "_new"
>Entry</a>
·
<a id="test_link_list" href = ".?id_form=<?php echo $_main_data->get_id(); ?>&list=1"
data-toggle = ""
title = "Test list form."
target = "_new"
>List</a>
<?php
}
else
{
?>
<span class="alert-success">New Record. Fill out form and save to create test links.</span>
<?php
}
?>
</p>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="label">Label</label>
<div class="col-sm-10">
<input
type ="text"
class ="form-control"
name ="label"
id ="label"
placeholder="Label"
value="<?php echo trim($_main_data->get_label()); ?>">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="slug">Slug</label>
<div class="col-sm-10">
<p class="small">This is a human readable search that is used to access the form with desired data via URL. Make sure to only use URL compatible text.</p>
<input
type ="text"
class ="form-control"
name ="slug"
id ="slug"
placeholder="Search slug."
value="<?php echo trim($_main_data->get_slug()); ?>">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="file_name">File Name</label>
<div class="col-sm-10">
<p class="small">If the form is part of a unique file instead of Common Entry, enter the file name here.</p>
<input
type ="text"
class ="form-control"
name ="file_name"
id ="file_name"
placeholder="File name."
value="<?php echo trim($_main_data->get_file_name()); ?>">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="title">Title</label>
<div class="col-sm-10">
<p class="small">This is the marque title that is displayed in bold at top of page and in the task bar.</p>
<input
type ="text"
class ="form-control"
name ="title"
id ="title"
placeholder="Display title."
value="<?php echo trim($_main_data->get_title()); ?>">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="description">Description</label>
<div class="col-sm-10">
<p class="small">Description will appear directly below the title and tells the end user what the form is for.</p>
<textarea class="form-control wysiwyg" rows="2" name="description" id="description"><?php echo $_main_data->get_description(); ?></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="main_sql_name">Main SQL Name</label>
<div class="col-sm-10">
<p class="small">Stored procedure name that form will call for its primary record sets.</p>
<input
type ="text"
class ="form-control"
name ="main_sql_name"
id ="main_sql_name"
placeholder="SQL Stored Procedure Name."
value="<?php echo trim($_main_data->get_main_sql_name()); ?>">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="main_object_name">Main Object Name</label>
<div class="col-sm-10">
<p class="small">Name of class that will be called and used to create object for form's main data.</p>
<input
type ="text"
class ="form-control"
name ="main_object_name"
id ="main_object_name"
placeholder="Object class name."
value="<?php echo trim($_main_data->get_main_object_name()); ?>">
</div>
</div>
<hr />
<div class="form-group">
<div class="col-sm-12">
<?php echo $obj_navigation_rec->get_markup_cmd_save_block(); ?>
</div>
</div>
</form>
<?php echo $obj_navigation_main->generate_markup_footer(); ?>
</div><!--container-->
<script src="source/javascript/verify_save.js"></script>
<script>
//Google Analytics Here//
$(document).ready(function(){
});
</script>
</body>
</html>
<?php
// Collect and output page markup.
echo $page_obj->markup_and_flush();
?>