| 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/onesupportdemo.onesolution.hk/customerProfile/views/ |
Upload File : |
<?php
require_once(__DIR__ . '/../../checkuser.php');
$id = $_GET["id"];
?>
<!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;
}
.actLst>tbody>tr:hover {
background-color: teal;
color:white;
}
.actMain>tbody>tr>td,
.actMain>tbody>tr{
border-top:none;
border-spacing:0px;
}
</style>
<?php require(__DIR__ . '/../../inc/_head_script.php'); ?>
<script type="text/javascript">
$(function () {
$('#search_btn').click(function (event) {
event.preventDefault();
$('#search_form').toggle();
});
$('.date-picker').datetimepicker({ pickTime: false });
$('.time-picker').datetimepicker({ pickDate: false, pickSeconds: false });
$('.select2').select2();
$('#search_form').validate();
});
</script>
</head>
<body>
<?php require(__DIR__ . '/../../inc/_navbar.php'); ?>
<div class="container">
<?php if (isset($_GET["message"]) && !empty($_GET["message"])): ?>
<div class="alert alert-info">
<button id="closeButton" type="button" class="close" data-dismiss="alert">×</button>
<h5 class="alert-heading">Note:</h5>
<p><?= $_GET["message"] ?></p>
</div>
<?php endif; ?>
<?php
$sql = "SELECT * FROM customerProfile WHERE customer_id = ? and status = 0";
//$parameters = array($id);
//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");
//}
//$cpProfile = $sth->fetchAll();
$cpProfile = tableInfo::recordData($sql, $id, "Y");
$sql = "SELECT * FROM v_cm_customer_support WHERE cust_id = ?";
$customer = tableInfo::recordData($sql, $id, "Y");
//var_dump($customer);
//var_dump($customer[0]["company_name"]);
?>
<h4>Profile Listing for customer [ <?php echo $customer[0]["company_name"] ?> ] </h4>
<div style="padding-bottom: 50px;">
<!--<a href="add.php?addProfile=1&id=<?= $id ?>" class="btn btn-primary">New Device</a>-->
<form id="profile_<?= $id ?>" name="profile_<?= $id ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="cust_id" value="<?= $id ?>"/>
<input type="hidden" id="formAction" name="formAction" value="modify"/>
<table class="table table-striped">
<thead>
<tr>
<th>Device Type</th>
<th>Location</th>
<th>Login Info</th>
<th>IP</th>
<th>Mac_Addr</th>
<th>Port</th>
<th>Domain</th>
<th>Device Name</th>
<th>Function</th>
<th>Remark</th>
<th>OS_Version</th>
<th>Other</th>
<th>Brand</th>
<th>Model</th>
<th>Serial Number</th>
<th>Processor</th>
<th>RAM</th>
<th>HDD Size</th>
</tr>
</thead>
<tbody>
<?php
foreach ($cpProfile as $cp){
?>
<tr>
<td>
<input type="hidden" name="line_id[]" value="<?= $cp["id"] ?>"/>
<div class="control-group">
<?php $attribute = 'device_type';
$deviceText = "";
$label = 'Device Type'; ?>
<div class="controls">
<select id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]" 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'] == $cp[$attribute] ? ' selected="selected"' : '' ?>>
<?= h($_device_type['txt']) ?>
</option>
<?php $deviceText = $_device_type['val'] == $cp[$attribute] && $deviceText == "" ? h($_device_type['txt']) : $deviceText ?>
<?php endforeach; ?>
</select>
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'location';
$label = 'Location'; ?>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]" class="span4"
placeholder="<?= $label ?>"><?= h($cp[$attribute]) ?></textarea>
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $label = 'Account'; ?>
<div class="controls">
<button id="account_<?= $cp['id'] ?>" type="button" class="btn btn-default" data-bs-toggle="modal" data-bs-target="#edit" data-id="<?= $cp['id'] ?>">Account
</button>
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'ip_address';
$label = 'IP address'; ?>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'mac_address';
$label = 'MAC Address'; ?>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'port';
$label = 'Port No.'; ?>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'domain_name';
$label = 'Domain Name'; ?>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'device_name';
$label = 'Device Name'; ?>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'function_text';
$label = 'Function'; ?>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]" class="span4"
placeholder="<?= $label ?>"><?= h($cp[$attribute]) ?></textarea>
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'remark';
$label = 'Remark'; ?>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]" class="span4"
placeholder="<?= $label ?>"><?= h($cp[$attribute]) ?></textarea>
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'os_version';
$label = 'OS version'; ?>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'other';
$label = 'Other'; ?>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]" class="span4"
placeholder="<?= $label ?>"><?= h($cp[$attribute]) ?></textarea>
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'brand';
$label = 'Brand'; ?>
<div class="controls">
<select id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]" 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'] == $cp[$attribute] ? ' selected="selected"' : '' ?>>
<?= h($_brand['txt']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'model';
$label = 'Model'; ?>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'serial_number';
$label = 'Serial Number'; ?>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'processor';
$label = 'Processor'; ?>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
</td>
</td>
<td>
<div class="control-group">
<?php $attribute = 'ram';
$label = 'RAM'; ?>
<div class="controls">
<input type="text" id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
</div>
</div>
</td>
<td>
<div class="control-group">
<?php $attribute = 'disk_size';
$label = 'Disk Size'; ?>
<div class="controls">
<textarea id="<?= $attribute ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]" class="span4"
placeholder="<?= $label ?>"><?= h($cp[$attribute]) ?></textarea>
</div>
</div>
</td>
<td>
<?php $attribute = 'status';
$label = 'Status'; ?>
<input type="hidden" id="<?= $attribute ?>_<?= $cp["id"] ?>" name="<?= $attribute ?>[<?= $cp["id"] ?>]"
value="<?= h($cp[$attribute]) ?>" placeholder="<?= $label ?>" />
<button type="submit" class="btn btn-danger"
onclick="var r=confirm('Are you sure to delete this line for [ <?php echo $deviceText?> ] ?');
if (r==true) {
$('#<?= $attribute . '_' . $cp['id'] ?>').val(1);
return true;
};
return false;">X</button>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="19">
<button type="submit" class="btn btn-primary"
onclick="var r=confirm('Are you sure to add new device?');
if (r==true) {
$('#formAction').val('Add');
return true;
};
return false;">New Device
</button>
<button type="submit" class="btn btn-danger">Save</button>
</td>
</tr>
</tbody>
</table>
</form>
</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 Account 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 actLst">
<thead>
<tr>
<th>Account For</th>
<th>Login Id</th>
<th>Password</th>
<th class="hidden">id</th>
<th class="hidden">profile_id</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div>
<input id="d_id" class="text hidden">
<input id="d_profile_id" class="text hidden" >
<input id="d_profile_delete" class="text hidden" value="N">
</div>
<div style="padding: 15px 10px 10px 10px;">
<table id="mId" class="table actMain">
<tr>
<td>
<label class="control-label pull-right" for="userFor">Account For</label>
</td>
<td>
<input type="text" id="userFor" name="userFor" value="" placeholder="Account For" />
</td>
</tr>
<tr>
<td>
<label class="control-label pull-right" for="loginId">Login ID</label>
</td>
<td>
<input type="text" id="loginId" name="loginId" value="" placeholder="Login ID" />
</td>
</tr>
<tr>
<td>
<label class="control-label pull-right" for="loginPw">Password</label>
</td>
<td>
<input type="text" id="loginPw" name="loginPw" value="" placeholder="Password" />
</td>
</tr>
</table>
</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>
</body>
</html>
<script type="text/javascript">
$(function () {
$('.select2').select2();
$('#form').validate({
rules: {
'loginpw': {
minlength: 4
},
'loginpw2': {
equalTo: '#loginpw'
}
}
});
});
$('table').click(function () {
$("#closeButton").click();
});
$('[id^=account_]').click(function () {
var profileId = $(this).attr('data-id');
$("#d_profile_id").val(profileId);
$("#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){
$("#tbl.table>tbody").empty();
console.log(Object.entries(result));
//alert(result.length);
for ( var i=0; i< result.length; i++ ) {
$("#tbl.table>tbody").append("<tr onclick=(myFunction(this))>" +
"<td>" + result[i]['account_for'] + "</td>" +
"<td>" + result[i]['login_id'] + "</td>" +
"<td>" + 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) {
//alert(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){
//alert(result);
$(".actLst>tbody").empty();
console.log(Object.entries(result));
//alert(result.length);
for ( var i=0; i< result.length; i++ ) {
$(".actLst>tbody").append("<tr onclick=(myFunction(this))>" +
"<td>" + result[i]['account_for'] + "</td>" +
"<td>" + result[i]['login_id'] + "</td>" +
"<td>" + 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>