trabajando ya en el formulario

This commit is contained in:
2024-04-17 12:19:42 +02:00
parent b702d286ce
commit 82beb615a3
6 changed files with 2920 additions and 5 deletions

View File

@ -82,5 +82,11 @@ class Js_loader extends BaseController
return view('themes/backend/vuexy/form/presupuestos/cosidotapablanda/_presupuestos.js');
}
function presupuestoCliente_js()
{
$this->response->setHeader('Content-Type', 'text/javascript');
return view('themes/backend/vuexy/form/presupuestos/cliente/presupuestoCliente.js');
}
}

View File

@ -151,10 +151,14 @@ class Presupuestocliente extends \App\Controllers\GoBaseResourceController
$presupuestoEntity = isset($sanitizedData) ? new PresupuestoEntity($sanitizedData) : new PresupuestoEntity();
$presupuestoEntity->POD = model('App\Models\Configuracion\ConfiguracionSistemaModel')->getPOD();
$presupuestoEntity->clienteId = $clienteId;
$datosPresupuesto = (object)array();
$datosPresupuesto->paisList = model('App\Models\Configuracion\PaisModel')->getAllForMenu('id, nombre', 'nombre', true);
$this->viewData['formAction'] = route_to('crearPresupuestoCliente');
$this->viewData['presupuestoEntity'] = $presupuestoEntity;
$this->viewData['datosPresupuesto'] = $datosPresupuesto;
$this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . $this->viewData['pageTitle'] . ' ' . lang('Basic.global.addNewSuffix');

View File

@ -0,0 +1,175 @@
<!-- Fila 1 -->
<div class="col-12 pb-2">
<div class="row g-2">
<div class="col-sm-6 mb-3">
<label for="titulo" class="form-label">
<?=lang('Presupuestos.titulo') ?>*
</label>
<input type="text" id="titulo" name="titulo" maxLength="300" class="form-control" value="<?=old('titulo', $presupuestoEntity->titulo) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-6 mb-3">
<label for="autor" class="form-label">
<?=lang('Presupuestos.autor') ?>
</label>
<input type="text" id="autor" name="autor" maxLength="150" class="form-control" value="<?=old('autor', $presupuestoEntity->autor) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-6 mb-3">
<label for="coleccion" class="form-label">
<?=lang('Presupuestos.coleccion') ?>
</label>
<input type="text" id="coleccion" name="coleccion" maxLength="255" class="form-control" value="<?=old('coleccion', $presupuestoEntity->coleccion) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-6 mb-3">
<label for="numeroEdicion" class="form-label">
<?=lang('Presupuestos.numeroEdicion') ?>
</label>
<input type="text" id="numeroEdicion" name="numero_edicion" maxLength="50" class="form-control" value="<?=old('numero_edicion', $presupuestoEntity->numero_edicion) ?>">
</div><!--//.mb-3 -->
<div class="col-sm-6 mb-3">
<label for="numeroEdicion" class="form-label">
<?=lang('Presupuestos.numeroEdicion') ?>
</label>
<input type="text" id="numeroEdicion" name="numero_edicion" maxLength="50" class="form-control" value="<?=old('numero_edicion', $presupuestoEntity->numero_edicion) ?>">
</div>
<div class="col-sm-6 mb-3">
<label for="isbn" class="form-label">
<?=lang('Presupuestos.isbn') ?>
</label>
<input type="text" id="isbn" name="isbn" maxLength="50" class="form-control" value="<?=old('isbn', $presupuestoEntity->isbn) ?>">
</div>
<label for="id" class="form-label">
<?= lang('Presupuestos.id') ?>
</label>
<input readonly style="background: #E8E8E8;" id="id" name="id" maxLength="12" class="form-control" value="<?= old('id', $presupuestoEntity->id) ?>">
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<label for="created_at" class="form-label">
<?= lang('Presupuestos.created_at') ?>
</label>
<?php if(str_contains($formAction,'edit')): ?>
<input readonly style="background: #E8E8E8;" id="updated_at" name="updated_at" maxLength="12" class="form-control" value="<?= old('created_at', (isset($presupuestoEntity->updated_at)) ? date ('d/m/Y', strtotime($presupuestoEntity->updated_at)) : "") ?>">
<?php else: ?>
<input readonly style="background: #E8E8E8;" id="created_at" name="created_at" maxLength="12" class="form-control" value="<?= old('created_at', (isset($presupuestoEntity->created_at)) ? date ('d/m/Y', strtotime($presupuestoEntity->created_at)) : "") ?>">
<?php endif; ?>
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<label for="estadoId" class="form-label">
<?= lang('Presupuestos.presupuestoEstado') ?>
</label>
<select disabled id="estadoId" name="estado_id" maxLength="11" style="background-color: #E8E8E8;" class="form-control" value="<?= old(1, $presupuestoEntity->estado_id) ?>">
<option value=1><?=lang('Presupuestos.presupuestoEstadoBorrador') ?></option>
<option value=2><?=lang('Presupuestos.presupuestoEstadoAceptado') ?></option>
</select>
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<label for="incRei" class="form-label">
<?= lang('Presupuestos.incRei') ?>
</label>
<select id="incRei" name="inc_rei" maxLength="11" class="form-control" value="<?= old('inc_rei', $presupuestoEntity->inc_rei) ?>">
<?php if (isset($incReiList) && is_array($incReiList) && !empty($incReiList)) : ?>
<option> </option>
<?php foreach ($incReiList as $k => $v) : ?>
<option value="<?= $k ?>" <?= $k == $presupuestoEntity->inc_rei ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
</div><!--//.col -->
</div> <!--//.row -->
<!-- Fila 2 -->
<div class="row">
<div class="col-md-12 col-lg-6 px-4">
</div><!--//.col -->
<div class="col-md-12 col-lg-6 px-4">
</div><!--//.col -->
</div> <!--//.row -->
<!-- Fila 3 -->
<div class="row">
<div class="col-md-12 col-lg-3 px-4">
</div>
<div class="col-md-12 col-lg-3 px-4">
<div class="mb-3">
<label for="paisId" class="form-label">
<?=lang('Presupuestos.paisId') ?>*
</label>
<select id="paisId" name="pais_id" class="form-control select2bs" style="width: 100%;" >
<option value=""><?=lang('Basic.global.pleaseSelectA', [lang('Presupuestos.paisId')]) ?></option>
<?php foreach ($datosPresupuesto->paisList as $item) : ?>
<option value="<?=$item->id ?>"<?=$item->id==$presupuestoEntity->pais_id ? ' selected':'' ?>>
<?=$item->nombre ?>
</option>
<?php endforeach; ?>
</select>
</div><!--//.mb-3 -->
</div>
</div> <!--//.row -->
<!-- Fila 3 -->
<div class="row">
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<label for="clienteId" class="form-label">
<?= lang('Presupuestos.clienteId') ?>*
</label>
<select id="clienteId" name="cliente_id" class="form-control select2bs2" style="width: 100%;">
<?php if (isset($clienteList) && is_array($clienteList) && !empty($clienteList)) :
foreach ($clienteList as $k => $v) : ?>
<option value="<?= $k ?>" <?= $k == $presupuestoEntity->cliente_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<label for="referenciaCliente" class="form-label">
<?=lang('Presupuestos.referenciaCliente') ?>
</label>
<input type="text" id="referenciaCliente" name="referencia_cliente" maxLength="100" class="form-control" value="<?=old('referencia_cliente', $presupuestoEntity->referencia_cliente) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
</div> <!--//.row -->

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

@ -6,7 +6,7 @@
<?= $this->section("content") ?>
<div class="row">
<div class="container-xxl flex-grow-1 container-p-y">
<div class="col-12">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
<?= csrf_field() ?>
@ -18,7 +18,7 @@
<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-circle"><i class="ti ti-list-details 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>
@ -29,7 +29,7 @@
<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-circle"><i class="ti ti-book 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>
@ -40,7 +40,7 @@
<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-circle"><i class="ti ti-map-pins 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>
@ -66,6 +66,8 @@
<div id="datos-generales" class="content active dstepper-block fv-plugins-bootstrap5 fv-plugins-framework">
<div class="row g-3">
<?= view("themes/backend/vuexy/form/presupuestos/cliente/_datosLibroItems") ?>
<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>
@ -351,5 +353,5 @@
<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>
<script src="<?= site_url('assets/js/presupuestoCliente.js') ?>"></script>
<script src="<?= site_url('js_loader/presupuestoCliente_js') ?>"></script>
<?= $this->endSection() ?>