diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index a70553cbfb0..bab7b5e5da4 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -26,6 +26,7 @@ include_once 'inc.php'; if (file_exists($conffile)) include_once $conffile; require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php'; +include_once $dolibarr_main_document_root.'/core/lib/images.lib.php'; require_once $dolibarr_main_document_root.'/core/class/extrafields.class.php'; require_once 'lib/repair.lib.php'; @@ -72,11 +73,12 @@ $actiondone=1; print '
*** Restore thirdparties logo '; //foreach($exts as $ext) //{ @@ -393,8 +395,66 @@ if ($ok && GETPOST('restore_thirdparties_logos')) } +// rebuild_product_thumbs: Rebuild thumbs for product files +if ($ok && GETPOST('rebuild_product_thumbs','alpha')) +{ + $ext=''; + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini; + + print ' | |
*** Rebuild product thumbs '; + + $sql="SELECT s.rowid, s.ref FROM ".MAIN_DB_PREFIX."product as s ORDER BY s.ref"; + $resql=$db->query($sql); + if ($resql) + { + $num=$db->num_rows($resql); + $i=0; + + while($i < $num) + { + $obj=$db->fetch_object($resql); + + if (! empty($obj->ref)) + { + $files=dol_dir_list($dolibarr_main_data_root.'/produit/'.$obj->ref, 'files', 0); + foreach($files as $file) + { + // Generate thumbs. + if (image_format_supported($file['fullname']) == 1) + { + $imgThumbSmall='notbuild'; + if (GETPOST('rebuild_product_thumbs','alpha') == 'confirmed') + { + // Used on logon for example + $imgThumbSmall = vignette($file['fullname'], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + } + print 'Check product '.$obj->rowid.", file ".$file['fullname']." -> ".$imgThumbSmall." maxwidthsmall=".$maxwidthsmall." maxheightsmall=".$maxheightsmall." \n"; + $imgThumbMini='notbuild'; + if (GETPOST('rebuild_product_thumbs','alpha') == 'confirmed') + { + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($file['fullname'], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + } + print 'Check product '.$obj->rowid.", file ".$file['fullname']." -> ".$imgThumbMini." maxwidthmini=".$maxwidthmini." maxheightmini=".$maxheightmini." \n"; + } + } + } + + $i++; + } + } + else + { + $ok=0; + dol_print_error($db); + } + + print ' | |
*** Check table of linked elements and delete orphelins links | |
| ';
print 'Delete orphelins file '.$file['fullname'].' '; - if (GETPOST('clean_orphelin_dir') == 'confirmed') + if (GETPOST('clean_orphelin_dir','alpha') == 'confirmed') { dol_delete_file($file['fullname'],1,1,1); dol_delete_dir(dirname($file['fullname']),1); @@ -545,12 +605,12 @@ if ($ok && GETPOST('clean_orphelin_dir')) } // clean_linked_elements: Check and clean linked elements -if ($ok && GETPOST('clean_product_stock_batch')) +if ($ok && GETPOST('clean_product_stock_batch','alpha')) { - $methodtofix=GETPOST('methodtofix')?GETPOST('methodtofix'):'updatestock'; - + $methodtofix=GETPOST('methodtofix','alpha')?GETPOST('methodtofix','alpha'):'updatestock'; + print ' | |
*** Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch) | |
| Product '.$obj->rowid.'-'.$obj->ref.' in warehose '.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' (product_stock.reel) != '.($obj->reelbatch?$obj->reelbatch:'0').' (sum product_batch)'; - + // Fix if ($obj->reel != $obj->reelbatch) { @@ -599,9 +659,9 @@ if ($ok && GETPOST('clean_product_stock_batch')) if (GETPOST('clean_product_stock_batch') == 'confirmed') { $error=0; - + $db->begin(); - + $sql2 ="UPDATE ".MAIN_DB_PREFIX."product_stock"; $sql2.=" SET reel = ".($obj->reelbatch?$obj->reelbatch:'0')." WHERE rowid = ".$obj->psrowid; $resql2=$db->query($sql2); @@ -610,26 +670,26 @@ if ($ok && GETPOST('clean_product_stock_batch')) // We update product_stock, so we must field stock into product too. $sql3='UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid)'; $resql3=$db->query($sql3); - if (! $resql3) + if (! $resql3) { $error++; dol_print_error($db); } } - else + else { $error++; dol_print_error($db); } - + if (!$error) $db->commit(); else $db->rollback(); } } } - + print' | |
Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch) | |
*** Set value of time spent without amount | |