function build_edit_emergency_popup($id) { $db_functions_obj = new DbFunctions(); $helper_obj = new Helper(); $emergency_info = $db_functions_obj->get_emergency_by_id($id); global $base_path; $operator = new Operator(); $output = "<div class='popup-header'>" . $helper_obj->t("Edit Emergency Call") . "</div>"; $output .= "<form class='form-horizontal form-validate form-vertical form-bordered' name='edit_emergency' id='edit_emergency' method='post' action='{$base_path}" . "edit_emergency'>"; $output .= "<div class='control-group'>\n <label class='control-label' for='textarea'>name</label>\n <div class='controls'>\n <input id='textfield' class='input-xlarge' type='text' data-rule-required='true' value='{$emergency_info->name}' placeholder='{$emergency_info->name}' name='name'>\n </div>\n </div>"; $output .= "<div class='control-group'>\n <label class='control-label' for='numberfield'>phone</label>\n <div class='controls'>\n <input id='numberfield' class='input-xlarge' type='text' data-rule-number='true' data-rule-required='true' value='{$emergency_info->phone}' placeholder='{$emergency_info->phone}' name='phone'>\n </div>\n </div>"; $output .= $operator->build_country_list('emergency', $emergency_info->country_id); $output .= "<input type='hidden' name='emergency_id' value='" . $emergency_info->id . "'>"; $output .= "<input class='btn btn-primary' type='submit' value='" . $helper_obj->t("Save") . "'>"; $output .= "</form>"; $output .= "<script>\n \$(document).ready(function() { \n \$(\"#emergency_textfield\").datepicker(); \n \n \$('#edit_emergency').ajaxForm(function(res) { \n var isvalid = \$(\"#edit_emergency\").valid();\n if (isvalid) { \n var data = res.split(\"***#***\"); \n \$('#emergency_' + data[1]).after(data[0]);\n \$('#emergency_' + data[1]).remove(); \n closePopup();\n } \n }); \n });\n </script>"; return $output; }
function edit_emergency() { $emergency_obj = new EmergencyCalls(); $db_functions_obj = new DbFunctions(); $helper_obj = new Helper(); global $user; $rid = $user['rid']; //only super admin can delete hidt if ($helper_obj->user_is_logged_in() && $helper_obj->check_role(SUPER_ADMIN_ROLE_ID)) { $db_functions_obj->edit_emergency($_POST['emergency_id'], $_POST['name'], $_POST['phone'], $_POST['emergency_country']); $emergency_info = $db_functions_obj->get_emergency_by_id($_POST['emergency_id']); echo $emergency_obj->build_emergency_row($_POST['emergency_id']) . "***#***" . $_POST['emergency_id']; } else { $this->set_access_denied(1); } exit; }