This commit is contained in:
pbao9
2026-01-30 10:49:48 +07:00
parent 891fe5d161
commit 68ee544ecb
137 changed files with 12519 additions and 695 deletions
@@ -0,0 +1,110 @@
<div class="modal fade" id="AddonModal" tabindex="-1" role="dialog" aria-labelledby="AddonModal" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="AddonModal">Add new Addon to Product Service</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="box-append__element"></div>
<div class="row row-order_id form-group">
<label for="Order" class="col-md-4">Order ID:</label>
<div class="col-md-8">
<select name="order_id" class="form-control" id="Order">
<option value="0">New Order</option>
<option value="{{ $product->order_id }}">{{ $product->order_id }}</option>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-access__addon btn-primary">Confirm</button>
</div>
</div>
</div>
</div>
@push('scripts')
<script>
$('.btn-trigger__addon').click(function (){
$.get('{{route('api.GetAddonProduct')}}',{product: {{$product->id}}})
.done(function (response){
if (response.error === false)
{
$('.box-append__element').empty().append(response.data)
} else {
console.log(response)
}
})
.catch(function (error){
console.log(error)
})
})
$('.btn-access__addon').click(function (){
let body = $('body');
let order = body.find('#AddonModal #Order option:selected').val()
let addOnCPU = Number(body.find('#AddonModal #cpu').val())
let addOnRAM = Number(body.find('#AddonModal #ram').val())
let addOnSSD = Number(body.find('#AddonModal #ssd').val())
if(addOnCPU === 0 && addOnRAM === 0 && addOnSSD === 0)
{
Swal.fire({
title: "Opp...",
text: 'Invalid Request',
icon: 'error',
confirmButtonColor: "red",
confirmButtonText: "Confirm"
})
return false;
}
$.ajax({
url: '{{route('api.AcceptAddon')}}',
data: {
order: order,
cpu: addOnCPU,
ram: addOnRAM,
ssd: addOnSSD,
product: {{$product->id}}
},
type: 'post',
beforeSend: function (){
swal.fire(
{
html: sweet_loader + "<h4>Please waiting ...</h4>",
showConfirmButton: false
}
)
},
success: function (response)
{
if (response.error === false) {
Swal.fire({
title: "Thành công",
text: response.message,
icon: "success",
confirmButtonColor: "#28a745",
confirmButtonText: "Xác nhận"
}).then((result) => {
if (result.isConfirmed) {
location.reload()
}
});
} else {
Swal.fire({
title: "Opp...",
text: response.message,
icon: 'error',
confirmButtonColor: "#28a745",
confirmButtonText: "Xác nhận"
})
}
}
})
})
</script>
@endpush
@@ -0,0 +1,33 @@
<div class="row form-group">
<div class="col">
<select class="custom-select" name="change-product">
@foreach($allService as $item)
@php
$productName = $item->description ?? 'Product #' . $item->product_id;
@endphp
<option value="{{ $item->product_id.'|'.$item->product_type }}"
data-url="{{ route('customer.product',['userid' => $userid,'product' => $item->product_id,'type' => $item->product_type]) }}"
@selected($product && "$product->id|$type" === "$item->product_id|$item->product_type")>
{{ $productName }}
</option>
@endforeach
</select>
</div>
@if($product)
@switch($type)
@case(3)
<a href="{{ $product->Server ? "https://".$product->Server->name.":8880" : "" }}"
target="_blank"
class="btn bg-gradient-success">Login with Panel</a>
@break
@case(4)
<button
data-toggle="modal"
data-target="#AddonModal"
class="btn btn-trigger__addon bg-gradient-success">Add new addon
</button>
@break
@endswitch
@endif
</div>
@@ -0,0 +1,123 @@
@extends("admin.main")
@section("content")
@if(auth()->guard('admins')->user()->can("add customer"))
<div class="card card-outline card-primary">
<form action="{{ route('customer.store') }}" method="post">
@csrf
<div class="card-body">
<div class="row">
<div class="col">
{{--First name--}}
<div class="form-group row">
<label class="col-md-4" for="firstname">First Name</label>
<div class="col-md-8">
<input type="text" id="firstname" name="firstname" placeholder="First Name"
value="{{ old('firstname') }}" class="form-control">
</div>
</div>
{{--Last name--}}
<div class="form-group row">
<label class="col-md-4" for="lastname">Last Name</label>
<div class="col-md-8">
<input type="text" id="lastname" name="lastname" placeholder="Last Name"
value="{{ old('lastname') }}" class="form-control">
</div>
</div>
{{--Company--}}
<div class="form-group row">
<label class="col-md-4" for="company">Company</label>
<div class="col-md-8">
<input type="text" id="company" name="company" placeholder="Company"
value="{{ old('company') }}" class="form-control">
</div>
</div>
{{--Email--}}
<div class="form-group row">
<label class="col-md-4" for="email">Email Address</label>
<div class="col-md-8">
<input type="email" id="email" name="email" placeholder="Email Address"
value="{{ old('email') }}" class="form-control">
</div>
</div>
{{--Phone--}}
<div class="form-group row">
<label class="col-md-4" for="phone">Phone Number</label>
<div class="col-md-8">
<input type="text" id="phone" name="phone" placeholder="(+84) 123. 456. 789)"
value="{{ old('phone') }}" class="form-control">
</div>
</div>
{{--Password--}}
<div class="form-group row">
<label class="col-md-4" for="password">Password</label>
<div class="col-md-8">
<input type="password" id="password" name="password" placeholder="******"
value="{{ old('password') }}" class="form-control">
</div>
</div>
</div>
<div class="col">
{{--Address--}}
<div class="form-group row">
<label class="col-md-4" for="address">Address</label>
<div class="col-md-8">
<input type="text" id="address" name="address" placeholder="Address"
value="{{ old('address') }}" class="form-control">
</div>
</div>
{{--City--}}
<div class="form-group row">
<label class="col-md-4" for="city">City</label>
<div class="col-md-8">
<input type="text" id="city" name="city" placeholder="City"
value="{{ old('city') }}" class="form-control">
</div>
</div>
{{--State--}}
<div class="form-group row">
<label class="col-md-4" for="state">State</label>
<div class="col-md-8">
<input type="text" id="state" name="state" placeholder="State"
value="{{ old('state') }}" class="form-control">
</div>
</div>
{{--Postcode--}}
<div class="form-group row">
<label class="col-md-4" for="postcode">Postcode</label>
<div class="col-md-8">
<input type="text" id="postcode" name="postcode" placeholder="Postcode"
value="{{ old('postcode') }}" class="form-control">
</div>
</div>
{{--Country--}}
<div class="form-group row">
<label class="col-md-4" for="country">Country</label>
<div class="col-md-8">
<input type="text" id="country" name="country" placeholder="Country"
value="{{ old('country') }}" class="form-control">
</div>
</div>
{{--Password--}}
<div class="form-group row">
<label class="col-md-4" for="email_marketing">Marketing Emails Opt-in</label>
<div class="col-md-8">
<input type="checkbox" name="email_marketing" id="email_marketing" @checked(old('email_marketing') === "on")>
Send Client Marketing Emails
</div>
</div>
</div>
</div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-outline-primary">Save</button>
</div>
</form>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection
@@ -0,0 +1,69 @@
@extends("admin.main")
@section("content")
@if(auth()->guard('admins')->user()->can("edit customer"))
<div class="card card-outline card-primary">
<div class="card-header">
@include("admin.block.nav")
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<form action="{{ route('customer.addPayStore',['userid' => $userid]) }}" method="post">
@csrf
@method('put')
<div class="card-body">
<div class="row">
<div class="col">
<h3>Add Amount</h3>
<hr>
<input type="hidden" name="action" value="+">
<div class="form-group row">
<label class="col-md-4" for="amount_add">Total</label>
<div class="col-md-8">
<input type="number" id="amount_add" name="amount" placeholder="0"
value="{{ old('amount') }}" class="form-control">
</div>
</div>
</div>
</div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-outline-primary">Save</button>
</div>
</form>
</div>
<div class="col-md-6">
<form action="{{ route('customer.addPayStore',['userid' => $userid]) }}" method="post">
@csrf
@method('put')
<div class="card-body">
<div class="row">
<div class="col">
<h3>Remove Amount</h3>
<hr>
<input type="hidden" name="action" value="-">
<div class="form-group row">
<label class="col-md-4" for="amount_remove">Total</label>
<div class="col-md-8">
<input type="number" id="amount_remove" name="amount" placeholder="0"
value="{{ old('amount') }}" class="form-control">
</div>
</div>
</div>
</div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-outline-primary">Save</button>
</div>
</form>
</div>
</div>
</div>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection
@@ -0,0 +1,273 @@
@extends('admin.main')
@push('style')
<link rel="stylesheet" href="{{ asset('lib/wmks/css/wmks-all.css') }}" />
<link rel="stylesheet" href="{{ asset('lib/adminlte/adminlte.css') }}">
<link rel="stylesheet" href="{{ asset('css/service/console.css') }}">
@endpush
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-12">
<!-- Header -->
<div class="card">
<div class="card-header">
<h3 class="card-title">VMware Console</h3>
<div class="card-tools">
<a href="{{ route('customer.product', ['userid' => $userid ?? 0, 'product' => $product->id ?? 0, 'type' => $type ?? 4]) }}"
class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Quay lại
</a>
</div>
</div>
<div class="card-body">
<p class="mb-0"><strong>VM:</strong> {{ $product->name ?? 'VM Console' }}</p>
</div>
</div>
<!-- Control Panel -->
<div class="card">
<div class="card-header">
<h5 class="card-title">Điều khiển Console</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6 mb-3">
<label for="sendStringText">Nhập văn bản:</label>
<input id="sendStringText" class="form-control" type="text"
placeholder="Nhập văn bản...">
</div>
<div class="col-md-6 mb-3">
<label>&nbsp;</label>
<div class="btn-group d-flex" role="group">
<button onclick="enterFullScreen()" class="btn btn-primary flex-fill">
<i class="fas fa-expand"></i> Toàn màn hình
</button>
<button onclick="sendCAD()" class="btn btn-success flex-fill">
<i class="fas fa-keyboard"></i> Ctrl+Alt+Del
</button>
<button onclick="sendInputString()" class="btn btn-info flex-fill">
<i class="fas fa-paper-plane"></i> Gửi văn bản
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Console Container -->
<div class="card">
<div class="card-body p-0 position-relative">
<!-- Loading State -->
<div id="loadingState"
class="loading-container d-flex align-items-center justify-content-center text-black fade-transition"
style="height: 70vh;">
<div class="text-center">
<!-- Modern Spinner -->
<div class="spinner-box">
<div class="three-quarter-spinner"></div>
</div>
<!-- Loading Text -->
<h4 class="mb-3 font-weight-bold">{{ __('Đang kết nối đến vCenter') }}</h4>
<p class="mb-4 text-light" id="loadingText">{{ __('Khởi tạo kết nối Console') }}
</p>
<!-- Loading Dots Animation -->
<div class="loading-dots justify-content-center">
<span></span>
<span></span>
<span></span>
</div>
<!-- Connection Status -->
<div class="mt-4">
<small class="text-dark opacity-75"
id="connectionStatus">{{ __('Đang thiết lập phiên làm việc...') }}</small>
</div>
</div>
</div>
<!-- Console Display -->
<div id="wmksContainer"
class="console-container d-flex justify-content-center align-items-center bg-dark fade-transition"
style="height: 70vh; opacity: 0; position: absolute; top: 0; left: 0; right: 0;">
</div>
</div>
</div>
</div>
</div>
</div>
<script src="{{ asset('lib/jquery/jquery.min.js') }}"></script>
<script src="{{ asset('lib/jquery-ui/jquery-ui.min.js') }}"></script>
<script src="{{ asset('lib/wmks/wmks.min.js') }}"></script>
<script src="{{ asset('lib/wmks/wmks-sdk-example.js') }}"></script>
<script type="text/javascript">
// Loading management variables
let loadingSteps = [
'{{ __('Khởi tạo kết nối...') }}',
'{{ __('Đang xác thực...') }}',
'{{ __('Thiết lập phiên làm việc...') }}',
'{{ __('Đang kết nối Console...') }}',
'{{ __('Sẵn sàng!') }}'
];
let currentStep = 0;
// Initialize loading state
$(document).ready(function() {
showLoadingState();
animateLoadingText();
});
// Show loading state with smooth animation
function showLoadingState() {
$('#loadingState').css('opacity', '1').show();
$('#wmksContainer').css('opacity', '0').hide();
}
// Hide loading state and show console
function hideLoadingAndShowConsole() {
$('#loadingText').text('{{ __('Kết nối thành công!') }}');
$('#connectionStatus').text('{{ __('Console đã sẵn sàng') }}');
setTimeout(() => {
$('#loadingState').animate({
opacity: 0
}, 400, function() {
$(this).hide();
$('#wmksContainer').show().animate({
opacity: 1
}, 400);
});
}, 800);
}
// Show error state
function showErrorState(errorMessage) {
$('#loadingState').animate({
opacity: 0
}, 300, function() {
$(this).hide();
$('#wmksContainer').html(`
<div class="d-flex align-items-center justify-content-center w-100 h-100">
<div class="text-center text-black">
<div class="mb-3">
<i class="fas fa-exclamation-triangle text-danger" style="font-size: 3rem;"></i>
</div>
<h5>{{ __('Kết nối thất bại') }}</h5>
<p class="text-muted">${errorMessage || '{{ __('Máy chủ không sẵn sàng hoặc có lỗi kết nối') }}'}</p>
<button onclick="location.reload()" class="btn btn-primary">
<i class="fas fa-redo"></i> {{ __('Thử lại') }}
</button>
</div>
</div>
`).show().animate({
opacity: 1
}, 400);
});
}
// Animate loading text through steps
function animateLoadingText() {
setInterval(() => {
if (currentStep < loadingSteps.length - 1) {
currentStep++;
$('#loadingText').fadeOut(200, function() {
$(this).text(loadingSteps[currentStep]).fadeIn(200);
});
}
}, 1500);
}
// Update connection status
function updateConnectionStatus(status) {
$('#connectionStatus').fadeOut(200, function() {
$(this).text(status).fadeIn(200);
});
}
let WMKSContainer = $('#wmksContainer');
var wmks = WMKS.createWMKS("wmksContainer", {})
.register(WMKS.CONST.Events.CONNECTION_STATE_CHANGE, function(event, data) {
if (data.state === WMKS.CONST.ConnectionState.CONNECTED) {
console.log("connection state change : connected");
// Hide loading when WMKS successfully connects
hideLoadingAndShowConsole();
}
});
const getTicket = new Promise((resolve, reject) => {
updateConnectionStatus('{{ __('Đang lấy ticket xác thực...') }}');
$.ajax({
url: '{{ route('api.GetConsoleTicket') }}',
type: 'get',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json',
'Authorization': 'Bearer {{ request()->cookie('accessToken') }}'
},
data: {
product: {{ $product->id ?? 0 }}
},
success: function(response) {
if (response.error === false) {
updateConnectionStatus('{{ __('Đang thiết lập kết nối Console...') }}');
resolve(response);
} else {
reject(response.message);
}
},
error: function(xhr, status, error) {
reject(`{{ __('Lỗi kết nối:') }} ${error}`);
}
});
});
getTicket
.then(result => {
if (result !== false) {
updateConnectionStatus('{{ __('Đang kết nối đến Console...') }}');
const wmksHost = '{{ config('vmware.wmks_host', '10.10.10.120') }}';
wmks.connect(`wss://${wmksHost}/ticket/${result.data}`);
}
})
.catch(error => {
console.log(`Có lỗi xảy ra: ${error}.`);
showErrorState(error);
});
// Console control functions
function enterFullScreen() {
if (wmks && wmks.canFullScreen()) {
wmks.enterFullScreen();
}
}
function sendCAD() {
if (wmks) {
wmks.sendCAD();
}
}
function sendInputString() {
const inputText = $('#sendStringText').val().trim();
if (inputText && wmks) {
wmks.sendInputString(inputText);
$('#sendStringText').val('');
} else if (!inputText) {
alert('{{ __('Vui lòng nhập văn bản cần gửi') }}');
}
}
// Enter key support for input field
$('#sendStringText').on('keypress', function(e) {
if (e.which == 13) {
sendInputString();
}
});
</script>
@endsection
@@ -0,0 +1,20 @@
@extends("admin.main")
@section("content")
@if(auth()->guard('admins')->user()->can("edit customer"))
<div class="card card-outline card-primary">
<div class="card-header">
@include("admin.block.nav")
</div>
<div class="card-body">
<div class="alert alert-warning" role="alert">
Feature in development
</div>
</div>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection
@@ -0,0 +1,120 @@
@php use Illuminate\Support\Carbon; @endphp
@php use App\Http\Helpers\Helper; @endphp
<div class="box clients-summary__box p-4">
<div class="row form-group">
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody>
<tr>
<td class="fieldlabel">Order #</td>
<td class="fieldarea">
<strong>{{ $product->Order->id }}</strong> -
<a href="{{ route('admin.order.edit', ['id' => $product->order->id]) }}">View Order</a>
</td>
<td class="fieldlabel">Registration Date</td>
<td class="fieldarea">
{!! Carbon::parse($product->Order->date)->format('d-m-Y') !!}
</td>
</tr>
<tr>
<td class="fieldlabel">Product/Service</td>
<td class="fieldarea">
@isset($productName->name)
{{ $productName->name }}
@endisset
</td>
<td class="fieldlabel">Quantity</td>
<td class="fieldarea"><strong>1</strong></td>
</tr>
<tr>
<td class="fieldlabel">Server</td>
<td class="fieldarea">
@if ($product->server)
{{ $product->server->name }}
@else
Not Found
@endif
</td>
<td class="fieldlabel">First Payment Amount</td>
<td class="fieldarea">
<input type="number" class="form-control" readonly name="first_payment"
value="{{ $product->first_payment }}" id="">
</td>
</tr>
<tr>
<td class="fieldlabel">Domain</td>
<td class="fieldarea">
<input type="text" class="form-control change-validate" placeholder="abc.com" name="name"
value="{{ $product->name }}" id="">
</td>
<td class="fieldlabel">Recurring Amount</td>
<td class="fieldarea">
<input type="number" class="form-control" readonly name="first_payment"
value="{{ $product->next_payment }}" id="">
</td>
</tr>
<tr>
<td class="fieldlabel">Billing Cycle</td>
<td class="fieldarea">
{!! $invoice_item ? $invoice_item->getBilling() : 'N/A' !!}
</td>
<td class="fieldlabel">Next Due Date</td>
<td class="fieldarea">
<input type="text" name="next_due_date" id="next_due_date"
class="form-control datetime-picker" placeholder="dd/mm/yy"
value=" {{ Carbon::parse($product->next_due_date)->format('d/m/Y') }}">
</td>
</tr>
<tr>
<td class="fieldlabel">Payment Method</td>
<td class="fieldarea">
{{ $product->Order->Payment->name }}
</td>
<td class="fieldlabel">Status</td>
<td class="fieldarea">
{!! $product->getStatus() !!}
</td>
</tr>
<tr>
<td class="fieldlabel">Username</td>
<td class="fieldarea">
<input type="text" class="form-control" name="username" value="{{ $product->username }}">
</td>
<td class="fieldlabel">Password</td>
<td class="fieldarea">
<input type="text" class="form-control" name="password"
value="{{ $product->password ? SignRSA::DecryptFunc($product->password) : '' }}">
</td>
</tr>
</tbody>
</table>
</div>
<div class="row form-group">
<div class="col">
<form action="{{ route('task.manager') }}" method="post">
@csrf
<input type="hidden" name="type" value="{{ $type }}">
<input type="hidden" name="product" value="{{ $product->id }}">
<input type="hidden" name="userid" value="{{ $userid }}">
<input type="hidden" name="domain" value="{{ $product->name }}">
<input type="hidden" name="action" value="create">
<button type="submit" {{ $product->status === 0 ? '' : 'disabled' }}
class="btn btn-block btn-outline-secondary">Create
</button>
</form>
</div>
<div class="col">
<button type="button" class="btn btn-block btn-outline-secondary">Suspend</button>
</div>
<div class="col">
<button type="button" class="btn btn-block btn-outline-secondary">Unsuspend</button>
</div>
<div class="col">
<button type="button" class="btn btn-block btn-outline-secondary">Change Password</button>
</div>
</div>
</div>
@@ -0,0 +1,569 @@
<script>
const productId = {{ $product->id }};
const vmId = '{{ $product->vmware_id }}';
// Cấu hình toast nếu có thể
if (typeof FuiToast !== 'undefined' && FuiToast.config) {
FuiToast.config({
position: 'top-center'
});
}
function showNotification(message, type = 'success') {
if (typeof FuiToast !== 'undefined') {
if (type === 'success') {
FuiToast.success(message);
} else {
FuiToast.error(message);
}
} else {
alert(message);
}
}
async function startVirtualMachine() {
const startBtn = document.getElementById('startVMButton');
if (startBtn.disabled) return;
const accessToken = '{{ request()->cookie('accessToken') }}';
if (!accessToken) {
showNotification('Chưa đăng nhập, vui lòng đăng nhập lại', 'error');
setTimeout(() => {
window.location.href = '/login';
}, 2000);
return;
}
const requestBody = {
vm_id: vmId
};
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Authorization': 'Bearer ' + accessToken
};
const startPromise = fetch('/api/v1/start-virtual-machine', {
method: 'POST',
headers: headers,
body: JSON.stringify(requestBody),
credentials: 'same-origin'
}).then(async (response) => {
if (response.redirected || response.status === 401) {
throw new Error('Phiên đăng nhập đã hết hạn, vui lòng đăng nhập lại');
}
let data;
try {
data = await response.json();
} catch (parseError) {
throw new Error('Lỗi định dạng dữ liệu từ máy chủ');
}
if (!data.error) {
setTimeout(() => {
location.reload();
}, 2000);
return data.message;
} else {
if (data.type === 'com.vmware.vapi.std.errors.already_in_desired_state' ||
(data.message && data.message.error_type === 'ALREADY_IN_DESIRED_STATE')) {
setTimeout(() => {
location.reload();
}, 2000);
return 'Máy chủ đã được bật';
} else {
let errorMessage = 'Có lỗi xảy ra';
if (data.message) {
if (typeof data.message === 'object') {
if (data.message.messages && data.message.messages.length > 0) {
errorMessage = data.message.messages[0].default_message || data.message
.messages[0]
.message || 'Có lỗi xảy ra';
} else if (data.message.error_type) {
errorMessage = `Lỗi: ${data.message.error_type}`;
} else {
errorMessage = 'Có lỗi xảy ra từ hệ thống';
}
} else {
errorMessage = data.message;
}
} else if (data.value && data.value.messages && data.value.messages.length > 0) {
errorMessage = data.value.messages[0].default_message;
} else if (typeof data === 'string') {
errorMessage = data;
} else if (data.error) {
if (typeof data.error === 'object') {
if (data.error.message) {
errorMessage = data.error.message;
} else if (data.error.toString && data.error.toString() !==
'[object Object]') {
errorMessage = data.error.toString();
} else {
errorMessage = 'Có lỗi xảy ra từ hệ thống';
}
} else {
errorMessage = data.error;
}
}
throw new Error(errorMessage);
}
}
});
if (typeof FuiToast !== 'undefined' && FuiToast.promise) {
FuiToast.promise(
startPromise, {
loading: 'Đang khởi động máy ảo...',
success: (data) => {
console.log(data);
return data;
},
error: (error) => {
console.error(error);
return error.message || 'Có lỗi xảy ra khi khởi động máy ảo';
}
}, {
isClose: true
}
);
} else {
showNotification('Đang khởi động máy ảo...', 'success');
startPromise.then(data => {
showNotification(data, 'success');
}).catch(error => {
showNotification(error.message || 'Có lỗi xảy ra khi khởi động máy ảo', 'error');
});
}
}
async function stopVirtualMachine() {
const stopBtn = document.getElementById('stopVMButton');
if (stopBtn.disabled) return;
const accessToken = '{{ request()->cookie('accessToken') }}';
if (!accessToken) {
showNotification('Chưa đăng nhập, vui lòng đăng nhập lại', 'error');
setTimeout(() => {
window.location.href = '/login';
}, 2000);
return;
}
const requestBody = {
vm_id: vmId
};
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Authorization': 'Bearer ' + accessToken
};
const stopPromise = fetch('/api/v1/stop-virtual-machine', {
method: 'POST',
headers: headers,
body: JSON.stringify(requestBody),
credentials: 'same-origin'
}).then(async (response) => {
if (response.redirected || response.status === 401) {
throw new Error('Phiên đăng nhập đã hết hạn, vui lòng đăng nhập lại');
}
let data;
try {
data = await response.json();
} catch (parseError) {
throw new Error('Lỗi định dạng dữ liệu từ máy chủ');
}
if (!data.error) {
setTimeout(() => {
location.reload();
}, 2000);
return data.message;
} else {
if (data.type === 'com.vmware.vapi.std.errors.already_in_desired_state' ||
(data.message && data.message.error_type === 'ALREADY_IN_DESIRED_STATE')) {
setTimeout(() => {
location.reload();
}, 2000);
return 'Máy chủ đã được tắt';
} else {
let errorMessage = 'Có lỗi xảy ra';
if (data.message) {
if (typeof data.message === 'object') {
if (data.message.messages && data.message.messages.length > 0) {
errorMessage = data.message.messages[0].default_message || data.message
.messages[0]
.message || 'Có lỗi xảy ra';
} else if (data.message.error_type) {
errorMessage = `Lỗi: ${data.message.error_type}`;
} else {
errorMessage = 'Có lỗi xảy ra từ hệ thống';
}
} else {
errorMessage = data.message;
}
} else if (data.value && data.value.messages && data.value.messages.length > 0) {
errorMessage = data.value.messages[0].default_message;
} else if (typeof data === 'string') {
errorMessage = data;
} else if (data.error) {
if (typeof data.error === 'object') {
if (data.error.message) {
errorMessage = data.error.message;
} else if (data.error.toString && data.error.toString() !==
'[object Object]') {
errorMessage = data.error.toString();
} else {
errorMessage = 'Có lỗi xảy ra từ hệ thống';
}
} else {
errorMessage = data.error;
}
}
throw new Error(errorMessage);
}
}
});
if (typeof FuiToast !== 'undefined' && FuiToast.promise) {
FuiToast.promise(
stopPromise, {
loading: 'Đang dừng máy ảo...',
success: (data) => {
console.log(data);
return data;
},
error: (error) => {
console.error(error);
return error.message || 'Có lỗi xảy ra khi dừng máy ảo';
}
}, {
isClose: true
}
);
} else {
showNotification('Đang dừng máy ảo...', 'success');
stopPromise.then(data => {
showNotification(data, 'success');
}).catch(error => {
showNotification(error.message || 'Có lỗi xảy ra khi dừng máy ảo', 'error');
});
}
}
async function restartVirtualMachine() {
const restartBtn = document.getElementById('restartVMButton');
if (restartBtn.disabled) return;
const restartPromise = fetch(`/api/v1/restart-virtual-machine`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({
vm_id: vmId
})
}).then(async (response) => {
let data;
try {
data = await response.json();
} catch (parseError) {
throw new Error('Lỗi định dạng dữ liệu từ máy chủ');
}
if (data.success) {
setTimeout(() => {
location.reload();
}, 2000);
return data.message;
} else {
let errorMessage = 'Có lỗi xảy ra';
if (data.message) {
if (typeof data.message === 'object') {
if (data.message.messages && data.message.messages.length > 0) {
errorMessage = data.message.messages[0].default_message || data.message
.messages[0]
.message || 'Có lỗi xảy ra';
} else if (data.message.error_type) {
errorMessage = `Lỗi: ${data.message.error_type}`;
} else {
errorMessage = 'Có lỗi xảy ra từ hệ thống';
}
} else {
errorMessage = data.message;
}
} else if (data.error) {
if (typeof data.error === 'object') {
if (data.error.message) {
errorMessage = data.error.message;
} else if (data.error.toString && data.error.toString() !== '[object Object]') {
errorMessage = data.error.toString();
} else {
errorMessage = 'Có lỗi xảy ra từ hệ thống';
}
} else {
errorMessage = data.error;
}
} else if (typeof data === 'string') {
errorMessage = data;
}
throw new Error(errorMessage);
}
});
if (typeof FuiToast !== 'undefined' && FuiToast.promise) {
FuiToast.promise(
restartPromise, {
loading: 'Đang khởi động lại máy ảo...',
success: (data) => {
console.log(data);
return data;
},
error: (error) => {
console.error(error);
return error.message || 'Có lỗi xảy ra khi khởi động lại máy ảo';
}
}, {
isClose: true
}
);
} else {
showNotification('Đang khởi động lại máy ảo...', 'success');
restartPromise.then(data => {
showNotification(data, 'success');
}).catch(error => {
showNotification(error.message || 'Có lỗi xảy ra khi khởi động lại máy ảo', 'error');
});
}
}
async function suspendVirtualMachine() {
const suspendBtn = document.getElementById('suspendVMButton');
if (suspendBtn.disabled) return;
const suspendPromise = fetch(`/api/v1/suspend-virtual-machine`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({
vm_id: vmId
})
}).then(async (response) => {
let data;
try {
data = await response.json();
} catch (parseError) {
throw new Error('Lỗi định dạng dữ liệu từ máy chủ');
}
if (data.success) {
setTimeout(() => {
location.reload();
}, 2000);
return data.message;
} else {
let errorMessage = 'Có lỗi xảy ra';
if (data.message) {
if (typeof data.message === 'object') {
if (data.message.messages && data.message.messages.length > 0) {
errorMessage = data.message.messages[0].default_message || data.message
.messages[0]
.message || 'Có lỗi xảy ra';
} else if (data.message.error_type) {
errorMessage = `Lỗi: ${data.message.error_type}`;
} else {
errorMessage = 'Có lỗi xảy ra từ hệ thống';
}
} else {
errorMessage = data.message;
}
} else if (data.error) {
if (typeof data.error === 'object') {
if (data.error.message) {
errorMessage = data.error.message;
} else if (data.error.toString && data.error.toString() !== '[object Object]') {
errorMessage = data.error.toString();
} else {
errorMessage = 'Có lỗi xảy ra từ hệ thống';
}
} else {
errorMessage = data.error;
}
} else if (typeof data === 'string') {
errorMessage = data;
}
throw new Error(errorMessage);
}
});
if (typeof FuiToast !== 'undefined' && FuiToast.promise) {
FuiToast.promise(
suspendPromise, {
loading: 'Đang tạm dừng máy ảo...',
success: (data) => {
console.log(data);
return data;
},
error: (error) => {
console.error(error);
return error.message || 'Có lỗi xảy ra khi tạm dừng máy ảo';
}
}, {
isClose: true
}
);
} else {
showNotification('Đang tạm dừng máy ảo...', 'success');
suspendPromise.then(data => {
showNotification(data, 'success');
}).catch(error => {
showNotification(error.message || 'Có lỗi xảy ra khi tạm dừng máy ảo', 'error');
});
}
}
async function shutdownVirtualMachine() {
const shutdownBtn = document.getElementById('shutdownVMButton');
if (shutdownBtn.disabled) return;
const shutdownPromise = fetch(`/api/v1/shutdown-virtual-machine`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({
vm_id: vmId
})
}).then(async (response) => {
let data;
try {
data = await response.json();
} catch (parseError) {
throw new Error('Lỗi định dạng dữ liệu từ máy chủ');
}
if (data.success) {
setTimeout(() => {
location.reload();
}, 2000);
return data.message;
} else {
let errorMessage = 'Có lỗi xảy ra';
if (data.message) {
if (typeof data.message === 'object') {
if (data.message.messages && data.message.messages.length > 0) {
errorMessage = data.message.messages[0].default_message || data.message
.messages[0]
.message || 'Có lỗi xảy ra';
} else if (data.message.error_type) {
errorMessage = `Lỗi: ${data.message.error_type}`;
} else {
errorMessage = 'Có lỗi xảy ra từ hệ thống';
}
} else {
errorMessage = data.message;
}
} else if (data.error) {
if (typeof data.error === 'object') {
if (data.error.message) {
errorMessage = data.error.message;
} else if (data.error.toString && data.error.toString() !== '[object Object]') {
errorMessage = data.error.toString();
} else {
errorMessage = 'Có lỗi xảy ra từ hệ thống';
}
} else {
errorMessage = data.error;
}
} else if (typeof data === 'string') {
errorMessage = data;
}
throw new Error(errorMessage);
}
});
if (typeof FuiToast !== 'undefined' && FuiToast.promise) {
FuiToast.promise(
shutdownPromise, {
loading: 'Đang shutdown máy ảo...',
success: (data) => {
console.log(data);
return data;
},
error: (error) => {
console.error(error);
return error.message || 'Có lỗi xảy ra khi shutdown máy ảo';
}
}, {
isClose: true
}
);
} else {
showNotification('Đang shutdown máy ảo...', 'success');
shutdownPromise.then(data => {
showNotification(data, 'success');
}).catch(error => {
showNotification(error.message || 'Có lỗi xảy ra khi shutdown máy ảo', 'error');
});
}
}
// DOM ready
document.addEventListener('DOMContentLoaded', function() {
const startBtn = document.getElementById('startVMButton');
const stopBtn = document.getElementById('stopVMButton');
const restartBtn = document.getElementById('restartVMButton');
const suspendBtn = document.getElementById('suspendVMButton');
const shutdownBtn = document.getElementById('shutdownVMButton');
if (startBtn) {
startBtn.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
startVirtualMachine();
});
}
if (stopBtn) {
stopBtn.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
stopVirtualMachine();
});
}
if (restartBtn) {
restartBtn.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
restartVirtualMachine();
});
}
if (suspendBtn) {
suspendBtn.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
suspendVirtualMachine();
});
}
if (shutdownBtn) {
shutdownBtn.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
shutdownVirtualMachine();
});
}
});
</script>
@@ -0,0 +1,431 @@
<div class="box clients-summary__box p-4">
<div class="row form-group">
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
<tbody>
<tr>
<td class="fieldlabel">Order #</td>
<td class="fieldarea">
<strong>{{ $product->order->id }}</strong> -
<a href="{{ route('admin.order.edit', ['id' => $product->order->id]) }}">View Order</a>
</td>
<td class="fieldlabel">Registration Date</td>
<td class="fieldarea">
@isset($product->order->date)
@time($product->order->date)
@endisset
</td>
</tr>
<tr>
<td class="fieldlabel">Product/Service</td>
<td class="fieldarea">
@isset($productName->name)
{{ $productName->name }}
@endisset
</td>
<td class="fieldlabel">Quantity</td>
<td class="fieldarea"><strong>1</strong></td>
</tr>
<tr>
<td class="fieldlabel">Server</td>
<td class="fieldarea">
@isset($product->ipaddress->host->datacenter->vCenter->host)
{{ $product->ipaddress->host->datacenter->vCenter->host }}
@endisset
</td>
<td class="fieldlabel">First Payment Amount</td>
<td class="fieldarea">
<input type="number" class="form-control" readonly name="first_payment"
value="{{ $product->first_payment }}" id="">
</td>
</tr>
<tr>
<td class="fieldlabel">IP Address</td>
<td class="fieldarea">
@isset($product->ipaddress->ip)
{{ $product->ipaddress->ip }}
@endisset
</td>
<td class="fieldlabel">Recurring Amount</td>
<td class="fieldarea">
<input type="number" class="form-control" name="next_payment_input"
value="{{ $product->next_payment }}" id="">
</td>
</tr>
<tr>
<td class="fieldlabel">Billing Cycle</td>
<td class="fieldarea">
{{-- {{ Helpers::BillingCycle($product->getInvoiceItem()->billing) }} --}}
{!! $invoice_item ? $invoice_item->getBilling() : 'N/A' !!}
</td>
<td class="fieldlabel">Next Due Date</td>
<td class="fieldarea">
<input type="text" name="next_due_date_input" id="next_due_date"
class="form-control datetime-picker" placeholder="dd/mm/yy" value="@time($product->next_due_date_input)">
</td>
</tr>
<tr>
<td class="fieldlabel">Payment Method</td>
<td class="fieldarea">
@isset($product->order->payment->name)
{{ $product->order->payment->name }}
@endisset
</td>
<td class="fieldlabel">Status</td>
<td class="fieldarea">
<select name="select_status" class="form-control">
<option value="1" @selected($product->status == 1)>Active</option>
<option value="2" @selected($product->status == 2)>Suspend</option>
<option value="3" @selected($product->status == 3)>Pending</option>
<option value="0" @selected($product->status == 0)>Power Off</option>
<option value="4" @selected($product->status == 4)>Expiry</option>
</select>
</td>
</tr>
<tr>
<td class="fieldlabel">Username</td>
<td class="fieldarea">
<input type="text" class="form-control" readonly name="username"
value="{{ $product->user }}">
</td>
<td class="fieldlabel">Password</td>
<td class="fieldarea">
<input type="text" class="form-control" readonly name="password"
value="{{ $product->password ? SignRSA::DecryptFunc($product->password) : '' }}">
</td>
</tr>
</tbody>
</table>
</div>
<!-- VM Information Section -->
<div class="card mt-4">
<div class="card-header">
<h5 class="mb-0">Thông tin máy ảo</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<table class="table table-sm table-borderless">
<tr>
<td class="text-muted">Tên VM:</td>
<td>{{ $product->name ?? 'Chưa đặt tên' }}</td>
</tr>
<tr>
<td class="text-muted">Trạng thái:</td>
<td>
@if ($product->status == 1)
<span class="badge badge-success">Đang chạy</span>
@elseif($product->status == 2)
<span class="badge badge-warning">Tạm dừng</span>
@elseif($product->status == 3)
<span class="badge badge-info">Đang khởi tạo</span>
@elseif($product->status == 0)
<span class="badge badge-danger">Đã dừng</span>
@elseif($product->status == 4)
<span class="badge badge-secondary">Hết hạn</span>
@else
<span class="badge badge-secondary">Không xác định</span>
@endif
</td>
</tr>
<tr>
<td class="text-muted">Hostname:</td>
<td>{{ $product->hostname ?? 'N/A' }}</td>
</tr>
</table>
</div>
<div class="col-md-6">
<table class="table table-sm table-borderless">
<tr>
<td width="30%" class="text-muted">IP Address:</td>
<td><code>{{ $product->ipaddress->ip ?? 'N/A' }}</code></td>
</tr>
<tr>
<td class="text-muted">Username:</td>
<td>{{ $product->user ?? 'N/A' }}</td>
</tr>
<tr>
<td class="text-muted">Hệ điều hành:</td>
<td>
@if (isset($product->os) && isset($product->os->osGroup))
{{ $product->os->osGroup->name ?? 'Unknown' }} {{ $product->os->version ?? '' }}
@else
N/A
@endif
</td>
</tr>
<tr>
<td class="text-muted">vCenter:</td>
<td>
@if (
isset($product->ipaddress) &&
isset($product->ipaddress->host) &&
isset($product->ipaddress->host->datacenter) &&
isset($product->ipaddress->host->datacenter->vCenter)
)
{{ $product->ipaddress->host->datacenter->vCenter->host ?? 'N/A' }}
@else
N/A
@endif
</td>
</tr>
</table>
</div>
</div>
<!-- Windows Login Info -->
@if (isset($product->os) && isset($product->os->osGroup) && $product->os->osGroup->name == 'Windows')
<div class="alert alert-info mt-3">
<h6><i class="fas fa-info-circle"></i> Thông tin đăng nhập Windows</h6>
<div class="row">
<div class="col-md-6">
<strong>Username:</strong> <code>administrator</code>
</div>
<div class="col-md-6">
<strong>Password:</strong> <code>TGS@123</code>
<button type="button" onclick="navigator.clipboard.writeText('TGS@123')"
class="btn btn-sm btn-outline-primary ml-2">Copy</button>
</div>
</div>
<small class="text-muted">* Đổi mật khẩu sau khi đăng nhập lần đầu để bảo mật tốt hơn.</small>
</div>
@endif
</div>
</div>
<!-- VM Control Section -->
<div class="card mt-4">
<div class="card-header">
<h5 class="mb-0">Điều khiển VM</h5>
</div>
<div class="card-body">
<div class="row">
<!-- Power On -->
<div class="col-md-3 col-sm-6 mb-2">
<button type="button" id="startVMButton" class="btn btn-success btn-block">
<i class="fas fa-play"></i> Khởi động
</button>
</div>
<!-- Power Off -->
<div class="col-md-3 col-sm-6 mb-2">
<button type="button" id="stopVMButton" class="btn btn-danger btn-block">
<i class="fas fa-stop"></i> Tắt máy
</button>
</div>
<!-- Shutdown Guest -->
<div class="col-md-3 col-sm-6 mb-2">
<button type="button" id="shutdownVMButton" class="btn btn-warning btn-block">
<i class="fas fa-power-off"></i> Shutdown
</button>
</div>
<!-- Suspend -->
<div class="col-md-3 col-sm-6 mb-2">
<button type="button" id="suspendVMButton" class="btn btn-secondary btn-block"
{{ $product->status === 2 ? 'disabled' : '' }}>
<i class="fas fa-pause"></i> Tạm dừng
</button>
</div>
<!-- Restart -->
<div class="col-md-3 col-sm-6 mb-2">
<button type="button" id="restartVMButton" class="btn btn-info btn-block">
<i class="fas fa-redo"></i> Khởi động lại
</button>
</div>
<!-- Console -->
<div class="col-md-3 col-sm-6 mb-2">
<a href="{{ route('task.console', ['product' => $product->id, 'vmware-id' => $product->vmware_id]) }}"
target="_blank" class="btn btn-dark btn-block">
<i class="fas fa-terminal"></i> Console
</a>
</div>
<!-- Reinstall -->
<div class="col-md-3 col-sm-6 mb-2">
<button type="button" data-toggle="modal" data-target="#modal-lg"
class="btn btn-outline-secondary btn-block" data-ajax="{{ route('task.reinstall') }}">
Cài lại
</button>
</div>
</div>
<!-- Status Info -->
<div class="mt-3 p-3 bg-light">
<h6 class="mb-2">Thông tin chi tiết:</h6>
<div class="row">
<div class="col-md-6">
<small class="text-muted">Trạng thái VM:</small>
@if ($product->status == 1)
<span class="badge badge-success ml-1">Đang chạy</span>
@elseif($product->status == 2)
<span class="badge badge-warning ml-1">Tạm dừng</span>
@elseif($product->status == 3)
<span class="badge badge-info ml-1">Đang khởi tạo</span>
@elseif($product->status == 0)
<span class="badge badge-danger ml-1">Đã dừng</span>
@elseif($product->status == 4)
<span class="badge badge-secondary ml-1">Hết hạn</span>
@endif
</div>
</div>
<div class="row mt-1">
<div class="col-md-6">
<small class="text-muted">IP Address:</small>
<code>{{ $product->ipaddress->ip ?? 'N/A' }}</code>
</div>
<div class="col-md-6">
<small class="text-muted">Ngày tạo:</small>
{{ $product->order->date ? \Carbon\Carbon::parse($product->order->date)->format('d/m/Y H:i') : 'N/A' }}
</div>
</div>
</div>
<!-- Notes -->
<div class="alert alert-light mt-3 mb-0">
<small>
<strong>Lưu ý:</strong><br>
• Các thao tác có thể mất vài giây để hoàn thành<br>
• VM sẽ được khởi động lại sau khi thay đổi cấu hình<br>
• Vui lòng đợi thao tác hoàn thành trước khi thực hiện tiếp<br>
• Console sẽ mở trong tab mới
</small>
</div>
</div>
</div>
<form action="{{ route('customer.product.update') }}" method="post">
<div class="box bg-white rounded p-3">
@csrf
@method('put')
<input type="hidden" name="next_due_date"
value="{{ (session('next_due_date') ? \Carbon\Carbon::parse(session('next_due_date'))->format('d/m/Y') : null) ?? ($product->next_due_date ? \Carbon\Carbon::parse($product->next_due_date)->format('d/m/Y') : null) }}">
<input type="hidden" name="next_payment"
value="{{ session('next_payment') ?? $product->next_payment }}">
<input type="hidden" name="product_id" value="{{ session('product_id') ?? $product->id }}">
<input type="hidden" name="product_type" value="4">
<input type="hidden" name="status" value="{{ session('status') ?? $product->status }}">
{{-- Vmware Name --}}
<div class="row form-group align-items-center mb-0">
<label for="name" class="col-md-3 text-right">VM Name</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" name="name" class="form-control" id="name"
value="{{ session('name') ?? $product->name }}">
</div>
</div>
{{-- Vmware Hostname --}}
<div class="row form-group align-items-center mb-0">
<label for="hostname" class="col-md-3 text-right">VM Hostname</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" name="hostname" class="form-control" id="hostname"
value="{{ session('hostname') ?? $product->hostname }}">
</div>
</div>
{{-- Vmware Port --}}
<div class="row form-group align-items-center mb-0">
<label for="port" class="col-md-3 text-right">VM Port</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" name="port" class="form-control" id="port"
value="{{ session('port') ?? $product->port }}">
</div>
</div>
{{-- Username --}}
<div class="row form-group align-items-center mb-0">
<label for="user" class="col-md-3 text-right">Username</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" name="user" class="form-control" id="user"
value="{{ session('user') ?? $product->user }}">
</div>
</div>
{{-- Password --}}
<div class="row form-group align-items-center mb-0">
<label for="password" class="col-md-3 text-right">Password</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" name="password" class="form-control" id="password"
value="{{ session('password') ?? ($product->password ? SignRSA::DecryptFunc($product->password) : '') }}">
</div>
</div>
{{-- vmware_id --}}
<div class="row form-group align-items-center mb-0">
<label for="vmware_id" class="col-md-3 text-right">VirtualMachine ID</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" name="vmware_id" class="form-control" id="vmware_id"
value="{{ session('vmware_id') ?? $product->vmware_id }}">
</div>
</div>
{{-- vCenter --}}
<x-module.v-center :model="$product" />
{{-- Datacenter --}}
<x-module.datacenter :model="$product" />
{{-- Host --}}
<x-module.host :model="$product" />
{{-- Network --}}
<x-module.network :model="$product" />
{{-- IP Address --}}
<x-module.ip-address :model="$product" />
{{-- OS Group --}}
<x-module.os :model="$product" />
{{-- OS Version --}}
<x-module.os-version :model="$product" />
</div>
<div class="card-footer text-center">
<button type="submit" class="btn bg-gradient-success">
<i class="far fa-check-circle"></i>
Save
</button>
<a href="{{ route('customer.index') }}" class="btn bg-gradient-secondary">Cancel
</a>
</div>
</form>
<div class="modal fade" id="modal-lg">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Configuration for create VPS</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form action="{{ route('task.manager') }}" method="post">
@csrf
<div class="modal-body">
<input type="hidden" name="type" value="{{ $type }}">
<input type="hidden" name="product" value="{{ $product->id }}">
<input type="hidden" name="userid" value="{{ $userid }}">
<input type="hidden" class="form-action" name="action" value="create">
<x-module.v-center :model="null" />
<x-module.datacenter :model="null" />
<x-module.host :model="null" />
<x-module.network :model="null" />
<x-module.os :model="null" />
{{-- <x-module.os-version :model="null" /> --}}
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save changes</button>
</div>
</form>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
@include('admin.customer.action.addon')
</div>
@include('admin.customer.form.scripts.vps')
@@ -0,0 +1,115 @@
@extends("admin.main")
@section("content")
@if(auth()->guard('admins')->user()->can("manager customer"))
<div class="card card-primary card-outline">
<div class="card-header">
<form action="{{ route('customer.index') }}" method="get">
<div class="row form-group mb-0">
<div class="col">
<div class="form-group">
<label for="inputName">
Client/Company Name </label>
<input type="text" name="name" id="inputName" class="form-control" value="{{ request()->name ?? "" }}">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="inputEmail">
Email Address</label>
<input type="email" name="email" id="inputEmail" class="form-control" value="{{ request()->email ?? "" }}">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="inputPhone">
Phone Number</label>
<input type="text" name="phone" id="inputPhone" class="form-control" value="{{ request()->phone ?? "" }}">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="inputStatus">
Status</label>
<select name="status" class="form-control" id="inputStatus">
<option value="full" @selected(request()->status === "full")>Any</option>
<option value="active" @selected(request()->status === "active")>Active</option>
<option value="de_active" @selected(request()->status === "de_active")>In Active</option>
<option value="closed" @selected(request()->status === "closed")>Closed</option>
</select>
</div>
</div>
<div class="col">
<label class="clear-search hidden">
</label>
<button type="submit" class="form-control btn btn-block bg-gradient-primary">
<i class="fas fa-search"></i> Search
</button>
</div>
</div>
</form>
<span>{{ $customers->count() }} Records Found</span>
</div>
<div class="card-body">
<table class="table table-invoice table-bordered">
<thead>
<tr>
<th style="width: 10px">
<label for=""></label><input type="checkbox" name="check" class="check-all" id="">
</th>
<th>First Name</th>
<th>Last Name</th>
<th>Company</th>
<th>Email Address</th>
<th style="width: 40px">Services</th>
<th style="width: 40px">Created</th>
<th style="width: 40px">Status</th>
</tr>
</thead>
<tbody>
@if($customers->count())
@foreach($customers->all() as $item)
<tr>
<td>
<input type="checkbox" name="id[]" id="" value="{{ $item->id }}">
</td>
<td>
<a href="{{ route("customer.info",['userid' => $item->id]) }}"
title="View Profile"> {{ $item->firstname }}</a>
</td>
<td>
{{ $item->lastname }}
</td>
<td>
{{ $item->company }}
</td>
<td>
{{ $item->email }}
</td>
<td class="text-center">
{!! Helpers::get_count_service($item) !!}
</td>
<td>
@time($item->created_at)
</td>
<td>
{!! $item->getStatus() !!}
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
<div class="card-footer">
{{ $customers->withQueryString()->links() }}
</div>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection
@@ -0,0 +1,310 @@
@extends("admin.main")
@section("content")
@if(auth()->guard('admins')->user()->can("edit customer"))
<div class="card card-outline card-primary">
<div class="card-header">
@include("admin.block.nav")
</div>
<div class="card-body">
<div class="row">
<!--Clients Information-->
<div class="col-md-4">
<div class="clients-summary__box">
<h4 class="title">Clients Information</h4>
<!--Box info-->
<div class="summary__box">
<table class="table table-borderless">
<tbody>
<tr>
<th scope="row">First Name</th>
<td>{{ $customer->firstname }}</td>
</tr>
<tr>
<th scope="row">Last Name</th>
<td>{{ $customer->lastname }}</td>
</tr>
<tr>
<th scope="row">Company</th>
<td>{{ $customer->company }}</td>
</tr>
<tr>
<th scope="row">Email</th>
<td>{{ $customer->email }}</td>
</tr>
<tr>
<th scope="row">Address</th>
<td>{{ $customer->address }}</td>
</tr>
<tr>
<th scope="row">City</th>
<td>{{ $customer->city }}</td>
</tr>
<tr>
<th scope="row">Country</th>
<td>{{ $customer->country }}</td>
</tr>
<tr>
<th scope="row">Phone Number</th>
<td>{{ $customer->phone }}</td>
</tr>
</tbody>
</table>
</div>
<!--Box Action-->
<div class="summary--box__action mt-2">
<ul class="list-unstyled">
<li>
<a id="summary-reset-password"
href="{{ route('customer.PasswordReset', ['userid' => $customer->id]) }}">
<img src="{{ asset('images/resetpw.png') }}">
Reset & Send Password
</a>
</li>
<li>
<a target="_blank" id="summary-login-as-client"
href="{{ route('customer.Login', ['userid' => $customer->id]) }}">
<img src="{{ asset('images/clientlogin.png') }}"> Login as Client
</a>
</li>
</ul>
</div>
</div>
</div>
<!--Invoices/Billing-->
<div class="col-md-4">
<div class="clients-summary__box">
<h4 class="title">Invoices/Billing</h4>
<!--Box info-->
<div class="summary__box">
<table class="table table-borderless">
<tbody>
<tr>
<th scope="row">Invoice Paid</th>
<td>{{ $customer->invoices_status_count_1 }}
(@money($customer->invoices_status_1)
đ)
</td>
</tr>
<tr>
<th scope="row">Invoice UnPaid</th>
<td>{{ $customer->invoices_status_count_0 }}
(@money($customer->invoices_status_0)
đ)
</td>
</tr>
<tr>
<th scope="row">Total</th>
<td>@money($customer->invoices_status_0 + $customer->invoices_status_1) đ</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="clients-summary__box">
<h4 class="title">Recent Emails</h4>
<div class="summary__box">
@if($customer->mail->count())
<table class="table table-borderless">
<tbody>
@foreach($customer->mail->take(4)->all() as $item)
<tr>
<td>
<a href="{{ route('customer.email', ['userid' => $userid, 'email_id' => $item->id]) }}"
target="_blank">{{ $item->created_at }}
- {{ $item->subject }}</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p class="text-center m-0">No recent Email</p>
@endif
</div>
</div>
</div>
<!--Products/Services-->
<div class="col-md-4">
<!--Products/Services-->
<div class="clients-summary__box">
<h4 class="title">Products/Services</h4>
<!--Box info-->
<div class="summary__box">
<table class="table table-borderless">
<tbody>
<tr>
<th scope="row">VPS/Server</th>
<td>{{ $customer->vps_count}}</td>
</tr>
<tr>
<th scope="row">Hosting</th>
<td>{{ $customer->hosting_count }}</td>
</tr>
<tr>
<th scope="row">Domain</th>
<td>{{ $customer->domain_count }}</td>
</tr>
<tr>
<th scope="row">Support Tickets</th>
<td>{{ $customer->ticket_count }}</td>
</tr>
</tbody>
</table>
</div>
</div>
<!--File-->
<div class="clients-summary__box">
<h4 class="title">Files</h4>
<div class="summary__box">
@if($customer->file->count())
<table class="table table-borderless">
<tbody>
@foreach($customer->file->all() as $item)
<tr>
<td>
<a href="{{ $item->file_url }}" download
target="_blank">{{ $item->filename }}</a>
</td>
<td class="text-right">
<button data-id="{{ $item->id }}"
class="btn btn-outline-secondary p-1 border-0 btn-remove__file">
<i class="fas fa-trash"></i>
</button>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p class="text-center m-0">No files uploaded</p>
@endif
</div>
<div class="box-add__file mt-2">
<a onclick="$('.box-add__input').removeClass('d-none')" class="cursor-point pointer-event">
<img alt="Add File" src="{{ asset('images/add.png') }}"> Add File
</a>
<div class="box-add__input d-none mt-2">
<div class="summary__box p-2">
<div class="row">
<div class="col-md-12">
<label for="input-file">File:</label>
<input type="text" class="form-control mt-2" id="input-file" name="file">
</div>
</div>
<button class="btn mt-2 btn-open__ckfinder btn-outline-secondary">
Choose File
</button>
<button class="btn mt-2 btn-save__data btn-outline-secondary">
Save
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-footer">
</div>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection
@push('scripts')
<script type="text/javascript">
$('.btn-open__ckfinder').click(function () {
CKFinder.popup({
chooseFiles: true,
onInit: function (finder) {
finder.on('files:choose', function (evt) {
let input_file = $('.box-add__input #input-file');
if (input_file.length) {
input_file.val(evt.data.files.first().getUrl())
}
});
}
});
})
$('.btn-save__data').click(function () {
let file = $('.box-add__input #input-file')
if (!file.val()) {
if (!file.hasClass('border-danger')) {
file.addClass('border-danger')
}
return this;
}
if (file.hasClass('border-danger')) {
file.removeClass('border-danger')
}
$.post('{{ route('api.CustomerUpdateFile') }}', {
user_id: {{$customer->id}},
file: file.val()
})
.then(function (response) {
if (response.error === false) {
Swal.fire({
title: "Successfully",
text: response.message,
icon: "success",
confirmButtonColor: "#3085d6",
confirmButtonText: "Xác nhận"
}).then((result) => {
if (result.isConfirmed) {
location.reload()
}
})
} else {
Swal.fire({
title: "Opp?",
text: response.message,
icon: "warning",
showCancelButton: false,
confirmButtonColor: "var(--color-brand)",
confirmButtonText: "Xác nhận"
})
}
})
})
$('.btn-remove__file').click(function () {
let id = $(this).data('id')
$.post('{{ route('api.CustomerRemoveFile') }}', {
file: id
})
.then(function (response) {
if (response.error === false) {
Swal.fire({
title: "Successfully",
text: response.message,
icon: "success",
confirmButtonColor: "#3085d6",
confirmButtonText: "Xác nhận"
}).then((result) => {
if (result.isConfirmed) {
location.reload()
}
})
} else {
Swal.fire({
title: "Opp?",
text: response.message,
icon: "warning",
showCancelButton: false,
confirmButtonColor: "var(--color-brand)",
confirmButtonText: "Xác nhận"
})
}
})
})
</script>
@endpush
@@ -0,0 +1,80 @@
@extends('admin.main')
@section('content')
@if (auth()->guard('admins')->user()->can('edit customer'))
<div class="card card-outline card-primary">
<div class="card-header">
@include('admin.block.nav')
</div>
<div class="card-body">
<table class="table table-invoice table-bordered">
<thead>
<tr>
<th style="width: 10px">
<label for=""></label><input type="checkbox" name="check" class="check-all"
id="">
</th>
<th>Invoice #</th>
<th>Invoice Date</th>
<th>Due Date</th>
<th>Date Paid</th>
<th>Total</th>
<th>Payment Method</th>
<th style="width: 40px">Status</th>
</tr>
</thead>
<tbody>
@if (count($invoices) > 0)
@foreach ($invoices as $item)
<tr>
<td>
<input type="checkbox" name="id[]" id="" value="{{ $item->id }}">
</td>
<td class="text-center">
<a
href="{{ route('admin.invoice.edit', ['id' => $item->id]) }}">{{ $item->id }}</a>
</td>
<td class="text-center">
@time($item->date)
</td>
<td class="text-center">
@time($item->due_date)
</td>
<td class="text-center">
@if ($item->status === 1)
@time($item->date_paid)
@endif
</td>
<td class="text-center">
@money($item->total) đ
</td>
<td class="text-center">
{{ $item->payment->name ?? 'VN Pay' }}
</td>
<td class="text-center">
{!! $item->getStatus() !!}
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="8">
No Records Found
</td>
</tr>
@endif
</tbody>
<tfoot>
{!! $invoices->withQueryString()->links() !!}
</tfoot>
</table>
</div>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection
@@ -0,0 +1,56 @@
@extends('admin.main')
@section('content')
@if (auth()->guard('admins')->user()->can('edit customer'))
<div class="card card-outline card-primary">
<div class="card-header">
@include('admin.block.nav')
</div>
<div class="card-body">
<table class="table table-invoice table-bordered">
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th style="width: 100px">Username</th>
<th style="width: 100px">Client IP</th>
</tr>
</thead>
<tbody>
@if (count($logs) > 0)
@foreach ($logs as $item)
<tr>
<td>
{{ $item->created_at }}
</td>
<td>
{{ $item->description }}
</td>
<td>
{{ $item->username }}
</td>
<td>
{{ $item->client_ip }}
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="8">
No Records Found
</td>
</tr>
@endif
</tbody>
<tfoot>
{!! $logs->withQueryString()->links() !!}
</tfoot>
</table>
</div>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection
@@ -0,0 +1,72 @@
@extends('admin.main')
@section('content')
@if (auth()->guard('admins')->user()->can('edit customer'))
<div class="card card-outline card-primary">
<div class="card-header">
@include('admin.block.nav')
</div>
<div class="card-body">
<table class="table table-invoice table-bordered">
<thead>
<tr>
<th style="width: 10px">
<label for=""></label><input type="checkbox" name="check" class="check-all"
id="">
</th>
<th>Date</th>
<th>Subject</th>
<th style="width: 40px"></th>
<th style="width: 40px"></th>
</tr>
</thead>
<tbody>
@if (count($emails) > 0)
@foreach ($emails as $item)
<tr>
<td>
<input type="checkbox" name="id[]" id="" value="{{ $item->id }}">
</td>
<td>
{{ $item->created_at }}
</td>
<td>
{{ $item->subject }}
</td>
<td>
<a target="_blank"
href="{{ route('customer.email', ['userid' => $userid, 'email_id' => $item->id]) }}">
<i class="fas fa-share"></i>
</a>
</td>
<td>
<form action="" method="post">
@csrf
@method('put')
<input type="hidden" name="mail_id" value="{{ $item->id }}">
<button type="submit" class="text-danger"><i class="fas fa-trash"></i></button>
</form>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="8">
No Records Found
</td>
</tr>
@endif
</tbody>
<tfoot>
{!! $emails->withQueryString()->links() !!}
</tfoot>
</table>
</div>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection
@@ -0,0 +1,57 @@
@extends("admin.main")
@section("content")
@if(auth()->guard('admins')->user()->can("edit customer"))
<div class="card card-outline card-primary">
<div class="card-header">
@include("admin.block.nav")
</div>
<div class="card-body">
@if($allService->count())
@include("admin.customer.action.selector")
@if((int) $type === 3)
@include("admin.customer.form.hosting")
@endif
@if((int) $type === 4)
@include("admin.customer.form.vps")
@endif
@else
<div class="alert alert-warning" role="alert">
No products found for this user. Click here to place a new order.
</div>
@endif
</div>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection
@push('style')
<link rel="stylesheet" href="{{ asset('lib/jquery-ui/jquery-ui.min.css') }}">
@endpush
@push('scripts')
<script src="{{ asset('lib/jquery-ui/jquery-ui.min.js') }}"></script>
<script src="{{ asset('lib/vcenter/action.js') }}"></script>
<script type="text/javascript">
//Date picker
$('.datetime-picker').datepicker({
dateFormat: 'dd/mm/yy'
});
$('input[name="next_due_date_input"]').change(function () {
let data = $(this).val()
$('input[type="hidden"][name="next_due_date"]').empty().val(data)
})
$('select[name="select_status"]').change(function () {
let data = $(this).find('option:selected').val()
$('input[type="hidden"][name="status"]').empty().val(data)
})
$('input[name="next_payment_input"]').keyup(function () {
let data = $(this).val()
$('input[type="hidden"][name="next_payment"]').empty().val(data)
})
</script>
@endpush
@@ -0,0 +1,145 @@
@extends("admin.main")
@section("content")
@if(auth()->guard('admins')->user()->can("edit customer"))
<div class="card card-outline card-primary">
<div class="card-header">
@include("admin.block.nav")
</div>
<form action="{{ route('customer.profile.store',['userid' => $customer->id]) }}" method="post">
@csrf
<div class="card-body">
<div class="row">
<div class="col">
{{--First name--}}
<div class="form-group row">
<label class="col-md-4" for="firstname">First Name</label>
<div class="col-md-8">
<input type="text" id="firstname" name="firstname" placeholder="First Name"
value="{{ $customer->firstname }}" class="form-control">
</div>
</div>
{{--Last name--}}
<div class="form-group row">
<label class="col-md-4" for="lastname">Last Name</label>
<div class="col-md-8">
<input type="text" id="lastname" name="lastname" placeholder="Last Name"
value="{{ $customer->lastname }}" class="form-control">
</div>
</div>
{{--Company--}}
<div class="form-group row">
<label class="col-md-4" for="company">Company</label>
<div class="col-md-8">
<input type="text" id="company" name="company" placeholder="Company"
value="{{ $customer->company }}" class="form-control">
</div>
</div>
{{--Email--}}
<div class="form-group row">
<label class="col-md-4" for="email">Email Address</label>
<div class="col-md-8">
<input type="email" id="email" name="email" placeholder="Email Address"
value="{{ $customer->email }}" class="form-control">
</div>
</div>
{{--Phone--}}
<div class="form-group row">
<label class="col-md-4" for="phone">Phone Number</label>
<div class="col-md-8">
<input type="text" id="phone" name="phone" placeholder="(+84) 123. 456. 789)"
value="{{ $customer->phone }}" class="form-control">
</div>
</div>
{{--Password--}}
<div class="form-group row">
<label class="col-md-4" for="password">Password</label>
<div class="col-md-8">
<input type="password" id="password" name="password" placeholder="******"
value="" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-md-4" for="email_marketing">Marketing Emails Opt-in</label>
<div class="col-md-8">
<input type="checkbox" name="email_marketing" id="email_marketing" @checked($customer->email_marketing === 1)>
Send Client Marketing Emails
</div>
</div>
</div>
<div class="col">
{{--Address--}}
<div class="form-group row">
<label class="col-md-4" for="address">Address</label>
<div class="col-md-8">
<input type="text" id="address" name="address" placeholder="Address"
value="{{ $customer->address }}" class="form-control">
</div>
</div>
{{--City--}}
<div class="form-group row">
<label class="col-md-4" for="city">City</label>
<div class="col-md-8">
<input type="text" id="city" name="city" placeholder="City"
value="{{ $customer->city }}" class="form-control">
</div>
</div>
{{--State--}}
<div class="form-group row">
<label class="col-md-4" for="state">State</label>
<div class="col-md-8">
<input type="text" id="state" name="state" placeholder="State"
value="{{ $customer->state }}" class="form-control">
</div>
</div>
{{--Postcode--}}
<div class="form-group row">
<label class="col-md-4" for="postcode">Postcode</label>
<div class="col-md-8">
<input type="text" id="postcode" name="postcode" placeholder="Postcode"
value="{{ $customer->postcode }}" class="form-control">
</div>
</div>
{{--Country--}}
<div class="form-group row">
<label class="col-md-4" for="country">Country</label>
<div class="col-md-8">
<input type="text" id="country" name="country" placeholder="Country"
value="{{ $customer->country }}" class="form-control">
</div>
</div>
{{--Limit Snapshot--}}
<div class="form-group row">
<label class="col-md-4" for="snapshot_limit">SnapShot Limit</label>
<div class="col-md-8">
<input type="text" id="country" name="snapshot_limit" placeholder="snapshot_limit"
value="{{ $customer->snapshot->limit }}" class="form-control">
</div>
</div>
{{--Status--}}
<div class="form-group row">
<label class="col-md-4" for="status">Status</label>
<div class="col-md-8">
<select name="status" class="form-control" id="status">
<option value="1" @selected($customer->status == 1)>Actived</option>
<option value="2" @selected($customer->status == 2)>De-Active</option>
<option value="0" @selected($customer->status == 0)>Banned</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-outline-primary">Save</button>
</div>
</form>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection
@@ -0,0 +1,53 @@
@extends('admin.main')
@section('content')
@if (auth()->guard('admins')->user()->can('edit customer'))
<div class="card card-outline card-primary">
<div class="card-header">
@include('admin.block.nav')
</div>
<div class="card-body">
<table class="table table-invoice table-bordered">
<thead>
<tr>
<th>Transaction ID</th>
<th>Amount</th>
<th>Date</th>
</tr>
</thead>
<tbody>
@if (count($transactions))
@foreach ($transactions as $item)
<tr>
<td class="text-center">
{{ $item->trans }}
</td>
<td class="text-center">
{{ number_format($item->amount, 0, ',', '.') }} đ
</td>
<td class="text-center">
{{ $item->created_at }}
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="8">
No Records Found
</td>
</tr>
@endif
</tbody>
<tfoot>
{!! $transactions->withQueryString()->links() !!}
</tfoot>
</table>
</div>
</div>
@else
<div class="alert alert-danger alert-dismissible">
<h5 class="mb-0"><i class="icon fas fa-ban"></i> Access Denied - You are not assigned to any Customer
management department</h5>
</div>
@endif
@endsection