From e039f7cc22eea102f4b233af0236b2777fed69df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Aug 2017 16:37:24 +0200 Subject: [PATCH 01/16] Complete repair script --- htdocs/install/mysql/migration/repair.sql | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 5e888399d9c..c86ab8d7ff7 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -13,11 +13,26 @@ -- flush privileges; --- Requests to change character set and collation of a column +-- Request to change default pagecode + colation of database +-- ALTER DATABASE name_of_database CHARACTER SET utf8 COLLATE utf8_unicode_ci; --- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; --- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; --- You can check with "show full columns from llx_accountingaccount"; +-- Request to change default pagecode + colation of table +-- ALTER TABLE name_of_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci; + +-- Request to change character set and collation of a varchar column. +-- utf8 and utf8_unicode_ci is recommended (or even better utf8mb4 and utf8mb4_unicode_ci with mysql 5.5.3+) +-- ALTER TABLE name_of_table MODIFY field VARCHAR(20) CHARACTER SET utf8; +-- ALTER TABLE name_of_table MODIFY field VARCHAR(20) COLLATE utf8_unicode_ci; +-- You can check with 'show full columns from mytablename'; + + + +-- VMYSQLUTF8UNICODE ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODE ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODE ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODE ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODE ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODE ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; From a3b5caaae0f7f35b38648e8ac82d96d1f274e18d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Aug 2017 18:41:05 +0200 Subject: [PATCH 02/16] Prepare rc --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 6d14f47af10..9b6435d8210 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.0-beta'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.0-rc'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 1c157c7c3d5f149e2c18cca4ac3c2613d60ba7e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Aug 2017 21:23:40 +0200 Subject: [PATCH 03/16] Fix pb with mix collation. Add a way to fix this in repair. --- htdocs/core/lib/admin.lib.php | 43 ++++++++++++++--------- htdocs/install/mysql/migration/repair.sql | 12 +++---- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 288082296f3..1225f510774 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -146,7 +146,7 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker $buf = fgets($fp, 4096); // Test if request must be ran only for particular database or version (if yes, we must remove the -- comment) - if (preg_match('/^--\sV(MYSQL|PGSQL|)([0-9\.]+)/i',$buf,$reg)) + if (preg_match('/^--\sV(MYSQL|PGSQL)([^\s]*)/i',$buf,$reg)) { $qualified=1; @@ -159,20 +159,29 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker // restrict on version if ($qualified) { - - $versionrequest=explode('.',$reg[2]); - //print var_dump($versionrequest); - //print var_dump($versionarray); - if (! count($versionrequest) || ! count($versionarray) || versioncompare($versionrequest,$versionarray) > 0) - { - $qualified=0; - } + if (! empty($reg[2])) + { + if (is_numeric($reg[2])) // This is a version + { + $versionrequest=explode('.',$reg[2]); + //print var_dump($versionrequest); + //print var_dump($versionarray); + if (! count($versionrequest) || ! count($versionarray) || versioncompare($versionrequest,$versionarray) > 0) + { + $qualified=0; + } + } + else // This is a test on a constant. For example when we have -- VMYSQLUTF8UNICODE, we test constant $conf->global->UTF8UNICODE + { + if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != strtoupper(preg_replace('/_/', '', $conf->db->dolibarr_main_db_collation)))) $qualified=0; + } + } } if ($qualified) { // Version qualified, delete SQL comments - $buf=preg_replace('/^--\sV(MYSQL|PGSQL|)([0-9\.]+)/i','',$buf); + $buf=preg_replace('/^--\sV(MYSQL|PGSQL)([^\s]*)/i','',$buf); //print "Ligne $i qualifi?e par version: ".$buf.'
'; } } @@ -769,7 +778,7 @@ function activateModule($value,$withdeps=1) } $result=$objMod->init(); - if ($result <= 0) + if ($result <= 0) { $ret['errors'][]=$objMod->error; } @@ -799,19 +808,19 @@ function activateModule($value,$withdeps=1) break; } } - + if ($activate) { $ret['nbmodules']+=$resarray['nbmodules']; $ret['nbperms']+=$resarray['nbperms']; } - else + else { $ret['errors'][] = $langs->trans('activateModuleDependNotSatisfied', $objMod->name, $objMod->depends[$i]); } } } - + if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && ! empty($objMod->conflictwith)) { // Desactivation des modules qui entrent en conflit @@ -830,12 +839,12 @@ function activateModule($value,$withdeps=1) } } - if (! count($ret['errors'])) + if (! count($ret['errors'])) { $ret['nbmodules']++; $ret['nbperms']+=count($objMod->rights); } - + return $ret; } @@ -1307,7 +1316,7 @@ function showModulesExludedForExternal($modules) //if (empty($conf->global->$moduleconst)) continue; if (! in_array($modulename,$listofmodules)) continue; //var_dump($modulename.'eee'.$langs->trans('Module'.$module->numero.'Name')); - + if ($i > 0) $text.=', '; else $text.=' '; $i++; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index c86ab8d7ff7..fa48dfad9d2 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -27,12 +27,12 @@ --- VMYSQLUTF8UNICODE ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; --- VMYSQLUTF8UNICODE ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODE ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8; --- VMYSQLUTF8UNICODE ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; --- VMYSQLUTF8UNICODE ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; --- VMYSQLUTF8UNICODE ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; From c2a89ae58e935955bd73b142f4d9e5d1c91155cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Aug 2017 22:58:52 +0200 Subject: [PATCH 04/16] Code comment --- htdocs/install/mysql/data/llx_c_tva.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 7f9c5f97ea4..df533f39db0 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -133,13 +133,13 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 3 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 34, 3, '0','0','VAT Rate 0',1); -- INDIA (id country=117) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1171, 117, '12.5','0','VAT standard rate',0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1172, 117, '4','0','VAT reduced rate',0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1171, 117, '12.5','0','VAT standard rate', 0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1172, 117, '4','0','VAT reduced rate', 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1173, 117, '1','0','VAT super-reduced rate',0); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1174, 117, '0','0','VAT Rate 0',0); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1174, 117, '0','0','VAT Rate 0', 0); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'IGST+CGST', 8, 8, '1', 0, '0', 0, 'IGST+CGST', 1); -insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'SGST', 0, 0, '0', 16, '1', 0, 'SGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1176, 117, 'IGST+CGST', 8, 8, '1', 0, '0', 0, 'IGST+CGST', 1); +insert into llx_c_tva(rowid,fk_pays,code,taux,localtax1,localtax1_type,localtax2,localtax2_type,recuperableonly,note,active) values (1177, 117, 'SGST' , 0, 0, '0', 16, '1', 0, 'SGST', 1); -- IRELAND (id country=8) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (81, 8, '0','0','VAT Rate 0',1); From 975fd0a6d3f37a7b7ba6f92a851e51be408e8f59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Aug 2017 15:43:42 +0200 Subject: [PATCH 05/16] Fix font size --- htdocs/core/lib/pdf.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 19063ae79c2..5b344056efb 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -748,7 +748,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default $pdf->MultiCell($tmplength, 3, $outputlangs->convToOutputCharset($content), 0, 'C', 0); $pdf->SetXY($curx, $cury + 1); $curx += $tmplength; - $pdf->SetFont('', 'B', $default_font_size - 4); + $pdf->SetFont('', 'B', $default_font_size - $diffsizecontent); $pdf->MultiCell($tmplength, 3, $outputlangs->transnoentities($val), 0, 'C', 0); if (empty($onlynumber)) { $pdf->line($curx, $cury + 1, $curx, $cury + 7); @@ -794,6 +794,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default $pdf->MultiCell(100, 3, $val, 0, 'L', 0); $tmpy=$pdf->getStringHeight(100, $val); $cury+=$tmpy; + $cur+=1; } else if (! $usedetailedbban) $cury+=1; From d791476708274b0ff152a161ae4eca50f7203c6c Mon Sep 17 00:00:00 2001 From: John Date: Mon, 7 Aug 2017 15:47:55 +0200 Subject: [PATCH 06/16] Fix doaction call --- htdocs/resource/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 02d38c2b924..42b8b953c87 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -58,6 +58,9 @@ if( ! $user->rights->resource->read) accessforbidden(); $object = new Dolresource($db); +$objectFetchRes = $object->fetch($id); +if ( !$objectFetchRes> 0 ) dol_print_error(); + $extrafields = new ExtraFields($db); @@ -162,7 +165,7 @@ llxHeader('',$pagetitle,''); $form = new Form($db); $formresource = new FormResource($db); -if ( $object->fetch($id) > 0 ) +if ( $objectFetchRes > 0 ) { $head=resource_prepare_head($object); From 76bee575536bd3729b5f180408e809fa36560180 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 7 Aug 2017 15:49:17 +0200 Subject: [PATCH 07/16] Fix Add doaction hook --- htdocs/resource/add.php | 116 +++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 54 deletions(-) diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php index a294dfb94db..a6cd75cccf8 100644 --- a/htdocs/resource/add.php +++ b/htdocs/resource/add.php @@ -66,64 +66,72 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); -if ($action == 'confirm_add_resource') +$hookmanager->initHooks(array('resource_card_add','globalcard')); +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - if (! $cancel) - { - $error=''; - $ref=GETPOST('ref','alpha'); - $description=GETPOST('description','alpha'); - $fk_code_type_resource=GETPOST('fk_code_type_resource','alpha'); - - if (empty($ref)) - { - $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); - setEventMessages($mesg, null, 'errors'); - $error++; - } - - if (! $error) - { - $object=new Dolresource($db); - $object->ref=$ref; - $object->description=$description; - $object->fk_code_type_resource=$fk_code_type_resource; - - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) { - $error ++; - } - - $result=$object->create($user); - if ($result > 0) - { - // Creation OK - $db->commit(); - setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null, 'mesgs'); - Header("Location: card.php?id=" . $object->id); - return; - } - else - { - // Creation KO - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } - } - else - { - $action = ''; - } - } - else - { - Header("Location: list.php"); - } + if ($action == 'confirm_add_resource') + { + if (! $cancel) + { + $error=''; + + $ref=GETPOST('ref','alpha'); + $description=GETPOST('description','alpha'); + $fk_code_type_resource=GETPOST('fk_code_type_resource','alpha'); + + if (empty($ref)) + { + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); + setEventMessages($mesg, null, 'errors'); + $error++; + } + + if (! $error) + { + $object=new Dolresource($db); + $object->ref=$ref; + $object->description=$description; + $object->fk_code_type_resource=$fk_code_type_resource; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + } + + $result=$object->create($user); + if ($result > 0) + { + // Creation OK + $db->commit(); + setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null, 'mesgs'); + Header("Location: card.php?id=" . $object->id); + return; + } + else + { + // Creation KO + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } + } + else + { + $action = ''; + } + } + else + { + Header("Location: list.php"); + } + } } - /* * View */ From fd38a55f51fe28c71035116d77fec53c2d9eaf9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Aug 2017 15:49:54 +0200 Subject: [PATCH 08/16] FIX amount overlap other amount when a pagebreak is done due to an image at the bottom of page. --- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 3eb284ec7fc..d2ecfb60d81 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -451,8 +451,6 @@ class pdf_azur extends ModelePDFPropales // Description of product line $curX = $this->posxdesc-1; - $showpricebeforepagebreak=1; - $pdf->startTransaction(); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); From 0960473c9b9e47e99fdc2272f36f452f10f5a98b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Aug 2017 15:51:30 +0200 Subject: [PATCH 09/16] More complete repair of unicode field --- htdocs/install/mysql/migration/repair.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index fa48dfad9d2..467455e57de 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -33,6 +33,8 @@ -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_batchlot MODIFY batch VARCHAR(30) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_batch MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; From a7c1ff402afe89ea9857be73024261d0dfe9c355 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Aug 2017 16:06:38 +0200 Subject: [PATCH 10/16] Fix picto on support page --- htdocs/support/index.php | 81 +++------------------------------------- 1 file changed, 5 insertions(+), 76 deletions(-) diff --git a/htdocs/support/index.php b/htdocs/support/index.php index 0e27107ef54..dc1872a1b45 100644 --- a/htdocs/support/index.php +++ b/htdocs/support/index.php @@ -70,12 +70,12 @@ print ''; print ''; print '