| Server IP : 104.21.21.239 / Your IP : 216.73.217.123 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.7 System : Linux ip-172-31-69-123.ec2.internal 6.1.177-224.371.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 27 20:28:29 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/hotel-dev/public_html/mod/ |
Upload File : |
<?php include('_mod_security.php'); ?>
<?php
form_prep('users', 'basic_info');
if ($_POST['ajax_event_submitted'] == '1') :
form_reload_check();
if (isset($_POST['active_tab'])) :
$active_tab = $_POST['active_tab'];
else :
$active_tab = 'basic_info';
endif;
$ar_err = array();
form_validate('user_name', 'string', true);
form_validate('full_name', 'string', true);
if (empty($_POST['password']) && $action == "Add New") :
$ar_err['password'] = 'Password is required!';
$err_flag = true;
$err_tab = 'basic_info';
endif;
if (!empty($_POST['password']) || !empty($_POST['password2'])) :
if ($_POST['password'] != $_POST['password2']) :
$ar_err['password2'] = 'Passwords do not match!';
$err_flag = true;
$err_tab = 'basic_info';
endif;
endif;
if (!$err_flag) :
$str_password_sql = '';
if (!empty($_POST['password']) || !empty($_POST['password2'])) :
$_POST['password_expired'] = 1;
$str_password_sql = "password = ".$db->quote(trim(password_hash($_POST['password'], PASSWORD_BCRYPT))).", ";
endif;
if (empty($_SESSION[$_POST['session_id']]['roles'])) :
$_SESSION[$_POST['session_id']]['roles'] = array();
endif;
$ar_combined_roles = array_unique(array_merge($_SESSION[$_POST['session_id']]['roles'], array('driver')));
$set = "user_name = ".$db->quote(trim($_POST['user_name'])).", ".
"full_name = ".$db->quote(trim($_POST['full_name'])).", ".
"email = ".$db->quote(trim($_POST['email'])).", ".
$str_password_sql.
"roles = ".$db->quote(trim(implode(',',$ar_combined_roles))).", ".
"active = ".nz(trim($_POST['active']),'0').", ".
"password_expired = ".nz(trim($_POST['password_expired']),'0').", ".
sql_set_update();
if ($action == 'Edit') :
$sql = "UPDATE sys_users set ".$set.
"WHERE user_id = ".nz(trim($_REQUEST['id']), '0')." ";
$db->query($sql) or die('Database Error!');
post_set_update();
else :
if ($action == 'Add New') :
$sql = "INSERT INTO sys_users SET ".
sql_set_create().
$set;
//echo '==='.$sql.'===';
$db->query($sql) or die('Database Error!');
$_REQUEST['id'] = last_id();
$_POST['user_id'] = $_REQUEST['id'];
post_set_create_update();
endif;
endif;
$form_message = "Saved sucessfully!";
form_uid_reset();
if ($_POST['xsubmit'] == 'Save & Close') :
echo "<SCRIPT>";
//echo "window.location.href = 'index.php?IX=".$_REQUEST['ref']."'";
echo "appstack_pop()";
echo "</SCRIPT>";
endif;
if ($_POST['xsubmit'] == 'Save & New') :
echo "<SCRIPT>";
echo "window.location.href = 'index.php?IX=user_form&ref=".urlencode($_REQUEST['ref'])."'";
echo "</SCRIPT>";
endif;
else :
$active_tab = $err_tab;
$form_message = "Errors found!";
endif;
else:
if ($action == 'Edit') :
$sql = "SELECT * FROM sys_users WHERE user_id = ".nz(trim($_REQUEST['id']), '0')." ";
$result = $db->query($sql) or die('Database Error!');
if ($result->rowCount() > 0) :
$row = $result->fetch(PDO::FETCH_OBJ);
$_POST['user_id'] = $row->user_id;
$_POST['user_name'] = $row->user_name;
$_POST['full_name'] = $row->full_name;
$_POST['email'] = $row->email;
$session_id = 'driver_form_'.time();
$_SESSION[$session_id]['roles'] = explode(',',$row->roles);
$_POST['session_id'] = $session_id;
//$_POST['roles'] = explode(',',$row->roles);
$_POST['active'] = $row->active;
$_POST['password_expired'] = $row->password_expired;
post_set_load_create_update();
else :
echo form_fatal_error('Invalid Operation!');
return;
endif;
else :
$_POST['active'] = 1;
$_POST['password_expired'] = 1;
endif;
endif;
?>
<script>
var active_page = '<?php echo $_REQUEST['IX']; ?>';
var active_tab = '';
update_route = function(route_id)
{
if ($('#route_' + route_id).prop('checked'))
{
var func = 'add';
}
else
{
var func = 'remove';
}
$.ajax({
url: "ajax.php?call=driver_routes_ajax&func=" + func + "&driver_id=<?php echo nz($_REQUEST['id'], '0'); ?>&route=" + route_id,
cache: false,
dataType: "json",
headers: {
"Accept": "application/json"
},
success: function(json) {
if (json.result == 'Success')
{
$('#ajax_result_msg').show().text('Updated');
setTimeout(function() {$('#ajax_result_msg').text('').hide(); }, 300);
}
else
{
alert(json.result);
}
}
,error: function (request, status, error) { alert(status + ", " + error); }
})
}
update_header = function()
{
if ($("#user_name").val() > "" && $("#full_name").val() > "" )
{
$("#header_repeater").text(" - " + $("#user_name").val() + ' - ' + $("#full_name").val());
}
}
$(document).ready(function()
{
switch_tab('<?php echo $active_tab; ?>');
update_header();
$(':input:not(.search)').change(function() {sheet_dirty = true; } );
}
)
</script>
<h1>Driver - <?php echo $action; ?><span id="header_repeater"></span></h1>
<?php echo form_message($form_message); ?>
<form style="" name="frm_user" id="frm_user" method="post" action="">
<input name="ajax_event_submitted" type="hidden" value="1" />
<input name="id" type="hidden" value="<?php echo $_REQUEST['id']; ?>" />
<input name="active_tab" id="active_tab" type="hidden" value="basic_info" />
<input name="session_id" type="hidden" value="<?php echo $_POST['session_id']; ?>" />
<?php form_button_strip('top'); ?>
<div class="tab_strip">
<div id="ajax_result_msg" class="ajax_result_msg"></div>
<?php
form_tab_header('basic_info', 'Basic Info', 'distributor');
if (!empty($_REQUEST['id'])) :
form_tab_header('routes', 'Routes', 'distributor');
endif;
?>
</div>
<div class="cleardiv">
</div>
<div class="tab_content" id="tab_content_basic_info">
<div class="form_header">
Basic Info
</div>
<div class="input_column">
<?php
form_field('user_id', 'text', 50, 0, false, false, true, '', '', 'user_id', 'User ID');
form_field('user_name', 'text', 50, 0, true, false, false, '', '', 'user_name', 'User Login Name', array(), '', 'update_header();');
form_field('full_name', 'text', 50, 0, true, false, false, '', '', 'full_name', 'Full Name', array(), '', 'update_header();');
form_field('email', 'text', 50, 0, false, false, false, '', '', 'email', 'Email');
form_field('password', 'password', 50, 0, false, false, false, '', '', 'password', 'Password');
form_field('password2', 'password', 50, 0, false, false, false, '', '', 'password2', 'Re-enter Password');
?>
</div>
<div class="input_column">
<?php
form_field('active', 'checkbox', 50, 0, false, false, false, '', '', 'active', 'Active');
form_field('password_expired', 'checkbox', 50, 0, false, false, false, '', '', 'password_expired', 'Password Expired');
?>
</div>
</div>
<!-- -------------------------------------------------------------------------------------------------------------- -->
<?php
if (!empty($_REQUEST['id'])) :
?>
<!-- -------------------------------------------------------------------------------------------------------------- -->
<div class="tab_content" id="tab_content_routes">
<div class="form_header">
Routes
</div>
<?php
$ix_form = 'route_form&route_id='.trim($_REQUEST['id']);
db_navigator_bar(array('table_id'=>'db_grid_routes', 'form'=>$ix_form, 'print_section'=>'db_grid_hotels', 'call'=>'driver_routes_ajax', 'sort_col'=>'1', 'sort_order'=>'0', 'subtab'=>'true', 'parm1'=>"", 'func'=>'grid' ));
?>
</div>
<!-- -------------------------------------------------------------------------------------------------------------- -->
<?php
endif;
?>
<?php form_button_strip('bottom'); ?>
</form>