- Aggiunto bottone Aggiungi al Carrello sulla lista dei libri dei cataloghi
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -58,9 +58,6 @@ const CatalogSchema = new Schema({
|
|||||||
idPageAssigned: {
|
idPageAssigned: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
idPageAssigned_stampa: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
referenti: [
|
referenti: [
|
||||||
{
|
{
|
||||||
type: String,
|
type: String,
|
||||||
@@ -169,7 +166,6 @@ CatalogSchema.statics.executeQueryTable = function (idapp, params, user) {
|
|||||||
};*/
|
};*/
|
||||||
|
|
||||||
CatalogSchema.statics.findAllIdApp = async function (idapp) {
|
CatalogSchema.statics.findAllIdApp = async function (idapp) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const arrrec = await this.aggregate([
|
const arrrec = await this.aggregate([
|
||||||
{ $match: { idapp } },
|
{ $match: { idapp } },
|
||||||
@@ -182,7 +178,6 @@ CatalogSchema.statics.findAllIdApp = async function (idapp) {
|
|||||||
console.error('Errore:', err);
|
console.error('Errore:', err);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CatalogSchema.statics.getCatalogById = async function (id) {
|
CatalogSchema.statics.getCatalogById = async function (id) {
|
||||||
@@ -249,7 +244,15 @@ CatalogSchema.statics.getCatalogById = async function (id) {
|
|||||||
// controlla prima se nella lista ci sono dei product che non esistono piu allora li devi rimuovere !
|
// controlla prima se nella lista ci sono dei product che non esistono piu allora li devi rimuovere !
|
||||||
for (const catalog of arrrec) {
|
for (const catalog of arrrec) {
|
||||||
const originalLength = catalog.lista_prodotti.length;
|
const originalLength = catalog.lista_prodotti.length;
|
||||||
catalog.lista_prodotti = catalog.lista_prodotti.filter((product) => product.idProductInfo);
|
catalog.lista_prodotti = catalog.lista_prodotti.filter(
|
||||||
|
(product) =>
|
||||||
|
product.idProductInfo &&
|
||||||
|
product.idProductInfo.code &&
|
||||||
|
product.idProductInfo.code !== '' &&
|
||||||
|
product.idProductInfo.imagefile &&
|
||||||
|
//product.idProductInfo.imagefile !== 'noimg.jpg' &&
|
||||||
|
!product.delete
|
||||||
|
);
|
||||||
if (catalog.lista_prodotti.length !== originalLength) {
|
if (catalog.lista_prodotti.length !== originalLength) {
|
||||||
await catalog.save();
|
await catalog.save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const productSchema = new Schema({
|
|||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
delete: {
|
deleted: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
active: {
|
active: {
|
||||||
@@ -610,7 +610,12 @@ module.exports.findAllIdApp = async function (idapp, code, id, all, isbn) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ $unwind: { path: '$productInfo', preserveNullAndEmptyArrays: true } },
|
{ $unwind: { path: '$productInfo', preserveNullAndEmptyArrays: true } },
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
'productInfo.code': { $exists: true, $ne: '' },
|
||||||
|
//'productInfo.imagefile': { $ne: 'noimg.jpg' },
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'gasordines',
|
from: 'gasordines',
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const productInfoSchema = new Schema({
|
|||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
delete: {
|
deleted: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
department: {
|
department: {
|
||||||
@@ -212,8 +212,8 @@ module.exports.findAllIdApp = async function (idapp, code, id) {
|
|||||||
myfind = {
|
myfind = {
|
||||||
idapp,
|
idapp,
|
||||||
$or: [
|
$or: [
|
||||||
{ delete: { $exists: false } },
|
{ deleted: { $exists: false } },
|
||||||
{ delete: false }
|
{ deleted: false }
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -550,14 +550,14 @@ module.exports.removeProductInfoWithoutDateUpdatedFromGM = async function (idapp
|
|||||||
if (Product) {
|
if (Product) {
|
||||||
await Product.updateMany(
|
await Product.updateMany(
|
||||||
{ idProductInfo: productinfo._id },
|
{ idProductInfo: productinfo._id },
|
||||||
{ $set: { delete: true } }
|
{ $set: { deleted: true } }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ora rimuovi anche questo productInfo
|
// Ora rimuovi anche questo productInfo
|
||||||
await ProductInfo.updateOne(
|
await ProductInfo.updateOne(
|
||||||
{ _id: productinfo._id },
|
{ _id: productinfo._id },
|
||||||
{ $set: { delete: true } }
|
{ $set: { deleted: true } }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,6 @@ const RaccoltaCataloghiSchema = new Schema({
|
|||||||
idPageAssigned: {
|
idPageAssigned: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
idPageAssigned_stampa: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
|
|
||||||
nomefile_da_generare: String,
|
nomefile_da_generare: String,
|
||||||
|
|
||||||
|
|||||||
62
src/server/models/t_web_argomenti.js
Executable file
62
src/server/models/t_web_argomenti.js
Executable file
@@ -0,0 +1,62 @@
|
|||||||
|
const mongoose = require('mongoose');
|
||||||
|
const { Schema } = mongoose;
|
||||||
|
|
||||||
|
mongoose.Promise = global.Promise;
|
||||||
|
mongoose.level = "F";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} T_Web_Argomenti
|
||||||
|
* @property {bigint} Id
|
||||||
|
* @property {number} IdArgomento
|
||||||
|
* @property {string} Descrizione
|
||||||
|
* @property {Date} DataOra
|
||||||
|
* @property {boolean} Enabled
|
||||||
|
* @property {boolean} EnabledAlFresco
|
||||||
|
*/
|
||||||
|
|
||||||
|
const T_Web_ArgomentiSchema = new Schema({
|
||||||
|
IdArgomento: Number,
|
||||||
|
Descrizione: { type: String },
|
||||||
|
DataOra: Date,
|
||||||
|
Enabled: Boolean,
|
||||||
|
EnabledAlFresco: Boolean
|
||||||
|
}, { collection: 't_web_argomentis' });
|
||||||
|
|
||||||
|
const T_Web_Argomenti = module.exports = mongoose.model('T_Web_Argomenti', T_Web_ArgomentiSchema);
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.findAllIdApp = async function () {
|
||||||
|
const myfind = {};
|
||||||
|
|
||||||
|
const myquery = [
|
||||||
|
{
|
||||||
|
$sort: { IdTipologia: 1, DataOra: -1 } // ordina per ID e DataOra decrescente
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$group: {
|
||||||
|
_id: "$IdTipologia",
|
||||||
|
IdTipologia: { $first: "$IdTipologia" },
|
||||||
|
Descrizione: { $first: "$Descrizione" },
|
||||||
|
DataOra: { $first: "$DataOra" },
|
||||||
|
// aggiungi altri campi se servono
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$sort: { IdTipologia: 1 } // opzionale, per ordinare il risultato
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 0,
|
||||||
|
IdTipologia: 1,
|
||||||
|
Descrizione: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
const rec = await T_Web_Argomenti.aggregate(myquery);
|
||||||
|
return rec;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class Cart {
|
|||||||
|
|
||||||
const myitem = this.items.find((rec) => rec.order._id.toString() === itemorder._id)
|
const myitem = this.items.find((rec) => rec.order._id.toString() === itemorder._id)
|
||||||
if (!!myitem) {
|
if (!!myitem) {
|
||||||
let stepmin = myitem.order.product.minStepQty;
|
let stepmin = myitem.order?.product?.minStepQty || 1;
|
||||||
let step = stepmin;
|
let step = stepmin;
|
||||||
if (this.isAvailableByOrder(myitem.order)) {
|
if (this.isAvailableByOrder(myitem.order)) {
|
||||||
if (myitem.order.quantity === 0)
|
if (myitem.order.quantity === 0)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1978,6 +1978,7 @@ async function importaCatalogo(data) {
|
|||||||
|
|
||||||
let nontrovati = 0;
|
let nontrovati = 0;
|
||||||
|
|
||||||
|
|
||||||
for (const product of dataObjects) {
|
for (const product of dataObjects) {
|
||||||
let isnuovo = false;
|
let isnuovo = false;
|
||||||
let setta = false;
|
let setta = false;
|
||||||
|
|||||||
@@ -5938,6 +5938,7 @@ module.exports = {
|
|||||||
|
|
||||||
async downloadImgIfMissing(productInfo) {
|
async downloadImgIfMissing(productInfo) {
|
||||||
const ProductInfo = require('../models/productInfo');
|
const ProductInfo = require('../models/productInfo');
|
||||||
|
const Product = require('../models/product');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.sulServer()) {
|
if (this.sulServer()) {
|
||||||
@@ -6015,7 +6016,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let fileesistente = false;
|
let fileesistente = false;
|
||||||
if (productInfo.imagefile) {
|
if (productInfo.imagefile && productInfo.imagefile !== 'noimg.jpg') {
|
||||||
// controlla se esiste il file
|
// controlla se esiste il file
|
||||||
const img =
|
const img =
|
||||||
this.getdirByIdApp(productInfo.idapp) +
|
this.getdirByIdApp(productInfo.idapp) +
|
||||||
@@ -6030,7 +6031,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!vecchiomodo && (!productInfo.image_link || !fileesistente)) {
|
if (!vecchiomodo && (!productInfo.image_link || !fileesistente)) {
|
||||||
let scarica_da_sito = !productInfo.imagefile;
|
let scarica_da_sito = !productInfo.imagefile || productInfo.imagefile === 'noimg.jpg';
|
||||||
|
|
||||||
if (!scarica_da_sito && productInfo.imagefile) {
|
if (!scarica_da_sito && productInfo.imagefile) {
|
||||||
scarica_da_sito = !fileesistente; // Se non esiste lo scarico !
|
scarica_da_sito = !fileesistente; // Se non esiste lo scarico !
|
||||||
@@ -6054,7 +6055,7 @@ module.exports = {
|
|||||||
let aggiornatoimg;
|
let aggiornatoimg;
|
||||||
try {
|
try {
|
||||||
aggiornatoimg = await downloader.downloadImage(link, savePath, {
|
aggiornatoimg = await downloader.downloadImage(link, savePath, {
|
||||||
maxRetries: 1,
|
maxRetries: 3,
|
||||||
initialDelay: 300,
|
initialDelay: 300,
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
nomefileoriginale: true,
|
nomefileoriginale: true,
|
||||||
@@ -6062,11 +6063,24 @@ module.exports = {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
aggiornatoimg = { ris: false };
|
aggiornatoimg = { ris: false };
|
||||||
}
|
}
|
||||||
if (aggiornatoimg?.code === 404) {
|
if (
|
||||||
|
aggiornatoimg?.code === 404 ||
|
||||||
|
(aggiornatoimg?.filepath && aggiornatoimg.filepath.includes('noimg.jpg'))
|
||||||
|
) {
|
||||||
// non trovato quindi la prossima volta non richiederlo
|
// non trovato quindi la prossima volta non richiederlo
|
||||||
await ProductInfo.setImgNotFound(productInfo._id);
|
await ProductInfo.setImgNotFound(productInfo._id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (aggiornatoimg?.filepath.includes('noimg.jpg')) {
|
||||||
|
// nascondi il prodotto se non trovo l'immagine !
|
||||||
|
await Product.updateOne(
|
||||||
|
{ idProductInfo: productInfo._id },
|
||||||
|
{ $set: { deleted: true } }
|
||||||
|
);
|
||||||
|
|
||||||
|
aggiornatoimg = { ris: false, deleted: true };
|
||||||
|
}
|
||||||
|
|
||||||
if (aggiornatoimg?.filepath) {
|
if (aggiornatoimg?.filepath) {
|
||||||
const filenamebase = path.basename(aggiornatoimg.filepath);
|
const filenamebase = path.basename(aggiornatoimg.filepath);
|
||||||
// const img = '/upload/products/' + filenamebase;
|
// const img = '/upload/products/' + filenamebase;
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.2.52
|
1.2.53
|
||||||
Reference in New Issue
Block a user