trabajando en la vista

This commit is contained in:
jaimejimenezortega
2024-04-16 23:16:17 +02:00
parent 2a48b044a6
commit e15ddbc8ab
8 changed files with 7659 additions and 679 deletions

View File

@ -0,0 +1,237 @@
/**
* Cliente presupuesto Wizard
*/
'use strict';
(function () {
// Init custom option check
//window.Helpers.initCustomOptionCheck();
// Vertical Wizard
// --------------------------------------------------------------------
const clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente');
if (typeof clientePresupuestoWizard !== undefined && clientePresupuestoWizard !== null) {
// Wizard form
const clientePresupuestoWizardForm = clientePresupuestoWizard.querySelector('#presupuesto-cliente-form');
// Wizard steps
const clientePresupuestoWizardFormStep1 = clientePresupuestoWizardForm.querySelector('#datos-generales');
const clientePresupuestoWizardFormStep2 = clientePresupuestoWizardForm.querySelector('#disenio-libro');
const clientePresupuestoWizardFormStep3 = clientePresupuestoWizardForm.querySelector('#direcciones-libro');
const clientePresupuestoWizardFormStep4 = clientePresupuestoWizardForm.querySelector('#resumen-libro');
// Wizard next prev button
const clientePresupuestoWizardNext = [].slice.call(clientePresupuestoWizardForm.querySelectorAll('.btn-next'));
const clientePresupuestoWizardPrev = [].slice.call(clientePresupuestoWizardForm.querySelectorAll('.btn-prev'));
let validationStepper = new Stepper(clientePresupuestoWizard, {
linear: true
});
// Deal Type
const FormValidation1 = FormValidation.formValidation(clientePresupuestoWizardFormStep1, {
fields: {
dealAmount: {
validators: {
notEmpty: {
message: 'Please enter amount'
},
numeric: {
message: 'The amount must be a number'
}
}
},
dealRegion: {
validators: {
notEmpty: {
message: 'Please select region'
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap5: new FormValidation.plugins.Bootstrap5({
// Use this for enabling/changing valid/invalid class
// eleInvalidClass: '',
eleValidClass: '',
rowSelector: '.col-sm-6'
}),
autoFocus: new FormValidation.plugins.AutoFocus(),
submitButton: new FormValidation.plugins.SubmitButton()
}
}).on('core.form.valid', function () {
// Jump to the next step when all fields in the current step are valid
validationStepper.next();
});
// select2 (Region)
const dealRegion = $('#dealRegion');
if (dealRegion.length) {
dealRegion.wrap('<div class="position-relative"></div>');
dealRegion
.select2({
placeholder: 'Select an region',
dropdownParent: dealRegion.parent()
})
.on('change.select2', function () {
// Revalidate the region field when an option is chosen
FormValidation1.revalidateField('dealRegion');
});
}
// Deal Details
const FormValidation2 = FormValidation.formValidation(clientePresupuestoWizardFormStep2, {
fields: {
// * Validate the fields here based on your requirements
dealTitle: {
validators: {
notEmpty: {
message: 'Please enter deal title'
}
}
},
dealCode: {
validators: {
notEmpty: {
message: 'Please enter deal code'
},
stringLength: {
min: 4,
max: 10,
message: 'The deal code must be more than 4 and less than 10 characters long'
},
regexp: {
regexp: /^[A-Z0-9]+$/,
message: 'The deal code can only consist of capital alphabetical and number'
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap5: new FormValidation.plugins.Bootstrap5({
// Use this for enabling/changing valid/invalid class
// eleInvalidClass: '',
eleValidClass: '',
rowSelector: '.col-sm-6'
}),
autoFocus: new FormValidation.plugins.AutoFocus(),
submitButton: new FormValidation.plugins.SubmitButton()
}
}).on('core.form.valid', function () {
// Jump to the next step when all fields in the current step are valid
validationStepper.next();
});
// select2 (Offered Item)
const dealOfferedItem = $('#dealOfferedItem');
if (dealOfferedItem.length) {
dealOfferedItem.wrap('<div class="position-relative"></div>');
dealOfferedItem
.select2({
placeholder: 'Select an offered item',
dropdownParent: dealOfferedItem.parent()
})
.on('change.select2', function () {
// Revalidate the field if needed when an option is chosen
// FormValidation2.revalidateField('dealOfferedItem');
});
}
// Deal Usage
const FormValidation3 = FormValidation.formValidation(clientePresupuestoWizardFormStep3, {
fields: {
// * Validate the fields here based on your requirements
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap5: new FormValidation.plugins.Bootstrap5({
// Use this for enabling/changing valid/invalid class
// eleInvalidClass: '',
eleValidClass: '',
rowSelector: '.col-sm-6'
}),
autoFocus: new FormValidation.plugins.AutoFocus(),
submitButton: new FormValidation.plugins.SubmitButton()
}
}).on('core.form.valid', function () {
validationStepper.next();
});
// Deal Usage
const FormValidation4 = FormValidation.formValidation(clientePresupuestoWizardFormStep4, {
fields: {
// * Validate the fields here based on your requirements
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap5: new FormValidation.plugins.Bootstrap5({
// Use this for enabling/changing valid/invalid class
// eleInvalidClass: '',
eleValidClass: '',
rowSelector: '.col-md-12'
}),
autoFocus: new FormValidation.plugins.AutoFocus(),
submitButton: new FormValidation.plugins.SubmitButton()
}
}).on('core.form.valid', function () {
// You can submit the form
// clientePresupuestoWizardForm.submit()
// or send the form data to server via an Ajax request
// To make the demo simple, I just placed an alert
alert('Submitted..!!');
});
clientePresupuestoWizardNext.forEach(item => {
item.addEventListener('click', event => {
// When click the Next button, we will validate the current step
switch (validationStepper._currentIndex) {
case 0:
FormValidation1.validate();
break;
case 1:
FormValidation2.validate();
break;
case 2:
FormValidation3.validate();
break;
case 3:
FormValidation4.validate();
break;
default:
break;
}
});
});
clientePresupuestoWizardPrev.forEach(item => {
item.addEventListener('click', event => {
switch (validationStepper._currentIndex) {
case 3:
validationStepper.previous();
break;
case 2:
validationStepper.previous();
break;
case 1:
validationStepper.previous();
break;
case 0:
default:
break;
}
});
});
}
})();

View File

@ -0,0 +1,351 @@
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?= $this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
<form id="presupuestoForm" class="card-body" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<!-- Create Deal Wizard -->
<div id="wizard-presupuesto-cliente" class="bs-stepper vertical mt-2 linear">
<div class="bs-stepper-header">
<div class="step active" data-target="#datos-generales">
<button type="button" class="step-trigger" aria-selected="true">
<span class="bs-stepper-circle"><i class="ti ti-users ti-sm"></i></span>
<span class="bs-stepper-label">
<span class="bs-stepper-title">Datos generales</span>
<span class="bs-stepper-subtitle">Información del libro</span>
</span>
</button>
</div>
<div class="line"></div>
<div class="step" data-target="#disenio-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
<span class="bs-stepper-circle"><i class="ti ti-id ti-sm"></i></span>
<span class="bs-stepper-label">
<span class="bs-stepper-title">Diseño del libro</span>
<span class="bs-stepper-subtitle">Detalles técnicos del libro</span>
</span>
</button>
</div>
<div class="line"></div>
<div class="step" data-target="#direcciones-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
<span class="bs-stepper-circle"><i class="ti ti-credit-card ti-sm"></i></span>
<span class="bs-stepper-label">
<span class="bs-stepper-title">Direcciones</span>
<span class="bs-stepper-subtitle">Dirección envío, facturación</span>
</span>
</button>
</div>
<div class="line"></div>
<div class="step" data-target="#resumen-libro">
<button type="button" class="step-trigger" aria-selected="false" disabled="disabled">
<span class="bs-stepper-circle"><i class="ti ti-checkbox ti-sm"></i></span>
<span class="bs-stepper-label">
<span class="bs-stepper-title">Resumen del presupuesto</span>
</span>
</button>
</div>
</div>
<div class="bs-stepper-content">
<form id="presupuesto-cliente-form" onsubmit="return false">
<!-- Datos Generales -->
<div id="datos-generales" class="content active dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-label-secondary btn-prev waves-effect">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none">Previous</span>
</button>
<button class="btn btn-primary btn-next waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Next</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
</div>
</div>
</div>
<!-- Deal Details -->
<div id="disenio-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<div class="col-sm-6 fv-plugins-icon-container">
<label class="form-label" for="dealTitle">Deal Title</label>
<input type="text" id="dealTitle" name="dealTitle" class="form-control" placeholder="Black friday sale, 25% off">
<div class="fv-plugins-message-container invalid-feedback"></div></div>
<div class="col-sm-6 fv-plugins-icon-container">
<label class="form-label" for="dealCode">Deal Code</label>
<input type="text" id="dealCode" name="dealCode" class="form-control" placeholder="25PEROFF">
<div class="fv-plugins-message-container invalid-feedback"></div></div>
<div class="col-sm-6">
<label class="form-label" for="dealDescription">Deal Description</label>
<textarea id="dealDescription" name="dealDescription" class="form-control" rows="5" placeholder="To sell or distribute something as a business deal"></textarea>
</div>
<div class="col-sm-6">
<div class="row">
<div class="col-12 mb-3">
<label class="form-label" for="dealOfferedItem">Offered Items</label>
<div class="position-relative">
<select class="select2 select2-hidden-accessible" id="dealOfferedItem" name="dealOfferedItem" multiple="" data-select2-id="dealOfferedItem" tabindex="-1" aria-hidden="true">
<option disabled="" value="">Select offered item</option>
<option value="65328">Apple iPhone 12 Pro Max (256GB)</option>
<option value="25612">Apple iPhone 12 Pro (512GB)</option>
<option value="65454">Apple iPhone 12 Mini (256GB)</option>
<option value="12365">Apple iPhone 11 Pro Max (256GB)</option>
<option value="85466">Apple iPhone 11 (64GB)</option>
<option value="98564">OnePlus Nord CE 5G (128GB)</option>
</select><span class="select2 select2-container select2-container--default" dir="ltr" data-select2-id="2" style="width: auto;"><span class="selection"><span class="select2-selection select2-selection--multiple" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="-1" aria-disabled="false"><ul class="select2-selection__rendered"><li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="0" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="searchbox" aria-autocomplete="list" placeholder="Select an offered item" style="width: 0px;"></li></ul></span></span><span class="dropdown-wrapper" aria-hidden="true"></span></span></div>
</div>
<div class="col-12">
<label class="form-label" for="dealCartCondition">Cart condition</label>
<select class="form-select" id="dealCartCondition" name="dealCartCondition">
<option disabled="" value="">Select cart condition</option>
<option value="all">Cart must contain all selected Downloads</option>
<option value="any">Cart needs one or more of the selected Downloads</option>
</select>
</div>
</div>
</div>
<div class="col-sm-6">
<label for="dealDuration" class="form-label">Deal Duration</label>
<input type="text" id="dealDuration" name="dealDuration" class="form-control flatpickr-input" placeholder="YYYY-MM-DD to YYYY-MM-DD" readonly="readonly">
</div>
<div class="col-sm-6">
<label class="form-label">Notify Users</label>
<div class="row">
<div class="col mt-2">
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="dealNotifyEmail" name="dealNotifyEmail" value="email">
<label class="form-check-label" for="dealNotifyEmail">Email</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="dealNotifySMS" name="dealNotifySMS" value="sms">
<label class="form-check-label" for="dealNotifySMS">SMS</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="dealNotifyPush" name="dealNotifyPush" value="push">
<label class="form-check-label" for="dealNotifyPush">Push Notification</label>
</div>
</div>
</div>
</div>
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-label-secondary btn-prev waves-effect">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none">Previous</span>
</button>
<button class="btn btn-primary btn-next waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Next</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
</div>
</div>
</div>
<!-- Deal Usage -->
<div id="direcciones-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<div class="col-sm-6">
<label class="form-label" for="dealUserType">User Type</label>
<select id="dealUserType" name="dealUserType" class="form-select">
<option selected="" disabled="" value="">Select user type</option>
<option value="all">All</option>
<option value="registered">Registered</option>
<option value="unregistered">Unregistered</option>
<option value="prime-members">Prime members</option>
</select>
</div>
<div class="col-sm-6">
<label class="form-label" for="dealMaxUsers">Max Users</label>
<input type="number" id="dealMaxUsers" name="dealMaxUsers" class="form-control" placeholder="500">
</div>
<div class="col-sm-6">
<label class="form-label" for="dealMinimumCartAmount">Minimum Cart Amount</label>
<input type="number" id="dealMinimumCartAmount" name="dealMinimumCartAmount" class="form-control" placeholder="$99">
</div>
<div class="col-sm-6">
<label class="form-label" for="dealPromotionalFee">Promotional Fee</label>
<input type="number" id="dealPromotionalFee" name="dealPromotionalFee" class="form-control" placeholder="$9">
</div>
<div class="col-sm-6">
<label class="form-label" for="dealPaymentMethod">Payment Method</label>
<select id="dealPaymentMethod" name="dealPaymentMethod" class="form-select">
<option selected="" disabled="" value="">Select payment method</option>
<option value="any">Any</option>
<option value="credit-card">Credit Card</option>
<option value="net-banking">Net Banking</option>
<option value="wallet">Wallet</option>
</select>
</div>
<div class="col-sm-6">
<label class="form-label" for="dealStatus">Deal Status</label>
<select id="dealStatus" name="dealStatus" class="form-select">
<option selected="" disabled="" value="">Select status</option>
<option value="active">Active</option>
<option value="inactive">Inactive</option>
<option value="suspend">Suspend</option>
<option value="abandon">Abandone</option>
</select>
</div>
<div class="col-lg-12">
<label class="switch">
<input type="checkbox" class="switch-input" id="dealLimitUser" name="dealLimitUser">
<span class="switch-toggle-slider">
<span class="switch-on"></span>
<span class="switch-off"></span>
</span>
<span class="switch-label"> Limit this discount to a single-use per customer?</span>
</label>
</div>
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-label-secondary btn-prev waves-effect">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none">Previous</span>
</button>
<button class="btn btn-primary btn-next waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Next</span>
<i class="ti ti-arrow-right ti-xs"></i>
</button>
</div>
</div>
</div>
<!-- Review & Complete -->
<div id="resumen-libro" class="content fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<div class="col-lg-6">
<div class="row">
<div class="col-12 mb-0">
<h3>Almost done! 🚀</h3>
<p>Confirm your deal details information and submit to create it.</p>
</div>
<div class="col-12 mb-0">
<table class="table table-borderless">
<tbody>
<tr>
<td class="ps-0 align-top text-nowrap py-1"><strong>Deal Type</strong></td>
<td class="px-0 py-1">Percentage</td>
</tr>
<tr>
<td class="ps-0 align-top text-nowrap py-1"><strong>Amount</strong></td>
<td class="px-0 py-1">25%</td>
</tr>
<tr>
<td class="ps-0 align-top text-nowrap py-1"><strong>Deal Code</strong></td>
<td class="px-0 py-1">
<div class="badge bg-label-warning">25PEROFF</div>
</td>
</tr>
<tr>
<td class="ps-0 align-top text-nowrap py-1"><strong>Deal Title</strong></td>
<td class="px-0 py-1">Black friday sale, 25% OFF</td>
</tr>
<tr>
<td class="ps-0 align-top text-nowrap py-1"><strong>Deal Duration</strong></td>
<td class="px-0 py-1">
<span class="fw-semibold">2021-07-14</span> to
<span class="fw-semibold">2021-07-30</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-xl-6 col-lg-5 d-flex justify-content-center border rounded pt-3">
<img class="img-fluid" src="../../assets/img/illustrations/wizard-create-deal-confirm.png" alt="deal image cap">
</div>
<div class="col-md-12">
<label class="switch">
<input type="checkbox" class="switch-input" id="dealConfirmed" name="dealConfirmed">
<span class="switch-toggle-slider">
<span class="switch-on"></span>
<span class="switch-off"></span>
</span>
<span class="switch-label"> I have confirmed the deal details.</span>
</label>
</div>
<div class="col-12 d-flex justify-content-between mt-4">
<button class="btn btn-label-secondary btn-prev waves-effect">
<i class="ti ti-arrow-left ti-xs me-sm-1 me-0"></i>
<span class="align-middle d-sm-inline-block d-none">Previous</span>
</button>
<button class="btn btn-success btn-submit btn-next waves-effect waves-light">
<span class="align-middle d-sm-inline-block d-none me-sm-1">Submit</span><i class="ti ti-check ti-xs"></i>
</button>
</div>
</div>
</div>
</form>
</div>
</div>
<!-- /Create Deal Wizard -->
<div class="pt-4">
<input type="submit"
class="btn btn-primary float-start me-sm-3 me-1"
name="save"
id="saveForm"
value="<?= lang("Basic.global.Save") ?>"
/>
</div>
</form>
</div><!--//.col -->
</div><!--//.row -->
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>
<?= $this->endSection() ?>
<?= $this->section("additionalInlineJs") ?>
<?= $this->endSection() ?>
<?= $this->section('css') ?>
<?php
/*
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
<link rel="stylesheet" href="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.css") ?>">
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/sk-datatables.css') ?>">
*/
?>
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/bs-stepper/bs-stepper.css') ?>" />
<?= $this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="<?= site_url("themes/vuexy/vendor/libs/bs-stepper/bs-stepper.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/dataTables.buttons.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.bootstrap5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.html5.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/buttons/buttons.print.min.js") ?>"></script>
<script src="<?= site_url("themes/vuexy/vendor/libs/datatables-sk/plugins/select/dataTables.select.min.js") ?>"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/vendor/libs/autosize/autosize.js') ?>"></script>
<script src="<?= site_url('js_loader/translate_js/Presupuestos') ?>"></script>
<?= $this->endSection() ?>