mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
finalizado nuevo presupuesto cliente a falta de confirmar
This commit is contained in:
@ -414,6 +414,7 @@ $routes->group('clienteusuarios', ['namespace' => 'App\Controllers\Clientes'], f
|
||||
$routes->group('misdirecciones', ['namespace' => 'App\Controllers\Clientes'], function ($routes) {
|
||||
$routes->get('', 'Clientedirecciones::index', ['as' => 'clientedireccionesIndex']);
|
||||
$routes->get('get/(:num)', 'Clientedirecciones::get/$1', ['as' => 'get']);
|
||||
$routes->get('getDireccionPresupuesto/(:num)', 'Clientedirecciones::getDireccionPresupuesto/$1', ['as' => 'getDireccionPresupuesto']);
|
||||
$routes->post('add', 'Clientedirecciones::add', ['as' => 'newClientedirecciones']);
|
||||
$routes->get('getSelect2', 'Clientedirecciones::getSelect2', ['as' => 'listaClientedirecciones']);
|
||||
});
|
||||
|
||||
@ -229,6 +229,25 @@ class Clientedirecciones extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function getDireccionPresupuesto($id)
|
||||
{
|
||||
try {
|
||||
$model = model('App\Models\Presupuestos\PresupuestoDireccionesModel');
|
||||
$resourceData = $model->getDireccion($id);
|
||||
$response = (object)[
|
||||
'error' => false,
|
||||
'data' => $resourceData
|
||||
];
|
||||
return $this->respond($response);
|
||||
} catch (\Exception $e) {
|
||||
$response = (object)[
|
||||
'error' => true,
|
||||
'message' => $e->getMessage()
|
||||
];
|
||||
return $this->fail($response);
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable_editor()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
@ -994,74 +994,7 @@ class Presupuestocliente extends \App\Controllers\BaseResourceController
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
;
|
||||
/*
|
||||
|
||||
if (this.datos.tipo == "cosido") {
|
||||
this.datos.paginasCuadernillo = this.datosGenerales.paginasCuadernillo.val();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//////////////////////////
|
||||
this.datos = {
|
||||
|
||||
|
||||
tamanio: this.datosGenerales.getDimensionLibro(),
|
||||
tirada: this.datosGenerales.getTiradas(),
|
||||
paginas: this.datosGenerales.paginas.val(),
|
||||
paginasColor: this.datosGenerales.paginasColor.val(),
|
||||
paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(),
|
||||
papelInteriorDiferente: this.datosGenerales.papelDiferente.is(':checked') ? 1 : 0,
|
||||
|
||||
tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
|
||||
|
||||
isColor: this.datosGenerales.getIsColor() ? 1 : 0,
|
||||
isHq: this.disenioInterior.getIsHq() ? 1 : 0,
|
||||
|
||||
interior: {
|
||||
papelInterior: this.disenioInterior.getPapel(),
|
||||
gramajeInterior: this.disenioInterior.getGramaje(),
|
||||
},
|
||||
|
||||
cubierta: {
|
||||
tipoCubierta: this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
||||
papelCubierta: this.disenioCubierta.getPapel(),
|
||||
gramajeCubierta: this.disenioCubierta.getGramaje(),
|
||||
cabezada: this.disenioCubierta.getCabezada(),
|
||||
acabados: this.disenioCubierta.getAcabados(),
|
||||
carasImpresion: this.disenioCubierta.carasCubierta.val(),
|
||||
},
|
||||
|
||||
guardas: this.disenioCubierta.getGuardas(),
|
||||
sobrecubierta: this.disenioCubierta.getSobrecubierta(),
|
||||
faja: this.disenioCubierta.getFaja(),
|
||||
|
||||
|
||||
let solapasCubierta = this.disenioCubierta.getSolapasCubierta();
|
||||
if (solapasCubierta !== null && solapasCubierta !== undefined) {
|
||||
|
||||
if (solapasCubierta === false)
|
||||
this.datos.cubierta.solapas = 0;
|
||||
else {
|
||||
this.datos.cubierta.solapas = 1;
|
||||
this.datos.cubierta.tamanioSolapas = solapasCubierta;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.datos.cubierta.solapas = 0;
|
||||
}
|
||||
|
||||
if (this.direcciones.direcciones.length > 0) {
|
||||
this.datos.direcciones = [];
|
||||
for (let i = 0; i < this.direcciones.direcciones.length; i++) {
|
||||
this.datos.direcciones.push(this.direcciones.direcciones[i].getFormData());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////*/
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
|
||||
@ -123,4 +123,21 @@ class PresupuestoDireccionesModel extends \App\Models\BaseModel
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function getDireccion($id = -1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.att AS att,
|
||||
t1.email AS email, t1.direccion AS direccion, t1.pais_id AS pais_id, t3.nombre AS pais,
|
||||
t1.municipio AS municipio, t1.provincia AS provincia, t1.cp AS cp, t1.telefono AS telefono"
|
||||
);
|
||||
|
||||
$builder->where('t1.id', $id);
|
||||
$builder->join("lg_paises t3", "t1.pais_id = t3.id", "left");
|
||||
|
||||
|
||||
return $builder->get()->getResultObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -111,7 +111,37 @@ class DatosGenerales {
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
const value2 = $("#tirada2").val();
|
||||
const value3 = $("#tirada3").val();
|
||||
const value4 = $("#tirada4").val();
|
||||
let tiradas = [value];
|
||||
|
||||
if(!(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0)){
|
||||
return {
|
||||
valid: false,
|
||||
message: window.translations["validation"].integer_greatherThan_0,
|
||||
};
|
||||
}
|
||||
if(value2.length > 0 && Number.isInteger(parseInt(value2)) && parseInt(value2) > 0){
|
||||
tiradas.push(value2);
|
||||
}
|
||||
if(value3.length > 0 && Number.isInteger(parseInt(value3)) && parseInt(value3) > 0){
|
||||
tiradas.push(value3);
|
||||
}
|
||||
if(value4.length > 0 && Number.isInteger(parseInt(value4)) && parseInt(value4) > 0){
|
||||
tiradas.push(value4);
|
||||
}
|
||||
// comprobar si hay valores > 30
|
||||
const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30));
|
||||
const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30));
|
||||
if(noPOD && siPOD){
|
||||
return {
|
||||
valid: false,
|
||||
message: "No se pueden mezclar tiradas <30 con >30",
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ class Direcciones {
|
||||
this.entregaPieCallero = this.domItem.find('#entregaPieCalle');
|
||||
|
||||
this.direccionesCliente = new ClassSelect($("#direcciones"), '/misdirecciones/getSelect2');
|
||||
|
||||
|
||||
this.divDirecciones = $(this.domItem.find('#divDirecciones'));
|
||||
this.divTiradas = this.domItem.find('#containerTiradasEnvios');
|
||||
|
||||
@ -63,6 +63,7 @@ class Direcciones {
|
||||
tiradas_envio.sort((a, b) => a - b);
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
tiradas_envio.forEach(tirada => {
|
||||
self.insertTirada(tirada);
|
||||
});
|
||||
@ -91,7 +92,7 @@ class Direcciones {
|
||||
if (unidades == null || unidades <= 0 || unidades == undefined)
|
||||
return;
|
||||
|
||||
let peticion = new Ajax('/misdirecciones/get/' + id, {}, {},
|
||||
let peticion = new Ajax('/misdirecciones/getDireccionPresupuesto/' + id, {}, {},
|
||||
(response) => {
|
||||
let tarjeta = new tarjetaDireccion(this.divDirecciones, divId, response.data[0]);
|
||||
tarjeta.setUnidades(unidades);
|
||||
@ -179,16 +180,6 @@ class Direcciones {
|
||||
}
|
||||
|
||||
|
||||
getDirecciones() {
|
||||
|
||||
let direcciones = this.divDirecciones.find('.direccion-cliente')
|
||||
if (direcciones.length > 0) {
|
||||
direcciones.forEach(element => {
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
insertTirada(tirada) {
|
||||
|
||||
const self = this;
|
||||
|
||||
@ -174,7 +174,7 @@ class DisenioCubierta {
|
||||
}, 0);
|
||||
}
|
||||
|
||||
if (datosSobrecubierta) {
|
||||
if(datosSobrecubierta && datosSobrecubierta.papel) {
|
||||
this.sobrecubierta.trigger('click');
|
||||
this.papelSobrecubierta.val(datosSobrecubierta.papel.code + "_" + datosSobrecubierta.gramaje).trigger('change');
|
||||
this.solapasSobrecubierta.val(datosSobrecubierta.solapas_ancho);
|
||||
|
||||
@ -79,12 +79,49 @@ class PresupuestoCliente {
|
||||
}
|
||||
|
||||
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
|
||||
}
|
||||
|
||||
|
||||
#checkTiradas() {
|
||||
|
||||
let tiradas = [parseInt(this.datosGenerales.tirada1.val())];
|
||||
|
||||
if (this.datosGenerales.tirada2.val().length > 0 &&
|
||||
Number.isInteger(parseInt(this.datosGenerales.tirada2.val())) &&
|
||||
parseInt(this.datosGenerales.tirada2.val()) > 0 &&
|
||||
this.datosGenerales.tirada2.val() != "") {
|
||||
|
||||
tiradas.push(parseInt(this.datosGenerales.tirada2.val()));
|
||||
}
|
||||
if (this.datosGenerales.tirada3.val().length > 0 &&
|
||||
Number.isInteger(parseInt(this.datosGenerales.tirada3.val())) &&
|
||||
parseInt(this.datosGenerales.tirada3.val()) > 0 &&
|
||||
this.datosGenerales.tirada3.val() != "") {
|
||||
|
||||
tiradas.push(parseInt(this.datosGenerales.tirada3.val()));
|
||||
}
|
||||
if (this.datosGenerales.tirada4.val().length > 0 &&
|
||||
Number.isInteger(parseInt(this.datosGenerales.tirada4.val())) &&
|
||||
parseInt(this.datosGenerales.tirada4.val()) > 0 &&
|
||||
this.datosGenerales.tirada4.val() != "") {
|
||||
|
||||
tiradas.push(parseInt(this.datosGenerales.tirada4.val()));
|
||||
}
|
||||
|
||||
const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30));
|
||||
const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30));
|
||||
|
||||
this.datosGenerales.formValidation.validateField('tirada');
|
||||
return !(noPOD && siPOD);
|
||||
}
|
||||
|
||||
|
||||
checkForm(event) {
|
||||
|
||||
if (!this.#checkTiradas()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.calcularPresupuesto) {
|
||||
|
||||
if (event.target.id === 'divDirecciones') {
|
||||
@ -273,7 +310,7 @@ class PresupuestoCliente {
|
||||
|
||||
$('#loader').modal('hide');
|
||||
|
||||
if(response === null || response === undefined || response === ""){
|
||||
if (response === null || response === undefined || response === "") {
|
||||
popErrorAlert("No se ha podido calcular el presupuesto para los datos proporcionados. Por favor, póngase en contacto con el departamento comercial."
|
||||
, "sk-alert-2", false);
|
||||
return;
|
||||
@ -285,9 +322,9 @@ class PresupuestoCliente {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
popAlert2Hide();
|
||||
}
|
||||
|
||||
popAlert2Hide();
|
||||
|
||||
|
||||
if (response.tiradas && response.tiradas.length) {
|
||||
|
||||
@ -466,11 +503,6 @@ class PresupuestoCliente {
|
||||
this.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
||||
|
||||
setTimeout(() => {
|
||||
//this.checkForm({ target: { id: 'tirada' } });
|
||||
/*this.validationStepper.next();
|
||||
this.validationStepper.next();
|
||||
this.validationStepper.next();
|
||||
this.validationStepper.next();*/
|
||||
$('#loader').modal('hide');
|
||||
this.calcularPresupuesto = true;
|
||||
this.checkForm({ target: { id: 'tirada' } });
|
||||
|
||||
@ -65,17 +65,18 @@ class Resumen {
|
||||
|
||||
#btnPreview() {
|
||||
|
||||
if(this.divPreview.hasClass('d-none')){
|
||||
if (this.divPreview.hasClass('d-none')) {
|
||||
this.btnPreviewCubierta.text('Ocultar desarrollo cubierta');
|
||||
this.divPreview.removeClass('d-none');
|
||||
this.generate();
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.btnPreviewCubierta.text('Mostrar desarrollo cubierta');
|
||||
this.divPreview.addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
generate() {
|
||||
|
||||
this.titulo.text(this.datosGenerales.titulo.val());
|
||||
@ -94,9 +95,12 @@ class Resumen {
|
||||
this.formato.text(this.datosGenerales.papelFormatoId.find('option:selected').text());
|
||||
}
|
||||
|
||||
|
||||
this.divPreview.empty();
|
||||
|
||||
new previewFormas(
|
||||
this.divPreview,
|
||||
this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
|
||||
this.divPreview,
|
||||
this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
|
||||
this.disenioCubierta.disenioCubierta.filter('.selected').attr('id'),
|
||||
"resumen",
|
||||
{
|
||||
@ -174,20 +178,43 @@ class Resumen {
|
||||
const tarjetaPrecio = $('.tarjeta-tiradas-precios').filter(function () {
|
||||
return parseInt($(this).find('.tarjeta-tiradas-precios-tirada').attr('data')) == unidades;
|
||||
});
|
||||
this.precio_unidad.text(tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').attr('data'));
|
||||
|
||||
|
||||
let precio_u_text = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio-unidad').text();
|
||||
precio_u_text = precio_u_text.replace('€/u', '');
|
||||
precio_u_text = this.#changeDecimalFormat(precio_u_text);
|
||||
|
||||
const base = tarjetaPrecio.find('.tarjeta-tiradas-precios-precio').attr('data');
|
||||
let base_text = this.#changeDecimalFormat(base);
|
||||
|
||||
const iva_porcentaje = this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? 0.21 : 0.04;
|
||||
const iva = (parseFloat(base) * iva_porcentaje).toFixed(2);
|
||||
this.total_base.text(base);
|
||||
let iva_text = this.#changeDecimalFormat(iva);
|
||||
|
||||
const total = (parseFloat(base) + parseFloat(iva)).toFixed(2);
|
||||
let total_text = this.#changeDecimalFormat(total);
|
||||
|
||||
this.precio_unidad.text(precio_u_text);
|
||||
this.total_base.text(base_text);
|
||||
this.iva_porcentaje.text(this.datosGenerales.ivaReducido.find('option:selected').val() == 1 ? '21' : '4');
|
||||
this.iva.text(iva);
|
||||
this.total.text((parseFloat(base) + parseFloat(iva)).toFixed(2));
|
||||
this.iva.text(iva_text);
|
||||
this.total.text(total_text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#capitalizeFirstLetter(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
|
||||
#changeDecimalFormat(number) {
|
||||
|
||||
let cleanedNumber = String(number).replace(/[^\d.]/g, '');
|
||||
let partes = cleanedNumber.split('.');
|
||||
partes[0] = partes[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.');
|
||||
return partes.join(',');
|
||||
}
|
||||
}
|
||||
|
||||
export default Resumen;
|
||||
@ -26,12 +26,12 @@ class previewFormas {
|
||||
}
|
||||
else if (this.tipoLibro.includes("espiral") || this.tipoLibro.includes("wire-o")) {
|
||||
if (this.tipoTapa.includes("dura"))
|
||||
this.#portadaEspiral(isThumbnail, true);
|
||||
this.#portadaEspiral(true);
|
||||
else
|
||||
this.#portadaEspiral(isThumbnail, false);
|
||||
this.#portadaEspiral(false);
|
||||
}
|
||||
else if (this.tipoLibro.includes("grapado")) {
|
||||
portadaGrapado(isThumbnail);
|
||||
this.#portadaGrapado();
|
||||
}
|
||||
|
||||
}
|
||||
@ -369,7 +369,7 @@ class previewFormas {
|
||||
#portadaEspiral(isTapaDura = false) {
|
||||
|
||||
// Variables locales
|
||||
let altoLibro, anchoLibro, anchoCalle, anchoCubierta, altoSangrado, anchoSangrado, anchoSolapa, offsetCubierta;
|
||||
let altoLibro, anchoLibro, anchoCalle, altoSangrado, anchoSangrado, anchoSolapa, offsetCubierta, anchoCubierta;
|
||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
||||
let sangradoTexto = (isTapaDura) ? "Sangrado 20 mm" : "Sangrado 5 mm";
|
||||
let sangradoValor = (isTapaDura) ? parseFloat(20) : parseFloat(5); // mm
|
||||
@ -377,7 +377,7 @@ class previewFormas {
|
||||
|
||||
// Definicion de los parametros del Esquema de Cubierta (EC)
|
||||
if ((anchoSolapa !== 0) && (!isTapaDura)) {
|
||||
if (isThumbnail) {
|
||||
if (this.size == "thumbnail") {
|
||||
anchoSangrado = 350; // px
|
||||
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
||||
} else {
|
||||
@ -440,7 +440,7 @@ class previewFormas {
|
||||
solapa2.linewidth = 1;
|
||||
|
||||
// Cotas y textos
|
||||
if (!isThumbnail) {
|
||||
if (this.size != "thumbnail") {
|
||||
// Cotas
|
||||
var cotaSolapa2 = previewEC.makeDobleArrow(
|
||||
origenEC.x - (anchoCalle / 2 + sangradoValor + anchoLibro + anchoSolapa),
|
||||
@ -462,8 +462,8 @@ class previewFormas {
|
||||
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
||||
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
||||
// Textos Cotas Solapas
|
||||
previewEC.makeText(anchoSolapa + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||
previewEC.makeText(anchoSolapa + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||
previewEC.makeText((anchoSolapa).toFixed(1) + " mm", origenEC.x - anchoLibro - (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||
previewEC.makeText(anchoSolapa.toFixed(1) + " mm", origenEC.x + anchoLibro + (anchoCalle + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||
}
|
||||
|
||||
}
|
||||
@ -495,7 +495,7 @@ class previewFormas {
|
||||
calle.linewidth = 1;
|
||||
|
||||
// Cotas y textos
|
||||
if (!isThumbnail) {
|
||||
if (this.size != "thumbnail") {
|
||||
// Cotas:
|
||||
var cotaAnchoCubierta = previewEC.makeDobleArrow(
|
||||
origenEC.x - (anchoSangrado / 2),
|
||||
@ -564,7 +564,7 @@ class previewFormas {
|
||||
origenEC.y,
|
||||
styleCotas
|
||||
).rotation = -Math.PI / 2;
|
||||
previewEC.makeText(((2 * anchoLibro) + lomoLibro + (2 * sangradoValor)).toFixed(1) + " mm",
|
||||
previewEC.makeText(((2 * anchoLibro) + this.lomo + (2 * sangradoValor)).toFixed(1) + " mm",
|
||||
origenEC.x,
|
||||
origenEC.y + (altoLibro / 2) + 50,
|
||||
styleCotas);
|
||||
@ -573,6 +573,180 @@ class previewFormas {
|
||||
previewEC.update();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#portadaGrapado() {
|
||||
|
||||
// Variables locales
|
||||
let altoLibro, anchoLibro, lomoLibro, anchoSolapa, anchoCubierta, altoSangrado, anchoSangrado;
|
||||
let styleCotas = { size: 12, family: 'Public Sans' };
|
||||
let sangradoTexto = "Sangrado 5 mm";
|
||||
let sangradoValor = parseFloat(5); // mm
|
||||
let offsetSolapaValor = parseFloat(0); // mm
|
||||
|
||||
// Definicion de los parametros del Esquema de Cubierta (EC)
|
||||
if (anchoSolapa == 0) {
|
||||
if (this.size == "thumbnail") {
|
||||
anchoSangrado = 350; // px
|
||||
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
||||
} else {
|
||||
anchoSangrado = 750; // px
|
||||
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
|
||||
}
|
||||
altoLibro = altoSangrado * 0.97;
|
||||
anchoLibro = anchoSangrado * 0.48;
|
||||
anchoSolapa = 0;
|
||||
lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO
|
||||
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
|
||||
|
||||
} else {
|
||||
if (this.size == "thumbnail") {
|
||||
anchoSangrado = 350; // px
|
||||
altoSangrado = (anchoSangrado * 0.647 > 300) ? 300 : anchoSangrado * 0.647; // px
|
||||
} else {
|
||||
anchoSangrado = 750; // px
|
||||
altoSangrado = (anchoSangrado * 0.647 > 650) ? 650 : anchoSangrado * 0.647; // px
|
||||
}
|
||||
altoLibro = altoSangrado * 0.95;
|
||||
anchoLibro = anchoSangrado * 0.3;
|
||||
anchoSolapa = anchoSangrado * 0.18;
|
||||
lomoLibro = 0; // ESTA ES LA DIFERENCIA PARA GRAPADO
|
||||
anchoCubierta = (2 * anchoLibro) + (2 * anchoSolapa) + lomoLibro;
|
||||
}
|
||||
|
||||
var previewEC = new Two({ fitted: true }).appendTo(this.container[0]);
|
||||
// Calculate the center of the canvas element
|
||||
var origenEC = new Two.Vector(previewEC.width / 2, previewEC.height / 2);
|
||||
|
||||
var sangrado = previewEC.makeRectangle(
|
||||
origenEC.x,
|
||||
origenEC.y,
|
||||
anchoSangrado,
|
||||
altoSangrado
|
||||
);
|
||||
sangrado.stroke = 'black';
|
||||
sangrado.dashes = [5, 5];
|
||||
sangrado.fill = '#FCEAF1';
|
||||
sangrado.linewidth = 1;
|
||||
|
||||
if (anchoSolapa != 0) {
|
||||
var solapas = previewEC.makeRectangle(
|
||||
origenEC.x,
|
||||
origenEC.y,
|
||||
anchoCubierta,
|
||||
altoLibro);
|
||||
solapas.stroke = 'black';
|
||||
solapas.linewidth = 1;
|
||||
|
||||
// Cotas y textos
|
||||
if (this.size != "thumbnail") {
|
||||
// Cotas
|
||||
var cotaSolapa2 = previewEC.makeDobleArrow(
|
||||
origenEC.x - anchoCubierta / 2,
|
||||
origenEC.y - (altoLibro / 3),
|
||||
origenEC.x - anchoLibro - lomoLibro / 2,
|
||||
origenEC.y - (altoLibro / 3),
|
||||
10);
|
||||
cotaSolapa2.linewidth = 2;
|
||||
var cotaSolapa1 = previewEC.makeDobleArrow(
|
||||
origenEC.x + anchoCubierta / 2,
|
||||
origenEC.y - (altoLibro / 3),
|
||||
origenEC.x + anchoLibro + lomoLibro / 2,
|
||||
origenEC.y - (altoLibro / 3),
|
||||
10);
|
||||
cotaSolapa1.linewidth = 2;
|
||||
|
||||
// Textos Solapas
|
||||
let stylesSolapa = { size: 18, family: 'Public Sans' };
|
||||
previewEC.makeText("Solapa 1", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
||||
previewEC.makeText("Solapa 2", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y, stylesSolapa);
|
||||
// Textos Cotas Solapas
|
||||
previewEC.makeText(anchoSolapa + " mm", origenEC.x - anchoLibro - (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||
previewEC.makeText(anchoSolapa + " mm", origenEC.x + anchoLibro + (lomoLibro + anchoSolapa) / 2, origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var libro = previewEC.makeRectangle(
|
||||
origenEC.x,
|
||||
origenEC.y,
|
||||
((2 * anchoLibro) + lomoLibro),
|
||||
altoLibro);
|
||||
libro.stroke = 'black';
|
||||
libro.linewidth = 1;
|
||||
|
||||
var lomo = previewEC.makeRectangle(
|
||||
origenEC.x,
|
||||
origenEC.y,
|
||||
lomoLibro,
|
||||
altoLibro);
|
||||
lomo.stroke = 'black';
|
||||
lomo.fill = '#F4F8F2';
|
||||
lomo.linewidth = 1;
|
||||
|
||||
// Cotas y textos
|
||||
if (this.size != "thumbnail") {
|
||||
// Cotas:
|
||||
var cotaAnchoCubierta = previewEC.makeDobleArrow(
|
||||
origenEC.x - (anchoSangrado / 2),
|
||||
origenEC.y + (altoLibro / 2) + 35,
|
||||
origenEC.x + (anchoSangrado / 2),
|
||||
origenEC.y + (altoLibro / 2) + 35,
|
||||
10);
|
||||
cotaAnchoCubierta.linewidth = 2;
|
||||
var cotaAltoCubierta = previewEC.makeDobleArrow(
|
||||
origenEC.x + (anchoCubierta / 2) + 35,
|
||||
origenEC.y + (altoSangrado / 2),
|
||||
origenEC.x + (anchoCubierta / 2) + 35,
|
||||
origenEC.y - (altoSangrado / 2),
|
||||
10);
|
||||
cotaAltoCubierta.linewidth = 2;
|
||||
var cotaAltoLibro = previewEC.makeDobleArrow(
|
||||
origenEC.x + (lomoLibro / 2) + 35,
|
||||
origenEC.y + (altoLibro / 2),
|
||||
origenEC.x + (lomoLibro / 2) + 35,
|
||||
origenEC.y - (altoLibro / 2),
|
||||
10);
|
||||
cotaAltoLibro.linewidth = 2;
|
||||
var cotaContraportada = previewEC.makeDobleArrow(
|
||||
origenEC.x - (lomoLibro / 2 + anchoLibro),
|
||||
origenEC.y - (altoLibro / 3),
|
||||
origenEC.x - (lomoLibro / 2),
|
||||
origenEC.y - (altoLibro / 3),
|
||||
10);
|
||||
cotaContraportada.linewidth = 2;
|
||||
var cotaPortada = previewEC.makeDobleArrow(
|
||||
origenEC.x + (lomoLibro / 2),
|
||||
origenEC.y - (altoLibro / 3),
|
||||
origenEC.x + (lomoLibro / 2 + anchoLibro),
|
||||
origenEC.y - (altoLibro / 3),
|
||||
10);
|
||||
cotaPortada.linewidth = 2;
|
||||
|
||||
// Textos:
|
||||
// Titulos generales
|
||||
let stylesEC = { size: 22, weight: 'bold', family: 'Public Sans' };
|
||||
previewEC.makeText("Portada", origenEC.x + (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
|
||||
previewEC.makeText("Contraportada", origenEC.x - (lomoLibro + anchoLibro) / 2, origenEC.y, stylesEC);
|
||||
// Sangrados
|
||||
let styleSangrado = { size: 10, family: 'Public Sans', style: 'italic', fill: 'red' };
|
||||
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y + (altoLibro / 2 + 20), styleSangrado);
|
||||
previewEC.makeText(sangradoTexto, origenEC.x, origenEC.y - (altoLibro / 2 + 20), styleSangrado);
|
||||
previewEC.makeText(sangradoTexto, origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
||||
previewEC.makeText(sangradoTexto, origenEC.x - (lomoLibro / 2 + anchoLibro + anchoSolapa + 20), origenEC.y, styleSangrado).rotation = -Math.PI / 2;
|
||||
// Cotas
|
||||
previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x - (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||
previewEC.makeText((anchoLibro + offsetSolapaValor).toFixed(1) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro / 2), origenEC.y - (altoLibro / 3) + 15, styleCotas);
|
||||
previewEC.makeText(altoLibro.toFixed(1) + " mm", origenEC.x + (lomoLibro / 2) + 25, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
||||
previewEC.makeText(altoLibro.toFixed(1) + (2 * sangradoValor) + " mm", origenEC.x + (lomoLibro / 2 + anchoLibro + anchoSolapa) + 50, origenEC.y, styleCotas).rotation = -Math.PI / 2;
|
||||
previewEC.makeText(((2 * anchoLibro) + (2 * (anchoSolapa + offsetSolapaValor)) + lomoLibro + (2 * sangradoValor)).toFixed(1) + " mm",
|
||||
origenEC.x,
|
||||
origenEC.y + (altoLibro / 2) + 50,
|
||||
styleCotas);
|
||||
}
|
||||
|
||||
previewEC.update();
|
||||
}
|
||||
}
|
||||
|
||||
export default previewFormas;
|
||||
@ -1016,25 +1190,5 @@ function portadaGrapado(isThumbnail = false) {
|
||||
}
|
||||
|
||||
|
||||
function getObjetoToPreview() {
|
||||
|
||||
if ($('#cosidoDiv').length) {
|
||||
pvObj = {
|
||||
lomoLibro: $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()),
|
||||
anchoSolapa: $('#solapasCubierta').is(':checked') ? parseFloat($('#anchoSolapasCubierta').val()) : parseFloat(0),
|
||||
altoLibro: getDimensionLibro().alto,
|
||||
anchoLibro: getDimensionLibro().ancho
|
||||
};
|
||||
} else {
|
||||
let tamanio = $('#resumenTamanio').text().split(' ')[1].split('x');
|
||||
let solapas = parseInt($('#resumenSolapasCubierta').length ? $('#resumenSolapasCubierta').text().split(' ')[1].replace("mm", '') : 0);
|
||||
pvObj = {
|
||||
lomoLibro: $('#lomo_cubierta').val() === '' ? parseFloat('0.0') : parseFloat($('#lomo_cubierta').val()),
|
||||
anchoSolapa: solapas,
|
||||
altoLibro: parseInt(tamanio[1]),
|
||||
anchoLibro: parseInt(tamanio[0])
|
||||
};
|
||||
}
|
||||
//console.log($('#lomo_cubierta').val());
|
||||
}
|
||||
*/
|
||||
9166
xdebug.log
9166
xdebug.log
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user