| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/onesupportsys.onesolution.hk/profile/views/ |
Upload File : |
<!--
<?php
if (!Util::isAdmin()) {
header("Location: ../index.php");
exit;
}
$sql = "SELECT * FROM customerProfile";
$parameters = array(0);
if (!($sth = $dbh->prepare($sql))) {
throw new Exception("sql prepare statement failure: $sql");
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
if (!$sth->execute($parameters)) {
throw new Exception("sql execute statement failure: $sql");
}
$customers = $sth->fetchAll();
?>
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php require(__DIR__ . '/../../inc/_head_meta.php'); ?>
<?php require(__DIR__ . '/../../inc/_head_css.php'); ?>
<style type="text/css">
body {
padding-top: 60px;
/* 60px to make the container go all the way to the bottom of the topbar */
padding-bottom: 40px;
}
</style>
<?php require(__DIR__ . '/../../inc/_head_script.php'); ?>
<style>
tbody>tr:hover {
background-color: teal;
color:white;
}
</style>
<script type="text/javascript">
$(function () {
$('.select2').select2();
});
</script>
</head>
<body>
<?php require(__DIR__ . '/../../inc/_navbar.php'); ?>
<div class="container">
<?php if (isset($message) && !empty($message)): ?>
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<h5 class="alert-heading">Note:</h5>
<p>
<?= $message ?>
</p>
</div>
<?php endif; ?>
<!-- <h2><?= empty($customer['cust_id']) ? 'Add' : 'Modify' ?> Customer Profile</h2> -->
<h3>Maintain Customer Profile </h3>
<form id="form" class="form-horizontal" method="post">
<?php $attribute = 'id'; ?>
<input type="hidden" name="<?= $attribute ?>" value="<?= h($customer[$attribute]) ?>" />
<?php $attribute = 'customer_id'; ?>
<input type="hidden" name="<?= $attribute ?>" value="<?= h($customer[$attribute]) ?>" />
<div class="control-group">
<?php $attribute = 'device_type';
$label = 'Device Type'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<select id="<?= $attribute ?>" name="<?= $attribute ?>" placeholder="Select a <?= $label ?>"
class="select2">
<option value=""></option>
<?php
$_device_types = lookuplist::selectOptions('deviceType');
foreach ($_device_types as $_device_type):
?>
<option value="<?= h($_device_type['val']) ?>" <?= $_device_type['val'] == $customer[$attribute] ? ' selected="selected"' : '' ?>>
<?= h($_device_type['txt']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="control-group">
<?php $attribute = 'location';
$label = 'Location'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>" class="span6"
placeholder="<?= $label ?>"><?= h($customer[$attribute]) ?></textarea>
</div>
</div>
<div class="control-group">
<?php $attribute = 'ip_address';
$label = 'IP address'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>"
value="<?= h($customer[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
<div class="control-group">
<?php $attribute = 'mac_address';
$label = 'MAC Address'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>"
value="<?= h($customer[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
<div class="control-group">
<?php $attribute = 'port';
$label = 'Port No.'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>"
value="<?= h($customer[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
<div class="control-group">
<?php $attribute = 'domain_name';
$label = 'Domain Name'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>"
value="<?= h($customer[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
<div class="control-group">
<?php $attribute = 'device_name';
$label = 'Device Name'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>"
value="<?= h($customer[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
<div class="control-group">
<?php $attribute = 'function_text ';
$label = 'Function'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>" class="span6"
placeholder="<?= $label ?>"><?= h($customer[$attribute]) ?></textarea>
</div>
</div>
<div class="control-group">
<?php $attribute = 'remark';
$label = 'Remark'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>" class="span6"
placeholder="<?= $label ?>"><?= h($customer[$attribute]) ?></textarea>
</div>
</div>
<div class="control-group">
<?php $attribute = 'os_version';
$label = 'OS version'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>"
value="<?= h($customer[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
<div class="control-group">
<?php $attribute = 'other';
$label = 'Other'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>" class="span6"
placeholder="<?= $label ?>"><?= h($customer[$attribute]) ?></textarea>
</div>
</div>
<div class="control-group">
<?php $attribute = 'brand';
$label = 'Brand'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<select id="<?= $attribute ?>" name="<?= $attribute ?>" placeholder="Select a <?= $label ?>"
class="select2">
<option value=""></option>
<?php
$_brands = lookuplist::selectOptions('brand');
foreach ($_brands as $_brand):
?>
<option value="<?= h($_brand['val']) ?>" <?= $_brand['val'] == $customer[$attribute] ? ' selected="selected"' : '' ?>>
<?= h($_brand['txt']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="control-group">
<?php $attribute = 'model';
$label = 'Model'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>"
value="<?= h($customer[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
<div class="control-group">
<?php $attribute = 'serial_number';
$label = 'Serial Number'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>"
value="<?= h($customer[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
<div class="control-group">
<?php $attribute = 'processor';
$label = 'Processor'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>"
value="<?= h($customer[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
<div class="control-group">
<?php $attribute = 'ram';
$label = 'RAM'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>"
value="<?= h($customer[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
<div class="control-group">
<?php $attribute = 'disk_size';
$label = 'Disk Size'; ?>
<label class="control-label" for="<?= $attribute ?>">
<?= $label ?>
</label>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>" class="span6"
placeholder="<?= $label ?>"><?= h($customer[$attribute]) ?></textarea>
</div>
</div>
<div class="container">
<div class="controls">
<button type="submit" class="btn btn-primary" style="width:100px;">Save</button>
<button id="account" type="button" class="btn btn-danger <?= $customer['id'] == "0" ? " hidden" : "" ?>" style="width:100px;" data-bs-toggle="modal" data-bs-target="#edit" data-id="<?= $customer['id'] ?>">
Account
</button>
</div>
</div>
<!-- The Modal -->
<div id="myModal" class="modal" style="display: none;">
<div class="modal-header">
<div>
<span class="close">×</span>
<h4 class="modal-title" id="staticBackdropLabel">User Acccount Information</h4>
</div>
</div>
<!-- Modal content -->
<div class="modal-content" style="padding-top:10px;">
<div id="mHdr">
<div style="padding-left: 10px;padding-right: 10px;">
<p id="actionType" style="background-color:green;text-align:center;font-weight:900;color:white;">Addition</p>
</div>
</div>
<div id="mDtl">
<div style="padding-left: 10px;padding-right: 10px;">
<table id="tbl" class="table">
<thead>
<tr>
<th>Account For</th>
<th>Login Id</th>
<th class="hidden">Password</th>
<th class="hidden">id</th>
<th class="hidden">profile_id</th>
</tr>
</thead>
<tbody>
<!--
<tr>
<td>Doe</td>
<td>john@example.com</td>
<td class="hidden">Tai</td>
<td class="hidden">1</td>
<td class="hidden">20</td>
</tr>
<tr>
<td>Moe</td>
<td>mary@example.com</td>
<td class="hidden">Man</td>
<td class="hidden">2</td>
<td class="hidden">21</td>
</tr> -->
</tbody>
</table>
</div>
<input id="d_id" class="text hidden">
<input id="d_profile_id" class="text hidden" value="<?= $customer['id'] ?>">
<input id="d_profile_delete" class="text hidden" value="N">
<div class="control-group">
<label class="control-label" for="userFor">Account For</label>
<div class="controls">
<input type="text" id="userFor" name="userFor" value="" placeholder="Account For" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="loginId">Login ID</label>
<div class="controls">
<input type="text" id="loginId" name="loginId" value="" placeholder="Login ID" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="loginPw">Password</label>
<div class="controls">
<input type="text" id="loginPw" name="loginPw" value="" placeholder="Password" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" id="closeModal"
data-id="1" data-type="1">Close</button>
<button type="button" class="btn btn-warning" id="clearModal""
data-id="1" data-type="1">Clear</button>
<button type="button" class="btn btn-danger hidden" id="deleteModal">Delete</button>
<button type="button" class="btn btn-primary hidden" id="saveModal">Save</button>
</div>
</div>
</form>
<script type="text/javascript">
$(function () {
$('.select2').select2();
$('#form').validate({
rules: {
'loginpw': {
minlength: 4
},
'loginpw2': {
equalTo: '#loginpw'
}
}
});
});
$("#account").click(function () {
var profileId = $(this).attr('data-id');
$("#myModal").css("display", "block");
$.ajax({url: 'modify.php',
type: 'POST',
data:{ profileId:profileId,
actionCode:'R'
},
dataType: 'json',
timeout: 1000,
error: function(){
alert('Error loading PHP document');
/*
window.location.reload();},*/
},
success: function(result){
$(".table>tbody").empty();
console.log(Object.entries(result));
//alert(result.length);
for ( var i=0; i< result.length; i++ ) {
$(".table>tbody").append("<tr onclick=(myFunction(this))>" +
"<td>" + result[i]['account_for'] + "</td>" +
"<td>" + result[i]['login_id'] + "</td>" +
"<td class='hidden'>" + result[i]['login_pw'] + "</td>" +
"<td class='hidden'>" + result[i]['id'] + "</td>" +
"<td class='hidden'>" + result[i]['profile_id'] + "</td>" + "</tr>");
}
}
});
return false;
})
function getAccountList (profileId) {
$.ajax({url: 'modify.php',
type: 'POST',
data:{ profileId:profileId,
actionCode:'R'
},
dataType: 'json',
timeout: 1000,
error: function(){
alert('Error loading PHP document');
/*
window.location.reload();},*/
},
success: function(result){
$(".table>tbody").empty();
console.log(Object.entries(result));
//alert(result.length);
for ( var i=0; i< result.length; i++ ) {
$(".table>tbody").append("<tr onclick=(myFunction(this))>" +
"<td>" + result[i]['account_for'] + "</td>" +
"<td>" + result[i]['login_id'] + "</td>" +
"<td class='hidden'>" + result[i]['login_pw'] + "</td>" +
"<td class='hidden'>" + result[i]['id'] + "</td>" +
"<td class='hidden'>" + result[i]['profile_id'] + "</td>" + "</tr>");
}
}
});
}
$("#userFor, #loginId, #loginPw").change(function () {
if ( $("#userFor").val().length > 0 &&
$("#loginId").val().length > 0 &&
$("#loginPw").val().length > 0 ) {
$("#saveModal").removeClass("hidden");
} else {
$("#saveModal").addClass("hidden");
}
});
$("#deleteModal").click(function () {
if ( confirm("Are you sure you want to delete this record!") ) {
$("#d_profile_delete").val("Y");
$("#saveModal").click();
}
return false;
});
$("#saveModal").click(function () {
var profileId = $("#d_profile_id").val();
var userFor = $("#userFor").val();
var login_id = $("#loginId").val();
var login_pw = $("#loginPw").val();
var profile_delete = $("#d_profile_delete").val();
var id = $("#d_id").val();
id = id == "" ? "0" : id;
$("#myModal").css("display", "block");
//alert(profileId + " - " + userFor + " - " + login_id + " - " + login_pw + " - " + id + " - " + profile_delete);
$.ajax({url: 'modify.php',
type: 'POST',
data:{ profile_id:$("#d_profile_id").val(),
account_for:$("#userFor").val(),
login_id:$("#loginId").val(),
login_pw:$("#loginPw").val(),
id:id,
actionCode:'S',
profile_delete:$("#d_profile_delete").val()
},
dataType: 'text',
timeout: 1000,
error: function(){
alert('Error loading PHP document');
/*
window.location.reload();},*/
},
success: function(result){
//$(".table>tbody").empty();
//alert($("#d_profile_id").val());
//alert(result);
getAccountList($("#d_profile_id").val());
$("#clearModal").click();
}
});
return false;
})
$(".close, #closeModal").click(function () {
$("#myModal").css("display", "none");
$("#clearModal").click();
})
$("#clearModal").click(function () {
$("#d_id").val("");
//$("#d_profile_id").val("");
$("#userFor").val("");
$("#loginId").val("");
$("#loginPw").val("");
$("#d_profile_delete").val("N");
$("#actionType").text("Addtion").css('background-color', 'green');
$("#saveModal, #deleteModal").addClass("hidden");
//clearHighlight();
})
//$("tr").click(function () {
// var currentRow = $(this);
// var col1 = currentRow.find("td:eq(0)").text(); // get current row 1st TD - User For
// var col2 = currentRow.find("td:eq(1)").text(); // get current row 2nd TD - Login id
// var col3 = currentRow.find("td:eq(2)").text(); // get current row 3rd TD - Password
// var col4 = currentRow.find("td:eq(3)").text(); // get current row 4th TD - Table sequence Id
// var col5 = currentRow.find("td:eq(4)").text(); // get current row 5th TD - Customer Profile Id
// $("#userFor").val(col1);
// $("#loginId").val(col2);
// $("#loginPw").val(col3);
//});
function myFunction(x) {
//clearHighlight();
document.getElementById("userFor").value = x.getElementsByTagName("td")[0].innerHTML;
document.getElementById("loginId").value = x.getElementsByTagName("td")[1].innerHTML;
document.getElementById("loginPw").value = x.getElementsByTagName("td")[2].innerHTML;
document.getElementById("d_id").value = x.getElementsByTagName("td")[3].innerHTML;
document.getElementById("d_profile_id").value = x.getElementsByTagName("td")[4].innerHTML;
$("#actionType").text("Modification").css('background-color', 'red');
$("#deleteModal").removeClass("hidden");
//x.style.background = "#ffffb3";
}
function clearHighlight(){
var table = document.getElementById('tbl');
for (var i=0;i < table.rows.length;i++){
var row = table.rows[i];
row.style.background ="white";
}
}
</script>
<?php require(__DIR__ . '/../../inc/_footer.php'); ?>
</div> <!-- /container -->
</body>
</html>