añadido el fichero de nullable para la tabla clientes

This commit is contained in:
2024-11-17 21:05:37 +01:00
parent 9f46f7c8e5
commit 0862128f60
2 changed files with 103 additions and 0 deletions

View File

@ -0,0 +1,37 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class ModifyNullableComercialSoporte extends Migration
{
public function up()
{
$this->forge->modifyColumn('clientes', [
'comercial_id' => [
'type' => 'int(10) unsigned',
'null' => true, // Permitir valores NULL
],
'soporte_id' => [
'type' => 'int(10) unsigned',
'null' => true, // Permitir valores NULL
],
]);
}
public function down()
{
$this->forge->modifyColumn('clientes', [
'comercial_id' => [
'type' => 'int(10) unsigned',
'null' => false,
],
'soporte_id' => [
'type' => 'int(10) unsigned',
'null' => false,
],
]);
}
}

View File

@ -0,0 +1,66 @@
import ClassSelect from '../../components/select2.js';
class Cliente {
constructor() {
this.csrf_token = this.getToken();
this.csrf_hash = $('#clienteForm').find('input[name="' + this.csrf_token + '"]').val();
this.pais = new ClassSelect($("#paisId"), '/paises/menuitems2', "Seleccione un país", {[this.csrf_token]: this.csrf_hash});
this.soporte = new ClassSelect($("#soporteId"), '/users/getMenuComerciales', "Seleccione un usuario", {[this.csrf_token]: this.csrf_hash});
this.comercial = new ClassSelect($("#comercialId"), '/users/getMenuComerciales', "Seleccione un usuario", {[this.csrf_token]: this.csrf_hash});
this.formaPago = new ClassSelect($("#formaPagoId"), '/formas-pago/menuitems', "Seleccione una forma de pago", {[this.csrf_token]: this.csrf_hash});
this.provincia = new ClassSelect($("#provinciaId"), '/provincias/menuitems2', "Seleccione una provincia", {[this.csrf_token]: this.csrf_hash});
this.comunidadAutonoma = new ClassSelect($("#comunidadAutonomaId"), '/comunidades-autonomas/menuitems2', "Seleccione una comunidad autónoma", {[this.csrf_token]: this.csrf_hash});
this.init();
}
init() {
// Fuerza el foco en el campo de búsqueda de select2
$(document).on('select2:open', () => {
document.querySelector('.select2-search__field').focus();
});
this.pais.init();
this.soporte.init();
this.comercial.init();
this.formaPago.init();
this.provincia.init();
this.comunidadAutonoma.init();
$(document).keypress(function (e) {
var key = e.which;
if (key == 13) // the enter key code
{
e.preventDefault()
if ($('#addressForm').hasClass('show')) {
$("#saveAdd").click();
}
else if ($('#convert2Template').hasClass('show')) {
$("#saveTemplate").click();
}
else {
$('#saveForm').click();
}
}
});
}
getToken(){
const scriptUrl = new URL(import.meta.url);
const params = new URLSearchParams(scriptUrl.search);
const paramsObject = Object.fromEntries(params.entries());
return paramsObject.token;
}
}
document.addEventListener('DOMContentLoaded', function () {
new Cliente().init();
});