From a47accb1c3f7bf91486fb8870201a0d6e0bc0f0c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Mar 2016 18:08:08 +0200 Subject: [PATCH 1/6] FIX PMP is deprecated at warehouse level --- htdocs/core/modules/modStock.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 67bebc0d6d7..81454a52222 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -189,13 +189,13 @@ class modStock extends DolibarrModules $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('ps'=>MAIN_DB_PREFIX.'product_stock'); - $this->import_fields_array[$r]=array('ps.fk_product'=>"Product*",'ps.fk_entrepot'=>"Warehouse*",'ps.reel'=>"Stock*",'ps.pmp'=>"PMP" ); + $this->import_fields_array[$r]=array('ps.fk_product'=>"Product*",'ps.fk_entrepot'=>"Warehouse*",'ps.reel'=>"Stock*"); $this->import_convertvalue_array[$r]=array( 'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'), 'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'label') ); - $this->import_examplevalues_array[$r]=array('ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10",'ps.pmp'=>"25" + $this->import_examplevalues_array[$r]=array('ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10" ); } From feb35adbe1d5235d5bb8fa824d8e2fcfadd7a090 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Mar 2016 15:22:43 +0200 Subject: [PATCH 2/6] FIX Missing clean of criteria --- htdocs/societe/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3aa18ed5018..48202706ff7 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -200,6 +200,7 @@ if (empty($reshook)) // Do we click on purge search criteria ? if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { + $search_nom=''; $search_categ=''; $search_sale=''; $search_barcode=""; From be483bd7879d2331d86a9ed6f953f5394451c716 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2016 12:26:42 +0200 Subject: [PATCH 3/6] FIX Some records were lost into margin per product report --- htdocs/langs/en_US/products.lang | 1 + htdocs/margin/productMargins.php | 34 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 52eadb2e11c..9298bdc9669 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -175,6 +175,7 @@ PredefinedProductsAndServicesToSell=Predefined products/services to sell PredefinedProductsToPurchase=Predefined product to purchase PredefinedServicesToPurchase=Predefined services to purchase PredefinedProductsAndServicesToPurchase=Predefined products/services to puchase +NotPredefinedProducts=Not predefined products/services GenerateThumb=Generate thumb ProductCanvasAbility=Use special "canvas" addons ServiceNb=Service #%s diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index e8483c90a34..c74c38caef2 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -165,16 +165,15 @@ print ''; $sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,"; if ($id > 0) $sql.= " d.fk_product,"; if ($id > 0) $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; -$sql.= " sum(d.total_ht) as selling_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; +$sql.= " SUM(d.total_ht) as selling_price,"; +$sql.= " SUM(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; +$sql.= " SUM(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = d.fk_product"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.fk_soc = s.rowid"; -$sql.= " AND d.fk_product = p.rowid"; $sql.= " AND f.fk_statut > 0"; $sql.= " AND d.fk_facture = f.rowid"; if ($id > 0) @@ -186,8 +185,8 @@ if (!empty($enddate)) $sql .= " AND d.buy_price_ht IS NOT NULL"; if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; -if ($id > 0) $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, d.fk_product, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; -else $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref"; +if ($id > 0) $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; +else $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity"; $sql.=$db->order($sortfield,$sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); @@ -260,13 +259,20 @@ if ($result) } else { print ''; - $product_static->type=$objp->fk_product_type; - $product_static->id=$objp->rowid; - $product_static->ref=$objp->ref; - $product_static->label=$objp->label; - $product_static->entity=$objp->pentity; - $text=$product_static->getNomUrl(1); - print $text.= ' - '.$objp->label; + if ($objp->rowid > 0) + { + $product_static->type=$objp->fk_product_type; + $product_static->id=$objp->rowid; + $product_static->ref=$objp->ref; + $product_static->label=$objp->label; + $product_static->entity=$objp->pentity; + $text=$product_static->getNomUrl(1); + print $text.= ' - '.$objp->label; + } + else + { + print $langs->trans("NotPredefinedProducts"); + } print "\n"; //print "".$product_static->getNomUrl(1)."\n"; } From be8384389f04a9310f37e8edf35c167af7a16870 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Apr 2016 14:15:38 +0200 Subject: [PATCH 4/6] FIX Creation of thumb image for size "small" was not done. Conflicts: htdocs/core/lib/files.lib.php --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 25b5712d3f4..df0ae0d40ee 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1467,7 +1467,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio { // Create small thumbs for image (Ratio is near 16/9) // Used on logon for example - $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheigthsmall, '_small', 50, "thumbs"); + $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); From c0b2d7405a676fcc9d6788f9732df0d6a6b87bd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Apr 2016 14:46:04 +0200 Subject: [PATCH 5/6] FIX Generated thumbs must always use the png format so using thumbs can work. --- htdocs/core/lib/files.lib.php | 4 ++-- htdocs/core/lib/images.lib.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index df0ae0d40ee..a1bdf274995 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1467,10 +1467,10 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio { // Create small thumbs for image (Ratio is near 16/9) // Used on logon for example - $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs", IMAGETYPE_PNG); // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example - $imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + $imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs", IMAGETYPE_PNG); } setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs'); diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 20a58d7021c..2fe9065b21c 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -301,7 +301,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s * @param string $extName Extension to differenciate thumb file name ('_small', '_mini') * @param int $quality Quality of compression (0=worst, 100=best) * @param string $outdir Directory where to store thumb - * @param int $targetformat New format of target (1,2,3,... or 0 to keep old format) + * @param int $targetformat New format of target (IMAGETYPE_GIF, IMAGETYPE_JPG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP ... or 0 to keep old format) * @return string Full path of thumb or '' if it fails */ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0) From 066c793de2336a37490c486253a27f1f996cd8b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Apr 2016 15:00:58 +0200 Subject: [PATCH 6/6] FIX image extension must be in lower case Conflicts: htdocs/core/lib/files.lib.php --- htdocs/core/class/html.formfile.class.php | 10 +++++++--- htdocs/core/lib/files.lib.php | 6 ++++++ htdocs/core/lib/images.lib.php | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1226d3b35ba..8c704aba52d 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -859,11 +859,15 @@ class FormFile { $fileinfo = pathinfo($file['name']); print ''; - $minifile=$fileinfo['filename'].'_mini.'.strtolower($fileinfo['extension']); // Thumbs are created with filename in lower case if (image_format_supported($file['name']) > 0) { - print ''; - print ''; + $minifile=getImageFileNameForSize($file['name'], '_mini', '.png'); // Thumbs are created with filename in lower case and with .png extension + //print $relativepath.'
'; + //print $file['path'].'/'.$minifile.'
'; + if (! dol_is_file($file['path'].'/'.$minifile)) $minifile=getImageFileNameForSize($file['name'], '_mini', '.'.$fileinfo['extension']); // For old thumbs + //print $file['path'].'/'.$minifile.'
'; + print '
'; + print ''; print ''; } else print ' '; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index a1bdf274995..4b1d3f3e491 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1451,6 +1451,12 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio $destfile=preg_replace('/__file__/',$_FILES[$varfiles]['name'],$savingdocmask); } + // lowercase extension + $info = pathinfo($destpath); + $destpath = $info['dirname'].'/'.$info['filename'].'.'.strtolower($info['extension']); + $info = pathinfo($destfile); + $destfile = $info['filename'].'.'.strtolower($info['extension']); + $resupload = dol_move_uploaded_file($_FILES[$varfiles]['tmp_name'], $destpath, $allowoverwrite, 0, $_FILES[$varfiles]['error'], 0, $varfiles); if (is_numeric($resupload) && $resupload > 0) { diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 2fe9065b21c..669da7b751b 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -473,6 +473,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ } // Initialisation des variables selon l'extension de l'image + // $targetformat is 0 by default, in such case, we keep original extension switch($targetformat) { case IMAGETYPE_GIF: // 1