URL:
http://www.scic.com/files/website_gatekeeper/index.htmlI'm the master-detail example and cannot access the data in the form in the saveItem() function, the save_gatekeeper and update_gatekeeper call DO NOT get any parameters.
Here is the code for the show_form.php file:
<?php
$x = $_REQUEST['IND'];
$pc = $_REQUEST['PC'];
$st = $_REQUEST['ST'];
$typ = $_REQUEST['TYP'];
$us_states = array(
'OL' => 'OL',
'WB' => 'WB',
'AL' => 'Alabama',
'AK' => 'Alaska',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DE' => 'Delaware',
'DC' => 'District of Columbia',
'FL' => 'Florida',
'GA' => 'Georgia',
'HI' => 'Hawaii',
'ID' => 'Idaho',
'IL' => 'Illinois',
'IN' => 'Indiana',
'IA' => 'Iowa',
'KS' => 'Kansas',
'KY' => 'Kentucky',
'LA' => 'Louisiana',
'ME' => 'Maine',
'MD' => 'Maryland',
'MA' => 'Massachusetts',
'MI' => 'Michigan',
'MN' => 'Minnesota',
'MS' => 'Mississippi',
'MO' => 'Missouri',
'MT' => 'Montana',
'NE' => 'Nebraska',
'NV' => 'Nevada',
'NH' => 'New Hampshire',
'NJ' => 'New Jersey',
'NM' => 'New Mexico',
'NY' => 'New York',
'NC' => 'North Carolina',
'ND' => 'North Dakota',
'OH' => 'Ohio',
'OK' => 'Oklahoma',
'OR' => 'Oregon',
'PA' => 'Pennsylvania',
'PR' => 'Puerto Rico',
'RI' => 'Rhode Island',
'SC' => 'South Carolina',
'SD' => 'South Dakota',
'TN' => 'Tennessee',
'TX' => 'Texas',
'UT' => 'Utah',
'VI' => 'US Virgin Islands',
'VT' => 'Vermont',
'VA' => 'Virginia',
'WA' => 'Washington',
'WV' => 'West Virginia',
'WI' => 'Wisconsin',
'WY' => 'Wyoming'
);
?>
<form method="POST" >
<table class="dv-table" style="width:100%;background:#fafafa;padding:5px;margin-top:5px;">
<tr>
<td>Program Code</td>
<td><input name="prg_code" id="PRG_CODE" class="easyui-validatebox" required="true" value="<?php echo $pc; ?>" /></td>
<td>State</td>
<td>
<select class="unstyled" required="true" name="state" id="">
<?php
foreach($us_states as $key => $value) {
?>
<option value="<?php echo $key; ?>" <?php echo ($key==$st? "selected":"") ?>><?php echo $value;?></option>
<?php
}
?>
</select>
</td>
<td>Course Type</td>
<td>
<select required="true" name="type">
<option value="0" <?php echo ($typ=="0"? "selected":""); ?>>Online</option>
<option value="1" <?php echo ($typ=="1"? "selected":""); ?>>Classroom</option>
<option value="2" <?php echo ($typ=="2"? "selected":""); ?>>Webinar</option>
</select>
</td>
</tr>
<tr>
<td colspan="6">Text</td>
</tr>
<tr>
<td colspan="6"><textarea id="text_<?php echo $x;?>" class="jha_ta" cols="110" rows="25"></textarea></td>
</tr>
</table>
<div style="padding:5px 0;text-align:right;padding-right:30px">
<a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="saveItem(<?php echo $x;?>)">Save</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="cancelItem(<?php echo $x;?>)">Cancel</a>
</div>
</form>
Here's the code for the update_gatekeeper.php file:
<?php
$id = intval($_POST['id']);
$prg_code = $_POST['prg_code'];
$state = $_POST['state'];
$course_type = $_POST['type'];
$text = $_POST['text'];
if(strpos($_SERVER['SERVER_NAME'], 'localhost') > -1) {
require_once($_SERVER['DOCUMENT_ROOT'] ."/db_mysql.php");
} else {
require_once($_SERVER['DOCUMENT_ROOT'] . "/store/ajax/db_mysql.php");
}
$sql = "UPDATE exp_website_gk_text a, exp_website_gk_state b " .
"SET a.wgt_text = '".$text."', a.wgt_prg_code = '".$prg_code."', b.wgs_state = '".$state."', b.wgs_type type = ".$course_type.
" WHERE a.wgt_rid = ". $id." AND a.WGT_RID = b.wgs_wgt_rid";
$result = Db::getInstance()->returnQuery($sql, MYSQL_ASSOC);
echo json_encode(array(
'id' => $id,
'prg_code' => $prg_code,
'state' => $state,
'type' => $course_type,
'text' => $text
));
?>
And here's the code for the save_gatekeeper.php file:
<?php
$id = intval($_POST['id']);
$prg_code = $_POST['prg_code'];
$state = $_POST['state'];
$course_type = $_POST['type'];
$text = $_POST['text'];
if(strpos($_SERVER['SERVER_NAME'], 'localhost') > -1) {
require_once($_SERVER['DOCUMENT_ROOT'] ."/db_mysql.php");
} else {
require_once($_SERVER['DOCUMENT_ROOT'] . "/store/ajax/db_mysql.php");
}
$sql = "BEGIN; ".
"INSERT INTO exp_website_gk_text (WGT_PRG_CODE, WGT_TEXT) ".
" VALUES('".$prg_code."', '".$text."'); " .
"INSERT INTO exp_website_gk_state (WGS_STATE, WGS_TYPE, WGS_WGT_RID) ".
" VALUES('".$state."', ".$course_type.", LAST_INSERT_ID()); ".
"COMMIT;";
$result = Db::getInstance()->query($sql);
$sql = "SELECT WGS_WGT_RID id FROM exp_website_gk_text WHERE WGS_RID = ".mysql_insert_id();
$result = Db::getInstance()->returnQuery($sql, MYSQL_ASSOC);
echo json_encode(array(
'id' => $result["id"],
'prg_code' => $prg_code,
'state' => $state,
'type' => $course_type,
'text' => $text
));
?>