From 2be75420caaf2e95a29585d3f73ae24194dd592e Mon Sep 17 00:00:00 2001 From: altatof Date: Mon, 7 Aug 2017 10:21:38 +0200 Subject: [PATCH 01/12] FIX : supplier id was not passed to hooks --- htdocs/fourn/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index d3c0fa7357d..ee6ac67412a 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -66,7 +66,7 @@ $hookmanager->initHooks(array('suppliercard','globalcard')); * Action */ -$parameters=array('socid'=>$socid); +$parameters=array('id'=>$id); $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'); From 0bf4ac6fb3d592d5fc0d8d06535fd6b562e742dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Aug 2017 20:06:26 +0200 Subject: [PATCH 02/12] Add missing field fk_supplier_proposal --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index f1c94f346cf..8880f3fae97 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -34,6 +34,7 @@ ALTER TABLE llx_product_customer_price ADD COLUMN localtax1_type varchar(10) NO ALTER TABLE llx_product_customer_price ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0' after localtax2_tx; ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0' after localtax1_tx; ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0' after localtax2_tx; +ALTER TABLE llx_supplier_proposaldet CHANGE COLUMN fk_askpricesupplier fk_supplier_proposal integer NOT NULL; ALTER TABLE llx_opensurvey_sondage ADD COLUMN status integer DEFAULT 1 after date_fin; From ca3cdfabec0886fbf24c2545a5b821bcf5f769ef Mon Sep 17 00:00:00 2001 From: fappels Date: Wed, 9 Aug 2017 14:15:26 +0200 Subject: [PATCH 03/12] FIX Best buy price calculation Best buy price also depends on buy discount. --- htdocs/fourn/class/fournisseur.product.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 34a11663e2a..4d155bbce5f 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -581,7 +581,8 @@ class ProductFournisseur extends Product foreach($record_array as $record) { $fourn_price = $record["price"]; - $fourn_unitprice = $record["unitprice"]; + // discount calculated buy price + $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) + $record["unitcharges"] - $record["remise"]; if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { $prod_supplier = new ProductFournisseur($this->db); $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; @@ -613,7 +614,7 @@ class ProductFournisseur extends Product $this->fourn_qty = $record["quantity"]; $this->fourn_remise_percent = $record["remise_percent"]; $this->fourn_remise = $record["remise"]; - $this->fourn_unitprice = $fourn_unitprice; + $this->fourn_unitprice = $record["unitprice"]; $this->fourn_charges = $record["charges"]; // deprecated $this->fourn_unitcharges = $record["unitcharges"]; // deprecated $this->fourn_tva_tx = $record["tva_tx"]; @@ -622,7 +623,7 @@ class ProductFournisseur extends Product $this->delivery_time_days = $record["delivery_time_days"]; $this->fk_supplier_price_expression = $record["fk_supplier_price_expression"]; $this->id = $prodid; - $min = $this->fourn_unitprice; + $min = $fourn_unitprice; } } } From 112a6f7b44f4b3cd6b9d962f18be3a0a99293945 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Aug 2017 23:51:35 +0200 Subject: [PATCH 04/12] Fix travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4c18c5caa3b..58e749a532d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ # from Dolibarr GitHub repository. # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ +dist: precise sudo: required language: php From c793e847bc452f48ddf93d792a9c40c5c05a765a Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 18 Aug 2017 11:30:13 +0200 Subject: [PATCH 05/12] fix comondoc generator --- htdocs/core/class/commondocgenerator.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 1961cbb7af6..fe513f59ee7 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -374,13 +374,12 @@ abstract class CommonDocGenerator $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), - $array_key.'_total_discount_ht_locale' => price($object->getTotalDiscount(), 0, $outputlangs), + $array_key.'_total_ht'=>price2num($object->total_ht), $array_key.'_total_vat'=>(! empty($object->total_vat)?price2num($object->total_vat):price2num($object->total_tva)), $array_key.'_total_localtax1'=>price2num($object->total_localtax1), $array_key.'_total_localtax2'=>price2num($object->total_localtax2), $array_key.'_total_ttc'=>price2num($object->total_ttc), - $array_key.'_total_discount_ht' => price2num($object->getTotalDiscount()), $array_key.'_multicurrency_code' => price2num($object->multicurrency_code), $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), @@ -411,6 +410,14 @@ abstract class CommonDocGenerator $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT') ); + if (method_exists($object, 'getTotalDiscount')) { + $resarray[$array_key.'_total_discount_ht_locale'] = price($object->getTotalDiscount(), 0, $outputlangs); + $resarray[$array_key.'_total_discount_ht'] = price2num($object->getTotalDiscount()); + } else { + $resarray[$array_key.'_total_discount_ht_locale'] = ''; + $resarray[$array_key.'_total_discount_ht'] = ''; + } + // Add vat by rates foreach ($object->lines as $line) { From 874d61bb6d7b8505319533efd72c0f44e9fbd8c0 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 18 Aug 2017 11:35:20 +0200 Subject: [PATCH 06/12] Other fix --- .../core/class/commondocgenerator.class.php | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index fe513f59ee7..535200ab95a 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -419,17 +419,20 @@ abstract class CommonDocGenerator } // Add vat by rates - foreach ($object->lines as $line) + if (is_array($object->lines) && count($object->lines)>0) { - // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; - $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; - $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); - // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) - $vatformated=vatrate($line->tva_tx); - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; - $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; - $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); + foreach ($object->lines as $line) + { + // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; + $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; + $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); + // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) + $vatformated=vatrate($line->tva_tx); + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; + $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; + $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); + } } // Retrieve extrafields if (is_array($object->array_options) && count($object->array_options)) From b77fe285dc9acc03aaf9be20d670a8d34bb7e6b8 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Sun, 20 Aug 2017 09:39:51 +0200 Subject: [PATCH 07/12] fix 'Error cronjob->run_job: Permission denied' and add time and login used for debug helps --- scripts/cron/cron_run_jobs.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index fb03cad5757..28de8c46ab3 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -68,9 +68,11 @@ $error=0; /* * Main */ +// current date +$now=dol_now(); @set_time_limit(0); -print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=" . $userlogin . " ***** " . $now . " *****\n"; // Check security key if ($key != $conf->global->CRON_KEY) @@ -114,7 +116,9 @@ else exit(-1); } } - +//erics cf https://www.dolibarr.org/forum/12-howto-help/26035-cron-run-jobs-php-error-permission-denied +$user->getrights(); + if (isset($argv[3]) || $argv[3]) { $id = $argv[3]; @@ -138,9 +142,6 @@ if ($result<0) // TODO This sequence of code must be shared with code into cron_run_jobs.php php page. -// current date -$now=dol_now(); - if(is_array($object->lines) && (count($object->lines)>0)) { // Loop over job From 64aed245397f36e740b0ec540eccc0680b08dcbb Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Sun, 20 Aug 2017 09:45:11 +0200 Subject: [PATCH 08/12] remove comment --- scripts/cron/cron_run_jobs.php | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 28de8c46ab3..5c32272bed1 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -116,7 +116,6 @@ else exit(-1); } } -//erics cf https://www.dolibarr.org/forum/12-howto-help/26035-cron-run-jobs-php-error-permission-denied $user->getrights(); if (isset($argv[3]) || $argv[3]) From 7c3640a4c344e06e4a6210605a5660f4db7dbf1d Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 19 Aug 2017 13:26:50 +0200 Subject: [PATCH 09/12] Bad ojbject for extrafields https://www.dolibarr.fr/forum/527-bugs-sur-la-version-stable-courante/59536-extrafields-commande-dans-expedition --- htdocs/expedition/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 6c93166c063..f15c091263e 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -765,7 +765,7 @@ if ($action == 'create') print "".$langs->trans("DeliveryMethod").""; print ''; $expe->fetch_delivery_methods(); - print $form->selectarray("shipping_method_id",$expe->meths,GETPOST('shipping_method_id','int'),1,0,0,"",1); + print $form->selectarray("shipping_method_id", $expe->meths, GETPOST('shipping_method_id','int'),1,0,0,"",1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print "\n"; @@ -777,11 +777,11 @@ if ($action == 'create') // Other attributes $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print $expe->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit'); } From 749355abc2b96ac4d19c86c2c8be688cd5adfc50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Aug 2017 10:41:30 +0200 Subject: [PATCH 10/12] Update cron_run_jobs.php --- scripts/cron/cron_run_jobs.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 5c32272bed1..a0d4cb7caee 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -55,9 +55,9 @@ $key=$argv[1]; if (! isset($argv[2]) || ! $argv[2]) { usage($path,$script_file); exit(-1); -} else { - $userlogin=$argv[2]; -} +} + +$userlogin=$argv[2]; // Global variables From d2955cb32f489f037c166fd3cf9a96ff82ae0ebd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Aug 2017 08:31:23 +0200 Subject: [PATCH 11/12] Fix: virtualmin script update --- build/perl/virtualmin/README | 8 +++--- build/perl/virtualmin/dolibarr.pl | 45 +++++++++++++++++-------------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/build/perl/virtualmin/README b/build/perl/virtualmin/README index 22db444a31f..6da04e5f0b8 100644 --- a/build/perl/virtualmin/README +++ b/build/perl/virtualmin/README @@ -1,8 +1,10 @@ README (English) ################################################## -Install script for Virtualmin Pro +Install script for Virtualmin Professional / GPL ################################################## -This script will install automatically Dolibarr from Virtualmin Pro -http://www.virtualmin.com +This script will install automatically Dolibarr from Virtualmin. +(Included in the professional version and can be added in the GPL version) + +https://www.virtualmin.com http://www.webmin.com/virtualmin.html \ No newline at end of file diff --git a/build/perl/virtualmin/dolibarr.pl b/build/perl/virtualmin/dolibarr.pl index 32324d28e42..93439303833 100644 --- a/build/perl/virtualmin/dolibarr.pl +++ b/build/perl/virtualmin/dolibarr.pl @@ -1,7 +1,7 @@ #---------------------------------------------------------------------------- # \file dolibarr.pl # \brief Dolibarr script install for Virtualmin Pro -# \author (c)2009-2015 Regis Houssin +# \author (c)2009-2017 Regis Houssin #---------------------------------------------------------------------------- @@ -30,7 +30,12 @@ return "Regis Houssin"; # script_dolibarr_versions() sub script_dolibarr_versions { -return ( "3.8.1", "3.7.1", "3.6.4", "3.5.7" ); +return ( "5.0.4", "4.0.6", "3.9.4" ); +} + +sub script_dolibarr_release +{ +return 2; # for mysqli fix } sub script_dolibarr_category @@ -163,7 +168,7 @@ return ("tar", "gunzip"); } # script_dolibarr_install(&domain, version, &opts, &files, &upgrade-info) -# Actually installs dolibarr, and returns either 1 and an informational +# Actually installs joomla, and returns either 1 and an informational # message, or 0 and an error sub script_dolibarr_install { @@ -177,9 +182,9 @@ if ($opts->{'newdb'} && !$upgrade) { local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2); local $dbuser = $dbtype eq "mysql" ? &mysql_user($d) : &postgres_user($d); local $dbpass = $dbtype eq "mysql" ? &mysql_pass($d) : &postgres_pass($d, 1); -local $dbphptype = $dbtype eq "mysql" && $version >= 3.6 ? "mysql" : +local $dbphptype = $dbtype eq "mysql" && $version < 3.6 ? "mysql" : $dbtype eq "mysql" ? "mysqli" : "pgsql"; -local $dbhost = &get_database_host($dbtype); +local $dbhost = &get_database_host($dbtype, $d); local $dberr = &check_script_db_connection($dbtype, $dbname, $dbuser, $dbpass); return (0, "Database connection failed : $dberr") if ($dberr); @@ -206,9 +211,6 @@ $pgcharset = $tmpl->{'postgres_encoding'}; $charset = $dbtype eq "mysql" ? $mycharset : $pgcharset; $collate = $dbtype eq "mysql" ? $mycollate : "C"; -# Install filename -local $step = $version >= 3.8 ? "step" : "etape"; - $path = &script_path_url($d, $opts); if ($path =~ /^https:/ || $d->{'ssl'}) { $url = "https://$d->{'dom'}"; @@ -222,15 +224,11 @@ if ($opts->{'path'} =~ /\w/) { if (!$upgrade) { local $cdef = "$opts->{'dir'}/conf/conf.php.example"; - &run_as_domain_user($d, "cp ".quotemeta($cdef)." ".quotemeta($cfile)); + ©_source_dest_as_domain_user($d, $cdef, $cfile); &set_permissions_as_domain_user($d, 0777, $cfiledir); - &set_permissions_as_domain_user($d, 0666, $cfile); + ©_source_dest_as_domain_user($d, $cfile); &run_as_domain_user($d, "mkdir ".quotemeta($docdir)); &set_permissions_as_domain_user($d, 0777, $docdir); - if (!$version >= 3.7.2) { - &run_as_domain_user($d, "mkdir ".quotemeta($altdir)); - &set_permissions_as_domain_user($d, 0777, $altdir); - } } else { # Preserve old config file, documents and custom directory @@ -266,7 +264,8 @@ if ($upgrade) { [ "versionfrom", $upgrade->{'version'} ], [ "versionto", $ver ], ); - local $err = &call_dolibarr_wizard_page(\@params, $step."5", $d, $opts); + local $p = $ver >= 3.8 ? "step5" : "etape5"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Remove the installation directory. @@ -289,15 +288,17 @@ else { [ "main_force_https", $opts->{'forcehttps'} ], [ "dolibarr_main_db_character_set", $charset ], [ "dolibarr_main_db_collation", $collate ], - [ "main_use_alt_dir", "1" ], + [ "usealternaterootdir", "1" ], [ "main_alt_dir_name", "custom" ], ); - local $err = &call_dolibarr_wizard_page(\@params, $step."1", $d, $opts); + local $p = $ver >= 3.8 ? "step1" : "etape1"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Second page (Populate database) local @params = ( [ "action", "set" ] ); - local $err = &call_dolibarr_wizard_page(\@params, $step."2", $d, $opts); + local $p = $ver >= 3.8 ? "step2" : "etape2"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Third page (Add administrator account) @@ -306,7 +307,8 @@ else { [ "pass", $dompass ], [ "pass_verif", $dompass ], ); - local $err = &call_dolibarr_wizard_page(\@params, $step."5", $d, $opts); + local $p = $ver >= 3.8 ? "step5" : "etape5"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Remove the installation directory and protect config file. @@ -384,7 +386,10 @@ sub script_dolibarr_check_latest { local ($ver) = @_; local @vers = &osdn_package_versions("dolibarr", - $ver >= 3.8 ? "dolibarr\\-(3\\.[0-9\\.]+)\\.tgz" : + $ver >= 5.0 ? "dolibarr\\-(5\\.0\\.[0-9\\.]+)\\.tgz" : + $ver >= 4.0 ? "dolibarr\\-(4\\.0\\.[0-9\\.]+)\\.tgz" : + $ver >= 3.9 ? "dolibarr\\-(3\\.9\\.[0-9\\.]+)\\.tgz" : + $ver >= 3.8 ? "dolibarr\\-(3\\.8\\.[0-9\\.]+)\\.tgz" : $ver >= 3.7 ? "dolibarr\\-(3\\.7\\.[0-9\\.]+)\\.tgz" : $ver >= 3.6 ? "dolibarr\\-(3\\.6\\.[0-9\\.]+)\\.tgz" : $ver >= 3.5 ? "dolibarr\\-(3\\.5\\.[0-9\\.]+)\\.tgz" : From a17e4434beec2099f786ba668ba1d00a9e041f16 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Aug 2017 08:35:16 +0200 Subject: [PATCH 12/12] Fix: wrong app name --- build/perl/virtualmin/dolibarr.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/perl/virtualmin/dolibarr.pl b/build/perl/virtualmin/dolibarr.pl index 93439303833..08d02e8b2b8 100644 --- a/build/perl/virtualmin/dolibarr.pl +++ b/build/perl/virtualmin/dolibarr.pl @@ -168,7 +168,7 @@ return ("tar", "gunzip"); } # script_dolibarr_install(&domain, version, &opts, &files, &upgrade-info) -# Actually installs joomla, and returns either 1 and an informational +# Actually installs dolibarr, and returns either 1 and an informational # message, or 0 and an error sub script_dolibarr_install {