diff --git a/build/debian/control b/build/debian/control index 29c2469a4e6..970f192f094 100755 --- a/build/debian/control +++ b/build/debian/control @@ -10,12 +10,13 @@ Build-Depends: debhelper (>= 9), po-debconf Package: dolibarr Architecture: all -Depends: libapache2-mod-php | libapache2-mod-phpfilter | php-cgi | php-fpm | php, - php-cli, +# For debian 7 or 8 or 9 +Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | php5 | libapache2-mod-php | libapache2-mod-phpfilter | php-cgi | php-fpm | php, + php5-cli | php-cli, # Required PHP extensions - php-mysql | php-mysqli, php-curl, php-gd, php-ldap, + php5-mysql | php5-mysqli | php-mysql | php-mysqli, php5-curl | php-curl, php5-gd | php-gd, php5-ldap | php-gd, # Required PHP libraries - php-pear, php-mail-mime, php-xml, php-mbstring, + php-pear, php-mail-mime, # php-tcpdf, # libfpdf-tpl-php, php-fpdf, # libphp-adodb, @@ -30,7 +31,9 @@ Depends: libapache2-mod-php | libapache2-mod-phpfilter | php-cgi | php-fpm | php ${misc:Depends}, ${perl:Depends} Recommends: apache2 | lighttpd | httpd, - mariadb-server | virtual-mysql-server + mariadb-server | virtual-mysql-server, +# Required PHP extensions for debian 9 but we can't add them into a Depends, it does not exists on debian 7 and 8 + php-xml, php-mbstring Suggests: www-browser, php5-geoip Description: Web based software to manage a company or foundation Dolibarr ERP & CRM is an easy to use open source/free software package for diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index c8f68d2151c..5cb10e31e6d 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -145,7 +145,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent- $result=$object->delete($user); if ($result > 0) { - header("Location: card_subscriptions.php?rowid=".$object->fk_adherent); + header("Location: ".DOL_URL_ROOT."/adherents/card.php?rowid=".$object->fk_adherent); exit; } else diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e1b59f34772..462ba4756c5 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -464,6 +464,7 @@ class Commande extends CommonOrder if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); + $mouvP->origin = &$this; // We increment stock of product (and sub-products) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref)); if ($result < 0) { $error++; $this->error=$mouvP->error; break; } diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index dcc0fc85ecc..5afc6c3583b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -117,7 +117,7 @@ if ($action == 'add') if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { - setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error'); + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); $action='create'; // Force chargement page en mode creation $error++; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 51e4d2f106f..5dbbeb24e5a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -409,7 +409,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->plimit($limit+1,$offset); +$sql.= $db->plimit($limit,$offset); //print $sql; $resql = $db->query($sql); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b2de5ff9d54..c05d9268b74 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3765,7 +3765,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$thirdparty_seller->country_code."'"; $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'"; // If we have the code, we use it in priority - else $sql.= " AND t.recuperableonly ='".$npr."'"; + else $sql.= " AND t.recuperableonly ='".$vatnpr."'"; dol_syslog("get_localtax", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index bb34806965a..07d7509c80b 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -5,6 +5,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2015-2016 Raphaël Doursenaud + * Copyright (C) 2017 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1439,7 +1440,7 @@ function dol_print_reduction($reduction,$langs) } else { - $string = $reduction.'%'; + $string = price($reduction).'%'; } return $string; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index d3e777b13ba..b981686d7c7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -791,7 +791,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->facture->enabled)) { $langs->load("bills"); - $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire); + $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire, '', $mainmenu, 'customers_bills'); $newmenu->add("/compta/facture.php?action=create",$langs->trans("NewBill"),1,$user->rights->facture->creer); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("List"),1,$user->rights->facture->lire); diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 3b93eb85cc9..9d030035d76 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -227,9 +227,8 @@ if ($result > 0) print ''.$langs->trans('BankAccount').''; print ''; $accountstatic=new Account($db); - $accountstatic->id=$bankline->fk_account; - $accountstatic->label=$bankline->bank_account_ref.' - '.$bankline->bank_account_label; - print $accountstatic->getNomUrl(0); + $accountstatic->fetch($bankline->fk_account); + print $accountstatic->getNomUrl(1); print ''; print ''; } diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 0338945df0f..0cda019e312 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -74,9 +74,9 @@ print '

'.$langs->trans("Repair").'

'; print 'Option restore_thirdparties_logos is '.(GETPOST('restore_thirdparties_logos')?GETPOST('restore_thirdparties_logos'):'0').'
'."\n"; print 'Option clean_linked_elements is '.(GETPOST('clean_linked_elements')?GETPOST('clean_linked_elements'):'0').'
'."\n"; -print 'Option clean_orphelin_dir (1 or confirmed) is '.(GETPOST('clean_orphelin_dir')?GETPOST('clean_orphelin_dir'):'0').'
'."\n"; -print 'Option clean_product_stock_batch (1 or confirmed) is '.(GETPOST('clean_product_stock_batch')?GETPOST('clean_product_stock_batch'):'0').'
'."\n"; -print 'Option set_empty_time_spent_amount (1 or confirmed) is '.(GETPOST('set_empty_time_spent_amount')?GETPOST('set_empty_time_spent_amount'):'0').'
'."\n"; +print 'Option clean_orphelin_dir (0 or \'test\' or \'confirmed\') is '.(GETPOST('clean_orphelin_dir')?GETPOST('clean_orphelin_dir'):'0').'
'."\n"; +print 'Option clean_product_stock_batch (0 or \'test\' or \'confirmed\') is '.(GETPOST('clean_product_stock_batch')?GETPOST('clean_product_stock_batch'):'0').'
'."\n"; +print 'Option set_empty_time_spent_amount (0 or \'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount')?GETPOST('set_empty_time_spent_amount'):'0').'
'."\n"; print '
'; print ''; @@ -547,14 +547,17 @@ if ($ok && GETPOST('clean_orphelin_dir')) // clean_linked_elements: Check and clean linked elements if ($ok && GETPOST('clean_product_stock_batch')) { - print ''; + $methodtofix=GETPOST('methodtofix')?GETPOST('methodtofix'):'updatestock'; + + print ''; $sql ="SELECT p.rowid, p.ref, p.tobatch, ps.rowid as psrowid, ps.fk_entrepot, ps.reel, SUM(pb.qty) as reelbatch"; - $sql.=" FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product_batch as pb"; - $sql.=" WHERE p.rowid = ps.fk_product AND ps.rowid = pb.fk_product_stock"; + $sql.=" FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_stock as ps LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb ON ps.rowid = pb.fk_product_stock"; + $sql.=" WHERE p.rowid = ps.fk_product"; $sql.=" AND p.tobatch = 1"; $sql.=" GROUP BY p.rowid, p.ref, p.tobatch, ps.rowid, ps.fk_entrepot, ps.reel"; - $sql.=" HAVING reel != SUM(pb.qty)"; + $sql.=" HAVING reel != SUM(pb.qty) or SUM(pb.qty) IS NULL"; + print $sql; $resql = $db->query($sql); if ($resql) { @@ -566,13 +569,11 @@ if ($ok && GETPOST('clean_product_stock_batch')) while ($i < $num) { $obj=$db->fetch_object($resql); - print ''; + } } else { @@ -640,6 +645,34 @@ if ($ok && GETPOST('clean_product_stock_batch')) } +// clean_linked_elements: Check and clean linked elements +if ($ok && GETPOST('clean_product_stock_negative_if_batch')) +{ + print ''; + + $sql ="SELECT p.rowid, p.ref, p.tobatch, ps.rowid as psrowid, ps.fk_entrepot, ps.reel, SUM(pb.qty) as reelbatch"; + $sql.=" FROM ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product_batch as pb"; + $sql.=" WHERE p.rowid = ps.fk_product AND ps.rowid = pb.fk_product_stock"; + $sql.=" AND p.tobatch = 1"; + $sql.=" GROUP BY p.rowid, p.ref, p.tobatch, ps.rowid, ps.fk_entrepot, ps.reel"; + $sql.=" HAVING reel != SUM(pb.qty)"; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj=$db->fetch_object($resql); + print '

*** Clean table product_batch

*** Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)
'.$obj->rowid.'-'.$obj->ref.'-'.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' != '.$obj->reelbatch; + print '
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) { - $methodtofix='updatestock'; - if ($methodtofix == 'updatebatch') { // Method 1 @@ -594,7 +595,7 @@ if ($ok && GETPOST('clean_product_stock_batch')) if ($methodtofix == 'updatestock') { // Method 2 - print ' -> Update qty of stock with qty = '.$obj->reelbatch.' for ps.rowid = '.$obj->psrowid; + print ' -> Update qty of product_stock with qty = '.($obj->reelbatch?$obj->reelbatch:'0').' for ps.rowid = '.$obj->psrowid; if (GETPOST('clean_product_stock_batch') == 'confirmed') { $error=0; @@ -602,11 +603,11 @@ if ($ok && GETPOST('clean_product_stock_batch')) $db->begin(); $sql2 ="UPDATE ".MAIN_DB_PREFIX."product_stock"; - $sql2.=" SET reel = ".$obj->reelbatch." WHERE rowid = ".$obj->psrowid; + $sql2.=" SET reel = ".($obj->reelbatch?$obj->reelbatch:'0')." WHERE rowid = ".$obj->psrowid; $resql2=$db->query($sql2); if ($resql2) { - // We update product stock, so we must update product.stock too. + // 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) @@ -632,6 +633,10 @@ if ($ok && GETPOST('clean_product_stock_batch')) $i++; } } + else + { + print '
Nothing to do

Clean table product_batch, methodtofix='.$methodtofix.' (possible values: updatestock or updatebatch)
'.$obj->rowid.'-'.$obj->ref.'-'.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' != '.$obj->reelbatch; + + } + } + } +} // clean_linked_elements: Check and clean linked elements if ($ok && GETPOST('set_empty_time_spent_amount')) @@ -667,15 +700,18 @@ if ($ok && GETPOST('set_empty_time_spent_amount')) $db->begin(); - $sql2 ="UPDATE ".MAIN_DB_PREFIX."projet_task_time"; - $sql2.=" SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".$obj->user_id; - $resql2=$db->query($sql2); - if (! $resql2) + if (GETPOST('set_empty_time_spent_amount') == 'confirmed') { - $error++; - dol_print_error($db); + $sql2 ="UPDATE ".MAIN_DB_PREFIX."projet_task_time"; + $sql2.=" SET thm = ".$obj->user_thm." WHERE thm IS NULL AND fk_user = ".$obj->user_id; + $resql2=$db->query($sql2); + if (! $resql2) + { + $error++; + dol_print_error($db); + } } - + if (!$error) $db->commit(); else $db->rollback(); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 9ea58263dfd..c6ebb9e0834 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -125,7 +125,7 @@ BillStatusClosedPaidPartially=Paid (partially) BillShortStatusDraft=Draft BillShortStatusPaid=Paid BillShortStatusPaidBackOrConverted=Refund or converted -BillShortStatusConverted=Processed +BillShortStatusConverted=Paid BillShortStatusCanceled=Abandoned BillShortStatusValidated=Validated BillShortStatusStarted=Started