- aggiornamento Cataloghi
- Gestione delle versioni del prodotto ("Nuovi","Usati","Epub", ecc..)
This commit is contained in:
@@ -99,7 +99,7 @@ async function completaSettaggioProduct_AndProductInfo(arrcampi_productInfo, arr
|
||||
productInfo.img = 'upload/products/' + rec['img'];
|
||||
} else {
|
||||
productInfo.img = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,10 +119,10 @@ async function completaSettaggioProduct_AndProductInfo(arrcampi_productInfo, arr
|
||||
productInfo.code = preccode;
|
||||
}
|
||||
}
|
||||
if (rec.hasOwnProperty('productType')) {
|
||||
productInfo.productType = rec.hasOwnProperty('productType');
|
||||
if (rec.hasOwnProperty('productTypes')) {
|
||||
productInfo.productTypes = productInfo.productTypes;
|
||||
} else {
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.PRODUCT;
|
||||
productInfo.productTypes = [shared_consts.PRODUCTTYPE.PRODUCT];
|
||||
}
|
||||
|
||||
return { product, productInfo };
|
||||
@@ -339,6 +339,11 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
importa = false;
|
||||
|
||||
if (importa) {
|
||||
let versGM = product.Versione ? product.Versione : '';
|
||||
|
||||
// split versioneGM in array with separated ","
|
||||
let arrversGM = versGM.split(",").map(x => x.trim());
|
||||
|
||||
let productInfo = {
|
||||
idapp: product.idapp,
|
||||
code: product.isbn,
|
||||
@@ -361,41 +366,53 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
}
|
||||
|
||||
let versione = 0;
|
||||
let arrversioni = [];
|
||||
|
||||
// Download, DVD, Epub, Mobi, Nuovo, PDF, Streaming, Usato
|
||||
if (product.Versione === 'Nuovo')
|
||||
versione = shared_consts.VERSIONE.NUOVO
|
||||
else if (product.Versione === 'Usato')
|
||||
versione = shared_consts.VERSIONE.USATO;
|
||||
else if (product.Versione === 'Download')
|
||||
versione = shared_consts.VERSIONE.DOWNLOAD;
|
||||
else if (product.Versione === 'DVD')
|
||||
versione = shared_consts.VERSIONE.DVD;
|
||||
else if (product.Versione === 'Epub')
|
||||
versione = shared_consts.VERSIONE.EPUB;
|
||||
else if (product.Versione === 'Mobi')
|
||||
versione = shared_consts.VERSIONE.MOBI;
|
||||
else if (product.Versione === 'PDF')
|
||||
versione = shared_consts.VERSIONE.PDF;
|
||||
else if (product.Versione === 'Streaming')
|
||||
versione = shared_consts.VERSIONE.STREAMING;
|
||||
else
|
||||
versione = 100;
|
||||
productInfo.productTypes = [];
|
||||
// console.log('indprod', indprod, 'arrversGM', arrversGM, 'versione', product.Versione);
|
||||
|
||||
if (versione === shared_consts.VERSIONE.DOWNLOAD)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.DOWNLOAD;
|
||||
else if (versione === shared_consts.VERSIONE.DVD)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.DVD;
|
||||
else if (versione === shared_consts.VERSIONE.EPUB)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.EPUB;
|
||||
else if (versione === shared_consts.VERSIONE.MOBI)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.MOBI;
|
||||
else if (versione === shared_consts.VERSIONE.PDF)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.PDF;
|
||||
else if (versione === shared_consts.VERSIONE.STREAMING)
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.STREAMING;
|
||||
else
|
||||
productInfo.productType = shared_consts.PRODUCTTYPE.LIBRO;
|
||||
for (let i = 0; i < arrversGM.length; i++) {
|
||||
// Download, DVD, Epub, Mobi, Nuovo, PDF, Streaming, Usato
|
||||
if (arrversGM[i] === 'Nuovo')
|
||||
versione = shared_consts.VERSIONE.NUOVO
|
||||
else if (arrversGM[i] === 'Usato')
|
||||
versione = shared_consts.VERSIONE.USATO;
|
||||
else if (arrversGM[i] === 'Download')
|
||||
versione = shared_consts.VERSIONE.DOWNLOAD;
|
||||
else if (arrversGM[i] === 'DVD')
|
||||
versione = shared_consts.VERSIONE.DVD;
|
||||
else if (arrversGM[i] === 'Epub')
|
||||
versione = shared_consts.VERSIONE.EPUB;
|
||||
else if (arrversGM[i] === 'Mobi')
|
||||
versione = shared_consts.VERSIONE.MOBI;
|
||||
else if (arrversGM[i] === 'PDF')
|
||||
versione = shared_consts.VERSIONE.PDF;
|
||||
else if (arrversGM[i] === 'Streaming')
|
||||
versione = shared_consts.VERSIONE.STREAMING;
|
||||
|
||||
arrversioni.push(versione);
|
||||
|
||||
if (versione === shared_consts.VERSIONE.DOWNLOAD)
|
||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.DOWNLOAD);
|
||||
else if (versione === shared_consts.VERSIONE.DVD)
|
||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.DVD);
|
||||
else if (versione === shared_consts.VERSIONE.EPUB)
|
||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.EPUB);
|
||||
else if (versione === shared_consts.VERSIONE.MOBI)
|
||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.MOBI);
|
||||
else if (versione === shared_consts.VERSIONE.PDF)
|
||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.PDF);
|
||||
else if (versione === shared_consts.VERSIONE.STREAMING)
|
||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.STREAMING);
|
||||
else if (versione === shared_consts.VERSIONE.USATO)
|
||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.USATO);
|
||||
else if (versione === shared_consts.VERSIONE.NUOVO)
|
||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.NUOVO);
|
||||
}
|
||||
|
||||
/*if (productInfo.productTypes.length === 0) {
|
||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.LIBRO);
|
||||
}*/
|
||||
|
||||
if (product.Data)
|
||||
productInfo.date_publishing = new Date(product.Data * 1000);
|
||||
@@ -604,7 +621,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
}
|
||||
|
||||
// cerca l'indice della versione in arrvariazioni
|
||||
let ind = arrvariazioni.findIndex(x => x.versione === versione);
|
||||
let ind = arrvariazioni.findIndex(x => arrversioni.includes(x.versione));
|
||||
let nuovaVariazione = ind < 0;
|
||||
|
||||
//
|
||||
@@ -615,7 +632,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
}
|
||||
|
||||
variazione.active = true; // ++ ??
|
||||
variazione.versione = versione;
|
||||
variazione.arrversioni = arrversioni;
|
||||
variazione.status = product.Stato ? product.Stato : null;
|
||||
variazione.price = product.price ? parseFloat(tools.convertPriceEurToValue(product.price)) : null;
|
||||
variazione.sale_price = product.sale_price ? parseFloat(tools.convertPriceEurToValue(product.sale_price)) : null;
|
||||
@@ -770,7 +787,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
img: 'upload/products/' + product.code + '.jpg',
|
||||
weight: product.weight,
|
||||
unit: tools.getIdUnitsByText(product.unit),
|
||||
productType: shared_consts.PRODUCTTYPE.PRODUCT,
|
||||
productTypes: shared_consts.PRODUCTTYPE.PRODUCT,
|
||||
}
|
||||
|
||||
let reccateg = null;
|
||||
|
||||
Reference in New Issue
Block a user