/
inc_form_entity_status.php
363 lines (291 loc) · 12 KB
/
inc_form_entity_status.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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
<?php
$intra->requireComponent('jquery-ui', 'grid');
$DataAction = (isset($_POST['DataAction']) ? $_POST['DataAction'] : $_GET['DataAction'] );
$staID = (isset($_POST["staID"]) ? $_POST["staID"] : $_GET["staID"]);
$entID = (isset($_POST["entID"]) ? $_POST["entID"] : $_GET["entID"]);
$sqlSta = "SELECT * FROM stbl_status
INNER JOIN stbl_entity ON staEntityID=entID
WHERE staID='$staID' AND staEntityID='$entID'";
$rsSta = $oSQL->do_query($sqlSta);
$rwSta = $oSQL->fetch_array($rsSta);
$ffSta = $oSQL->ff($rsSta);
include_once('inc_actionmatrix.php') ;
switch($DataAction){
case "update":
$oSQL->q('START TRANSACTION');
$oSQL->startProfiling();
$sqlUpd = "UPDATE stbl_status SET
staID=".(int)$_POST['staID']."
, staTitle = ".$oSQL->escape_string($_POST['staTitle'])."
, staTitleLocal = ".$oSQL->escape_string($_POST['staTitleLocal'])."
, staTrackPrecision = ".$oSQL->escape_string($_POST['staTrackPrecision'])."
, staFlagCanUpdate = '".($_POST['staFlagCanUpdate']=='on' ? 1 : 0)."'
, staFlagCanDelete = '".($_POST['staFlagCanDelete']=='on' ? 1 : 0)."'
".(isset($ffSta['staDescription']) ? ', staDescription='.$oSQL->e($_POST['staDescription']) : '')."
".(isset($ffSta['staDescriptionLocal']) ? ', staDescriptionLocal='.$oSQL->e($_POST['staDescriptionLocal']) : '')."
".(isset($ffSta['staMenuItemClass']) ? ', staMenuItemClass='.$oSQL->e($_POST['staMenuItemClass']) : '')."
, staFlagDeleted = '".($_POST['staFlagDeleted']=='on' ? 1 : 0)."'
, staEditBy = '$usrID', staEditDate = NOW()
WHERE staID = '{$staID}'AND staEntityID = '{$entID}'";
$oSQL->q($sqlUpd);
if ($_POST['staFlagDeleted']=='on'){
if($oSQL->d("SHOW TABLES LIKE 'stbl_action_status'")){
$sqlAct = "UPDATE stbl_action INNER JOIN stbl_action_status ON atsActionID=actID SET actFlagDeleted=1
WHERE actEntityID='{$entID}'
AND (atsOldStatusID='".$_POST["staID"]."' OR atsNewStatusID='".$_POST["staID"]."')";
$oSQL->q($sqlAct);
} else {
$sqlAct = "UPDATE stbl_action SET actFlagDeleted=1
WHERE actEntityID='{$entID}'
AND (actOldStatusID='".$rwSta["staID"]."' OR actNewStatusID='".$rwSta["staID"]."')";
$oSQL->q($sqlAct);
}
}
$aAtr = array();
for ($i=1; $i< count($_POST["atrID"]); $i++){
if(!$_POST['atrID'][$i])
continue;
$atrID = $oSQL->unq($oSQL->e($_POST['atrID'][$i]));
$creterio = "satAttributeID='{$atrID}', satStatusID={$staID}, satEntityID='{$entID}'";
$sqlExists = "SELECT satID FROM stbl_status_attribute WHERE ".preg_replace('/\, /', ' AND ', $creterio);
$fields = "
satEditBy='{$intra->usrID}', satEditDate=NOW()
, satFlagEditable=".(int)$_POST["satFlagEditable"][$i]."
, satFlagShowInForm=".(int)$_POST["satFlagShowInForm"][$i]."
, satFlagShowInList=".(int)$_POST["satFlagShowInList"][$i]."
, satFlagTrackOnArrival=".(int)$_POST["satFlagTrackOnArrival"][$i]
;
if( !($satID = $oSQL->d($sqlExists)) ){
$sqlSAT = "INSERT INTO stbl_status_attribute SET {$fields}, {$creterio}, satInsertBy='{$intra->usrID}', satInsertDate=NOW()";
} else {
$sqlSAT = "UPDATE stbl_status_attribute SET {$fields} WHERE satID={$satID}";
}
$oSQL->q($sqlSAT);
$aAtr[] = $_POST['atrID'][$i];
}
$sqlSat = "DELETE FROM stbl_status_attribute WHERE satStatusID={$staID}
AND satEntityID='{$entID}'
AND satAttributeID NOT IN ('".implode("','", $aAtr)."')";
$oSQL->q($sqlSat);
// $oSQL->showProfileInfo();
// die();
$oSQL->q('COMMIT');
$intra->redirect($entID." ".$intra->translate("is updated"), $_SERVER["PHP_SELF"]."?dbName=$dbName&staID=$staID&entID=".urlencode($entID));
default:
break;
}
$arrActions[]= Array ('title' => $rwSta["entTitle"]
, 'action' => "entity_form.php?dbName=$dbName&entID=".$rwSta["entID"]
, 'class'=> 'ss_arrow_left'
);
include eiseIntraAbsolutePath."inc_top.php";
?>
<script>
$(document).ready(function(){
$('.eiseGrid').eiseGrid();
$("th.sat-satFlagShowInForm, th.sat-satFlagEditable, th.sat-satFlagShowInList")
.css("cursor", "pointer")
.click(function(){
var tdClass = ($(this).attr('class').split(/\s+/)[0]),
$grid = $(this).parents('.eiseGrid').first(),
$checkBoxes = $grid.find('.eg-data .'+tdClass+' input[type=checkbox]');
$checkBoxes.each(function(){
this.click();
})
});
});
</script>
<form action="<?php echo $_SERVER["PHP_SELF"] ; ?>" method="POST" class="eiseIntraForm eif-form">
<input type="hidden" name="DataAction" value="update">
<input type="hidden" name="dbName" value="<?php echo $dbName ; ?>">
<input type="hidden" name="entID" value="<?php echo $rwSta["staEntityID"] ; ?>">
<fieldset>
<legend>Status: <?php echo $rwSta["staTitle{$intra->local}"] ; ?></legend>
<table width="100%">
<tr>
<td width="50%">
<?php echo $intra->field($intra->translate('ID'), 'staID', $rwSta); ?>
<div class="eiseIntraField"><label><?php echo $intra->translate("Title (Eng.)") ?>:</label>
<?php echo $intra->showTextBox("staTitle", $rwSta["staTitle"]) ; ?>
</div>
<div class="eiseIntraField"><label><?php echo $intra->translate("Title") ?>:</label>
<?php echo $intra->showTextBox("staTitleLocal", $rwSta["staTitleLocal"]) ; ?>
</div>
<div class="eiseIntraField"><label><?php echo $intra->translate("Description (Eng.)") ?>:</label>
<?php echo $intra->showTextArea("staDescription", $rwSta["staDescription"]) ; ?>
</div>
<div class="eiseIntraField"><label><?php echo $intra->translate("Description") ?>:</label>
<?php echo $intra->showTextArea("staDescriptionLocal", $rwSta["staDescriptionLocal"]) ; ?>
</div>
<?php echo (isset($ffSta['staMenuItemClass'])
? $intra->field('Menu item class', 'staMenuItemClass', $rwSta['staMenuItemClass'])
: ''); ?>
<div class="eiseIntraField"><label><?php echo $intra->translate("Precision") ?>:</label>
<?php echo $intra->showCombo("staTrackPrecision", $rwSta["staTrackPrecision"], Array("date"=>$intra->translate("Date")
, "datetime"=>$intra->translate("Date+Time"))) ; ?>
</div>
<div class="eiseIntraField"><label><?php echo $intra->translate("Update Allowed?") ?>:</label>
<?php echo $intra->showCheckBox("staFlagCanUpdate", $rwSta["staFlagCanUpdate"]) ; ?>
</div>
<div class="eiseIntraField"><label><?php echo $intra->translate("Delete allowed?") ?>:</label>
<?php echo $intra->showCheckBox("staFlagCanDelete", $rwSta["staFlagCanDelete"]) ; ?>
</div>
<hr>
<div class="eiseIntraField"><label><?php echo $intra->translate("Deleted?") ?>:</label>
<?php echo $intra->showCheckBox("staFlagDeleted", $rwSta["staFlagDeleted"]) ; ?>
</div>
<?php
$mtx = new eiseActionMatrix($rwSta['staEntityID']);
if($oSQL->d("SHOW TABLES LIKE 'stbl_action_status'")):
?>
<div class="eiseIntraField"><label><?php echo $intra->translate("Actions") ?>:</label>
<div class="eiseIntraValue">
<ul>
<li><b><?php echo $intra->translate('Leading to') ?> "<?php echo $rwSta["staTitle"] ; ?>":</b></li>
<ul>
<?php
$sqlAct = "SELECT DISTINCT actID, actTitle, actTitleLocal, actFlagDeleted FROM stbl_action_status INNER JOIN stbl_action ON actID=atsActionID
WHERE atsNewStatusID='{$rwSta["staID"]}' AND actEntityID='{$entID}'
ORDER BY actFlagDeleted";
$rsAct = $oSQL->do_query($sqlAct);
if ($oSQL->n($rsAct)==0){echo " - ".$intra->translate('Nothing found')." - ";}
while ($rwAct=$oSQL->fetch_array($rsAct)) {
?>
<li><a href="action_form.php?entID=<?php
echo $entID ;
?>&actID=<?php
echo $rwAct["actID"] ;
?>&dbName=<?php
echo $dbName ;
?>"><?php echo $rwAct["actTitle{$intra->local}"].($rwAct['actFlagDeleted'] ? " (deleted)" : "") ; ?></a></li>
<?php
}
?>
</ul>
<li><b><?php echo $intra->translate('Leading from') ?> "<?php echo $rwSta["staTitle"] ; ?>":</b></li>
<ul>
<?php
$sqlAct = "SELECT DISTINCT actID, actTitle, actTitleLocal, actFlagDeleted FROM stbl_action_status INNER JOIN stbl_action ON actID=atsActionID
WHERE atsOldStatusID='{$rwSta["staID"]}' AND actEntityID='{$entID}'
ORDER BY actFlagDeleted";
$rsAct = $oSQL->do_query($sqlAct);
while ($rwAct=$oSQL->fetch_array($rsAct)) {
?>
<li><a href="action_form.php?entID=<?php
echo $entID ;
?>&actID=<?php
echo $rwAct["actID"] ;
?>&dbName=<?php
echo $dbName ;
?>"><?php echo $rwAct["actTitle{$intra->local}"].($rwAct['actFlagDeleted'] ? " (deleted)" : "") ; ?></a></li>
<?php
}
?>
</ul>
</ul>
</div>
</div>
<?php endif; ?>
</td>
<td width="50%">
<?php
$gridSAT = new easyGrid($oSQL
,'sat'
, Array(
'rowNum' =>40
, 'arrPermissions' => Array('FlagWrite'=>$intra->arrUsrData["FlagWrite"])
, 'strTable' => 'stbl_action_attribute'
, 'strPrefix' => 'aat'
, 'flagStandAlone' => true
, 'flagNoDelete' => true
)
);
$gridSAT->Columns[] = Array(
'type' => 'row_id'
, 'field' => 'atrID'
);
$gridSAT->Columns[] = Array(
'title' => ""
, 'field' => "satStatusID"
, 'type' => "text"
, 'default' => $staID
);
$gridSAT->Columns[] = Array(
'title' => ""
, 'field' => "satEntityID"
, 'type' => "text"
, 'default' => $entID
);
$gridSAT->Columns[] = Array(
'title' => ""
, 'field' => "satAttibuteID"
, 'type' => "text"
);
$gridSAT->Columns[] = Array(
'title' => $intra->translate("Field")
, 'field' => "atrID_"
, 'type' => "text"
, 'static' => true
);
$gridSAT->Columns[] = Array(
'title' => $intra->translate("Attribute")
, 'field' => "atrTitle{$intra->local}"
, 'type' => "text"
, 'disabled' => true
, 'width' => "100%"
);
$gridSAT->Columns[] = Array(
'title' => $intra->translate("Type")
, 'field' => "atrType"
, 'type' => "text"
, 'static' => true
);
$gridSAT->Columns[] = Array(
'title' => $intra->translate("Track?")
, 'field' => "satFlagTrackOnArrival"
, 'type' => "checkbox"
);
$gridSAT->Columns[] = Array(
'title' => $intra->translate("In Form?")
, 'field' => "satFlagShowInForm"
, 'type' => "checkbox"
);
$gridSAT->Columns[] = Array(
'title' => $intra->translate("Allowed?")
, 'field' => "satFlagEditable"
, 'type' => "checkbox"
);
$gridSAT->Columns[] = Array(
'title' => $intra->translate("In List?")
, 'field' => "satFlagShowInList"
, 'type' => "checkbox"
);
$sqlSAT = "SELECT * FROM stbl_attribute
LEFT OUTER JOIN stbl_status_attribute ON atrID=satAttributeID AND satStatusID='$staID' AND satEntityID='$entID'
WHERE atrEntityID='$entID'
ORDER BY atrOrder";
$rsSAT = $oSQL->do_query($sqlSAT);
while ($rwSAT = $oSQL->fetch_array($rsSAT)){
$rwSAT['atrID_'] = $rwSAT['atrID'];
$rwSAT["satAllowed"] = ($rwSAT["satID"] ? "1" : "0");
$gridSAT->Rows[] = $rwSAT;
}
$gridSAT->Execute();
?>
</td>
</tr>
<?php
if ($intra->arrUsrData["FlagWrite"]){ ?>
<tr>
<td colspan="2" align="center">
<input type="submit" value="<?php echo $intra->translate('Save') ?>" class="eiseIntraSubmit">
</td>
</tr>
<?php
} ?>
</table>
</fieldset>
</form>
<?php
include eiseIntraAbsolutePath."inc_bottom.php";
?>