File: /www/wwwroot/erp.nhatnamsst.com/storage/framework/views/8b1f7f9ff88467c55869fc0c853c6dfc.php
<div class="col-12">
<div class="row">
<!-- Row 1: Mã khách hàng (rộng), Loại khách hàng, Tên khách hàng* (rộng) -->
<div class="col-md-3 col-12">
<div class="mb-2">
<label class="form-label"><?php echo app('translator')->get('Mã khách hàng'); ?></label>
<input type="text" class="form-control" value="<?php echo e($customer->code); ?>" readonly>
</div>
</div>
<div class="col-md-3 col-12">
<div class="mb-2">
<label class="form-label required"><?php echo app('translator')->get('Loại khách hàng'); ?></label>
<?php if (isset($component)) { $__componentOriginal5fa9746c29c1e04ec81f3e9772da4d7b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal5fa9746c29c1e04ec81f3e9772da4d7b = $attributes; } ?>
<?php $component = Domains\Core\View\Components\Select\Select::resolve(['required' => true] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('core-select'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Domains\Core\View\Components\Select\Select::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'customer[type]','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('customer.type', $customer->type?->value))]); ?>
<option value=""><?php echo app('translator')->get('--Chọn Loại khách hàng--'); ?></option>
<?php $__currentLoopData = \Domains\Core\Enums\CustomerType::cases(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($type->value); ?>"
<?php echo e(old('customer.type', $customer->type?->value) == $type->value ? 'selected' : ''); ?>>
<?php echo e($type->description()); ?></option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal5fa9746c29c1e04ec81f3e9772da4d7b)): ?>
<?php $attributes = $__attributesOriginal5fa9746c29c1e04ec81f3e9772da4d7b; ?>
<?php unset($__attributesOriginal5fa9746c29c1e04ec81f3e9772da4d7b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal5fa9746c29c1e04ec81f3e9772da4d7b)): ?>
<?php $component = $__componentOriginal5fa9746c29c1e04ec81f3e9772da4d7b; ?>
<?php unset($__componentOriginal5fa9746c29c1e04ec81f3e9772da4d7b); ?>
<?php endif; ?>
</div>
</div>
<div class="col-md-6 col-12">
<div class="mb-2">
<label class="form-label required"><?php echo app('translator')->get('Tên khách hàng'); ?></label>
<?php if (isset($component)) { $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $attributes; } ?>
<?php $component = Domains\Core\View\Components\Input\Input::resolve(['required' => true] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('core-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Domains\Core\View\Components\Input\Input::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'customer[name]','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('customer.name', $customer->name))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $attributes = $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $component = $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
</div>
</div>
<!-- Row 2: Tên viết tắt* (rộng), Địa chỉ (rộng) -->
<div class="col-md-6 col-12">
<div class="mb-2">
<label class="form-label required"><?php echo app('translator')->get('Tên viết tắt'); ?></label>
<?php if (isset($component)) { $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $attributes; } ?>
<?php $component = Domains\Core\View\Components\Input\Input::resolve(['required' => true] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('core-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Domains\Core\View\Components\Input\Input::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'customer[short_name]','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('customer.short_name', $customer->short_name)),'maxlength' => '18','placeholder' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(@trans('Không vượt quá 18 ký tự'))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $attributes = $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $component = $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
</div>
</div>
<div class="col-md-6 col-12">
<div class="mb-2">
<label class="form-label"><?php echo app('translator')->get('Địa chỉ'); ?></label>
<?php if (isset($component)) { $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $attributes; } ?>
<?php $component = Domains\Core\View\Components\Input\Input::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('core-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Domains\Core\View\Components\Input\Input::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'customer[address]','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('customer.address', $customer->address))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $attributes = $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $component = $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
</div>
</div>
<!-- Row 3: Người liên hệ, Chức vụ, Mã số thuế (rộng) -->
<div class="col-md-3 col-12">
<div class="mb-2">
<label class="form-label"><?php echo app('translator')->get('Người liên hệ'); ?></label>
<?php if (isset($component)) { $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $attributes; } ?>
<?php $component = Domains\Core\View\Components\Input\Input::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('core-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Domains\Core\View\Components\Input\Input::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'customer[contact_person]','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('customer.contact_person', $customer->contact_person))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $attributes = $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $component = $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
</div>
</div>
<div class="col-md-3 col-12">
<div class="mb-2">
<label class="form-label"><?php echo app('translator')->get('Chức vụ'); ?></label>
<?php if (isset($component)) { $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $attributes; } ?>
<?php $component = Domains\Core\View\Components\Input\Input::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('core-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Domains\Core\View\Components\Input\Input::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'customer[position]','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('customer.position', $customer->position))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $attributes = $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $component = $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
</div>
</div>
<div class="col-md-6 col-12">
<div class="mb-2">
<label class="form-label"><?php echo app('translator')->get('Mã số thuế'); ?></label>
<?php if (isset($component)) { $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc = $attributes; } ?>
<?php $component = Domains\Core\View\Components\Input\Input::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('core-input'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Domains\Core\View\Components\Input\Input::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'customer[tax_code]','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('customer.tax_code', $customer->tax_code))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $attributes = $__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__attributesOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc)): ?>
<?php $component = $__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc; ?>
<?php unset($__componentOriginalf721e5e43a4885e8df1ae9a2bb0503fc); ?>
<?php endif; ?>
</div>
</div>
<!-- Row 4: Số điện thoại*, Email*, Phương thức thanh toán (rộng) -->
<div class="col-md-3 col-12">
<div class="mb-2">
<label class="form-label required"><?php echo app('translator')->get('Số điện thoại'); ?></label>
<?php if (isset($component)) { $__componentOriginal8d7f8639a25948713d2e461a9414b181 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal8d7f8639a25948713d2e461a9414b181 = $attributes; } ?>
<?php $component = Domains\Core\View\Components\Input\InputPhone::resolve(['required' => true] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('core-input-phone'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Domains\Core\View\Components\Input\InputPhone::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'customer[phone]','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('customer.phone', $customer->phone))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal8d7f8639a25948713d2e461a9414b181)): ?>
<?php $attributes = $__attributesOriginal8d7f8639a25948713d2e461a9414b181; ?>
<?php unset($__attributesOriginal8d7f8639a25948713d2e461a9414b181); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal8d7f8639a25948713d2e461a9414b181)): ?>
<?php $component = $__componentOriginal8d7f8639a25948713d2e461a9414b181; ?>
<?php unset($__componentOriginal8d7f8639a25948713d2e461a9414b181); ?>
<?php endif; ?>
</div>
</div>
<div class="col-md-3 col-12">
<div class="mb-2">
<label class="form-label required"><?php echo app('translator')->get('Email'); ?></label>
<?php if (isset($component)) { $__componentOriginal879e42e7cf75025b82735344c67500cd = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal879e42e7cf75025b82735344c67500cd = $attributes; } ?>
<?php $component = Domains\Core\View\Components\Input\InputEmail::resolve(['required' => true] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('core-input-email'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Domains\Core\View\Components\Input\InputEmail::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['name' => 'customer[email]','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('customer.email', $customer->email))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal879e42e7cf75025b82735344c67500cd)): ?>
<?php $attributes = $__attributesOriginal879e42e7cf75025b82735344c67500cd; ?>
<?php unset($__attributesOriginal879e42e7cf75025b82735344c67500cd); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal879e42e7cf75025b82735344c67500cd)): ?>
<?php $component = $__componentOriginal879e42e7cf75025b82735344c67500cd; ?>
<?php unset($__componentOriginal879e42e7cf75025b82735344c67500cd); ?>
<?php endif; ?>
</div>
</div>
<div class="col-md-6 col-12">
<div class="mb-2">
<label class="form-label"><?php echo app('translator')->get('Phương thức thanh toán'); ?></label>
<?php
$paymentMethods = $paymentMethods ?? collect();
$currentPaymentMethod = old('customer.payment_method', $customer->payment_method);
?>
<select name="customer[payment_method]" class="form-select">
<option value=""><?php echo app('translator')->get('--Chọn Phương thức thanh toán--'); ?></option>
<?php $__currentLoopData = $paymentMethods; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $method): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($method->name); ?>" <?php echo e($currentPaymentMethod == $method->name ? 'selected' : ''); ?>>
<?php echo e($method->name); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
</div>
</div>
<?php if($customer->sale): ?>
<div class="col-md-6 col-12">
<div class="mb-2 mt-3">
<span class="form-label"><?php echo app('translator')->get('Thuộc Sale'); ?>: <strong> <?php echo e($customer->sale->code ?? ''); ?> -
<?php echo e($customer->sale->fullname); ?> (<?php echo e($customer->sale->role->description()); ?>)</strong></span>
</div>
</div>
<?php endif; ?>
</div>
<div class="mt-3">
<span class="form-label"><?php echo app('translator')->get('Liên hệ'); ?></span>
<div class="">
<div class="ui-jqgrid-view table-responsive">
<table id="contacts-grid"></table>
<div id="contacts-pager"></div>
</div>
</div>
</div>
</div>
<?php $__env->startPush('libs-css'); ?>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/themes/ui-lightness/jquery-ui.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.5/css/ui.jqgrid.min.css">
<?php $__env->stopPush(); ?>
<?php $__env->startPush('libs-js'); ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.5/js/i18n/grid.locale-vi.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.5/jquery.jqgrid.min.js"></script>
<?php $__env->stopPush(); ?>
<?php $__env->startPush('js'); ?>
<script>
$(document).ready(function() {
let contactIndex = <?php echo e($customer->contacts->count() > 0 ? $customer->contacts->count() : 0); ?>;
// Khởi tạo jqGrid
$("#contacts-grid").jqGrid({
datatype: "local",
colNames: ['', 'Họ và tên', 'Số điện thoại', 'Số tài khoản', 'Ngân hàng', 'Chức vụ',
'Tình trạng'
],
colModel: [{
name: 'checkbox',
index: 'checkbox',
width: 50,
align: 'center',
formatter: function(cellvalue, options, rowObject) {
return '<input type="checkbox" class="form-check-input contact-checkbox" data-rowid="' +
options.rowId + '">';
},
sortable: false,
search: false
},
{
name: 'fullname',
index: 'fullname',
width: 150,
editable: true,
edittype: 'text',
editoptions: {
size: 20,
maxlength: 255,
dataInit: function(elem) {
$(elem).addClass('form-control');
}
},
},
{
name: 'phone',
index: 'phone',
width: 120,
editable: true,
edittype: 'text',
editoptions: {
size: 15,
maxlength: 20,
dataInit: function(elem) {
$(elem).addClass('form-control');
}
},
},
{
name: 'account_number',
index: 'account_number',
width: 150,
editable: true,
edittype: 'text',
editoptions: {
size: 20,
maxlength: 255,
dataInit: function(elem) {
$(elem).addClass('form-control');
}
},
},
{
name: 'bank',
index: 'bank',
width: 150,
editable: true,
edittype: 'text',
editoptions: {
size: 20,
maxlength: 255,
dataInit: function(elem) {
$(elem).addClass('form-control');
}
},
},
{
name: 'position',
index: 'position',
width: 120,
editable: true,
edittype: 'text',
editoptions: {
size: 15,
maxlength: 255,
dataInit: function(elem) {
$(elem).addClass('form-control');
}
},
},
{
name: 'status',
index: 'status',
width: 80,
align: 'center',
formatter: function(cellvalue, options, rowObject) {
var checked = (cellvalue == 1 || cellvalue == '1' || cellvalue ===
true) ? 'checked' : '';
return '<input type="checkbox" class="form-check-input contact-status" data-rowid="' +
options.rowId + '" ' + checked + '>';
},
sortable: false
}
],
rowNum: 10,
rowList: [10, 20, 30, 50, 100],
pager: '#contacts-pager',
sortname: 'fullname',
viewrecords: true,
sortorder: "asc",
caption: "",
height: 'auto',
autowidth: true,
shrinkToFit: true,
multiselect: false,
editurl: 'clientArray',
cellEdit: true,
cellsubmit: 'clientArray',
afterSaveCell: function(rowid, name, val, iRow, iCol) {
}
});
$(document).on('click', function(e) {
var $target = $(e.target);
if (!$target.closest('#contacts-grid').length &&
!$target.closest('.ui-jqgrid').length &&
!$target.closest('#contacts-pager').length) {
var $editingInput = $('#contacts-grid').find('input.editable:focus, input[type="text"]:focus');
if ($editingInput.length > 0) {
$editingInput.blur();
}
}
});
setTimeout(function() {
var btnGroup = $('<div class="btn-group">' +
'<button type="button" class="btn btn-sm btn-primary" id="btn-add-contact">' +
'<i class="ti ti-plus"></i> <?php echo app('translator')->get('Thêm'); ?></button>' +
'<button type="button" class="btn btn-sm btn-secondary" id="btn-copy-contact">' +
'<i class="ti ti-copy"></i> <?php echo app('translator')->get('Copy'); ?></button>' +
'<button type="button" class="btn btn-sm btn-warning" id="btn-edit-contact">' +
'<i class="ti ti-edit"></i> <?php echo app('translator')->get('Sửa'); ?></button>' +
'<button type="button" class="btn btn-sm btn-danger" id="btn-delete-contact">' +
'<i class="ti ti-trash"></i> <?php echo app('translator')->get('Xóa'); ?></button>' +
'<button type="button" class="btn btn-sm btn-info" id="btn-skip-contact">' +
'<i class="ti ti-power"></i> <?php echo app('translator')->get('Bỏ qua'); ?></button>' +
'<button type="button" class="btn btn-sm btn-success" id="btn-refresh-contact">' +
'<i class="ti ti-refresh"></i> <?php echo app('translator')->get('Làm mới'); ?></button>' +
'</div>');
$('#contacts-pager_left').html(btnGroup);
}, 100);
// Load dữ liệu từ server
<?php if($customer->contacts->count() > 0): ?>
var contactsData = [
<?php $__currentLoopData = $customer->contacts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $contact): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
{
id: 'row_<?php echo e($index); ?>',
fullname: '<?php echo e(addslashes($contact->fullname)); ?>',
phone: '<?php echo e(addslashes($contact->phone ?? '')); ?>',
account_number: '<?php echo e(addslashes($contact->account_number ?? '')); ?>',
bank: '<?php echo e(addslashes($contact->bank ?? '')); ?>',
position: '<?php echo e(addslashes($contact->position ?? '')); ?>',
status: <?php echo e($contact->status ? 1 : 0); ?>
}
<?php if(!$loop->last): ?>
,
<?php endif; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
];
for (var i = 0; i < contactsData.length; i++) {
$("#contacts-grid").jqGrid('addRowData', contactsData[i].id, {
fullname: contactsData[i].fullname,
phone: contactsData[i].phone,
account_number: contactsData[i].account_number,
bank: contactsData[i].bank,
position: contactsData[i].position,
status: contactsData[i].status
});
}
<?php else: ?>
// Thêm dữ liệu mặc định nếu không có contacts
addContactRow();
<?php endif; ?>
$(document).on('click', '#btn-add-contact', function() {
addContactRow();
});
$(document).on('click', '#btn-copy-contact', function() {
var selectedRowIds = [];
$('.contact-checkbox:checked').each(function() {
selectedRowIds.push($(this).data('rowid'));
});
if (selectedRowIds.length > 0) {
selectedRowIds.forEach(function(rowId) {
var rowData = $("#contacts-grid").jqGrid('getRowData', rowId);
var statusCheckbox = $("#contacts-grid").find('tr#' + rowId +
' .contact-status');
var status = statusCheckbox.is(':checked') ? 1 : 0;
var newRowData = {
fullname: rowData.fullname || '',
phone: rowData.phone || '',
account_number: rowData.account_number || '',
bank: rowData.bank || '',
position: rowData.position || '',
status: status
};
contactIndex++;
var newRowId = 'row_' + contactIndex;
$("#contacts-grid").jqGrid('addRowData', newRowId, newRowData);
});
} else {
alert('Vui lòng chọn ít nhất một dòng để copy');
}
});
// Xóa liên hệ - sử dụng event delegation
$(document).on('click', '#btn-delete-contact', function() {
var selectedRowIds = [];
$('.contact-checkbox:checked').each(function() {
selectedRowIds.push($(this).data('rowid'));
});
if (selectedRowIds.length > 0) {
if (confirm('Bạn có chắc chắn muốn xóa ' + selectedRowIds.length + ' dòng đã chọn?')) {
selectedRowIds.forEach(function(rowId) {
$("#contacts-grid").jqGrid('delRowData', rowId);
});
}
} else {
alert('Vui lòng chọn ít nhất một dòng để xóa');
}
});
// Bỏ qua - clear selection - sử dụng event delegation
$(document).on('click', '#btn-skip-contact', function() {
$('.contact-checkbox').prop('checked', false);
$("#contacts-grid").jqGrid('setSelection', null);
});
// Làm mới - reload grid - sử dụng event delegation
$(document).on('click', '#btn-refresh-contact', function() {
$("#contacts-grid").jqGrid('setGridParam', {
datatype: 'local'
}).trigger('reloadGrid');
});
function addContactRow() {
contactIndex++;
var newRowId = 'row_' + contactIndex;
var newRowData = {
fullname: '',
phone: '',
account_number: '',
bank: '',
position: '',
status: '1'
};
$("#contacts-grid").jqGrid('addRowData', newRowId, newRowData);
}
// Trước khi submit form, lấy dữ liệu từ grid và tạo hidden inputs
$('form').on('submit', function(e) {
var contacts = [];
var allRowIds = $("#contacts-grid").jqGrid('getDataIDs');
// Xóa các hidden inputs cũ
$('input[name^="contacts["]').remove();
allRowIds.forEach(function(rowId) {
var rowData = $("#contacts-grid").jqGrid('getRowData', rowId);
var fullname = rowData.fullname || '';
var phone = rowData.phone || '';
var account_number = rowData.account_number || '';
var bank = rowData.bank || '';
var position = rowData.position || '';
var statusCheckbox = $("#contacts-grid").find('tr#' + rowId +
' .contact-status');
var status = statusCheckbox.is(':checked') ? 1 : 0;
// Chỉ thêm nếu có fullname
if (fullname && fullname.trim() !== '') {
contacts.push({
fullname: fullname,
phone: phone,
account_number: account_number,
bank: bank,
position: position,
status: status
});
}
});
// Tạo hidden inputs cho contacts
contacts.forEach(function(contact, index) {
Object.keys(contact).forEach(function(key) {
var input = $('<input>').attr({
type: 'hidden',
name: 'contacts[' + index + '][' + key + ']',
value: contact[key]
});
$('form').append(input);
});
});
});
});
</script>
<?php $__env->stopPush(); ?>
<?php /**PATH /www/wwwroot/erp.nhatnamsst.com/resources/views/cms/customers/forms/edit-left.blade.php ENDPATH**/ ?>