From 76b1f0ca86a72faaf72eb5195ef3e571658caa84 Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 28 Nov 2015 22:16:45 +0100 Subject: [PATCH 001/421] modifs to fichinter/card.php FICHINTER_EMPTY_LINE_DESC --- htdocs/fichinter/card.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 3cb613934b9..d0535d81c50 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -6,6 +6,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Ferran Marcet * Copyright (C) 201 Charlie Benke + * Copyright (C) 2015 Abbes Bahfir * * 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 @@ -465,7 +466,7 @@ if (empty($reshook)) // Add line else if ($action == "addline" && $user->rights->ficheinter->creer) { - if (!GETPOST('np_desc')) + if (!GETPOST('np_desc')&&($conf->global->FICHINTER_EMPTY_LINE_DESC!=1)) { $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'
'; $error++; @@ -1568,10 +1569,12 @@ else if ($id > 0 || ! empty($ref)) print '\n"; print ''; // editeur wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('np_desc',GETPOST('np_desc','alpha'),'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,70); - $doleditor->Create(); - print ''; + if ($conf->global->FICHINTER_EMPTY_LINE_DESC != 1) { + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'alpha'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, 70); + $doleditor->Create(); + } + print ''; // Date intervention print ''; From 05258172aac57f3db17cec11a4ca0c1c5f548858 Mon Sep 17 00:00:00 2001 From: abb Date: Wed, 2 Dec 2015 19:08:14 +0100 Subject: [PATCH 002/421] update product.lang --- htdocs/langs/en_US/products.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index b21fd88539e..f4cd0824d70 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -297,3 +297,4 @@ PropalMergePdfProductChooseFile=Select PDF files IncludingProductWithTag=Including product with tag DefaultPriceRealPriceMayDependOnCustomer=Default price, real price may depend on customer WarningSelectOneDocument=Please select at least one document +DefaultUnitToShow=Units \ No newline at end of file From 613209eadb9aa9bdd876c5207568d26a5595e420 Mon Sep 17 00:00:00 2001 From: abb Date: Fri, 11 Dec 2015 12:14:46 +0100 Subject: [PATCH 003/421] confs sur filefunc --- htdocs/filefunc.inc.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 415a7addf4a..e4fbb602156 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -80,6 +80,12 @@ if (! empty($_GET['conf'])) $conffile = 'conf/'.$confname.'.php'; } */ +if (!empty($_GET['conf'])) { + setcookie('dolconf', $_GET['conf']); + $conffile = 'conf/' . $_GET['conf'] . '.php'; +} else { + $conffile = 'conf/' . (!empty($_COOKIE['dolconf']) ? $_COOKIE['dolconf'] : 'conf') . '.php'; +} // Include configuration $result=@include_once $conffile; // Keep @ because with some error reporting this break the redirect From 1bde35f98e0ad8c2316085014a96b487a56b0985 Mon Sep 17 00:00:00 2001 From: abb Date: Sun, 13 Dec 2015 12:10:43 +0100 Subject: [PATCH 004/421] add change customer function in customer orders --- htdocs/commande/card.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 8748b283abe..2b9163886f4 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1149,7 +1149,16 @@ if (empty($reshook)) $action = 'edit_extras'; } - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + if ($action == 'set_thirdparty' && $user->rights->commande->creer) + { + $object->fetch($id); + $object->setValueFrom('fk_soc', $socid); + + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); + exit(); + } + + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; /* @@ -1812,8 +1821,19 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; // Third party - print '' . $langs->trans('Company') . ''; - print '' . $soc->getNomUrl(1) . ''; + print ''; + print ''; + print ''; + print ''; + print '
' . $langs->trans('Company') . ''; + if (! empty($conf->global->COMMANDE_CHANGE_THIRDPARTY) && $action != 'editthirdparty' && $object->brouillon && $user->rights->commande->creer) + print 'id . '">' . img_edit($langs->trans('SetLinkToThirdParty'), 1) . '
'; + print ''; + if ($action == 'editthirdparty') { + $form->form_thirdparty($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, 'socid','client>0'); + } else { + print '  ' . $soc->getNomUrl(1, 'compta'); + } print ''; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { From f7afbcff6894a28445bea07439d8b8a2aff02038 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 18 Jan 2016 19:45:27 +0100 Subject: [PATCH 005/421] NEW integration of multicurrency module (creation fields in database and admin) NEW add multicurrency_code on create, update and fetch company object NEW add multicurrency on propal FIX travis FIX back quote into sql file --- htdocs/admin/multicurrency.php | 289 +++++++ htdocs/comm/propal.php | 81 ++ htdocs/comm/propal/class/propal.class.php | 92 ++- htdocs/core/class/commonobject.class.php | 99 ++- htdocs/core/class/html.form.class.php | 105 +++ htdocs/core/lib/multicurrency.lib.php | 54 ++ htdocs/core/lib/price.lib.php | 11 +- .../core/modules/modMultiCurrency.class.php | 290 +++++++ htdocs/core/tpl/objectline_create.tpl.php | 12 + htdocs/core/tpl/objectline_view.tpl.php | 9 +- .../install/mysql/migration/3.9.0-4.0.0.sql | 99 +++ htdocs/install/mysql/tables/llx_commande.sql | 8 +- .../mysql/tables/llx_commande_fournisseur.sql | 8 +- .../tables/llx_commande_fournisseurdet.sql | 9 +- .../install/mysql/tables/llx_commandedet.sql | 9 +- htdocs/install/mysql/tables/llx_facture.sql | 9 +- .../mysql/tables/llx_facture_fourn.sql | 8 +- .../mysql/tables/llx_facture_fourn_det.sql | 9 +- .../install/mysql/tables/llx_facturedet.sql | 8 +- .../mysql/tables/llx_multicurrency.sql | 28 + .../mysql/tables/llx_multicurrency_rate.sql | 28 + .../mysql/tables/llx_paiement_facture.sql | 6 +- .../tables/llx_paiementfourn_facturefourn.sql | 6 +- .../mysql/tables/llx_product_price.sql | 6 +- htdocs/install/mysql/tables/llx_propal.sql | 8 +- htdocs/install/mysql/tables/llx_propaldet.sql | 8 +- htdocs/install/mysql/tables/llx_societe.sql | 5 +- htdocs/langs/en_US/main.lang | 4 +- .../class/multicurrency.class.php | 726 ++++++++++++++++++ htdocs/societe/class/societe.class.php | 35 +- htdocs/societe/soc.php | 37 + .../theme/eldy/img/object_multicurrency.png | Bin 0 -> 733 bytes 32 files changed, 2080 insertions(+), 26 deletions(-) create mode 100644 htdocs/admin/multicurrency.php create mode 100644 htdocs/core/lib/multicurrency.lib.php create mode 100644 htdocs/core/modules/modMultiCurrency.class.php create mode 100644 htdocs/install/mysql/tables/llx_multicurrency.sql create mode 100644 htdocs/install/mysql/tables/llx_multicurrency_rate.sql create mode 100644 htdocs/multicurrency/class/multicurrency.class.php create mode 100644 htdocs/theme/eldy/img/object_multicurrency.png diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php new file mode 100644 index 00000000000..b5485392816 --- /dev/null +++ b/htdocs/admin/multicurrency.php @@ -0,0 +1,289 @@ + + * Copyright (C) 2015 ATM Consulting + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file admin/multicurrency.php + * \ingroup quickpriceupdate + * \brief This file is an example module setup page + * Put some comments here + */ +// Dolibarr environment + +require '../main.inc.php'; + +// Libraries +dol_include_once('/core/lib/admin.lib.php'); +dol_include_once('/core/lib/multicurrency.lib.php'); +dol_include_once('/multicurrency/class/multicurrency.class.php'); + +// Translations +$langs->load("multicurrency"); + +// Access control +if (! $user->admin) { + accessforbidden(); +} + +// Parameters +$action = GETPOST('action', 'alpha'); + +/* + * Actions + */ +if (preg_match('/set_(.*)/',$action,$reg)) +{ + $code=$reg[1]; + if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} + +if (preg_match('/del_(.*)/',$action,$reg)) +{ + $code=$reg[1]; + if (dolibarr_del_const($db, $code, 0) > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} + +if ($action == 'add_currency') +{ + $code = GETPOST('code', 'alpha'); + $name = GETPOST('name', 'alpha'); + $rate = GETPOST('rate', 'alpha'); + + $currency = new MultiCurrency($db); + $currency->code = $code; + $currency->name = $name; + + if ($currency->create($user) > 0) + { + if ($currency->addRate($rate)) setEventMessages($langs->trans('SuccessAddRate'), array()); + else setEventMessages($langs->trans('ErrorAddRateFail'), array(), 'errors'); + } + else setEventMessages($langs->trans('ErrorAddCurrencyFail'), array()); +} +elseif ($action == 'update_currency') +{ + $submit = GETPOST('submit', 'alpha'); + + if ($submit == $langs->trans('Modify')) + { + $fk_multicurrency = GETPOST('fk_multicurrency', 'int'); + $rate = GETPOST('rate', 'float'); + $currency = new MultiCurrency($db); + + if ($currency->fetch($fk_multicurrency) > 0) + { + $currency->updateRate($rate); + } + } + elseif ($submit == $langs->trans('Delete')) + { + $fk_multicurrency = GETPOST('fk_multicurrency', 'int'); + $currency = new MultiCurrency($db); + + if ($currency->fetch($fk_multicurrency) > 0) + { + if ($currency->delete() > 0) setEventMessages($langs->trans('SuccessDeleteCurrency'), array()); + else setEventMessages($langs->trans('ErrorDeleteCurrencyFail'), array(), 'errors'); + } + } +} + +$TCurrency = array(); +$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE entity = '.$conf->entity; +$resql = $db->query($sql); +if ($resql) +{ + while ($obj = $db->fetch_object($resql)) + { + $currency = new MultiCurrency($db); + $currency->fetch($obj->rowid); + $TCurrency[] = $currency; + } +} + +/* + * View + */ +$page_name = "multicurrency"; +llxHeader('', $langs->trans($page_name)); + +// Subheader +$linkback = '' + . $langs->trans("BackToModuleList") . ''; +print_fiche_titre($langs->trans($page_name), $linkback); + +// Configuration header +$head = multicurrencyAdminPrepareHead(); +dol_fiche_head( + $head, + 'settings', + $langs->trans("Module500000Name"), + 0, + "multicurrency" +); + +// Setup page goes here +$form=new Form($db); + +$var=false; +print ''; +print ''; +print ''."\n"; +print ''; +print ''."\n"; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +print '
'.$langs->trans("Parameters").' '.$langs->trans("Value").'
'.$langs->transnoentitiesnoconv("multicurrency_useRateOnInvoiceDate").' '; +print '
'; +print ''; +print ''; +print $form->selectyesno("MULTICURRENCY_USE_RATE_ON_INVOICE_DATE",$conf->global->MULTICURRENCY_USE_RATE_ON_INVOICE_DATE,1); +print ''; +print '
'; +print '
'.$langs->transnoentitiesnoconv("multicurrency_useOriginTx").' '; +print '
'; +print ''; +print ''; +print $form->selectyesno("MULTICURRENCY_USE_ORIGIN_TX",$conf->global->MULTICURRENCY_USE_ORIGIN_TX,1); +print ''; +print '
'; +print '
'.$langs->transnoentitiesnoconv("multicurrency_buyPriceInCurrency").' '; +print '
'; +print ''; +print ''; +print $form->selectyesno("MULTICURRENCY_BUY_PRICE_IN_CURRENCY",$conf->global->MULTICURRENCY_BUY_PRICE_IN_CURRENCY,1); +print ''; +print '
'; +print '
'.$langs->transnoentitiesnoconv("multicurrency_modifyRateApplication").' '; +print '
'; +print ''; +print ''; +print $form->selectarray('MULTICURRENCY_MODIFY_RATE_APPLICATION', array('PU_DOLIBARR' => 'PU_DOLIBARR', 'PU_CURRENCY' => 'PU_CURRENCY')); +print ''; +print '
'; +print '
'.$langs->transnoentitiesnoconv("multicurrency_appId").' '; +print '
'; +print ''; +print ''; +print ' '; +print ''; +print '
'; +print '
'.$langs->transnoentitiesnoconv("multicurrency_currencyFromToRate").' '; +print '
'; +print ''; +print ''; +print ' '; // CURRENCY_BASE - CURRENCY_ENTITY - ID_ENTITY +print ''; +print '
'; +print '
'; + +print ''; + +print '
'; +print ''; + +print ''; +print ''."\n"; +print ''; +print ''."\n"; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +foreach ($TCurrency as &$currency) +{ + $var=!$var; + print ''; + print ''; + print ''; + print ''; +} + +print '
'.$langs->trans("Currencies").' '.$langs->trans("Rate").'
-  '; +print ' '; +print ''; +print '
'.$currency->code.' - '.$currency->name.' '; + print '
'; + print ''; + print ''; + print ''; + print ' '; + print ' '; + print ''; + print '
'; + print '
'; + +llxFooter(); + +$db->close(); \ No newline at end of file diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e039342dd38..d83beedc9c5 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -344,6 +344,12 @@ if (empty($reshook)) $object->origin = GETPOST('origin'); $object->origin_id = GETPOST('originid'); + + // Multicurrency + if (!empty($conf->multicurrency->enabled)) + { + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + } for($i = 1; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i ++) { @@ -1084,6 +1090,16 @@ if (empty($reshook)) $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); } + // Multicurrency Code + else if ($action == 'setmulticurrencycode' && $user->rights->propal->creer) { + $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); + } + + // Multicurrency rate + else if ($action == 'setmulticurrencyrate' && $user->rights->propal->creer) { + $result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int')); + } + // bank account else if ($action == 'setbankaccount' && $user->rights->propal->creer) { $result=$object->setBankAccount(GETPOST('fk_account', 'int')); @@ -1422,6 +1438,17 @@ if ($action == 'create') print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); print ""; + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + print ''; + print ''.fieldLabel('Currency','multicurrency_code').''; + print ''; + $currency_code = (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)); + print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print ''; + } + // Public note print ''; print '' . $langs->trans('NotePublic') . ''; @@ -1991,6 +2018,45 @@ if ($action == 'create') print ''; } + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + // Multicurrency code + print ''; + print ''; + print ''; + if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('Currency','multicurrency_code'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print ''; + if ($action == 'editmulticurrencycode') { + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + } else { + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + } + print ''; + + // Multicurrency rate + print ''; + print ''; + print ''; + if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('Rate','multicurrency_tx'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print ''; + if ($action == 'editmulticurrencyrate') { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + } + print ''; + } + + // Other attributes $cols = 5; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -2034,6 +2100,21 @@ if ($action == 'create') print '' . $langs->trans('AmountTTC') . ''; print '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . ''; print ''; + + // Multicurrency Amount HT + print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ''; + print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''; + + // Multicurrency Amount VAT + print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ''; + print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''; + + // Multicurrency Amount TTC + print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ''; + print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''; // Statut print '' . $langs->trans('Status') . '' . $object->getLibStatut(4) . ''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b530b011d81..d9ba1e7ef59 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php"; require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php'; +dol_include_once('/multicurrency/class/multicurrency.class.php'); /** * Class to manage proposals @@ -156,6 +157,14 @@ class Propal extends CommonObject var $specimen; + // Multicurrency + var $fk_multicurrency; + var $multicurrency_code; + var $multicurrency_tx; + var $multicurrency_total_ht; + var $multicurrency_total_tva; + var $multicurrency_total_ttc; + /** * Draft status */ @@ -441,7 +450,7 @@ class Propal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -449,6 +458,11 @@ class Propal extends CommonObject $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + // Rang to use $rangtouse = $rang; if ($rangtouse == -1) @@ -505,6 +519,14 @@ class Propal extends CommonObject $this->line->origin_id = $origin_id; $this->line->origin = $origin; + // Multicurrency + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx); + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; @@ -756,6 +778,14 @@ class Propal extends CommonObject if (empty($this->availability_id)) $this->availability_id=0; if (empty($this->demand_reason_id)) $this->demand_reason_id=0; + if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + if (empty($this->fk_multicurrency)) + { + $this->multicurrency_code = ''; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } + dol_syslog(get_class($this)."::create"); // Check parameters @@ -819,6 +849,9 @@ class Propal extends CommonObject $sql.= ", fk_incoterms"; $sql.= ", location_incoterms"; $sql.= ", entity"; + $sql.= ", fk_multicurrency"; + $sql.= ", multicurrency_code"; + $sql.= ", multicurrency_tx"; $sql.= ") "; $sql.= " VALUES ("; $sql.= $this->socid; @@ -848,6 +881,9 @@ class Propal extends CommonObject $sql.= ", ".(int) $this->fk_incoterms; $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; $sql.= ", ".$conf->entity; + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".(double) $this->multicurrency_tx; $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -1184,6 +1220,7 @@ class Propal extends CommonObject $sql.= ', p.fk_account'; $sql.= ", p.fk_shipping_method"; $sql.= ", p.fk_incoterms, p.location_incoterms"; + $sql.= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc"; $sql.= ", i.libelle as libelle_incoterms"; $sql.= ", c.label as statut_label"; $sql.= ", ca.code as availability_code, ca.label as availability"; @@ -1268,6 +1305,14 @@ class Propal extends CommonObject $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_tx = $obj->multicurrency_tx; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + if ($obj->fk_statut == self::STATUS_DRAFT) { $this->brouillon = 1; @@ -1292,6 +1337,7 @@ class Propal extends CommonObject $sql.= " d.fk_unit,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; $sql.= ' d.date_start, d.date_end'; + $sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc'; $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql.= " WHERE d.fk_propal = ".$this->id; @@ -1357,6 +1403,15 @@ class Propal extends CommonObject $line->date_start = $objp->date_start; $line->date_end = $objp->date_end; + + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $line->fetch_optionals($line->id,$extralabelsline); $this->lines[$i] = $line; @@ -2785,6 +2840,7 @@ class Propal extends CommonObject $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; $sql.= ' p.description as product_desc,'; $sql.= ' p.entity'; + $sql.= ' ,pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' WHERE pt.fk_propal = '.$this->id; @@ -2833,6 +2889,14 @@ class Propal extends CommonObject $this->lines[$i]->date_start = $this->db->jdate($obj->date_start); $this->lines[$i]->date_end = $this->db->jdate($obj->date_end); $this->lines[$i]->fk_unit = $obj->fk_unit; + + // Multicurrency + $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; + $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; + $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; + $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; $i++; } @@ -3003,6 +3067,14 @@ class PropaleLigne extends CommonObjectLine var $skip_update_total; // Skip update price total for special lines + // Multicurrency + var $fk_multicurrency; + var $multicurrency_code; + var $multicurrency_subprice; + var $multicurrency_total_ht; + var $multicurrency_total_tva; + var $multicurrency_total_ttc; + /** * Class line Contructor * @@ -3026,6 +3098,7 @@ class PropaleLigne extends CommonObjectLine $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.fk_unit,'; $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; + $sql.= ' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc,'; $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; $sql.= ' pd.date_start, pd.date_end, pd.product_type'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd'; @@ -3078,6 +3151,14 @@ class PropaleLigne extends CommonObjectLine $this->date_start = $this->db->jdate($objp->date_start); $this->date_end = $this->db->jdate($objp->date_end); + // Multicurrency + $this->fk_multicurrency = $objp->fk_multicurrency; + $this->multicurrency_code = $objp->multicurrency_code; + $this->multicurrency_subprice = $objp->multicurrency_subprice; + $this->multicurrency_total_ht = $objp->multicurrency_total_ht; + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $this->db->free($result); return 1; @@ -3148,7 +3229,8 @@ class PropaleLigne extends CommonObjectLine $sql.= ' info_bits, '; $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,'; $sql.= ' fk_unit,'; - $sql.= ' date_start, date_end)'; + $sql.= ' date_start, date_end'; + $sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc)'; $sql.= " VALUES (".$this->fk_propal.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -3177,6 +3259,12 @@ class PropaleLigne extends CommonObjectLine $sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit).','; $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").','; $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); + $sql.= ", ".$this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".$this->multicurrency_subprice; + $sql.= ", ".$this->multicurrency_total_ht; + $sql.= ", ".$this->multicurrency_total_tva; + $sql.= ", ".$this->multicurrency_total_ttc; $sql.= ')'; dol_syslog(get_class($this).'::insert', LOG_DEBUG); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6b19a8ebe44..3e04f98574d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1414,6 +1414,80 @@ abstract class CommonObject } } + /** + * Change the multicurrency code + * + * @param string $code multicurrency code + * @return int >0 if OK, <0 if KO + */ + function setMulticurrencyCode($code) + { + dol_syslog(get_class($this).'::setMulticurrencyCode('.$id.')'); + if ($this->statut >= 0 || $this->element == 'societe') + { + $fieldname = 'multicurrency_code'; + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = "'.$this->db->escape($code).'"'; + $sql .= ' WHERE rowid='.$this->id; + + if ($this->db->query($sql)) + { + $this->multicurrency_code = $code; + return 1; + } + else + { + dol_syslog(get_class($this).'::setMulticurrencyCode Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog(get_class($this).'::setMulticurrencyCode, status of the object is incompatible'); + $this->error='Status of the object is incompatible '.$this->statut; + return -2; + } + } + + /** + * Change the multicurrency rate + * + * @param double $rate multicurrency rate + * @return int >0 if OK, <0 if KO + */ + function setMulticurrencyRate($rate) + { + dol_syslog(get_class($this).'::setMulticurrencyRate('.$id.')'); + if ($this->statut >= 0 || $this->element == 'societe') + { + $fieldname = 'multicurrency_tx'; + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.$rate; + $sql .= ' WHERE rowid='.$this->id; + + if ($this->db->query($sql)) + { + $this->multicurrency_tx = $rate; + return 1; + } + else + { + dol_syslog(get_class($this).'::setMulticurrencyRate Erreur '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } + else + { + dol_syslog(get_class($this).'::setMulticurrencyRate, status of the object is incompatible'); + $this->error='Status of the object is incompatible '.$this->statut; + return -2; + } + } + /** * Change the payments terms * @@ -2076,6 +2150,7 @@ abstract class CommonObject $sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,'; $sql.= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type'; if ($this->table_element_line == 'facturedet') $sql.= ', situation_percent'; + $sql.= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; if ($exclspec) @@ -2098,6 +2173,9 @@ abstract class CommonObject $total_ht_by_vats = array(); $total_tva_by_vats = array(); $total_ttc_by_vats = array(); + $this->multicurrency_total_ht = 0; + $this->multicurrency_total_tva = 0; + $this->multicurrency_total_ttc = 0; $num = $this->db->num_rows($resql); $i = 0; @@ -2106,11 +2184,11 @@ abstract class CommonObject $obj = $this->db->fetch_object($resql); // Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none' - + $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' { $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); - $tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100)); + $tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx); $diff=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); if ($diff) { @@ -2129,6 +2207,7 @@ abstract class CommonObject $this->total_localtax1 += $obj->total_localtax1; $this->total_localtax2 += $obj->total_localtax2; $this->total_ttc += $obj->total_ttc; + if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0; if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0; if (! isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate]=0; @@ -2174,7 +2253,12 @@ abstract class CommonObject $this->total_ttc -= $sit->total_ttc; } } - + + // Multicurrency + $this->multicurrency_total_ht += $this->total_ht * $multicurrency_tx; + $this->multicurrency_total_tva += $this->total_tva * $multicurrency_tx; + $this->multicurrency_total_ttc += $this->total_ttc * $multicurrency_tx; + $this->db->free($resql); // Now update global field total_ht, total_ttc and tva @@ -2198,6 +2282,9 @@ abstract class CommonObject $sql .= " ".$fieldlocaltax1."='".price2num($this->total_localtax1)."',"; $sql .= " ".$fieldlocaltax2."='".price2num($this->total_localtax2)."',"; $sql .= " ".$fieldttc."='".price2num($this->total_ttc)."'"; + $sql .= ", multicurrency_total_ht='".price2num($this->multicurrency_total_ht, 'MT', 1)."'"; + $sql .= ", multicurrency_total_tva='".price2num($this->multicurrency_total_tva, 'MT', 1)."'"; + $sql .= ", multicurrency_total_ttc='".price2num($this->multicurrency_total_ttc, 'MT', 1)."'"; $sql .= ' WHERE rowid = '.$this->id; //print "xx".$sql; @@ -3062,6 +3149,9 @@ abstract class CommonObject // Price HT print ''.$langs->trans('PriceUHT').''; + // Multicurrency + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency').''; + if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; // Qty @@ -3095,6 +3185,9 @@ abstract class CommonObject // Total HT print ''.$langs->trans('TotalHTShort').''; + // Multicurrency + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency').''; + print ''; // No width to allow autodim print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e081d902b16..c9f9bbe9d03 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3722,6 +3722,65 @@ class Form } } } + + /** + * Show form with multicurrency code + * + * @param string $page Page + * @param string $selected code pre-selectionne + * @param string $htmlname Name of select html field + * @return void + */ + function form_multicurrency_code($page, $selected='', $htmlname='multicurrency_code') + { + global $langs; + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $this->selectMultiCurrency($selected,$htmlname); + print '
'; + } + else + { + dol_include_once('/core/lib/company.lib.php'); + print !empty($selected) ? currency_name($selected,1) : ' '; + } + } + + /** + * Show form with multicurrency rate + * + * @param string $page Page + * @param double $rate Current rate + * @param string $htmlname Name of select html field + * @return void + */ + function form_multicurrency_rate($page, $rate='', $htmlname='multicurrency_tx') + { + global $langs; + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print ''; + print '
'; + } + else + { + print !empty($rate) ? $rate : 1; + } + } /** @@ -3925,7 +3984,53 @@ class Form return $out; } + /** + * Return array of currencies in user language + * + * @param string $selected preselected currency code + * @param string $htmlname name of HTML select list + * @param integer $useempty 1=Add empty line + * @return string + */ + function selectMultiCurrency($selected='',$htmlname='multicurrency_code', $useempty=0) + { + global $db,$conf,$langs,$user; + $langs->loadCacheCurrencies(''); + + $TCurrency = array(); + + $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; + $resql = $db->query($sql); + + if ($resql) + { + while ($obj = $db->fetch_object($resql)) $TCurrency[$obj->code] = $obj->code; + } + + $out=''; + $out.= ''; + return $out; + } + /** * Load into the cache vat rates of a country * diff --git a/htdocs/core/lib/multicurrency.lib.php b/htdocs/core/lib/multicurrency.lib.php new file mode 100644 index 00000000000..c3844309dd5 --- /dev/null +++ b/htdocs/core/lib/multicurrency.lib.php @@ -0,0 +1,54 @@ + + * Copyright (C) 2015 ATM Consulting + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file lib/multicurrency.lib.php + * \ingroup multicurency + * \brief This file is an example module library + * Put some comments here + */ + +/** + * Prepare array with list of tabs + * + * @return array Array of tabs to show + */ +function multicurrencyAdminPrepareHead() +{ + global $langs, $conf; + + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath("/admin/multicurrency.php", 1); + $head[$h][1] = $langs->trans("Parameters"); + $head[$h][2] = 'settings'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + //$this->tabs = array( + // 'entity:+tabname:Title:@quickpriceupdate:/quickpriceupdate/mypage.php?id=__ID__' + //); // to add new tab + //$this->tabs = array( + // 'entity:-tabname:Title:@quickpriceupdate:/quickpriceupdate/mypage.php?id=__ID__' + //); // to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'multicurrency'); + + return $head; +} diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 528abfcd6a5..d6ab9f51fab 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -49,6 +49,7 @@ * @param Societe $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc. * @param array $localtaxes_array Array with localtaxes info (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). * @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default) + * @param double $multicurrency_tx Currency rate (1 by default) * @return result[ 0=total_ht, * 1=total_vat, (main vat only) * 2=total_ttc, (total_ht + main vat + local taxes) @@ -65,8 +66,11 @@ * 13=!! should not be used * 14=total_tax1 for total_ht_without_discount, * 15=total_tax2 for total_ht_without_discount] + * 16=multicurrency_total_ht + * 17=multicurrency_total_tva + * 18=multicurrency_total_ttc */ -function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100) +function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1) { global $conf,$mysoc,$db; @@ -242,6 +246,11 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result[4] = price2num($result[5] - ($result3bis + $localtaxes[2]), 'MU'); } + // Multicurrency + $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); + $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); + $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); + // if there's some localtax without vat, we calculate localtaxes (we will add them at end) //If input unit price is 'TTC', we need to have the totals without main VAT for a correct calculation diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php new file mode 100644 index 00000000000..6642e33719f --- /dev/null +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -0,0 +1,290 @@ + + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2016 Regis Houssin + * Copyright (C) 2016 Pierre-Henry Favre + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \defgroup multicurrency Module MultiCurrency + * \brief Handle multiple currencies on company/propal/orders ... + * \file htdocs/core/modules/modMultiCurrency.class.php + * \ingroup multicurrency + * \brief Description and activation file for module MultiCurrency + */ +include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; + + +/** + * Description and activation class for module MyModule + */ +class modMultiCurrency extends DolibarrModules +{ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs,$conf; + + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 500000; // TODO Go on page http://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'multicurrency'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "financial"; + // Module position in the family + $this->module_position = 500; + // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + $this->familyinfo = array('financial' => array('position'=>'009', 'label'=>$langs->trans("ModuleFamilyFinancial"))); + + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i','',get_class($this)); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Description of module MyModule"; + + // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version + $this->version = 'development'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) + $this->special = 0; + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto='multicurrency'; + + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) + // for default path (eg: /multicurrency/core/xxxxx) (0=disable, 1=enable) + // for specific path of parts (eg: /multicurrency/core/modules/barcode) + // for specific css file (eg: /multicurrency/css/multicurrency.css.php) + //$this->module_parts = array( + // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) + // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) + // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) + // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) + // 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) + // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) + // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) + // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) + // 'css' => array('/multicurrency/css/multicurrency.css.php'), // Set this to relative path of css file if module has its own css file + // 'js' => array('/multicurrency/js/multicurrency.js'), // Set this to relative path of js file if module must load a js on all pages + // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module + // 'dir' => array('output' => 'othermodulename'), // To force the default directories names + // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@multicurrency')) // Set here all workflow context managed by module + // ); + $this->module_parts = array(); + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/multicurrency/temp"); + $this->dirs = array(); + + // Config pages. Put here list of php page, stored into multicurrency/admin directory, to use to setup module. + $this->config_page_url = array("multicurrency.php"); + + // Dependencies + $this->hidden = false; // A condition to hide module + $this->depends = array(); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->phpmin = array(5,0); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module + $this->langfiles = array("multicurrency"); + + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); + $this->const = array(); + + // Array to add new pages in new tabs + // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@multicurrency:$user->rights->multicurrency->read:/multicurrency/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 + // 'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@multicurrency:$user->rights->othermodule->read:/multicurrency/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // 'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname + // where objecttype can be + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view + $this->tabs = array(); + + // Dictionaries + if (! isset($conf->multicurrency->enabled)) + { + $conf->multicurrency=new stdClass(); + $conf->multicurrency->enabled=0; + } + $this->dictionaries=array(); + /* Example: + if (! isset($conf->multicurrency->enabled)) $conf->multicurrency->enabled=0; // This is to avoid warnings + $this->dictionaries=array( + 'langs'=>'mylangfile@multicurrency', + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor + 'tablib'=>array("Table1","Table2","Table3"), // Label of tables + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order + 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) + 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') + 'tabcond'=>array($conf->multicurrency->enabled,$conf->multicurrency->enabled,$conf->multicurrency->enabled) // Condition to show each dictionary + ); + */ + + // Boxes + // Add here list of php file(s) stored in core/boxes that contains class to show a box. + $this->boxes = array(); // List of boxes + // Example: + //$this->boxes=array( + // 0=>array('file'=>'myboxa.php@multicurrency','note'=>'','enabledbydefaulton'=>'Home'), + // 1=>array('file'=>'myboxb.php@multicurrency','note'=>''), + // 2=>array('file'=>'myboxc.php@multicurrency','note'=>'') + //); + + // Cronjobs + $this->cronjobs = array(); // List of cron jobs entries to add + // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600) + // ); + + // Permissions + $this->rights = array(); // Permission array used by this module + $r=0; + + // Add here list of permission defined by an id, a label, a boolean and two constant strings. + // Example: + // $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + // $this->rights[$r][1] = 'Permision label'; // Permission label + // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + // $r++; + + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; + + // Add here entries to declare new menus + // + // Example to declare a new Top Menu entry and its Left menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + // 'type'=>'top', // This is a Top menu entry + // 'titre'=>'MyModule top menu', + // 'mainmenu'=>'multicurrency', + // 'leftmenu'=>'multicurrency', + // 'url'=>'/multicurrency/pagetop.php', + // 'langs'=>'mylangfile@multicurrency', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'enabled'=>'$conf->multicurrency->enabled', // Define condition to show or hide menu entry. Use '$conf->multicurrency->enabled' if entry must be visible if module is enabled. + // 'perms'=>'1', // Use 'perms'=>'$user->rights->multicurrency->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + // + // Example to declare a Left Menu entry into an existing Top menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=xxx', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + // 'type'=>'left', // This is a Left menu entry + // 'titre'=>'MyModule left menu', + // 'mainmenu'=>'xxx', + // 'leftmenu'=>'multicurrency', + // 'url'=>'/multicurrency/pagelevel2.php', + // 'langs'=>'mylangfile@multicurrency', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'position'=>100, + // 'enabled'=>'$conf->multicurrency->enabled', // Define condition to show or hide menu entry. Use '$conf->multicurrency->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + // 'perms'=>'1', // Use 'perms'=>'$user->rights->multicurrency->level1->level2' if you want your menu with a permission rules + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + + + // Exports + $r=1; + + // Example: + // $this->export_code[$r]=$this->rights_class.'_'.$r; + // $this->export_label[$r]='MyModule'; // Translation key (used only if key ExportDataset_xxx_z not found) + // $this->export_enabled[$r]='1'; // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled. + // $this->export_icon[$r]='generic:MyModule'; + // $this->export_permission[$r]=array(array("multicurrency","level1","level2")); + // $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'); + // $this->export_TypeFields_array[$r]=array('t.date'=>'Date', 't.qte'=>'Numeric', 't.poids'=>'Numeric', 't.fad'=>'Numeric', 't.paq'=>'Numeric', 't.stockage'=>'Numeric', 't.fadparliv'=>'Numeric', 't.livau100'=>'Numeric', 't.forfait'=>'Numeric', 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.subprice'=>"Numeric",'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date",'fd.date_end'=>"Date",'fd.special_code'=>'Numeric','fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','p.accountancy_code_sell'=>'Text'); + // $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'); + // $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them + // $this->export_sql_start[$r]='SELECT DISTINCT '; + // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; + // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; + // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; + // $this->export_sql_order[$r] .=' ORDER BY s.nom'; + // $r++; + } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options='') + { + $sql = array(); + + //$this->_load_tables('/multicurrency/sql/'); + + return $this->_init($sql, $options); + } + + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); + + return $this->_remove($sql, $options); + } + +} + diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index e17648a7643..ba1f037370e 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -61,6 +61,9 @@ if (in_array($object->element,array('propal', 'supplier_proposal','facture','inv trans('VAT'); ?> trans('PriceUHT'); ?> + multicurrency->enabled)) { $colspan++;?> + trans('PriceUHTCurrency'); ?> + trans('PriceUTTC'); ?> @@ -227,6 +230,13 @@ else { "> + + multicurrency->enabled)) { $colspan++;?> + + "> + + + "> @@ -354,6 +364,8 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da } } + if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (! empty($usemargins)) { $colspan++; // For the buying price diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index f71b2b484d1..3abc0fb14c0 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -130,7 +130,11 @@ if (empty($usemargins)) $usemargins=0; tva_tx,'%',$line->info_bits); ?> subprice); ?> - + + multicurrency->enabled)) { ?> + multicurrency_subprice); ?> + + pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?> @@ -190,6 +194,9 @@ if (empty($usemargins)) $usemargins=0; trans('Option'); ?> total_ht); ?> + multicurrency->enabled)) { ?> + multicurrency_total_ht); ?> + statut == 0 && ($object_rights->creer)) { ?> 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 c6e8606c28f..7e9260c595e 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 @@ -37,3 +37,102 @@ ALTER TABLE llx_cronjob MODIFY COLUMN unitfrequency varchar(255) NOT NULL DEFAUL ALTER TABLE llx_facture ADD INDEX idx_facture_fk_statut (fk_statut); + +CREATE TABLE IF NOT EXISTS `llx_multicurrency` +( + `rowid` integer AUTO_INCREMENT PRIMARY KEY, + `date_create` datetime DEFAULT NULL, + `code` varchar(255) DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + `entity` integer DEFAULT NULL, + `fk_user` integer DEFAULT NULL, + KEY `code` (`code`) +) ENGINE=innodb; + +CREATE TABLE IF NOT EXISTS `llx_multicurrency_rate` +( + `rowid` integer AUTO_INCREMENT PRIMARY KEY, + `date_sync` datetime DEFAULT NULL, + `rate` double NOT NULL DEFAULT '0', + `fk_multicurrency` integer NOT NULL DEFAULT '0', + `entity` integer NOT NULL DEFAULT '0', + KEY `fk_multicurrency` (`fk_multicurrency`), + KEY `entity` (`entity`) +) ENGINE=innodb; + +ALTER TABLE llx_societe ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_societe ADD COLUMN multicurrency_code varchar(255); + +ALTER TABLE llx_product_price ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_product_price ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_product_price ADD COLUMN multicurrency_price double(24,8) DEFAULT 0; + +ALTER TABLE llx_commande ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_commande ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_commande ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1; +ALTER TABLE llx_commande ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_commande ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; +ALTER TABLE llx_commande ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; + +ALTER TABLE llx_commandedet ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_commandedet ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_commandedet ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0; +ALTER TABLE llx_commandedet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_commandedet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; +ALTER TABLE llx_commandedet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; + +ALTER TABLE llx_commande_fournisseur ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_commande_fournisseur ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_commande_fournisseur ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1; +ALTER TABLE llx_commande_fournisseur ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_commande_fournisseur ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; +ALTER TABLE llx_commande_fournisseur ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; + +ALTER TABLE llx_commande_fournisseurdet ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_commande_fournisseurdet ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_commande_fournisseurdet ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0; +ALTER TABLE llx_commande_fournisseurdet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_commande_fournisseurdet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; +ALTER TABLE llx_commande_fournisseurdet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; + +ALTER TABLE llx_facture_fourn ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_facture_fourn ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_facture_fourn ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1; +ALTER TABLE llx_facture_fourn ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_facture_fourn ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; +ALTER TABLE llx_facture_fourn ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; + +ALTER TABLE llx_facture_fourn_det ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_facture_fourn_det ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_facture_fourn_det ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0; +ALTER TABLE llx_facture_fourn_det ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_facture_fourn_det ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; +ALTER TABLE llx_facture_fourn_det ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; + +ALTER TABLE llx_facture ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_facture ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_facture ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1; +ALTER TABLE llx_facture ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_facture ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; +ALTER TABLE llx_facture ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; + +ALTER TABLE llx_facturedet ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_facturedet ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_facturedet ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0; +ALTER TABLE llx_facturedet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_facturedet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; +ALTER TABLE llx_facturedet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; + +ALTER TABLE llx_propal ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_propal ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_propal ADD COLUMN multicurrency_tx double(24,8) DEFAULT 1; +ALTER TABLE llx_propal ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_propal ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; +ALTER TABLE llx_propal ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; + +ALTER TABLE llx_propaldet ADD COLUMN fk_multicurrency integer; +ALTER TABLE llx_propaldet ADD COLUMN multicurrency_code varchar(255); +ALTER TABLE llx_propaldet ADD COLUMN multicurrency_subprice double(24,8) DEFAULT 0; +ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_ht double(24,8) DEFAULT 0; +ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_tva double(24,8) DEFAULT 0; +ALTER TABLE llx_propaldet ADD COLUMN multicurrency_total_ttc double(24,8) DEFAULT 0; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 553b2facad7..98740c232ac 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -70,6 +70,12 @@ create table llx_commande fk_incoterms integer, -- for incoterms location_incoterms varchar(255), -- for incoterms import_key varchar(14), - extraparams varchar(255) -- for stock other parameters with json format + extraparams varchar(255), -- for stock other parameters with json format + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_tx double(24,8) DEFAULT 1, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql index 18744a8ca2f..6d291dcfa00 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql @@ -66,6 +66,12 @@ create table llx_commande_fournisseur fk_incoterms integer, -- for incoterms location_incoterms varchar(255), -- for incoterms import_key varchar(14), - extraparams varchar(255) -- for stock other parameters with json format + extraparams varchar(255), -- for stock other parameters with json format + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_tx double(24,8) DEFAULT 1, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseurdet.sql b/htdocs/install/mysql/tables/llx_commande_fournisseurdet.sql index a3dbd87d359..f7b10c8e35e 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseurdet.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseurdet.sql @@ -49,5 +49,12 @@ create table llx_commande_fournisseurdet special_code integer DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, import_key varchar(14), - fk_unit integer DEFAULT NULL + fk_unit integer DEFAULT NULL, + + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_subprice double(24,8) DEFAULT 0, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_commandedet.sql b/htdocs/install/mysql/tables/llx_commandedet.sql index b01c270cc3e..9608c2ae44b 100644 --- a/htdocs/install/mysql/tables/llx_commandedet.sql +++ b/htdocs/install/mysql/tables/llx_commandedet.sql @@ -55,7 +55,14 @@ create table llx_commandedet special_code integer DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, fk_unit integer DEFAULT NULL, -- lien vers table des unités - import_key varchar(14) + import_key varchar(14), + + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_subprice double(24,8) DEFAULT 0, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; -- diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index e6da2bda214..b503401cd37 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -84,5 +84,12 @@ create table llx_facture situation_final smallint, -- is the situation final ? import_key varchar(14), - extraparams varchar(255) -- for other parameters with json format + extraparams varchar(255), -- for other parameters with json format + + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_tx double(24,8) DEFAULT 1, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_facture_fourn.sql b/htdocs/install/mysql/tables/llx_facture_fourn.sql index 1e7fa12d565..2517f17ad96 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn.sql @@ -70,6 +70,12 @@ create table llx_facture_fourn location_incoterms varchar(255), -- for incoterms model_pdf varchar(255), import_key varchar(14), - extraparams varchar(255) -- for stock other parameters with json format + extraparams varchar(255), -- for stock other parameters with json format + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_tx double(24,8) DEFAULT 1, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_facture_fourn_det.sql b/htdocs/install/mysql/tables/llx_facture_fourn_det.sql index ad066752ea0..feff72e39b9 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn_det.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn_det.sql @@ -49,5 +49,12 @@ create table llx_facture_fourn_det special_code integer DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, import_key varchar(14), - fk_unit integer DEFAULT NULL + fk_unit integer DEFAULT NULL, + + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_subprice double(24,8) DEFAULT 0, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index 63cd9ab3bc1..81074f299e0 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -61,8 +61,14 @@ create table llx_facturedet situation_percent real, -- % progression of lines invoicing fk_prev_id integer, -- id of the line in the previous situation, - fk_unit integer DEFAULT NULL -- id of the unit code¡ + fk_unit integer DEFAULT NULL, -- id of the unit code¡ + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_subprice double(24,8) DEFAULT 0, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; -- diff --git a/htdocs/install/mysql/tables/llx_multicurrency.sql b/htdocs/install/mysql/tables/llx_multicurrency.sql new file mode 100644 index 00000000000..2f01236a3b9 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_multicurrency.sql @@ -0,0 +1,28 @@ +-- ======================================================================== +-- Copyright (C) 2016 Pierre-Henry Favre +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +CREATE TABLE llx_multicurrency +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + date_create datetime DEFAULT NULL, + code varchar(255) DEFAULT NULL, + name varchar(255) DEFAULT NULL, + entity integer DEFAULT NULL, + fk_user integer DEFAULT NULL, + KEY code (code) +) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_multicurrency_rate.sql b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql new file mode 100644 index 00000000000..a403071930c --- /dev/null +++ b/htdocs/install/mysql/tables/llx_multicurrency_rate.sql @@ -0,0 +1,28 @@ +-- ======================================================================== +-- Copyright (C) 2016 Pierre-Henry Favre +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +CREATE TABLE llx_multicurrency_rate +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + date_sync datetime DEFAULT NULL, + rate double NOT NULL DEFAULT '0', + fk_multicurrency integer NOT NULL DEFAULT '0', + entity integer NOT NULL DEFAULT '0', + KEY fk_multicurrency (fk_multicurrency), + KEY entity (entity) +) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_paiement_facture.sql b/htdocs/install/mysql/tables/llx_paiement_facture.sql index 2dcf95b0dfc..9526ca3aa9d 100644 --- a/htdocs/install/mysql/tables/llx_paiement_facture.sql +++ b/htdocs/install/mysql/tables/llx_paiement_facture.sql @@ -21,5 +21,9 @@ create table llx_paiement_facture rowid integer AUTO_INCREMENT PRIMARY KEY, fk_paiement integer, fk_facture integer, - amount double(24,8) DEFAULT 0 + amount double(24,8) DEFAULT 0, + + multicurrency_code varchar(255), + multicurrency_tx double(24,8) DEFAULT 1, + multicurrency_amount double(24,8) DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_paiementfourn_facturefourn.sql b/htdocs/install/mysql/tables/llx_paiementfourn_facturefourn.sql index 58d51867d96..a9e8da8a530 100644 --- a/htdocs/install/mysql/tables/llx_paiementfourn_facturefourn.sql +++ b/htdocs/install/mysql/tables/llx_paiementfourn_facturefourn.sql @@ -23,5 +23,9 @@ create table llx_paiementfourn_facturefourn rowid integer AUTO_INCREMENT PRIMARY KEY, fk_paiementfourn INTEGER DEFAULT NULL, fk_facturefourn INTEGER DEFAULT NULL, - amount double(24,8) DEFAULT 0 + amount double(24,8) DEFAULT 0, + + multicurrency_code varchar(255), + multicurrency_tx double(24,8) DEFAULT 1, + multicurrency_amount double(24,8) DEFAULT 0 )ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql index 1341c49dcaa..b101b8b0250 100755 --- a/htdocs/install/mysql/tables/llx_product_price.sql +++ b/htdocs/install/mysql/tables/llx_product_price.sql @@ -39,6 +39,10 @@ create table llx_product_price tosell tinyint DEFAULT 1, price_by_qty integer NOT NULL DEFAULT 0, fk_price_expression integer, -- Link to the rule for dynamic price calculation - import_key varchar(14) + import_key varchar(14), + + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_price double(24,8) DEFAULT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index 8090b1fcb4d..2566769e7be 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -69,6 +69,12 @@ create table llx_propal location_incoterms varchar(255), -- for incoterms import_key varchar(14), extraparams varchar(255), -- for stock other parameters with json format - fk_delivery_address integer -- delivery address (deprecated) + fk_delivery_address integer, -- delivery address (deprecated) + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_tx double(24,8) DEFAULT 1, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_propaldet.sql b/htdocs/install/mysql/tables/llx_propaldet.sql index 299767ae2ed..3f372894182 100644 --- a/htdocs/install/mysql/tables/llx_propaldet.sql +++ b/htdocs/install/mysql/tables/llx_propaldet.sql @@ -53,8 +53,14 @@ create table llx_propaldet special_code integer DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, -- ordre affichage sur la propal - fk_unit integer DEFAULT NULL -- lien vers table des unités + fk_unit integer DEFAULT NULL, -- lien vers table des unités + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_subprice double(24,8) DEFAULT 0, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; -- diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 0244b9ea757..82e3b420e29 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -99,5 +99,8 @@ create table llx_societe canvas varchar(32), -- type of canvas if used (null by default) import_key varchar(14), -- import key webservices_url varchar(255), -- supplier webservice url - webservices_key varchar(128) -- supplier webservice key + webservices_key varchar(128), -- supplier webservice key + + fk_multicurrency integer, + multicurrency_code varchar(255) )ENGINE=innodb; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 7a23657123f..90e84d9a271 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -310,7 +310,8 @@ UnitPrice=Unit price UnitPriceHT=Unit price (net) UnitPriceTTC=Unit price PriceU=U.P. -PriceUHT=U.P. (net) +PriceUHT=U.P. (net in currency) +PriceUHTCurrency=U.P (currency) SupplierProposalUHT=U.P. net Requested PriceUTTC=U.P. (inc. tax) Amount=Amount @@ -335,6 +336,7 @@ Percentage=Percentage Total=Total SubTotal=Subtotal TotalHTShort=Total (net) +TotalHTShortCurrency=Total (net in currency) TotalTTCShort=Total (inc. tax) TotalHT=Total (net of tax) TotalHTforthispage=Total (net of tax) for this page diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php new file mode 100644 index 00000000000..2000d27d3d4 --- /dev/null +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -0,0 +1,726 @@ + + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Pierre-Henry Favre + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file dev/skeletons/skeleton_class.class.php + * \ingroup mymodule othermodule1 othermodule2 + * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) + * Put some comments here + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php"; + +/** + * Class Currency + * + * Put here description of your class + * @see CommonObject + */ +class MultiCurrency extends CommonObject +{ + /** + * @var string Id to identify managed objects + */ + public $element = 'multicurrency'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'multicurrency'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element_line="multicurrency_rate"; + + /** + * @var CurrencyRate[] rates + */ + public $rates = array(); + + /** + * @var mixed Sample property 1 + */ + public $id; + /** + * @var mixed Sample property 1 + */ + public $code; + /** + * @var mixed Sample property 2 + */ + public $name; + /** + * @var mixed Sample property 2 + */ + public $entity; + /** + * @var mixed Sample property 2 + */ + public $date_create; + /** + * @var mixed Sample property 2 + */ + public $fk_user; + /** + * @var mixed Sample property 2 + */ + public $rate; + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = &$db; + + return 1; + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $trigger true=launch triggers after, false=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $trigger = true) + { + global $conf; + + dol_syslog('Currency::create', LOG_DEBUG); + + $error = 0; + + if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity; + $now=date('Y-m-d H:i:s'); + + // Insert request + $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; + $sql .= ' code,'; + $sql .= ' name,'; + $sql .= ' entity,'; + $sql .= ' date_create,'; + $sql .= ' fk_user'; + $sql .= ') VALUES ('; + $sql .= ' \'' . $this->db->escape($this->code) . '\','; + $sql .= ' \'' . $this->db->escape($this->name) . '\','; + $sql .= ' \'' . $this->entity . '\','; + $sql .= ' \'' . $now . '\','; + $sql .= ' \'' . $user->id . '\''; + $sql .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog('Currency::create ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->date_create = $now; + $this->fk_user = $user->id; + + if ($trigger) { + $result=$this->call_trigger('CURRENCY_CREATE', $user); + if ($result < 0) $error++; + } + } + + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return $this->id; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $code code + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $code = null) + { + dol_syslog('Currency::fetch', LOG_DEBUG); + + $sql = 'SELECT'; + $sql .= ' c.rowid, c.name, c.code, c.entity, c.date_create, c.fk_user'; + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' AS c'; + if (!empty($code)) $sql .= ' WHERE c.code = "'.$this->db->escape($code).'"'; + else $sql .= ' WHERE c.rowid = ' . $id; + + $resql = $this->db->query($sql); + + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->name = $obj->name; + $this->code = $obj->code; + $this->entity = $obj->entity; + $this->date_create = $obj->date_create; + $this->fk_user = $obj->fk_user; + + $this->fetchAllCurrencyRate(); + $this->getRate(); + } + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog('Currency::fetch ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Load all rates in object from the database + * + * @return int <0 if KO, >=0 if OK + */ + public function fetchAllCurrencyRate() + { + dol_syslog('Currency::fetchAllCurrencyRate', LOG_DEBUG); + + $sql = 'SELECT cr.rowid'; + $sql.= ' FROM ' . MAIN_DB_PREFIX . $this->table_element_line. ' as cr'; + $sql.= ' WHERE cr.fk_multicurrency = '.$this->id; + $sql.= ' ORDER BY cr.date_sync DESC'; + + $this->rates = array(); + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) { + $rate = new CurrencyRate($this->db); + $rate->fetch($obj->rowid); + + $this->rates[] = $rate; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog('Currency::fetchAllCurrencyRate ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $trigger true=launch triggers after, false=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $trigger = true) + { + $error = 0; + + dol_syslog('Currency::update', LOG_DEBUG); + + // Clean parameters + $this->name = trim($this->name); + $this->code = trim($this->code); + + // Check parameters + if (empty($this->code)) { + $error++; + dol_syslog('Currency::update $this->code can not be empty', LOG_ERR); + + return -1; + } + + // Update request + $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + $sql .= ' name="'.$this->db->escape($this->name).'"'; + $sql .= ' code="'.$this->db->escape($this->code).'"'; + $sql .= ' WHERE rowid=' . $this->id; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog('Currency::update ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error && $trigger) { + $result=$this->call_trigger('CURRENCY_MODIFY',$user); + if ($result < 0) $error++; + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Delete object in database + * + * @param bool $trigger true=launch triggers after, false=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function delete($trigger = true) + { + global $user; + + dol_syslog('Currency::delete', LOG_DEBUG); + + $error = 0; + + $this->db->begin(); + + if ($trigger) { + $result=$this->call_trigger('CURRENCY_DELETE',$user); + if ($result < 0) $error++; + } + + if (!$error) { + // Delete all rates before + if (!$this->deleteRates()) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog('Currency::delete ' . join(',', $this->errors), LOG_ERR); + } + + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; + $sql .= ' WHERE rowid=' . $this->id; + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog('Currency::delete ' . join(',', $this->errors), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Delete rates in database + * + * @return bool false if KO, true if OK + */ + public function deleteRates() + { + foreach ($this->rates as &$rate) + { + if ($rate->delete() <= 0) + { + return false; + } + } + + return true; + } + + /** + * Delete rate in database + * + * @param double $rate rate value + * + * @return bool false if KO, true if OK + */ + public function addRate($rate) + { + $currencyRate = new CurrencyRate($this->db); + $currencyRate->rate = $rate; + + if ($currencyRate->create($this->id) > 0) + { + $this->rate = $currencyRate; + return 1; + } + else + { + $this->rate = null; + return -1; + } + } + + /** + * Update rate in database + * + * @param double $rate rate value + * + * @return int <0 if KO, >0 if OK + */ + public function updateRate($rate) + { + if (is_object($this->rate)) + { + $this->rate->rate = $rate; + return $this->rate->update(); + } + else + { + return $this->addRate($rate); + } + } + + /** + * Fetch CurrencyRate object in $this->rate + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function getRate() + { + $sql = 'SELECT cr.rowid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr'; + $sql.= ' WHERE cr.fk_multicurrency = '.$this->id; + $sql.= ' AND cr.date_sync >= ALL (SELECT cr2.date_sync FROM '.MAIN_DB_PREFIX.$this->table_element_line.' AS cr2 WHERE cr.rowid = cr2.rowid)'; + + $resql = $this->db->query($sql); + if ($resql && ($obj = $this->db->fetch_object($resql))) { + $this->rate = new CurrencyRate($this->db); + return $this->rate->fetch($obj->rowid); + } + + } + + /** + * Get id of currency from code + * + * @param DoliDB $db object db + * @param string $code code value search + * + * @return 0 if not found, >0 if OK + */ + public static function getIdFromCode(&$db, $code) + { + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE code = "'.$db->escape($code).'"'; + $resql = $db->query($sql); + if ($resql && $obj = $db->fetch_object($resql)) return $obj->rowid; + else return 0; + } + + /** + * Get id and rate of currency from code + * + * @param DoliDB $db object db + * @param string $code code value search + * + * @return array [0] => id currency + * [1] => rate + */ + public static function getIdAndTxFromCode(&$db, $code) + { + $sql = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)'; + $sql.= ' WHERE m.code = "'.$db->escape($code).'" AND mc.date_sync >= ALL (SELECT date_sync FROM '.MAIN_DB_PREFIX.'multicurrency_rate)'; + $resql = $db->query($sql); + if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate); + else return array(0, 1); + } +} + +/** + * Class CurrencyRate + */ +class CurrencyRate extends CommonObjectLine +{ + /** + * @var string Id to identify managed objects + */ + public $element = 'multicurrency_rate'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'multicurrency_rate'; + /** + * @var int ID + */ + public $id; + /** + * @var double Rate + */ + public $rate; + /** + * @var date Date synchronisation + */ + public $date_sync; + /** + * @var int Id of currency + */ + public $fk_multicurrency; + /** + * @var int Id of entity + */ + public $entity; + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = &$db; + + return 1; + } + + /** + * Create object into database + * + * @param int $fk_multicurrency Id of currency + * @param bool $trigger true=launch triggers after, false=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function create($fk_multicurrency, $trigger = true) + { + global $conf, $user; + + dol_syslog('CurrencyRate::create', LOG_DEBUG); + + $error = 0; + $this->rate = price2num($this->rate); + if (empty($this->entity) || $this->entity <= 0) $this->entity = $conf->entity; + $now=date('Y-m-d H:i:s'); + + // Insert request + $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; + $sql .= ' rate,'; + $sql .= ' date_sync,'; + $sql .= ' fk_multicurrency,'; + $sql .= ' entity'; + $sql .= ') VALUES ('; + $sql .= ' '.$this->rate.','; + $sql .= ' \'' . $now . '\','; + $sql .= ' \'' . $fk_multicurrency . '\','; + $sql .= ' \'' . $this->entity . '\''; + $sql .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog('CurrencyRate::create ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error) { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + $this->fk_multicurrency = $fk_multicurrency; + $this->date_sync = $now; + + if ($trigger) { + $result=$this->call_trigger('CURRENCYRATE_CREATE', $user); + if ($result < 0) $error++; + } + } + + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return $this->id; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id) + { + dol_syslog('CurrencyRate::fetch', LOG_DEBUG); + + $sql = 'SELECT cr.rowid, cr.rate, cr.date_sync, cr.fk_multicurrency, cr.entity'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' AS cr'; + $sql .= ' WHERE cr.rowid = ' . $id; + + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->rate = $obj->rate; + $this->date_sync = $obj->date_sync; + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->entity = $obj->entity; + } + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog('CurrencyRate::fetch ' . join(',', $this->errors), LOG_ERR); + + return - 1; + } + } + + /** + * Update object into database + * + * @param bool $trigger true=launch triggers after, false=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function update($trigger = true) + { + global $user; + + $error = 0; + + dol_syslog('CurrencyRate::update', LOG_DEBUG); + + $this->rate = price2num($this->rate); + + // Update request + $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; + $sql .= ' rate='.$this->rate; + $sql .= ' WHERE rowid=' . $this->id; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog('CurrencyRate::update ' . join(',', $this->errors), LOG_ERR); + } + + if (!$error && $trigger) { + $result=$this->call_trigger('CURRENCYRATE_MODIFY',$user); + if ($result < 0) $error++; + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Delete object in database + * + * @param bool $trigger true=launch triggers after, false=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function delete($trigger = true) + { + global $user; + + dol_syslog('CurrencyRate::delete', LOG_DEBUG); + + $error = 0; + + $this->db->begin(); + + if ($trigger) { + $result=$this->call_trigger('CURRENCYRATE_DELETE',$user); + if ($result < 0) $error++; + } + + if (!$error) { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' WHERE rowid='.$this->id; + + $resql = $this->db->query($sql); + if (!$resql) { + $error ++; + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog('CurrencyRate::delete ' . join(',', $this->errors), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return - 1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + +} diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1184a490495..b7cd05bf93c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -33,7 +33,7 @@ * \brief File for third party class */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; - +dol_include_once('/multicurrency/class/multicurrency.class.php'); /** * Class to manage third parties objects (customers, suppliers, prospects...) @@ -354,6 +354,10 @@ class Societe extends CommonObject var $location_incoterms; var $libelle_incoterms; //Used into tooltip + // Multicurrency + var $fk_multicurrency; + var $multicurrency_code; + /** * To contains a clone of this when we need to save old properties of object * @var Societe @@ -402,7 +406,14 @@ class Societe extends CommonObject if (empty($this->client)) $this->client=0; if (empty($this->fournisseur)) $this->fournisseur=0; $this->import_key = trim($this->import_key); - + + if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + if (empty($this->fk_multicurrency)) + { + $this->multicurrency_code = ''; + $this->fk_multicurrency = 0; + } + dol_syslog(get_class($this)."::create ".$this->name); // Check parameters @@ -427,7 +438,7 @@ class Societe extends CommonObject if ($result >= 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, name_alias, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, fk_incoterms, location_incoterms ,import_key, fk_multicurrency, multicurrency_code)"; $sql.= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$conf->entity.", '".$this->db->idate($now)."'"; $sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null"); $sql.= ", ".(! empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'":"null"); @@ -437,7 +448,9 @@ class Societe extends CommonObject $sql.= ", 0"; $sql.= ", ".(int) $this->fk_incoterms; $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null").")"; + $sql.= ", ".(! empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'":"null"); + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."')"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result=$this->db->query($sql); @@ -670,6 +683,13 @@ class Societe extends CommonObject $this->tva_intra = dol_sanitizeFileName($this->tva_intra,''); if (empty($this->status)) $this->status = 0; + if (!empty($this->multicurrency_code)) $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + if (empty($this->fk_multicurrency)) + { + $this->multicurrency_code = ''; + $this->fk_multicurrency = 0; + } + // Local taxes $this->localtax1_assuj=trim($this->localtax1_assuj); $this->localtax2_assuj=trim($this->localtax2_assuj); @@ -841,6 +861,8 @@ class Societe extends CommonObject $sql .= ", code_compta_fournisseur = ".(! empty($this->code_compta_fournisseur)?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null"); } $sql .= ", fk_user_modif = ".(! empty($user->id)?"'".$user->id."'":"null"); + $sql .= ", fk_multicurrency = ".(int) $this->fk_multicurrency; + $sql .= ', multicurrency_code = "'.$this->db->escape($this->multicurrency_code).'"'; $sql .= " WHERE rowid = '" . $id ."'"; @@ -992,6 +1014,7 @@ class Societe extends CommonObject $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj'; $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo'; $sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms'; + $sql .= ', s.fk_multicurrency, s.multicurrency_code'; $sql .= ', fj.libelle as forme_juridique'; $sql .= ', e.libelle as effectif'; $sql .= ', c.code as country_code, c.label as country'; @@ -1142,6 +1165,10 @@ class Societe extends CommonObject $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; + // multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $result = 1; // Retreive all extrafield for thirdparty diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 1eaff21f05f..8852f22686f 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -338,6 +338,13 @@ if (empty($reshook)) $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); } + + // Multicurrency + if (!empty($conf->multicurrency->enabled)) + { + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + } + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) @@ -1249,6 +1256,16 @@ else } } + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + print ''; + print ''.fieldLabel('Currency','multicurrency_code').''; + print ''; + print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1); + print ''; + } + // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -1801,6 +1818,16 @@ else } } + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + print ''; + print ''.fieldLabel('Currency','multicurrency_code').''; + print ''; + print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1); + print ''; + } + // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -2212,6 +2239,16 @@ else print ''; } + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + print ''; + print ''.fieldLabel('Currency','multicurrency_code').''; + print ''; + print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code,1) : ''; + print ''; + } + // Other attributes $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/theme/eldy/img/object_multicurrency.png b/htdocs/theme/eldy/img/object_multicurrency.png new file mode 100644 index 0000000000000000000000000000000000000000..51896a4c051a345c09fcffbe9c24d08dd8f70a88 GIT binary patch literal 733 zcmV<30wVp1P)j&|t~VM)>s4Kk57SvccsX5PFvZ~4BjON&a-@BTad7lJjk4?ISE=m-!Q zL~HjRxjY&mrs?q1VwS!dJ;4CraQ_6zD(UhR;@8`-``mb-Ze!VY#`&odRjIaZY8a;T z#59WW_)yydfWPA2-f>KibYf@ESo!9Ls%xQ;ug~xI*qpIN#<^-)ZZw}SCNgQg-_WfI zVc+?O0D$R{P5>Zv_2on1u-a!^PArl5);Tr#u6_39=cCJ+!XP-dFv?CkE)@v??7#HL z&s=&&E%DUX)JA)=nl7Z5^23rWE(jo^ZM$MtE4(c&3#vuaPHM}APo%zmRESiC&qgZ3 zqlzNAk|au$GH`GQ9E5W&Sf-QwKA-8CjdeZ!9Zgca3dyB)s%wQ|HKZOAB%#^Tt=o(; z?ND@=oMMA76u2YGB0vZ@2qdq30h|K>7-e=*x2~>iUz<-rqPEdN z9c6|(#3BR%+3VTrIL>4F|n)pt6{py2#1u`8O$z#|Q3< zviF!>(68i{=3SH!oj_5f#mhht=J Date: Thu, 21 Jan 2016 21:54:57 +0100 Subject: [PATCH 006/421] FIX add input multicurrency_subprice on edit line --- htdocs/core/tpl/objectline_edit.tpl.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 4316ab0b318..f34f3e52a49 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -121,6 +121,10 @@ $coldisplay=-1; // We remove first td if ($this->situation_counter > 1) print ' readonly'; print '>'; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } + if ($inputalsopricewithtax) { $coldisplay++; From 2d4f355792284fd26d4013e8c7685ad2081d2303 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 21 Jan 2016 21:57:09 +0100 Subject: [PATCH 007/421] FIX back quote into migration sql file --- .../install/mysql/migration/3.9.0-4.0.0.sql | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 7e9260c595e..23da9daacb9 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 @@ -38,26 +38,26 @@ ALTER TABLE llx_cronjob MODIFY COLUMN unitfrequency varchar(255) NOT NULL DEFAUL ALTER TABLE llx_facture ADD INDEX idx_facture_fk_statut (fk_statut); -CREATE TABLE IF NOT EXISTS `llx_multicurrency` +CREATE TABLE IF NOT EXISTS llx_multicurrency ( - `rowid` integer AUTO_INCREMENT PRIMARY KEY, - `date_create` datetime DEFAULT NULL, - `code` varchar(255) DEFAULT NULL, - `name` varchar(255) DEFAULT NULL, - `entity` integer DEFAULT NULL, - `fk_user` integer DEFAULT NULL, - KEY `code` (`code`) + rowid integer AUTO_INCREMENT PRIMARY KEY, + date_create datetime DEFAULT NULL, + code varchar(255) DEFAULT NULL, + name varchar(255) DEFAULT NULL, + entity integer DEFAULT NULL, + fk_user integer DEFAULT NULL, + KEY code (code) ) ENGINE=innodb; -CREATE TABLE IF NOT EXISTS `llx_multicurrency_rate` +CREATE TABLE IF NOT EXISTS llx_multicurrency_rate ( - `rowid` integer AUTO_INCREMENT PRIMARY KEY, - `date_sync` datetime DEFAULT NULL, - `rate` double NOT NULL DEFAULT '0', - `fk_multicurrency` integer NOT NULL DEFAULT '0', - `entity` integer NOT NULL DEFAULT '0', - KEY `fk_multicurrency` (`fk_multicurrency`), - KEY `entity` (`entity`) + rowid integer AUTO_INCREMENT PRIMARY KEY, + date_sync datetime DEFAULT NULL, + rate double NOT NULL DEFAULT '0', + fk_multicurrency integer NOT NULL DEFAULT '0', + entity integer NOT NULL DEFAULT '0', + KEY fk_multicurrency (fk_multicurrency), + KEY entity (entity) ) ENGINE=innodb; ALTER TABLE llx_societe ADD COLUMN fk_multicurrency integer; From 68857499d75789b41df22d365495a6ea7c7334e9 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 21 Jan 2016 22:26:51 +0100 Subject: [PATCH 008/421] NEW display multicurrency price on azur pdf model --- htdocs/core/lib/pdf.lib.php | 12 +++++-- .../modules/propale/doc/pdf_azur.modules.php | 31 +++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 62a92f4d5ac..13795933962 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1414,7 +1414,11 @@ function pdf_getlineupexcltax($object,$i,$outputlangs,$hidedetails=0) } if (empty($reshook)) { - if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * $object->lines[$i]->subprice, 0, $outputlangs); + if (empty($hidedetails) || $hidedetails > 1) + { + $subprice = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_subprice : $object->lines[$i]->subprice); + $result.=price($sign * $subprice, 0, $outputlangs); + } } return $result; } @@ -1735,7 +1739,11 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) { return $outputlangs->transnoentities("Option"); } - if (empty($hidedetails) || $hidedetails > 1) $result.=price($sign * $object->lines[$i]->total_ht, 0, $outputlangs); + if (empty($hidedetails) || $hidedetails > 1) + { + $total_ht = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ht : $object->lines[$i]->total_ht); + $result.=price($sign * $total_ht, 0, $outputlangs); + } } return $result; } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 8266efe74a5..5c77944843c 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -536,14 +536,15 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - $tvaligne=$object->lines[$i]->total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; + else $tvaligne=$object->lines[$i]->total_tva; $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; $localtax2_rate=$object->lines[$i]->localtax2_tx; $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; - + $localtax2_type=$object->lines[$i]->localtax2_type; + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; @@ -589,11 +590,11 @@ class pdf_azur extends ModelePDFPropales $pdf->setPage($pagenb); if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf,$object,$outputlangs,1); $pagenb++; @@ -605,11 +606,11 @@ class pdf_azur extends ModelePDFPropales { if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf,$object,$outputlangs,1); // New page @@ -623,12 +624,12 @@ class pdf_azur extends ModelePDFPropales // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } @@ -973,8 +974,9 @@ class pdf_azur extends ModelePDFPropales $pdf->SetXY($col1x, $tab2_top + 0); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248,248,248); @@ -1155,8 +1157,9 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); } } @@ -1220,9 +1223,10 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Langs object * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') { global $conf; @@ -1230,6 +1234,7 @@ class pdf_azur extends ModelePDFPropales $hidebottom=0; if ($hidetop) $hidetop=-1; + $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); // Amount in (at tab_top - 1) @@ -1238,7 +1243,7 @@ class pdf_azur extends ModelePDFPropales if (empty($hidetop)) { - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency)); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); From 148a5947a73f2e202f75395f19fd48e0dc56b53f Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 21 Jan 2016 22:40:07 +0100 Subject: [PATCH 009/421] FIX update propal line the multicurrency price do not change --- htdocs/comm/propal/class/propal.class.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index d9ba1e7ef59..fe0c85fce04 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -625,13 +625,18 @@ class Propal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; if ($remise_percent > 0) @@ -694,6 +699,12 @@ class Propal extends CommonObject $this->line->array_options=$array_options; } + // Multicurrency + $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $result=$this->line->update(); if ($result > 0) { @@ -3437,6 +3448,13 @@ class PropaleLigne extends CommonObjectLine $sql.= " , date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null"); $sql.= " , date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); $sql.= " , fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + + // Multicurrency + $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; + $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; + $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); From 21db62d6450072846f5e36fd6a8aaeceb6b5ae42 Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 22 Jan 2016 22:35:32 +0100 Subject: [PATCH 010/421] FIX multicurrency price always display and update line price if rate is update --- htdocs/comm/propal.php | 31 +++++++++++++---------- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/core/class/commonobject.class.php | 7 +++++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index d83beedc9c5..487d174b2bb 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -2101,21 +2101,24 @@ if ($action == 'create') print '' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . ''; print ''; - // Multicurrency Amount HT - print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ''; - print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; - print ''; + if (!empty($conf->multicurrency->enabled)) + { + // Multicurrency Amount HT + print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ''; + print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''; + + // Multicurrency Amount VAT + print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ''; + print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''; + + // Multicurrency Amount TTC + print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ''; + print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''; + } - // Multicurrency Amount VAT - print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ''; - print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; - print ''; - - // Multicurrency Amount TTC - print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ''; - print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; - print ''; - // Statut print '' . $langs->trans('Status') . '' . $object->getLibStatut(4) . ''; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index fe0c85fce04..cef54968cb7 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -792,7 +792,7 @@ class Propal extends CommonObject if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) { - $this->multicurrency_code = ''; + $this->multicurrency_code = $conf->currency; $this->fk_multicurrency = 0; $this->multicurrency_tx = 1; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3e04f98574d..60897072432 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1471,6 +1471,13 @@ abstract class CommonObject if ($this->db->query($sql)) { $this->multicurrency_tx = $rate; + + // Update line price + if (!empty($this->lines)) + { + foreach ($this->lines as &$line) $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit); + } + return 1; } else From e86ebd6799a37276f7bbe0d3d10da60987d652f4 Mon Sep 17 00:00:00 2001 From: phf Date: Sat, 23 Jan 2016 00:38:17 +0100 Subject: [PATCH 011/421] NEW add multicurency on customer order --- htdocs/comm/propal/class/propal.class.php | 1 + htdocs/commande/card.php | 98 ++++++++++++++++++++++- htdocs/commande/class/commande.class.php | 94 ++++++++++++++++++++-- htdocs/core/class/commonobject.class.php | 2 + htdocs/core/tpl/originproductline.tpl.php | 1 + 5 files changed, 189 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index cef54968cb7..26e65e09464 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -789,6 +789,7 @@ class Propal extends CommonObject if (empty($this->availability_id)) $this->availability_id=0; if (empty($this->demand_reason_id)) $this->demand_reason_id=0; + // Multicurrency if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); if (empty($this->fk_multicurrency)) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 9e7f5fae4f8..a362680b840 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -260,7 +260,9 @@ if (empty($reshook)) $object->contactid = GETPOST('contactid'); $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); - + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + // If creation from another object of another module (Example: origin=propal, originid=1) if (! empty($origin) && ! empty($originid)) { @@ -490,7 +492,17 @@ if (empty($reshook)) if ($result < 0) dol_print_error($db, $object->error); } + + // Multicurrency Code + else if ($action == 'setmulticurrencycode' && $user->rights->commande->creer) { + $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); + } + // Multicurrency rate + else if ($action == 'setmulticurrencyrate' && $user->rights->commande->creer) { + $result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int')); + } + else if ($action == 'setavailability' && $user->rights->commande->creer) { $result = $object->availability(GETPOST('availability_id')); if ($result < 0) @@ -1260,7 +1272,8 @@ if ($action == 'create' && $user->rights->commande->creer) $projectid = 0; $remise_absolue = 0; - + $currency_code = $conf->currency; + if (! empty($origin) && ! empty($originid)) { // Parse element/subelement (ex: project_task) $element = $subelement = $origin; @@ -1328,6 +1341,12 @@ if ($action == 'create' && $user->rights->commande->creer) $datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); + if (!empty($conf->multicurrency->enabled)) + { + if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + } + $note_private = $object->getDefaultCreateValueFor('note_private', (! empty($objectsrc->note_private) ? $objectsrc->note_private : null)); $note_public = $object->getDefaultCreateValueFor('note_public', (! empty($objectsrc->note_public) ? $objectsrc->note_public : null)); @@ -1348,6 +1367,8 @@ if ($action == 'create' && $user->rights->commande->creer) $remise_absolue = 0; $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:''; $projectid = 0; + + if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; $note_private = $object->getDefaultCreateValueFor('note_private'); $note_public = $object->getDefaultCreateValueFor('note_public'); @@ -1363,6 +1384,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; print ''; + if (!empty($currency_tx)) print ''; dol_fiche_head(''); @@ -1532,6 +1554,16 @@ if ($action == 'create' && $user->rights->commande->creer) print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF); print ""; + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + print ''; + print ''.fieldLabel('Currency','multicurrency_code').''; + print ''; + print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print ''; + } + // Note public print ''; print '' . $langs->trans('NotePublic') . ''; @@ -1603,6 +1635,13 @@ if ($action == 'create' && $user->rights->commande->creer) } print '' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . ""; + + if (!empty($conf->multicurrency->enabled)) + { + print '' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . ''; + print '' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . ""; + print '' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . ""; + } } else { @@ -2145,6 +2184,43 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + // Multicurrency code + print ''; + print ''; + print ''; + if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('Currency','multicurrency_code'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print ''; + if ($action == 'editmulticurrencycode') { + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + } else { + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + } + print ''; + + // Multicurrency rate + print ''; + print ''; + print ''; + if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('Rate','multicurrency_tx'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print ''; + if ($action == 'editmulticurrencyrate') { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + } + print ''; + } // Other attributes $cols = 3; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -2207,6 +2283,24 @@ if ($action == 'create' && $user->rights->commande->creer) // Total TTC print '' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . ''; + if (!empty($conf->multicurrency->enabled)) + { + // Multicurrency Amount HT + print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ''; + print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''; + + // Multicurrency Amount VAT + print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ''; + print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''; + + // Multicurrency Amount TTC + print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ''; + print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; + print ''; + } + // Statut print '' . $langs->trans('Status') . '' . $object->getLibStatut(4) . ''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b1e4651eace..080db4aa64f 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -33,6 +33,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/commonorder.class.php'; require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php"; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php'; +dol_include_once('/multicurrency/class/multicurrency.class.php'); /** * Class to manage customers orders @@ -143,6 +144,14 @@ class Commande extends CommonOrder var $nbtodo; var $nbtodolate; + // Multicurrency + var $fk_multicurrency; + var $multicurrency_code; + var $multicurrency_tx; + var $multicurrency_total_ht; + var $multicurrency_total_tva; + var $multicurrency_total_ttc; + /** * ERR Not enough stock */ @@ -692,7 +701,17 @@ class Commande extends CommonOrder // Clean parameters $this->brouillon = 1; // set command as draft - + + // Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate) + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + if (empty($this->fk_multicurrency)) + { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } + dol_syslog(get_class($this)."::create user=".$user->id); // Check parameters @@ -738,6 +757,9 @@ class Commande extends CommonOrder $sql.= ", remise_absolue, remise_percent"; $sql.= ", fk_incoterms, location_incoterms"; $sql.= ", entity"; + $sql.= ", fk_multicurrency"; + $sql.= ", multicurrency_code"; + $sql.= ", multicurrency_tx"; $sql.= ")"; $sql.= " VALUES ('(PROV)',".$this->socid.", '".$this->db->idate($now)."', ".$user->id; $sql.= ", ".($this->fk_project>0?$this->fk_project:"null"); @@ -763,6 +785,9 @@ class Commande extends CommonOrder $sql.= ", ".(int) $this->fk_incoterms; $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; $sql.= ", ".$conf->entity; + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".(double) $this->multicurrency_tx; $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -1254,13 +1279,18 @@ class Commande extends CommonOrder $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + // Rang to use $rangtouse = $rang; if ($rangtouse == -1) @@ -1318,6 +1348,14 @@ class Commande extends CommonOrder $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; + // Multicurrency + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->multicurrency_subprice = price2num($pu_ht * $this->multicurrency_tx); + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + // TODO Ne plus utiliser $this->line->price=$price; $this->line->remise=$remise; @@ -1464,6 +1502,7 @@ class Commande extends CommonOrder $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed'; $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_delivery_address, c.extraparams'; $sql.= ', c.fk_incoterms, c.location_incoterms'; + $sql.= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc"; $sql.= ", i.libelle as libelle_incoterms"; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; @@ -1537,6 +1576,14 @@ class Commande extends CommonOrder $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_tx = $obj->multicurrency_tx; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->lines = array(); @@ -1666,6 +1713,7 @@ class Commande extends CommonOrder $sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,'; $sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,'; $sql.= ' l.fk_unit,'; + $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)'; @@ -1728,6 +1776,14 @@ class Commande extends CommonOrder $line->date_start = $this->db->jdate($objp->date_start); $line->date_end = $this->db->jdate($objp->date_end); + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $this->lines[$i] = $line; $i++; @@ -2478,13 +2534,18 @@ class Commande extends CommonOrder $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + // Anciens indicateurs: $price, $subprice, $remise (a ne plus utiliser) $price = $pu; $subprice = $pu; @@ -2540,6 +2601,12 @@ class Commande extends CommonOrder $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; + // Multicurrency + $this->line->multicurrency_subprice = price2num($subprice * $this->multicurrency_tx); + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + // TODO deprecated $this->line->price=$price; $this->line->remise=$remise; @@ -3222,6 +3289,7 @@ class Commande extends CommonOrder $sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.localtax1_tx, l.localtax2_tx,'; $sql.= ' l.date_start, l.date_end,'; $sql.= ' l.fk_unit,'; + $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, '; $sql.= ' p.description as product_desc, p.stock as stock_reel,'; $sql.= ' p.entity'; @@ -3272,7 +3340,15 @@ class Commande extends CommonOrder $this->lines[$i]->marge_tx = $marginInfos[1]; $this->lines[$i]->marque_tx = $marginInfos[2]; $this->lines[$i]->fk_unit = $obj->fk_unit; - + + // Multicurrency + $line->fk_multicurrency = $obj->fk_multicurrency; + $line->multicurrency_code = $obj->multicurrency_code; + $line->multicurrency_subprice = $obj->multicurrency_subprice; + $line->multicurrency_total_ht = $obj->multicurrency_total_ht; + $line->multicurrency_total_tva = $obj->multicurrency_total_tva; + $line->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + $i++; } @@ -3608,7 +3684,9 @@ class OrderLine extends CommonOrderLine $sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,'; $sql.= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,'; $sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,'; - $sql.= ' fk_unit)'; + $sql.= ' fk_unit'; + $sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql.= ')'; $sql.= " VALUES (".$this->fk_commande.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -3639,6 +3717,12 @@ class OrderLine extends CommonOrderLine $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").','; $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").','; $sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql.= ", ".$this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".$this->multicurrency_subprice; + $sql.= ", ".$this->multicurrency_total_ht; + $sql.= ", ".$this->multicurrency_total_tva; + $sql.= ", ".$this->multicurrency_total_ttc; $sql.= ')'; dol_syslog(get_class($this)."::insert", LOG_DEBUG); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 60897072432..baa4fa8f8bb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3382,6 +3382,7 @@ abstract class CommonObject print ''.$langs->trans('Description').''; print ''.$langs->trans('VAT').''; print ''.$langs->trans('PriceUHT').''; + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency').''; print ''.$langs->trans('Qty').''; if($conf->global->PRODUCT_USE_UNITS) { @@ -3512,6 +3513,7 @@ abstract class CommonObject $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); $this->tpl['price'] = price($line->subprice); + $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; if($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $line->getLabelOfUnit('long'); $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index 7919668ae53..78006316f63 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -23,6 +23,7 @@ tpl['description']; ?> tpl['vat_rate']; ?> tpl['price']; ?> + multicurrency->enabled)) { ?>tpl['multicurrency_price']; ?> tpl['qty']; ?> global->PRODUCT_USE_UNITS) echo ''.$langs->trans($this->tpl['unit']).''; From 373225272b42992845cc1d5c679ed4d3cf1998fe Mon Sep 17 00:00:00 2001 From: phf Date: Sat, 23 Jan 2016 16:01:55 +0100 Subject: [PATCH 012/421] FIX reorder the display of currency and rate on propal/order FIX update line on propal/order NEW add mulitcurrency on customer invoice --- htdocs/comm/propal.php | 77 ++++++------ htdocs/commande/card.php | 75 ++++++------ htdocs/commande/class/commande.class.php | 21 ++-- htdocs/compta/facture.php | 110 +++++++++++++++++- htdocs/compta/facture/class/facture.class.php | 104 +++++++++++++++-- .../commande/doc/pdf_einstein.modules.php | 28 +++-- .../modules/facture/doc/pdf_crabe.modules.php | 30 +++-- 7 files changed, 327 insertions(+), 118 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 487d174b2bb..c8b775f40e2 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1927,6 +1927,44 @@ if ($action == 'create') } print ''; + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + // Multicurrency code + print ''; + print ''; + print ''; + if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('Currency','multicurrency_code'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print ''; + if ($action == 'editmulticurrencycode') { + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + } else { + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + } + print ''; + + // Multicurrency rate + print ''; + print ''; + print ''; + if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('Rate','multicurrency_tx'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print ''; + if ($action == 'editmulticurrencyrate') { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + } + print ''; + } + // Project if (! empty($conf->projet->enabled)) { @@ -2018,45 +2056,6 @@ if ($action == 'create') print ''; } - // Multicurrency - if (! empty($conf->multicurrency->enabled)) - { - // Multicurrency code - print ''; - print ''; - print ''; - if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) - print ''; - print '
'; - print fieldLabel('Currency','multicurrency_code'); - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print ''; - if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); - } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); - } - print ''; - - // Multicurrency rate - print ''; - print ''; - print ''; - if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) - print ''; - print '
'; - print fieldLabel('Rate','multicurrency_tx'); - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print ''; - if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); - } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); - } - print ''; - } - - // Other attributes $cols = 5; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index a362680b840..180914c7c38 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2090,6 +2090,44 @@ if ($action == 'create' && $user->rights->commande->creer) } print ''; + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + // Multicurrency code + print ''; + print ''; + print ''; + if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('Currency','multicurrency_code'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print ''; + if ($action == 'editmulticurrencycode') { + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + } else { + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + } + print ''; + + // Multicurrency rate + print ''; + print ''; + print ''; + if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('Rate','multicurrency_tx'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print ''; + if ($action == 'editmulticurrencyrate') { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + } + print ''; + } + // Availability print ''; print ''; } - // Multicurrency - if (! empty($conf->multicurrency->enabled)) - { - // Multicurrency code - print ''; - print ''; - - // Multicurrency rate - print ''; - print ''; - } // Other attributes $cols = 3; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 080db4aa64f..bc5a0767aff 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3289,7 +3289,7 @@ class Commande extends CommonOrder $sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.localtax1_tx, l.localtax2_tx,'; $sql.= ' l.date_start, l.date_end,'; $sql.= ' l.fk_unit,'; - $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc'; + $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, '; $sql.= ' p.description as product_desc, p.stock as stock_reel,'; $sql.= ' p.entity'; @@ -3342,12 +3342,12 @@ class Commande extends CommonOrder $this->lines[$i]->fk_unit = $obj->fk_unit; // Multicurrency - $line->fk_multicurrency = $obj->fk_multicurrency; - $line->multicurrency_code = $obj->multicurrency_code; - $line->multicurrency_subprice = $obj->multicurrency_subprice; - $line->multicurrency_total_ht = $obj->multicurrency_total_ht; - $line->multicurrency_total_tva = $obj->multicurrency_total_tva; - $line->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; + $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; + $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; + $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; $i++; } @@ -3850,6 +3850,13 @@ class OrderLine extends CommonOrderLine $sql.= " , fk_parent_line=".(! empty($this->fk_parent_line)?$this->fk_parent_line:"null"); if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " , fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + + // Multicurrency + $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; + $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; + $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c933482f98e..8ee26c3f102 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -271,6 +271,16 @@ if (empty($reshook)) dol_print_error($db, $object->error); } + // Multicurrency Code + else if ($action == 'setmulticurrencycode' && $user->rights->facture->creer) { + $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); + } + + // Multicurrency rate + else if ($action == 'setmulticurrencyrate' && $user->rights->facture->creer) { + $result = $object->setMulticurrencyRate(GETPOST('multicurrency_tx', 'int')); + } + else if ($action == 'setinvoicedate' && $user->rights->facture->creer) { $object->fetch($id); @@ -699,7 +709,9 @@ if (empty($reshook)) $object->remise_percent = $_POST['remise_percent']; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); - + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + // Proprietes particulieres a facture de remplacement $object->fk_facture_source = $_POST['fac_replacement']; $object->type = Facture::TYPE_REPLACEMENT; @@ -746,7 +758,9 @@ if (empty($reshook)) $object->remise_percent = $_POST['remise_percent']; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); - + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + // Proprietes particulieres a facture avoir $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; $object->type = Facture::TYPE_CREDIT_NOTE; @@ -831,7 +845,9 @@ if (empty($reshook)) $object->ref_client = $_POST['ref_client']; $object->ref_int = $_POST['ref_int']; $object->modelpdf = $_POST['model']; - + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + // Source facture $object->fac_rec = GETPOST('fac_rec'); @@ -876,6 +892,8 @@ if (empty($reshook)) $object->remise_percent = $_POST['remise_percent']; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); if (GETPOST('type') == Facture::TYPE_SITUATION) { @@ -1855,6 +1873,8 @@ if ($action == 'create') if ($socid > 0) $res = $soc->fetch($socid); + $currency_code = $conf->currency; + // Load objectsrc $remise_absolue = 0; @@ -1923,6 +1943,12 @@ if ($action == 'create') $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); + if (!empty($conf->multicurrency->enabled)) + { + if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + } + // Replicate extrafields $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; @@ -1936,6 +1962,8 @@ if ($action == 'create') $remise_percent = $soc->remise_percent; $remise_absolue = 0; $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice); // Do not set 0 here (0 for a date is 1970) + + if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } $absolute_discount = $soc->getAvailableDiscounts(); @@ -1958,7 +1986,8 @@ if ($action == 'create') print ''; print ''; print ''; - + if (!empty($currency_tx)) print ''; + dol_fiche_head(''); print '
'; @@ -2184,43 +2222,6 @@ if ($action == 'create' && $user->rights->commande->creer) print '
'; - print ''; - if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) - print ''; - print '
'; - print fieldLabel('Currency','multicurrency_code'); - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print '
'; - if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); - } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); - } - print '
'; - print ''; - if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) - print ''; - print '
'; - print fieldLabel('Rate','multicurrency_tx'); - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print '
'; - if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); - } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); - } - print '
'; @@ -2337,6 +2366,16 @@ if ($action == 'create') print $form->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF); print ""; + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + print ''; + print ''; + print ''; + } + // Public note print ''; print ''; @@ -2419,6 +2458,13 @@ if ($action == 'create') print '"; } print '"; + + if (!empty($conf->multicurrency->enabled)) + { + print ''; + print '"; + print '"; + } } else { @@ -3384,6 +3430,44 @@ else if ($id > 0 || ! empty($ref)) } print ''; + // Multicurrency + if (! empty($conf->multicurrency->enabled)) + { + // Multicurrency code + print ''; + print ''; + + // Multicurrency rate + print ''; + print ''; + } + // Bank Account print '
'.fieldLabel('Currency','multicurrency_code').''; + print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print '
' . $langs->trans('NotePublic') . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . "
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . '
' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . "
' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
'; + print ''; + if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('Currency','multicurrency_code'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print '
'; + if ($action == 'editmulticurrencycode') { + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); + } else { + $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); + } + print '
'; + print ''; + if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('Rate','multicurrency_tx'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print '
'; + if ($action == 'editmulticurrencyrate') { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx'); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none'); + } + print '
'; print ''; + if (!empty($conf->multicurrency->enabled)) + { + // Multicurrency Amount HT + print ''; + print ''; + print ''; + + // Multicurrency Amount VAT + print ''; + print ''; + print ''; + + // Multicurrency Amount TTC + print ''; + print ''; + print ''; + } + // Statut print ''; print ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 91221118f2a..4042af717c2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php"; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; - +dol_include_once('/multicurrency/class/multicurrency.class.php'); /** * Class to manage invoices @@ -107,6 +107,14 @@ class Facture extends CommonInvoice var $specimen; var $fac_rec; + + // Multicurrency + var $fk_multicurrency; + var $multicurrency_code; + var $multicurrency_tx; + var $multicurrency_total_ht; + var $multicurrency_total_tva; + var $multicurrency_total_ttc; /** * @var int Situation cycle reference number @@ -230,6 +238,16 @@ class Facture extends CommonInvoice if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; + // Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate) + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + if (empty($this->fk_multicurrency)) + { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } + dol_syslog(get_class($this)."::create user=".$user->id); // Check parameters @@ -301,6 +319,9 @@ class Facture extends CommonInvoice $sql.= ", fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf"; $sql.= ", situation_cycle_ref, situation_counter, situation_final"; $sql.= ", fk_incoterms, location_incoterms"; + $sql.= ", fk_multicurrency"; + $sql.= ", multicurrency_code"; + $sql.= ", multicurrency_tx"; $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; @@ -328,6 +349,9 @@ class Facture extends CommonInvoice $sql.= ", ".($this->situation_final?$this->situation_final:0); $sql.= ", ".(int) $this->fk_incoterms; $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".(double) $this->multicurrency_tx; $sql.=")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -973,6 +997,7 @@ class Facture extends CommonInvoice $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; $sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final'; $sql.= ', f.fk_account'; + $sql.= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc"; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', f.fk_incoterms, f.location_incoterms'; @@ -1045,6 +1070,14 @@ class Facture extends CommonInvoice $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_tx = $obj->multicurrency_tx; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + if ($this->type == self::TYPE_SITUATION && $fetch_situation) { $this->fetchPreviousNextSituationInvoice(); @@ -1104,6 +1137,7 @@ class Facture extends CommonInvoice $sql.= ' l.date_start as date_start, l.date_end as date_end,'; $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql.= ' l.fk_unit,'; + $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; @@ -1163,7 +1197,15 @@ class Facture extends CommonInvoice $line->situation_percent= $objp->situation_percent; $line->fk_prev_id = $objp->fk_prev_id; $line->fk_unit = $objp->fk_unit; - + + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $this->lines[$i] = $line; $i++; @@ -2255,7 +2297,7 @@ class Facture extends CommonInvoice $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -2264,6 +2306,11 @@ class Facture extends CommonInvoice $total_localtax2 = $tabprice[10]; $pu_ht = $tabprice[3]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + // Rank to use $rangtouse = $rang; if ($rangtouse == -1) @@ -2313,7 +2360,15 @@ class Facture extends CommonInvoice // infos marge $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; - + + // Multicurrency + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; + $this->line->multicurrency_subprice = price2num($this->line->subprice * $this->multicurrency_tx); + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + if (is_array($array_options) && count($array_options)>0) { $this->line->array_options=$array_options; } @@ -2424,7 +2479,7 @@ class Facture extends CommonInvoice $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -2435,6 +2490,11 @@ class Facture extends CommonInvoice $pu_tva = $tabprice[4]; $pu_ttc = $tabprice[5]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; + $multicurrency_total_tva = $tabprice[17]; + $multicurrency_total_ttc = $tabprice[18]; + // Old properties: $price, $remise (deprecated) $price = $pu; $remise = 0; @@ -2491,6 +2551,12 @@ class Facture extends CommonInvoice $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; + // Multicurrency + $this->line->multicurrency_subprice = price2num($this->line->subprice * $this->multicurrency_tx); + $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_tva = $multicurrency_total_tva; + $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + if (is_array($array_options) && count($array_options)>0) { $this->line->array_options=$array_options; } @@ -3591,6 +3657,7 @@ class Facture extends CommonInvoice $sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql.= ' l.date_start, l.date_end,'; $sql.= ' l.fk_unit,'; + $sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; $sql.= ' p.ref as product_ref, p.fk_product_type, p.label as product_label,'; $sql.= ' p.description as product_desc,'; $sql.= ' p.entity'; @@ -3643,7 +3710,15 @@ class Facture extends CommonInvoice $this->lines[$i]->marge_tx = $marginInfos[1]; $this->lines[$i]->marque_tx = $marginInfos[2]; $this->lines[$i]->fk_unit = $obj->fk_unit; - + + // Multicurrency + $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; + $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; + $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; + $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + $i++; } $this->db->free($resql); @@ -4079,7 +4154,9 @@ class FactureLigne extends CommonInvoiceLine $sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; $sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; $sql.= ' situation_percent, fk_prev_id,'; - $sql.= ' fk_unit)'; + $sql.= ' fk_unit'; + $sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; + $sql.= ')'; $sql.= " VALUES (".$this->fk_facture.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -4111,6 +4188,12 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", " . $this->situation_percent; $sql .= ", " . $this->fk_prev_id; $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + $sql.= ", ".$this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".$this->multicurrency_subprice; + $sql.= ", ".$this->multicurrency_total_ht; + $sql.= ", ".$this->multicurrency_total_tva; + $sql.= ", ".$this->multicurrency_total_ttc; $sql.= ')'; dol_syslog(get_class($this)."::insert", LOG_DEBUG); @@ -4284,6 +4367,13 @@ class FactureLigne extends CommonInvoiceLine if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql .= ", situation_percent=" . $this->situation_percent; $sql .= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); + + // Multicurrency + $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; + $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; + $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 593e4616fd0..cb9f7571858 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -449,8 +449,9 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - $tvaligne=$object->lines[$i]->total_tva; - + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; + else $tvaligne=$object->lines[$i]->total_tva; + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; @@ -501,11 +502,11 @@ class pdf_einstein extends ModelePDFCommandes $pdf->setPage($pagenb); if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf,$object,$outputlangs,1); $pagenb++; @@ -517,11 +518,11 @@ class pdf_einstein extends ModelePDFCommandes { if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf,$object,$outputlangs,1); // New page @@ -535,12 +536,12 @@ class pdf_einstein extends ModelePDFCommandes // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } @@ -827,8 +828,9 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + 0); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248,248,248); @@ -1006,8 +1008,9 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); } } @@ -1060,7 +1063,7 @@ class pdf_einstein extends ModelePDFCommandes * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') { global $conf; @@ -1068,6 +1071,7 @@ class pdf_einstein extends ModelePDFCommandes $hidebottom=0; if ($hidetop) $hidetop=-1; + $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); // Amount in (at tab_top - 1) @@ -1076,7 +1080,7 @@ class pdf_einstein extends ModelePDFCommandes if (empty($hidetop)) { - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency)); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index e967f6781ea..7df6b8c07cd 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -540,9 +540,11 @@ class pdf_crabe extends ModelePDFFactures $prev_progress = $object->lines[$i]->get_prev_progress(); if ($prev_progress > 0) // Compute progress from previous situation { - $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; + else $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; } else { - $tvaligne = $object->lines[$i]->total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; + else $tvaligne=$object->lines[$i]->total_tva; } $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; @@ -596,11 +598,11 @@ class pdf_crabe extends ModelePDFFactures $pdf->setPage($pagenb); if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf,$object,$outputlangs,1); $pagenb++; @@ -612,11 +614,11 @@ class pdf_crabe extends ModelePDFFactures { if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf,$object,$outputlangs,1); // New page @@ -630,12 +632,12 @@ class pdf_crabe extends ModelePDFFactures // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } @@ -1017,8 +1019,10 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + 0); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + + $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248,248,248); @@ -1211,8 +1215,9 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc, 0, $outputlangs), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); } } @@ -1285,7 +1290,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') { global $conf; @@ -1293,6 +1298,7 @@ class pdf_crabe extends ModelePDFFactures $hidebottom=0; if ($hidetop) $hidetop=-1; + $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); // Amount in (at tab_top - 1) @@ -1301,7 +1307,7 @@ class pdf_crabe extends ModelePDFFactures if (empty($hidetop)) { - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency)); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); From 93766992994b115984175fdbed0a43104d2b5a8e Mon Sep 17 00:00:00 2001 From: phf Date: Sat, 23 Jan 2016 16:16:15 +0100 Subject: [PATCH 013/421] FIX travis missing comment for new param --- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 1 + htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index cb9f7571858..3ea6fd63ef0 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1061,6 +1061,7 @@ class pdf_einstein extends ModelePDFCommandes * @param Translate $outputlangs Langs object * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code * @return void */ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 7df6b8c07cd..8eee3e5a471 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1288,6 +1288,7 @@ class pdf_crabe extends ModelePDFFactures * @param Translate $outputlangs Langs object * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code * @return void */ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') From 963d0c396bc31e4e046f15c04a88cf53bbc0e03a Mon Sep 17 00:00:00 2001 From: phf Date: Sat, 23 Jan 2016 21:36:07 +0100 Subject: [PATCH 014/421] FIX change rate on order/invoice do not update lines NEW if we change the currency on already existing propal/order/invoice the current rate is update too then update lines --- htdocs/core/class/commonobject.class.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index baa4fa8f8bb..b305beffe26 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1434,6 +1434,10 @@ abstract class CommonObject if ($this->db->query($sql)) { $this->multicurrency_code = $code; + + list($fk_multicurrency, $rate) = MultiCurrency::getIdAndTxFromCode($this->db, $code); + if ($rate) $this->setMulticurrencyRate($rate); + return 1; } else @@ -1475,7 +1479,24 @@ abstract class CommonObject // Update line price if (!empty($this->lines)) { - foreach ($this->lines as &$line) $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit); + foreach ($this->lines as &$line) + { + switch ($this->element) { + case 'propal': + $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit); + break; + case 'commande': + $this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit); + break; + case 'facture': + $this->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + break; + default: + dol_syslog(get_class($this).'::setMulticurrencyRate no updateline defined', LOG_DEBUG); + break; + } + + } } return 1; From b2b787f1ff12dc893ef5f57cf00b73e03ccf5674 Mon Sep 17 00:00:00 2001 From: phf Date: Mon, 25 Jan 2016 21:33:14 +0100 Subject: [PATCH 015/421] FIX Travis --- htdocs/core/class/link.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index 91eb8e21a7c..2a58876cdd7 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -275,7 +275,7 @@ class Link extends CommonObject /** * Return nb of links * - * @param DoliDb $dblinks Database handler + * @param DoliDb $db Database handler * @param string $objecttype type of the associated object in dolibarr * @param int $objectid id of the associated object in dolibarr * @return int Nb of links, -1 if error From 4baff7898dc44f923195a194966941a5f65ba794 Mon Sep 17 00:00:00 2001 From: phf Date: Tue, 26 Jan 2016 22:18:31 +0100 Subject: [PATCH 016/421] FIX insert FactureLigne FIX phpunit PriceTest with new values returned for multicurrency module NEW add test in PriceTest FIX FactureTest properties not defined --- htdocs/compta/facture/class/facture.class.php | 16 +++++---- htdocs/core/lib/price.lib.php | 14 ++++---- test/phpunit/FactureTest.php | 2 +- test/phpunit/PricesTest.php | 34 ++++++++++++------- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4042af717c2..24a1f89eeb9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4112,7 +4112,11 @@ class FactureLigne extends CommonInvoiceLine if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100; if (empty($this->pa_ht)) $this->pa_ht=0; - + if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0; + if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0; + if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; + if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; + // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) { @@ -4188,12 +4192,12 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", " . $this->situation_percent; $sql .= ", " . $this->fk_prev_id; $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); - $sql.= ", ".$this->fk_multicurrency; + $sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".$this->multicurrency_subprice; - $sql.= ", ".$this->multicurrency_total_ht; - $sql.= ", ".$this->multicurrency_total_tva; - $sql.= ", ".$this->multicurrency_total_ttc; + $sql.= ", ".price2num($this->multicurrency_subprice); + $sql.= ", ".price2num($this->multicurrency_total_ht); + $sql.= ", ".price2num($this->multicurrency_total_tva); + $sql.= ", ".price2num($this->multicurrency_total_ttc); $sql.= ')'; dol_syslog(get_class($this)."::insert", LOG_DEBUG); diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 5d497ade778..4d7803474d8 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -250,11 +250,6 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result[4] = price2num($result[5] - ($result3bis + $localtaxes[2]), 'MU'); } - // Multicurrency - $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); - $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); - $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); - // if there's some localtax without vat, we calculate localtaxes (we will add them at end) //If input unit price is 'TTC', we need to have the totals without main VAT for a correct calculation @@ -331,9 +326,14 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; } } - + + // Multicurrency + $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); + $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); + $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); + // initialize result array - //for ($i=0; $i <= 15; $i++) $result[$i] = (float) $result[$i]; + //for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i]; dol_syslog('Price.lib::calcul_price_total MAIN_ROUNDING_RULE_TOT='.$conf->global->MAIN_ROUNDING_RULE_TOT.' pu='.$pu.' qty='.$qty.' price_base_type='.$price_base_type.' total_ht='.$result[0].'-total_vat='.$result[1].'-total_ttc='.$result[2]); diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index d2ad97454bf..142a5284989 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -217,7 +217,7 @@ class FactureTest extends PHPUnit_Framework_TestCase $newlocalobject=new Facture($this->savdb); $newlocalobject->initAsSpecimen(); $this->changeProperties($newlocalobject); - $this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final')), array()); // Actual, Expected + $this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva','multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx')), array()); // Actual, Expected return $localobject; } diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 5e0169f9b36..aee698c1a6e 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -151,9 +151,17 @@ class PricesTest extends PHPUnit_Framework_TestCase $result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0),$result1,'Test1 FR'); - + $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36),$result1,'Test1 FR'); + // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value) + $mysoc->country_code='FR'; + $mysoc->country_id=1; + $result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205); + print __METHOD__." result1=".join(', ',$result1)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.56),$result1,'Test1 FR'); + + /* * Country Spain */ @@ -166,7 +174,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test1 ES'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110),$result2,'Test1 ES'); // 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (other method autodetect) $mysoc->country_code='ES'; @@ -176,7 +184,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test2 ES'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110),$result2,'Test2 ES'); // -------------------------------------------------------- @@ -188,7 +196,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2,'Test3 ES'); + $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4),$result2,'Test3 ES'); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect) $mysoc->country_code='ES'; @@ -198,7 +206,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0),$result2,'Test4 ES'); + $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4),$result2,'Test4 ES'); // -------------------------------------------------------- @@ -209,7 +217,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 1); // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19),$result2,'Test5 ES for service'); + $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91),$result2,'Test5 ES for service'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a service and not a product $mysoc->country_code='ES'; @@ -219,7 +227,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test6 ES for product'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110),$result2,'Test6 ES for product'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a product and not a service $mysoc->country_code='ES'; @@ -229,7 +237,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 1); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19),$result2,'Test6 ES for service'); + $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91),$result2,'Test6 ES for service'); // -------------------------------------------------------- @@ -241,7 +249,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0),$result2,'Test7 ES for product'); + $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110),$result2,'Test7 ES for product'); // Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect), we provide a service and not a product $mysoc->country_code='ES'; @@ -250,7 +258,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 1); print __METHOD__." result2=".join(', ',$result2)."\n"; - $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19),$result2,'Test8 ES for service'); + $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91),$result2,'Test8 ES for service'); /* @@ -267,7 +275,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 print __METHOD__." result3=".join(', ',$result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0),$result3,'Test9 CI'); + $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85),$result3,'Test9 CI'); // 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect) $mysoc->country_code='CI'; @@ -277,7 +285,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 print __METHOD__." result3=".join(', ',$result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0),$result3,'Test10 CI'); + $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85),$result3,'Test10 CI'); return true; } From 1baf25de3c279f3b2663238d7aecd0fc355cab07 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 27 Jan 2016 12:04:00 +0100 Subject: [PATCH 017/421] FIX ISSUE #4506 : make working the PROPAL_CLONE_ON_CREATE_PAGE hidden constant --- htdocs/comm/propal.php | 3 ++- htdocs/comm/propal/class/propal.class.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 08106bc2151..a637e4a87fa 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -293,7 +293,8 @@ if (empty($reshook)) $object->note = GETPOST('note'); $object->statut = 0; - $id = $object->create_from($user); + // the create is done below and further more the existing create_from function is quite hilarating + //$id = $object->create_from($user); } else { setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors'); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 372ac5d5a61..c7e4724d027 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -946,6 +946,7 @@ class Propal extends CommonObject */ function create_from($user) { + // i love this function because $this->products is not used in create function... $this->products=$this->lines; return $this->create($user); From d79478e66d25364f89b587e5bd2cf933ceb5b3cc Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 30 Jan 2016 09:43:02 +0100 Subject: [PATCH 018/421] Add hook on contacttpl The goal is to display additionnal feature a the bottom of the contact page like display contact adress and print stamp directly Another way is to show on a google maps the travel to do between us and the multiple thirdpartie present --- htdocs/core/tpl/contacts.tpl.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 638d54a62ef..e6037637d35 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2015 Laurent Destailleur - * Copyright (C) 2015 Charlie BENKE + * Copyright (C) 2015-2016 Charlie BENKE * * 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 @@ -228,4 +228,13 @@ $userstatic=new User($db); + +initHooks(array('contacttpl')); + $parameters=array(); + $reshook=$hookmanager->executeHooks('formContactTpl',$parameters,$object,$action); + } +?> From 32b6f207549b7e221abb5c465b2955602017be97 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Sat, 30 Jan 2016 17:13:58 +0100 Subject: [PATCH 019/421] Update smtps.class.php Set mail reply-to field to sender --- htdocs/core/class/smtps.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index dd2726d2306..8b8e9e4905c 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -1159,7 +1159,7 @@ class SMTPs $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; if ( $this->getErrorsTo() ) $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; - + $_header .= "Reply-To: ".$this->getFrom('addr') ."\r\n"; $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n" . 'Mime-Version: 1.0' . "\r\n"; From 324c1123e0c847d75d928c3894e70acd3d3fdf70 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 30 Jan 2016 17:21:42 +0100 Subject: [PATCH 020/421] Update contacts.tpl.php if permission modules right are not in french --- htdocs/core/tpl/contacts.tpl.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index e6037637d35..4908d162f8b 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -27,15 +27,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $module = $object->element; // Special cases -if ($module == 'propal') { $permission=$user->rights->propale->creer; } -elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; } +if ($module == 'propal') { $permission=$user->rights->propale->creer; } +elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; } elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; } elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; } -elseif ($module == 'project') { $permission=$user->rights->projet->creer; } -elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; } -elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; } -elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; } -elseif (! isset($permission)) { $permission=$user->rights->$module->creer; } // If already defined by caller page +elseif ($module == 'project') { $permission=$user->rights->projet->creer; } +elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; } +elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; } +elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; } +elseif (! isset($permission) && isset($user->rights->$module->creer)) +{ + $permission=$user->rights->$module->creer; +} +elseif (! isset($permission) && isset($user->rights->$module->write)) +{ + $permission=$user->rights->$module->write; +} $formcompany= new FormCompany($db); $companystatic=new Societe($db); From 2f40233e014574b7a35aafb05ceb7ed8aa2ca441 Mon Sep 17 00:00:00 2001 From: abb Date: Sun, 31 Jan 2016 10:10:30 +0100 Subject: [PATCH 021/421] fix : handle case of non existing third party field in object in fecth_thirdparty function --- htdocs/core/class/commonobject.class.php | 34 +++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 005f4684322..f0b0568d2f7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1001,26 +1001,30 @@ abstract class CommonObject { global $conf; - if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) return 0; + if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id)) + return 0; - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; - $idtofetch=isset($this->socid)?$this->socid:(isset($this->fk_soc)?$this->fk_soc:$this->fk_thirdparty); - if ($force_thirdparty_id) $idtofetch=$force_thirdparty_id; + $idtofetch = isset($this->socid) ? $this->socid : (isset($this->fk_soc) ? $this->fk_soc : $this->fk_thirdparty); + if ($force_thirdparty_id) + $idtofetch = $force_thirdparty_id; - $thirdparty = new Societe($this->db); - $result=$thirdparty->fetch($idtofetch); - $this->client = $thirdparty; // deprecated - $this->thirdparty = $thirdparty; + if ($idtofetch) { + $thirdparty = new Societe($this->db); + $result = $thirdparty->fetch($idtofetch); + $this->client = $thirdparty; // deprecated + $this->thirdparty = $thirdparty; - // Use first price level if level not defined for third party - if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->thirdparty->price_level)) - { - $this->client->price_level=1; // deprecated - $this->thirdparty->price_level=1; - } + // Use first price level if level not defined for third party + if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->thirdparty->price_level)) { + $this->client->price_level = 1; // deprecated + $this->thirdparty->price_level = 1; + } - return $result; + return $result; + } else + return -1; } From e22664b8cfce36e9d173e57448190ce5f734d33e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2016 01:00:10 +0100 Subject: [PATCH 022/421] FIX #4528 --- htdocs/core/lib/admin.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index e7630756127..12470310ae4 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -587,9 +587,11 @@ function listOfSessions() if(! @is_dir($fullpath) && is_readable($fullpath)) { $sessValues = file_get_contents($fullpath); // get raw session data - + // Example of possible value + //$sessValues = 'newtoken|s:32:"1239f7a0c4b899200fe9ca5ea394f307";dol_loginmesg|s:0:"";newtoken|s:32:"1236457104f7ae0f328c2928973f3cb5";dol_loginmesg|s:0:"";token|s:32:"123615ad8d650c5cc4199b9a1a76783f";dol_login|s:5:"admin";dol_authmode|s:8:"dolibarr";dol_tz|s:1:"1";dol_tz_string|s:13:"Europe/Berlin";dol_dst|i:0;dol_dst_observed|s:1:"1";dol_dst_first|s:0:"";dol_dst_second|s:0:"";dol_screenwidth|s:4:"1920";dol_screenheight|s:3:"971";dol_company|s:12:"MyBigCompany";dol_entity|i:1;mainmenu|s:4:"home";leftmenuopened|s:10:"admintools";idmenu|s:0:"";leftmenu|s:10:"admintools";'; + if (preg_match('/dol_login/i',$sessValues) && // limit to dolibarr session - preg_match('/dol_entity\|s:([0-9]+):"('.$conf->entity.')"/i',$sessValues) && // limit to current entity + (preg_match('/dol_entity\|i:'.$conf->entity.';/i',$sessValues) || preg_match('/dol_entity\|s:([0-9]+):"'.$conf->entity.'"/i',$sessValues)) && // limit to current entity preg_match('/dol_company\|s:([0-9]+):"('.$conf->global->MAIN_INFO_SOCIETE_NOM.')"/i',$sessValues)) // limit to company name { $tmp=explode('_', $file); From d65ee2252934aca902450108777f1c3415f60329 Mon Sep 17 00:00:00 2001 From: abcnet-lu Date: Wed, 3 Feb 2016 09:27:48 +0100 Subject: [PATCH 023/421] [Close] [#4555] Update label of intermediary VAT rate for Luxembourg (fix inverted labels) --- htdocs/install/mysql/data/llx_c_tva.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 5903243666d..5c0d3792ed3 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -149,8 +149,8 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (12 -- LUXEMBOURG (id country=140) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1401, 140, '17','0','VAT standard rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1402, 140, '14','0','VAT reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1403, 140, '8','0','VAT intermediary rate', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1402, 140, '14','0','VAT intermediary rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1403, 140, '8','0','VAT reduced rate', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1404, 140, '3','0','VAT super-reduced rate', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1405, 140, '0','0','VAT Rate 0', 1); From 6260c1ae9e259f25d14cfc109ad4e6eed3184e37 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Wed, 3 Feb 2016 11:33:13 +0100 Subject: [PATCH 024/421] FIX: Check stock of batch on shippment --- htdocs/expedition/card.php | 3 ++- htdocs/expedition/class/expedition.class.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 3bf17f76a4f..c7d91a28ce5 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -8,6 +8,7 @@ * Copyright (C) 2013 Marcos García * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014 Francis Appels + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -237,7 +238,7 @@ if (empty($reshook)) $ret=$object->addline_batch($batch_line[$i]); if ($ret < 0) { - $mesg='
'.$object->error.'
'; + $mesg='
'.$object->errorsToString().'
'; $error++; } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index cb77607261b..7dcf66d28ec 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2014-2015 Francis Appels + * Copyright (C) 2016 Ferran Marcet * * 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 @@ -857,6 +858,7 @@ class Expedition extends CommonObject */ function addline_batch($dbatch) { + global $conf,$langs; $num = count($this->lines); if ($dbatch['qty']>0) { @@ -882,7 +884,17 @@ class Expedition extends CommonObject if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT) { - // TODO + require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; + $prod_batch = new Productbatch($this->db); + $prod_batch->fetch($value['id_batch']); + + if ($prod_batch->qty < $linebatch->dluo_qty) + { + $this->errors[] = $langs->trans('ErrorStockIsNotEnough'); + dol_syslog(get_class($this)."::addline_batch error=Product ".$prod_batch->batch.": ".$this->errorsToString(), LOG_ERR); + $this->db->rollback(); + return -1; + } } //var_dump($linebatch); @@ -895,6 +907,7 @@ class Expedition extends CommonObject //var_dump($line); $this->lines[$num] = $line; + return 1; } } From d430676e51284609fb8fb97c4d734af4ce1221a9 Mon Sep 17 00:00:00 2001 From: abcnet-lu Date: Wed, 3 Feb 2016 12:14:26 +0100 Subject: [PATCH 025/421] [Close] [#4558] Add districts and cantons for Luxembourg --- htdocs/install/mysql/data/llx_10_c_regions.sql | 7 ++++++- .../install/mysql/data/llx_20_c_departements.sql | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index e736f7d993d..c3bed3ae3c6 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -284,4 +284,9 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) v INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5206, '', 0, 'Tarija', 1); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5207, '', 0, 'Santa Cruz', 1); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5208, '', 0, 'El Beni', 1); -INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5209, '', 0, 'Pando', 1); \ No newline at end of file +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 52, 5209, '', 0, 'Pando', 1); + +-- Regions (districts) Luxembourg (id country=140) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 140, 14001, '', 0, 'Diekirch', 1); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 140, 14002, '', 0, 'Grevenmacher', 1); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom, active) values ( 140, 14003, '', 0, 'Luxembourg', 1); diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 765f96f1da7..c1338fe5d1f 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -1223,4 +1223,18 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('109', 5209, '', 0, '', 'Madre de Dios', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('110', 5209, '', 0, '', 'Manuripi', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('111', 5209, '', 0, '', 'Nicolás Suárez', 1); -INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('112', 5209, '', 0, '', 'General Federico Román', 1); \ No newline at end of file +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('112', 5209, '', 0, '', 'General Federico Román', 1); + +-- Cantons Luxembourg (id country=140) +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0001', 14001, '', 0, '', 'Clervaux', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0002', 14001, '', 0, '', 'Diekirch', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0003', 14001, '', 0, '', 'Redange', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0004', 14001, '', 0, '', 'Vianden', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0005', 14001, '', 0, '', 'Wiltz', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0006', 14002, '', 0, '', 'Echternach', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0007', 14002, '', 0, '', 'Grevenmacher', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0008', 14002, '', 0, '', 'Remich', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0009', 14003, '', 0, '', 'Capellen', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0010', 14003, '', 0, '', 'Esch-sur-Alzette', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0011', 14003, '', 0, '', 'Luxembourg', 1); +INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('LU0012', 14003, '', 0, '', 'Mersch', 1); From 5f7cb75518168d679657b110eec382c26f529b54 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 3 Feb 2016 19:52:09 +0100 Subject: [PATCH 026/421] Fix #4556 desiredstock and seuil_stock_alerte cleared on modify product card removed inputs from update form also removed from update action --- htdocs/product/card.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index dbadd69cdcb..e6b48974d0b 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -321,8 +321,11 @@ if (empty($reshook)) $object->status = GETPOST('statut'); $object->status_buy = GETPOST('statut_buy'); $object->status_batch = GETPOST('status_batch'); + // removed from update view + /* $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $object->desiredstock = GETPOST('desiredstock'); + */ $object->duration_value = GETPOST('duration_value'); $object->duration_unit = GETPOST('duration_unit'); $object->canvas = GETPOST('canvas'); From 75c48883649603c04ef29b1d1941d296e73ead3b Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 3 Feb 2016 22:49:43 +0100 Subject: [PATCH 027/421] NEW feature hidden extrafields --- htdocs/core/actions_extrafields.inc.php | 2 ++ htdocs/core/class/commonobject.class.php | 5 ++-- htdocs/core/class/extrafields.class.php | 29 +++++++++++++------ htdocs/core/tpl/admin_extrafields_add.tpl.php | 2 ++ .../core/tpl/admin_extrafields_edit.tpl.php | 3 ++ .../core/tpl/admin_extrafields_view.tpl.php | 2 ++ htdocs/core/tpl/extrafields_view.tpl.php | 3 +- .../install/mysql/migration/3.9.0-4.0.0.sql | 2 +- .../install/mysql/tables/llx_extrafields.sql | 1 + htdocs/langs/en_US/admin.lang | 1 + 10 files changed, 37 insertions(+), 13 deletions(-) diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index b866c322158..b91cc49374c 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -162,6 +162,7 @@ if ($action == 'add') (GETPOST('alwayseditable')?1:0), (GETPOST('perms')?GETPOST('perms'):''), (GETPOST('list')?1:0) + ,(GETPOST('ishidden')?1:0) ); if ($result > 0) { @@ -312,6 +313,7 @@ if ($action == 'update') (GETPOST('alwayseditable')?1:0), (GETPOST('perms')?GETPOST('perms'):''), (GETPOST('list')?1:0) + ,(GETPOST('ishidden')?1:0) ); if ($result > 0) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 005f4684322..d90932d1738 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4085,6 +4085,7 @@ abstract class CommonObject else { $csstyle=''; + $class=(!empty($extrafields->attribute_hidden[$key]) ? 'class="hideobject" ' : ''); if (is_array($params) && count($params)>0) { if (array_key_exists('style',$params)) { $csstyle=$params['style']; @@ -4092,12 +4093,12 @@ abstract class CommonObject } if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { - $out .= '
'; + $out .= ''; $colspan='0'; } else { - $out .= ''; + $out .= ''; } // Convert date into timestamp format if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ee5f1465e3f..828483db3c7 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -61,6 +61,8 @@ class ExtraFields var $error; var $errno; + var $attribute_hidden; + public static $type2label=array( 'varchar'=>'String', 'text'=>'TextLong', @@ -98,6 +100,7 @@ class ExtraFields $this->attribute_required = array(); $this->attribute_perms = array(); $this->attribute_list = array(); + $this->attribute_hidden = array(); } /** @@ -116,9 +119,10 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param int $list Into list view by default + * @param int $ishidden Is hidden extrafield * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0, $perms='', $list=0) + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param=0, $alwayseditable=0, $perms='', $list=0, $ishidden=0) { if (empty($attrname)) return -1; if (empty($label)) return -1; @@ -135,7 +139,7 @@ class ExtraFields if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') { // Add declaration of field into table - $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable, $perms, $list); + $result2=$this->create_label($attrname,$label,$type,$pos,$size,$elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $ishidden); $err2=$this->errno; if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) { @@ -243,9 +247,10 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param int $list Into list view by default + * @param int $ishidden Is hidden extrafield * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=0) + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=0, $ishidden=0) { global $conf; @@ -271,7 +276,7 @@ class ExtraFields $params=''; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable, perms, list)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable, perms, list, ishidden)"; $sql.= " VALUES('".$attrname."',"; $sql.= " '".$this->db->escape($label)."',"; $sql.= " '".$type."',"; @@ -285,6 +290,7 @@ class ExtraFields $sql.= " '".$alwayseditable."',"; $sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").","; $sql.= " ".$list; + $sql.= ", ".$ishidden; $sql.=')'; dol_syslog(get_class($this)."::create_label", LOG_DEBUG); @@ -389,9 +395,10 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param int $list Into list view by default + * @param int $ishidden Is hidden extrafield * @return int >0 if OK, <=0 if KO */ - function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='',$list='') + function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0, $perms='',$list='',$ishidden=0) { if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'contact') $elementtype='socpeople'; @@ -432,7 +439,7 @@ class ExtraFields { if ($label) { - $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list); + $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$ishidden); } if ($result > 0) { @@ -483,12 +490,13 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param int $list Into list view by default + * @param int $ishidden Is hidden extrafield * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0) + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0,$ishidden=0) { global $conf; - dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list); + dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$ishidden); // Clean parameters if ($elementtype == 'thirdparty') $elementtype='societe'; @@ -526,6 +534,7 @@ class ExtraFields $sql.= " alwayseditable,"; $sql.= " param,"; $sql.= " list"; + $sql.= ", ishidden"; $sql.= ") VALUES ("; $sql.= "'".$attrname."',"; $sql.= " ".$conf->entity.","; @@ -540,6 +549,7 @@ class ExtraFields $sql.= " '".$alwayseditable."',"; $sql.= " '".$param."',"; $sql.= " ".$list; + $sql.= ", ".$ishidden; $sql.= ")"; dol_syslog(get_class($this)."::update_label", LOG_DEBUG); $resql2=$this->db->query($sql); @@ -585,7 +595,7 @@ class ExtraFields // For avoid conflicts with external modules if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list,ishidden"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; @@ -616,6 +626,7 @@ class ExtraFields $this->attribute_alwayseditable[$tab->name]=$tab->alwayseditable; $this->attribute_perms[$tab->name]=$tab->perms; $this->attribute_list[$tab->name]=$tab->list; + $this->attribute_hidden[$tab->name]=$tab->ishidden; } } } diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 174da1ae409..6273ea93940 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -118,6 +118,8 @@ + +global->MAIN_FEATURES_LEVEL >= 2) { ?> + +global->MAIN_FEATURES_LEVEL >= 2) { ?> '; print ''; print ''; print ''; +print ''; print ''; print "\n"; @@ -60,6 +61,7 @@ foreach($extrafields->attribute_type as $key => $value) print '\n"; print '\n"; print '\n"; + print '\n"; print '\n"; print ""; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 8b38cbc5520..9789922e6dc 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -45,7 +45,8 @@ if (empty($reshook) && ! empty($extrafields->attribute_label)) } else { - print ''; - $out .=''; + $html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : ''; + $out .=''; print '
'; @@ -3498,6 +3582,24 @@ else if ($id > 0 || ! empty($ref)) // Total with tax print '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('Status') . '' . ($object->getLibStatut(4, $totalpaye)) . '
trans("Required"); ?>>
trans("AlwaysEditable"); ?>>
trans("IsHidden"); ?>>
trans("ByDefaultInList"); ?> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 5551d848b5f..71b81ecee0f 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -60,6 +60,7 @@ $alwayseditable=$extrafields->attribute_alwayseditable[$attrname]; $param=$extrafields->attribute_param[$attrname]; $perms=$extrafields->attribute_perms[$attrname]; $list=$extrafields->attribute_list[$attrname]; +$ishidden=$extrafields->attribute_hidden[$attrname]; if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_array($param)) { @@ -117,6 +118,8 @@ if(($type == 'select') || ($type == 'sellist') || ($type == 'checkbox') || ($typ
trans("Required"); ?>>
trans("AlwaysEditable"); ?>>
trans("IsHidden"); ?>>
trans("ByDefaultInList"); ?> diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index a5890e36ea2..adb04bbc540 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -44,6 +44,7 @@ print ''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").''.$langs->trans("AlwaysEditable").''.$langs->trans("IsHidden").' 
'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.yn($extrafields->attribute_alwayseditable[$key])."'.yn($extrafields->attribute_hidden[$key])."'.img_edit().''; print "  ".img_delete()."
'; + if (!empty($extrafields->attribute_hidden[$key])) print '
'; + else print '
'; print 'attribute_required[$key])) print ' class="fieldrequired"'; 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 9ac450b90f8..e10746958aa 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 @@ -76,7 +76,7 @@ ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website,pa ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); - +ALTER TABLE llx_extrafields ADD COLUMN ishidden integer DEFAULT 0; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index 9ccbdf60bff..062f20b5c9f 100644 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -34,4 +34,5 @@ create table llx_extrafields alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status param text, -- extra parameters to define possible values of field list integer DEFAULT 0 -- list of values for field that are combo lists + ,ishidden integer DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 55eb22f0aee..cc596bae7e8 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1641,6 +1641,7 @@ CloseFiscalYear=Close fiscal year DeleteFiscalYear=Delete fiscal year ConfirmDeleteFiscalYear=Are you sure to delete this fiscal year ? AlwaysEditable=Can always be edited +IsHidden=Is not visible MAIN_APPLICATION_TITLE=Force visible name of application (warning: setting your own name here may break autofill login feature when using DoliDroid mobile application) NbMajMin=Minimum number of uppercase characters NbNumMin=Minimum number of numeric characters From 7b456d23f0dd35ed3c66730f660f6880c2f36a1f Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 3 Feb 2016 22:53:15 +0100 Subject: [PATCH 028/421] FIX if we add extrafield on socpeople we got sql error on the list of contact --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index c916710e087..b319072dc68 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -218,7 +218,7 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contact_extrafields as ef on (p.rowid = ef.fk_object)"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (p.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cs ON p.rowid = cs.fk_socpeople"; // We need this table joined to the select in order to filter by categ From 0c05342934d37dbb031ed6c996bbf0e67a9bbb2d Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 3 Feb 2016 22:54:48 +0100 Subject: [PATCH 029/421] FIX infinite loop --- htdocs/core/class/html.formpropal.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.formpropal.class.php b/htdocs/core/class/html.formpropal.class.php index d64cd23e98d..57dd6336a43 100644 --- a/htdocs/core/class/html.formpropal.class.php +++ b/htdocs/core/class/html.formpropal.class.php @@ -83,6 +83,7 @@ class FormPropal { $obj = $this->db->fetch_object($resql); $listofstatus[$obj->id]=array('id'=>$obj->id,'code'=>$obj->code,'label'=>$obj->label); + $i++; } } } From 490f3eaf82f5e6fc25d335f1e89d73ff87d26cb6 Mon Sep 17 00:00:00 2001 From: abcnet-lu Date: Thu, 4 Feb 2016 14:41:26 +0100 Subject: [PATCH 030/421] [#4566] Add legal forms for Luxembourg --- htdocs/install/mysql/data/llx_c_forme_juridique.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/install/mysql/data/llx_c_forme_juridique.sql b/htdocs/install/mysql/data/llx_c_forme_juridique.sql index 52d488d3706..550190a89c5 100644 --- a/htdocs/install/mysql/data/llx_c_forme_juridique.sql +++ b/htdocs/install/mysql/data/llx_c_forme_juridique.sql @@ -278,3 +278,13 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15404', 'Sociedad anónima', 1); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15405', 'Sociedad en comandita por acciones', 1); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (154, '15406', 'Sociedad cooperativa', 1); + +-- Luxembourg +INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (140, '14001', 'Entreprise individuelle', 1); +INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (140, '14002', 'Société en nom collectif (SENC)', 1); +INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (140, '14003', 'Société en commandite simple (SECS)', 1); +INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (140, '14004', 'Société en commandite par actions (SECA)', 1); +INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (140, '14005', 'Société à responsabilité limitée (SARL)', 1); +INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (140, '14006', 'Société anonyme (SA)', 1); +INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (140, '14007', 'Société coopérative (SC)', 1); +INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (140, '14008', 'Société européenne (SE)', 1); From f87bfffdd96b1f203fed705c479fdb46d8f927d9 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Thu, 4 Feb 2016 16:12:00 +0100 Subject: [PATCH 031/421] add edition feacture on product element --- .../core/modules/product/modules_product.php | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 htdocs/core/modules/product/modules_product.php diff --git a/htdocs/core/modules/product/modules_product.php b/htdocs/core/modules/product/modules_product.php new file mode 100644 index 00000000000..afe07e39503 --- /dev/null +++ b/htdocs/core/modules/product/modules_product.php @@ -0,0 +1,52 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2016 Charlie Benke + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + +/** + * \class ModeleProduct + * \brief Parent class for product models of doc generators + */ +abstract class ModeleProduct extends CommonDocGenerator +{ + var $error=''; + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='product'; + $liste=array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + + return $liste; + } +} From db0c8740b9321742a092727c1c6c6ca1d644183e Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Thu, 4 Feb 2016 16:17:45 +0100 Subject: [PATCH 032/421] add administration feature of products docs --- htdocs/product/admin/product.php | 226 ++++++++++++++++++++++++++++++- 1 file changed, 224 insertions(+), 2 deletions(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 57f6577f789..15b113ffffb 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -7,6 +7,7 @@ * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2012 Cedric Salvador + * Copyright (C) 2016 Charlie Benke * * 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 @@ -42,6 +43,9 @@ if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->e $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); +$type = GETPOST('type','alpha'); +$label = GETPOST('label','alpha'); +$scandir = GETPOST('scandir','alpha'); // Pricing Rules $select_pricing_rules=array( @@ -98,12 +102,13 @@ if ($action == 'setModuleOptions') if (! $error) { $db->commit(); - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + //setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); - setEventMessages($langs->trans("Error"), null, 'errors'); + // message yet present at the bottom if($action) + //setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -171,6 +176,86 @@ if ($action == 'other') $value = GETPOST('activate_usesearchtoselectproduct','alpha'); $res = dolibarr_set_const($db, "PRODUIT_USE_SEARCH_TO_SELECT", $value,'chaine',0,'',$conf->entity); } + +if ($action == 'specimen') // For products +{ + $modele= GETPOST('module','alpha'); + + $inter = new Fichinter($db); + $inter->initAsSpecimen(); + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/product/doc/pdf_".$modele.".modules.php",0); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($inter,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=products&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessage($obj->error,'errors'); + dol_syslog($obj->error, LOG_ERR); + } + } + else + { + setEventMessage($langs->trans("ErrorModuleNotFound"),'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + +// Activate a model +if ($action == 'set') +{ + $ret = addDocumentModel($value, $type, $label, $scandir); +} + +if ($action == 'del') +{ + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->PRODUCT_ADDON_PDF == "$value") dolibarr_del_const($db, 'PRODUCT_ADDON_PDF',$conf->entity); + } +} + +// Set default model +if ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "PRODUCT_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->PRODUCT_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + + if ($action == 'set') { $const = "PRODUCT_SPECIAL_".strtoupper(GETPOST('spe','alpha')); @@ -314,6 +399,143 @@ foreach ($dirproduct as $dirroot) } print '
'; + +print '
'; +print_titre($langs->trans("ModelModulesProduct")); + +// Load array def with activated templates +$def = array(); +$sql = "SELECT nom"; +$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql.= " WHERE type = 'product'"; +$sql.= " AND entity = ".$conf->entity; +$resql=$db->query($sql); +if ($resql) +{ + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} +else +{ + dol_print_error($db); +} + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +$var=true; +foreach ($dirproduct as $dirroot) +{ + $dir = dol_buildpath($dirroot.'core/modules/product/doc/',0); + $handle=@opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (preg_match('/\.modules\.php$/i',$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); + + try { + dol_include_once($dirroot.'core/modules/product/doc/'.$file); + } + catch(Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } + + $module = new $classname($db); + + $modulequalified=1; + if (! empty($module->version)) { + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + } + + if ($modulequalified) + { + $var = !$var; + print ''; + + // Activate / Disable + if (in_array($name, $def)) + { + print ""; + } + else + { + if (versioncompare($module->phpmin,versionphparray()) > 0) + { + print ""; + } + else + { + print ""; + } + } + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("WatermarkOnDraft").': '.yn((! empty($module->option_draft_watermark)?$module->option_draft_watermark:''), 1, 1); + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + closedir($handle); + } +} +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print $module->name; + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print '\n"; + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print "\n"; + print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'switch_off'); + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print "'; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + if ($module->type == 'pdf') + { + $linkspec=''.img_object($langs->trans("Preview"),'bill').''; + } + else + { + $linkspec=img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print $linkspec; + print '
'; + /* * Other conf */ From 0517435797c72fc338e8a3acf46dc05ba94c450f Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Thu, 4 Feb 2016 16:21:27 +0100 Subject: [PATCH 033/421] add product document generation --- htdocs/product/card.php | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index d65c7fe1f35..bdfdf986d17 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -13,6 +13,7 @@ * Copyright (C) 2014-2015 Ferran Marcet * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Charlie Benke * * 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 @@ -44,6 +45,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.php'; + if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -125,7 +128,33 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } + /* + * Build doc + */ + else if ($action == 'builddoc' && $user->rights->produit->creer) + { + // Save last template used to generate document + if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); + + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=product_create($db, $object, GETPOST('model','alpha'), $outputlangs); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + } + // Barcode type if ($action == 'setfk_barcode_type' && $createbarcode) { @@ -1649,7 +1678,28 @@ if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf-> { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',250,600); } +print '
'; +print ''; // ancre +/* + * Documents generes + */ +$filedir=$conf->product->dir_output.'/product/'.$object->id; + +$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; +$genallowed=$user->rights->produit->creer; +$delallowed=$user->rights->produit->supprimer; + +$var=true; + +$somethingshown=$formfile->show_documents('product',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang); + +print '
'; + + +print '
'; + +print '

'; /* ************************************************************************** */ From 1e9ea4f2ac181fe9a357692d65516057f8db42cc Mon Sep 17 00:00:00 2001 From: abcnet-lu Date: Thu, 4 Feb 2016 16:40:49 +0100 Subject: [PATCH 034/421] [#4568] Add professional IDs for Luxembourg --- htdocs/langs/de_DE/companies.lang | 6 ++++++ htdocs/langs/en_US/companies.lang | 6 ++++++ htdocs/langs/fr_FR/companies.lang | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/htdocs/langs/de_DE/companies.lang b/htdocs/langs/de_DE/companies.lang index caca577779f..7efd00d61ff 100644 --- a/htdocs/langs/de_DE/companies.lang +++ b/htdocs/langs/de_DE/companies.lang @@ -202,6 +202,12 @@ ProfId3IN=Prof Id 3 ProfId4IN=Prof Id 4 ProfId5IN=Prof Id 5 ProfId6IN=- +ProfId1LU=Id. prof. 1 (RCS) +ProfId2LU=Id. prof. 2 (Niederlassungsgenehmigung) +ProfId3LU=- +ProfId4LU=- +ProfId5LU=- +ProfId6LU=- ProfId1MA=Id prof. 1 (R.C.) ProfId2MA=Id prof. 2 (Patente) ProfId3MA=Id prof. 3 (I.F.) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 292fcafe238..588867b1f2f 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -202,6 +202,12 @@ ProfId3IN=Prof Id 3 (SRVC TAX) ProfId4IN=Prof Id 4 ProfId5IN=Prof Id 5 ProfId6IN=- +ProfId1LU=Id. prof. 1 (RCS) +ProfId2LU=Id. prof. 2 (Business permit) +ProfId3LU=- +ProfId4LU=- +ProfId5LU=- +ProfId6LU=- ProfId1MA=Id prof. 1 (R.C.) ProfId2MA=Id prof. 2 (Patente) ProfId3MA=Id prof. 3 (I.F.) diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index d9a85c72175..7c64149b5bf 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -202,6 +202,12 @@ ProfId3IN=Id. prof. 3 (SRVC TAX) ProfId4IN=Id. prof. 4 ProfId5IN=Id. prof. 5 ProfId6IN=- +ProfId1LU=Id. prof. 1 (RCS) +ProfId2LU=Id. prof. 2 (Autorisation d'établissement) +ProfId3LU=- +ProfId4LU=- +ProfId5LU=- +ProfId6LU=- ProfId1MA=Id. prof. 1 (R.C.) ProfId2MA=Id. prof. 2 (Patente) ProfId3MA=Id. prof. 3 (I.F.) From 87c5854382640069f4895e4b3253b968b6f22c00 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Thu, 4 Feb 2016 16:58:19 +0100 Subject: [PATCH 035/421] just change for rerun travis cheking --- htdocs/core/tpl/contacts.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 4908d162f8b..de3d79a790d 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2015 Laurent Destailleur +/* Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013-2015 Laurent Destailleur * Copyright (C) 2015-2016 Charlie BENKE * * This program is free software; you can redistribute it and/or modify From a65660712267f780dc47d812fe5e3e4679263c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 4 Feb 2016 17:12:58 +0100 Subject: [PATCH 036/421] Update CMailFile.class.php --- htdocs/core/class/CMailFile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index b3da46ff366..9f6f0995ded 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -375,7 +375,7 @@ class CMailFile if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { - dol_include_once('/core/class/hookmanager.class.php'); + require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); $hookmanager->initHooks(array( 'maildao' From 69e0f1ebc3405af903067c49a32582ec7b741265 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Feb 2016 17:55:30 +0100 Subject: [PATCH 037/421] Add log to help debug --- htdocs/main.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 25176c6bc93..39fd1a8eb1a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1501,7 +1501,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a /** * Show left menu bar * - * @param array $menu_array_before Table of menu entries to show before entries of menu handler + * @param array $menu_array_before Table of menu entries to show before entries of menu handler. This param is deprectaed and must be provided to ''. * @param string $helppagename Name of wiki page for help ('' by default). * Syntax is: For a wiki page: EN:EnglishPage|FR:FrenchPage|ES:SpanishPage * For other external page: http://server/url @@ -1519,6 +1519,8 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me $searchform=''; $bookmarks=''; + if (! empty($menu_array_before)) dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING); + if (empty($conf->dol_hide_leftmenu)) { // Instantiate hooks of thirdparty module From 70e051a1bf01c953e6e474f85719376e5a8aee1b Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Thu, 4 Feb 2016 18:05:35 +0100 Subject: [PATCH 038/421] Add goods customers boxes --- htdocs/core/boxes/box_bonsclients.php | 168 ++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 htdocs/core/boxes/box_bonsclients.php diff --git a/htdocs/core/boxes/box_bonsclients.php b/htdocs/core/boxes/box_bonsclients.php new file mode 100644 index 00000000000..0f650e6775c --- /dev/null +++ b/htdocs/core/boxes/box_bonsclients.php @@ -0,0 +1,168 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Charlie Benke + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_clients.php + * \ingroup societes + * \brief Module de generation de l'affichage de la box clients + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last thirdparties + */ +class box_bonsclients extends ModeleBoxes +{ + var $boxcode="goodcustomers"; + var $boximg="object_company"; + var $boxlabel="BoxGoodCustomers"; + var $depends = array("societe"); + + var $db; + var $enabled = 1; + + var $info_box_head = array(); + var $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + function __construct($db,$param='') + { + global $conf, $user; + + $this->db = $db; + + // disable box for such cases + if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + function loadBox($max=5) + { + global $user, $langs, $db, $conf; + $langs->load("boxes"); + + $this->max=$max; + + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic=new Societe($db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers",$max)); + + if ($user->rights->societe->lire) + { + + $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; + $sql.= " count(*) as nbfact, sum(if (f.paye=1,1,0)) as nbfactpaye"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; + $sql.= ' WHERE s.entity IN ('.getEntity('societe', 1).')'; + $sql.= ' AND s.rowid = f.fk_soc'; + $sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status"; + $sql.= $db->order("nbfact","DESC"); + $sql.= $db->plimit($max,0); + + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + + $line = 0; + while ($line < $num) + { + $objp = $db->fetch_object($result); + $datem=$db->jdate($objp->tms); + $thirdpartystatic->id = $objp->rowid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; + $nbfact = $objp->nbfact; + $nbimpaye = $objp->nbfact - $objp->nbfactpaye; + + $this->info_box_contents[$line][] = array( + 'td' => 'align="left"', + 'text' => $thirdpartystatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'align="right"', + 'text' => dol_print_date($datem, "day") + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'align="right"', + 'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'') + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'align="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status,3) + ); + + $line++; + } + + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedCustomers")); + + $db->free($result); + } + else { + $this->info_box_contents[0][0] = array( 'td' => 'align="left"', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql)); + } + } + else { + $this->info_box_contents[0][0] = array('align' => 'left', + 'text' => $langs->trans("ReadPermissionNotAllowed")); + } + + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @return void + */ + function showBox($head = null, $contents = null) + { + parent::showBox($this->info_box_head, $this->info_box_contents); + } +} + From 5498b1cd5a9362b61e0950c5006db874af235d5b Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Thu, 4 Feb 2016 18:06:43 +0100 Subject: [PATCH 039/421] Update modSociete.class.php --- htdocs/core/modules/modSociete.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 41fd00e5463..b8032cca13e 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -131,7 +131,9 @@ class modSociete extends DolibarrModules $this->boxes[$r][1] = "box_activity.php"; $this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)'; $r++; - + $this->boxes[$r][1] = "box_bonsclients.php"; + $this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)'; + $r++; // Permissions $this->rights = array(); $this->rights_class = 'societe'; From 9c896b18699834f331dbccb1bf404b042e8e41b1 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Thu, 4 Feb 2016 18:10:28 +0100 Subject: [PATCH 040/421] translations too --- htdocs/langs/en_US/boxes.lang | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 796c058e3b5..6afc6d7b7b2 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -60,6 +60,8 @@ BoxTitleLastContracts=Last %s contracts BoxTitleLastModifiedDonations=Last %s modified donations BoxTitleLastModifiedExpenses=Last %s modified expense reports BoxGlobalActivity=Global activity (invoices, proposals, orders) +BoxGoodCustomers=Good Customers +BoxTitleGoodCustomers= %s Good Customers FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Last successfull refresh date: %s LastRefreshDate=Last refresh date NoRecordedBookmarks=No bookmarks defined. @@ -95,4 +97,4 @@ ForCustomersInvoices=Customers invoices ForCustomersOrders=Customers orders ForProposals=Proposals LastXMonthRolling=The last %s month rolling -ChooseBoxToAdd=Add a box to your dashboard... \ No newline at end of file +ChooseBoxToAdd=Add a box to your dashboard... From 7e3a7876885b791392b3441041e2f5fed7e6fb07 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 4 Feb 2016 19:03:25 +0100 Subject: [PATCH 041/421] FIX phpcs --- htdocs/core/actions_extrafields.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index b91cc49374c..f31e2c184d8 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -161,8 +161,8 @@ if ($action == 'add') $params, (GETPOST('alwayseditable')?1:0), (GETPOST('perms')?GETPOST('perms'):''), - (GETPOST('list')?1:0) - ,(GETPOST('ishidden')?1:0) + (GETPOST('list')?1:0), + (GETPOST('ishidden')?1:0) ); if ($result > 0) { @@ -312,8 +312,8 @@ if ($action == 'update') $params, (GETPOST('alwayseditable')?1:0), (GETPOST('perms')?GETPOST('perms'):''), - (GETPOST('list')?1:0) - ,(GETPOST('ishidden')?1:0) + (GETPOST('list')?1:0), + (GETPOST('ishidden')?1:0) ); if ($result > 0) { From 32c0b2a9b14bdb11d39388d2ee7221282bf840b8 Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 4 Feb 2016 21:05:19 +0100 Subject: [PATCH 042/421] NEW add html id/class to locate value in the DOM html --- htdocs/core/class/commonobject.class.php | 3 ++- htdocs/core/tpl/extrafields_view.tpl.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d90932d1738..d1153a73eda 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4110,7 +4110,8 @@ abstract class CommonObject $label = ''.$label.''; $out .= '
'.$langs->trans($label).''; switch($mode) { case "view": diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 9789922e6dc..f4b817b583d 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -68,7 +68,8 @@ if (empty($reshook) && ! empty($extrafields->attribute_label)) print '' . img_edit().'
'; - print '
'; + $html_id = !empty($object->id) ? $object->element.'_extras_'.$key.'_'.$object->id : ''; + print ''; // Convert date into timestamp format if (in_array($extrafields->attribute_type[$key], array('date','datetime'))) { From a8e480e392fd8b26300d1568aab5a3f4af5478ff Mon Sep 17 00:00:00 2001 From: phf Date: Thu, 4 Feb 2016 23:15:06 +0100 Subject: [PATCH 043/421] FIX #3509 payment ref for suppliers --- htdocs/admin/supplier_payment.php | 220 ++++++++++++++++++ htdocs/core/lib/fourn.lib.php | 5 + .../mod_supplier_payment_brodator.php | 140 +++++++++++ .../mod_supplier_payment_bronan.php | 150 ++++++++++++ .../modules_supplier_payment.php | 101 ++++++++ htdocs/fourn/class/paiementfourn.class.php | 120 +++++++++- .../install/mysql/migration/3.8.0-3.9.0.sql | 3 + .../mysql/tables/llx_paiementfourn.sql | 2 + 8 files changed, 737 insertions(+), 4 deletions(-) create mode 100644 htdocs/admin/supplier_payment.php create mode 100644 htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php create mode 100644 htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php create mode 100644 htdocs/core/modules/supplier_payment/modules_supplier_payment.php diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php new file mode 100644 index 00000000000..41737f7a9d5 --- /dev/null +++ b/htdocs/admin/supplier_payment.php @@ -0,0 +1,220 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/payment.php + * \ingroup facture + * \brief Page to setup invoices payments + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; + +$langs->load("admin"); +$langs->load("errors"); +$langs->load('other'); +$langs->load('bills'); + +if (! $user->admin) accessforbidden(); + +$action = GETPOST('action','alpha'); +$value = GETPOST('value','alpha'); +$label = GETPOST('label','alpha'); +$scandir = GETPOST('scandir','alpha'); + + +/* + * Actions + */ + +if ($action == 'updateMask') +{ + $maskconstsupplierpayment=GETPOST('maskconstsupplierpayment','alpha'); + $masksupplierpayment=GETPOST('masksupplierpayment','alpha'); + if ($maskconstsupplierpayment) $res = dolibarr_set_const($db,$maskconstsupplierpayment,$masksupplierpayment,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + + if ($action == 'setmod') +{ + dolibarr_set_const($db, "SUPPLIER_PAYMENT_ADDON",$value,'chaine',0,'',$conf->entity); +} + +/* + * View + */ + +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + +llxHeader("",$langs->trans("SupplierPaymentSetup"),'EN:Supplier_Payment_Configuration|FR:Configuration_module_paiement_fournisseur'); + +$form=new Form($db); + + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("SupplierPaymentSetup"),$linkback,'title_setup'); + +print "
"; + +$head = supplierorder_admin_prepare_head(); +dol_fiche_head($head, 'supplierpayment', $langs->trans("SupplierPayment"), 0, 'invoice'); + +/* + * Numbering module + */ + +print load_fiche_titre($langs->trans("SupplierPaymentsNumberingModule")); + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''."\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + $var=true; + + while (($file = readdir($handle))!==false) + { + if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) + { + $filebis = $file; + $classname = preg_replace('/\.php$/','',$file); + // For compatibility + if (! is_file($dir.$filebis)) + { + $filebis = $file."/".$file.".modules.php"; + $classname = "mod_supplier_payment_".$file; + } + // Check if there is a filter on country + preg_match('/\-(.*)_(.*)$/',$classname,$reg); + if (! empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + + $classname = preg_replace('/\-.*$/','',$classname); + if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') + { + // Charging the numbering class + require_once $dir.$filebis; + + $module = new $classname($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + $var = !$var; + print ''; + + // Show example of numbering module + print ''."\n"; + + print ''; + + $payment=new PaiementFourn($db); + $payment->initAsSpecimen(); + + // Example + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval=$module->getNextValue($mysoc,$payment); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + + print "\n"; + + } + } + } + } + closedir($handle); + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'; + echo preg_replace('/\-.*$/','',preg_replace('/mod_supplier_payment_/','',preg_replace('/\.php$/','',$file))); + print "\n"; + + print $module->info(); + + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/',$tmp)) print '
'.$langs->trans($tmp).'
'; + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + //print "> ".$conf->global->SUPPLIER_PAYMENT_ADDON." - ".$file; + if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.'.php' == $file) + { + print img_picto($langs->trans("Activated"),'switch_on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + + if ($conf->global->PAYMENT_ADDON.'.php' == $file) // If module is the one used, we show existing errors + { + if (! empty($module->error)) dol_htmloutput_mesg($module->error,'','error',1); + } + + print '
'; + +dol_fiche_end(); + + +llxFooter(); + +$db->close(); diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index fdeece84d52..19d6429cc6e 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -178,6 +178,11 @@ function supplierorder_admin_prepare_head() $head[$h][1] = $langs->trans("SuppliersInvoice"); $head[$h][2] = 'invoice'; $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/supplier_payment.php"; + $head[$h][1] = $langs->trans("SuppliersPayment"); + $head[$h][2] = 'supplierpayment'; + $h++; complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin'); diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php new file mode 100644 index 00000000000..fb06c028aed --- /dev/null +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php @@ -0,0 +1,140 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php + * \ingroup supplier_payment + * \brief File containing class for numbering module Brodator + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier_payment.php'; + + +/** + * Class to manage customer payment numbering rules Ant + */ +class mod_supplier_payment_brodator extends ModeleNumRefPayments +{ + var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' + var $error = ''; + var $nom = 'Brodator'; + + + /** + * Renvoi la description du modele de numerotation + * + * @return string Texte descripif + */ + function info() + { + global $conf,$langs; + + $langs->load("bills"); + + $form = new Form($this->db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; + $texte.= '
'; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Order"),$langs->transnoentities("Order")); + $tooltip.=$langs->trans("GenericMaskCodes2"); + $tooltip.=$langs->trans("GenericMaskCodes3"); + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Order"),$langs->transnoentities("Order")); + $tooltip.=$langs->trans("GenericMaskCodes5"); + + // Parametrage du prefix + $texte.= ''; + $texte.= ''; + + $texte.= ''; + + $texte.= ''; + + $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('',$tooltip,1,1).' 
'; + $texte.= '
'; + + return $texte; + } + + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + function getExample() + { + global $conf,$langs,$mysoc; + + $old_code_client=$mysoc->code_client; + $mysoc->code_client='CCCCCCCCCC'; + $numExample = $this->getNextValue($mysoc,''); + $mysoc->code_client=$old_code_client; + + if (! $numExample) + { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next free value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + function getNextValue($objsoc,$object) + { + global $db,$conf; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + + // We get cursor rule + $mask=$conf->global->SUPPLIER_PAYMENT_BRODATOR_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + $numFinal=get_next_value($db,$mask,'paiementfourn','ref','',$objsoc,$object->datepaye); + + return $numFinal; + } + + + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @return string Next free value + */ + function commande_get_num($objsoc,$objforref) + { + return $this->getNextValue($objsoc,$objforref); + } + +} + diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php new file mode 100644 index 00000000000..e7146e2e1fd --- /dev/null +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -0,0 +1,150 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/payment/mod_payment_bronan.php + * \ingroup supplier_payment + * \brief File containing class for numbering module Bronan + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier_payment.php'; + +/** + * Class to manage customer payment numbering rules Cicada + */ +class mod_supplier_payment_bronan extends ModeleNumRefPayments +{ + var $version='dolibarr'; // 'development', 'experimental', 'dolibarr' + var $prefix='SPAY'; + var $error=''; + var $nom='Bronan'; + + + /** + * Return description of numbering module + * + * @return string Text with description + */ + function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); + } + + + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Test si les numeros deje en vigueur dans la base ne provoquent pas de + * de conflits qui empechera cette numerotation de fonctionner. + * + * @return boolean false si conflit, true si ok + */ + function canBeActivated() + { + global $conf,$langs,$db; + + $payyymm=''; $max=''; + + $posindice=9; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; + $sql.= " WHERE ref LIKE '".$this->prefix."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $payyymm = substr($row[0],0,6); $max=$row[0]; } + } + if ($payyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$payyymm)) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next free value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + function getNextValue($objsoc,$object) + { + global $db,$conf; + + // D'abord on recupere la valeur max + $posindice=10; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn"; + $sql.= " WHERE ref like '".$this->prefix."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; + } + else + { + dol_syslog(__METHOD__, LOG_DEBUG); + return -1; + } + + //$date=time(); + $date=$object->datepaye; + $yymm = strftime("%y%m",$date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); + + dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } + + + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @return string Next free value + */ + function payment_get_num($objsoc,$objforref) + { + return $this->getNextValue($objsoc,$objforref); + } + +} diff --git a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php new file mode 100644 index 00000000000..c9023a9fc65 --- /dev/null +++ b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php @@ -0,0 +1,101 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \class ModeleNumRefPayments + * \brief Payment numbering references mother class + */ + +abstract class ModeleNumRefPayments +{ + var $error=''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + function isEnabled() + { + return true; + } + + /** + * Return the default description of numbering module + * + * @return string Texte descripif + */ + function info() + { + global $langs; + $langs->load("bills"); + return $langs->trans("NoDescription"); + } + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + global $langs; + $langs->load("bills"); + return $langs->trans("NoExample"); + } + + /** + * Test if the existing numbers in the database do not cause conflicts that would prevent this numbering run. + * + * @return boolean false si conflit, true si ok + */ + function canBeActivated() + { + return true; + } + + /** + * Returns the next value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Valeur + */ + function getNextValue($objsoc,$object) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Returns the module numbering version + * + * @return string Value + */ + function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index bfdfea41fe4..bb84f8ca917 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -74,7 +74,7 @@ class PaiementFourn extends Paiement { $error=0; - $sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank,'; + $sql = 'SELECT p.rowid, p.ref, p.entity, p.datep as dp, p.amount, p.statut, p.fk_bank,'; $sql.= ' c.code as paiement_code, c.libelle as paiement_type,'; $sql.= ' p.num_paiement, p.note, b.fk_account'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiementfourn as p'; @@ -95,7 +95,8 @@ class PaiementFourn extends Paiement { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->ref = $obj->ref; + $this->entity = $obj->entity; $this->date = $this->db->jdate($obj->dp); $this->numero = $obj->num_paiement; $this->bank_account = $obj->fk_account; @@ -149,11 +150,12 @@ class PaiementFourn extends Paiement if ($this->total <> 0) // On accepte les montants negatifs { + $ref = $this->getNextNumRef(''); $now=dol_now(); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn ('; - $sql.= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)'; - $sql.= " VALUES ('".$this->db->idate($now)."',"; + $sql.= 'ref, entity, datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)'; + $sql.= " VALUES ('".$this->db->escape($ref)."', ".$conf->entity.", '".$this->db->idate($now)."',"; $sql.= " '".$this->db->idate($this->datepaye)."', '".$this->total."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.", 0)"; dol_syslog("PaiementFourn::create", LOG_DEBUG); @@ -513,4 +515,114 @@ class PaiementFourn extends Paiement if ($withpicto != 2) $result.=$link.$text.$linkend; return $result; } + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines + * @return void + */ + function initAsSpecimen($option='') + { + global $user,$langs,$conf; + + $now=dol_now(); + $arraynow=dol_getdate($now); + $nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); + + // Initialize parameters + $this->id=0; + $this->ref = 'SPECIMEN'; + $this->specimen=1; + $this->facid = 1; + $this->datepaye = $nownotime; + } + + /** + * Return next reference of supplier invoice not already used (or last reference) + * according to numbering module defined into constant SUPPLIER_PAYMENT_ADDON + * + * @param Societe $soc object company + * @param string $mode 'next' for next value or 'last' for last value + * @return string free ref or last ref + */ + function getNextNumRef($soc,$mode='next') + { + global $conf, $db, $langs; + $langs->load("bills"); + + // Clean parameters (if not defined or using deprecated value) + if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) $conf->global->SUPPLIER_PAYMENT_ADDON='mod_supplier_payment_bronan'; + else if ($conf->global->SUPPLIER_PAYMENT_ADDON=='brodator') $conf->global->SUPPLIER_PAYMENT_ADDON='mod_supplier_payment_brodator'; + else if ($conf->global->SUPPLIER_PAYMENT_ADDON=='bronan') $conf->global->SUPPLIER_PAYMENT_ADDON='mod_supplier_payment_bronan'; + + if (! empty($conf->global->SUPPLIER_PAYMENT_ADDON)) + { + $mybool=false; + + $file = $conf->global->SUPPLIER_PAYMENT_ADDON.".php"; + $classname = $conf->global->SUPPLIER_PAYMENT_ADDON; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + + foreach ($dirmodels as $reldir) { + + $dir = dol_buildpath($reldir."core/modules/supplier_payment/"); + + // Load file with numbering class (if found) + if (is_file($dir.$file) && is_readable($dir.$file)) + { + $mybool |= include_once $dir . $file; + } + } + + // For compatibility + if (! $mybool) + { + $file = $conf->global->SUPPLIER_PAYMENT_ADDON.".php"; + $classname = "mod_supplier_payment_".$conf->global->SUPPLIER_PAYMENT_ADDON; + $classname = preg_replace('/\-.*$/','',$classname); + // Include file with class + foreach ($conf->file->dol_document_root as $dirroot) + { + $dir = $dirroot."/core/modules/supplier_payment/"; + + // Load file with numbering class (if found) + if (is_file($dir.$file) && is_readable($dir.$file)) { + $mybool |= include_once $dir . $file; + } + } + } + + if (! $mybool) + { + dol_print_error('',"Failed to include file ".$file); + return ''; + } + + $obj = new $classname(); + $numref = ""; + $numref = $obj->getNextValue($soc,$this); + + /** + * $numref can be empty in case we ask for the last value because if there is no invoice created with the + * set up mask. + */ + if ($mode != 'last' && !$numref) { + dol_print_error($db,"SupplierPayment::getNextNumRef ".$obj->error); + return ""; + } + + return $numref; + } + else + { + $langs->load("errors"); + print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); + return ""; + } + } } diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 7c372a5c394..24fd141a217 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -583,3 +583,6 @@ ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN doc_ref varchar(300) NOT NU ALTER TABLE llx_holiday ADD COLUMN tms timestamp; ALTER TABLE llx_holiday ADD COLUMN entity integer DEFAULT 1 NOT NULL; + +ALTER TABLE llx_paiementfourn ADD COLUMN ref varchar(30) AFTER rowid; +ALTER TABLE llx_paiementfourn ADD COLUMN entity integer AFTER ref; diff --git a/htdocs/install/mysql/tables/llx_paiementfourn.sql b/htdocs/install/mysql/tables/llx_paiementfourn.sql index 701899d5a2f..cbcc93d9b0f 100644 --- a/htdocs/install/mysql/tables/llx_paiementfourn.sql +++ b/htdocs/install/mysql/tables/llx_paiementfourn.sql @@ -20,6 +20,8 @@ create table llx_paiementfourn ( rowid integer AUTO_INCREMENT PRIMARY KEY, + ref varchar(30), + entity integer DEFAULT 1, tms timestamp, datec datetime, -- date de creation de l'enregistrement datep datetime, -- date de paiement From 0ae8a3398d5b0158ae97a80ba7e1e84e65fa5f9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Feb 2016 10:56:45 +0100 Subject: [PATCH 044/421] Fix sql error when extrafields on contact --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index c916710e087..b319072dc68 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -218,7 +218,7 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contact_extrafields as ef on (p.rowid = ef.fk_object)"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (p.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cs ON p.rowid = cs.fk_socpeople"; // We need this table joined to the select in order to filter by categ From e1da95871a02c9f39cc987de6097691517bea2ef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Feb 2016 12:23:16 +0100 Subject: [PATCH 045/421] Fix bad name --- htdocs/core/js/select2_locale.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/js/select2_locale.js.php b/htdocs/core/js/select2_locale.js.php index 2600182dfa1..660b41820df 100644 --- a/htdocs/core/js/select2_locale.js.php +++ b/htdocs/core/js/select2_locale.js.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/core/js/timepicker.js.php + * \file htdocs/core/js/select2_locale.js.php * \brief File that include javascript functions for timepicker */ From 713050bd57e618f71debed9a81a0d70fe9665274 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Feb 2016 12:46:41 +0100 Subject: [PATCH 046/421] Fix style on payment page --- htdocs/fourn/facture/paiement.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index c4b2e4c01f6..253b55b4659 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -283,10 +283,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; + dol_fiche_head(''); + print ''; - print ''; - print ''; } print '
'.$langs->trans('Payment').'
'.$langs->trans('Company').''; + print '
'.$langs->trans('Company').''; $supplierstatic->id=$obj->socid; $supplierstatic->name=$obj->name; print $supplierstatic->getNomUrl(1,'supplier'); @@ -312,7 +313,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print '
 
'; - + dol_fiche_end(); $parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -339,7 +340,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { $i = 0; print '
'; - print $langs->trans('Invoices').'
'; if(!empty($conf->global->FAC_AUTO_FILLJS)){ //Add js for AutoFill @@ -351,15 +351,15 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ' });'."\n"; print ' '."\n"; } - print ''; + print '
'; print ''; - print ''; + print ''; print ''; print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; $var=True; @@ -425,7 +425,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if ($action != 'add_paiement') { print '
'.$langs->trans("ClosePaidInvoicesAutomatically"); - print '
'; + print '
'; } // Form to confirm payment From ede4453164c2432d1145626a8c5a4cf9335d07e2 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Fri, 5 Feb 2016 12:59:32 +0100 Subject: [PATCH 047/421] Fix: Avoid errors when batch stock is negative --- htdocs/expedition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index c7d91a28ce5..ea82a63732a 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -882,7 +882,7 @@ if ($action == 'create') if ($defaultqty<=0) { $defaultqty=0; } else { - $defaultqty -= min($defaultqty,$substock); + $defaultqty -= ($substock > 0 ? min($defaultqty,$substock) : 0); } $subj++; } From 36c7697b63ef561f261853327fd0ef98aa49562f Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 5 Feb 2016 13:43:06 +0100 Subject: [PATCH 048/421] FIX: retrieve correct pu_ttc (set by printObjectLine function) like in 3.7 --- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index d61831cfec2..7d570531213 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -124,7 +124,7 @@ $coldisplay=-1; // We remove first td if ($inputalsopricewithtax) { $coldisplay++; - print ''; } From f0aef885893cd217904eddb63c7a907e76abed4b Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 5 Feb 2016 13:49:19 +0100 Subject: [PATCH 049/421] better fix --- htdocs/core/class/commonobject.class.php | 4 +++- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1cf042e9d13..a78a1cfea49 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3051,6 +3051,8 @@ abstract class CommonObject $text.= ' - '.(! empty($line->label)?$line->label:$label); $description.=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($line->description)); // Description is what to show on popup. We shown nothing if already into desc. } + + $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer @@ -3074,7 +3076,7 @@ abstract class CommonObject if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"'; else $placeholder=' title="'.$langs->trans("Label").'"'; - $pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); + $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 7d570531213..d61831cfec2 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -124,7 +124,7 @@ $coldisplay=-1; // We remove first td if ($inputalsopricewithtax) { $coldisplay++; - print ''; } From bf7181a0640df531b033c507e501bb206392733f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Feb 2016 18:37:01 +0100 Subject: [PATCH 050/421] All messages separated with , into errorsToString --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c281d9bebbd..019be7fcc09 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -381,7 +381,7 @@ abstract class CommonObject */ function errorsToString() { - return $this->error.(is_array($this->errors)?(($this->error!=''?' ':'').join(',',$this->errors)):''); + return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):''); } /** From 7a6c7f10a6c14bcd93003a0e7ee29277d9d65535 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 5 Feb 2016 19:14:40 +0100 Subject: [PATCH 051/421] FIX: add missing global def for ttc column --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 99e497046e0..704bc097db7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2540,7 +2540,7 @@ abstract class CommonObject */ function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { - global $conf,$langs,$user,$object,$hookmanager; + global $conf,$langs,$user,$object,$hookmanager,$inputalsopricewithtax; print ''; From 0cee4b016bb682c52a4925e97591dff4dfebbf9b Mon Sep 17 00:00:00 2001 From: Sof Date: Fri, 5 Feb 2016 19:46:01 +0100 Subject: [PATCH 052/421] FIX : Typo --- htdocs/product/stock/product.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 7038c745364..ba083cc1527 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -714,12 +714,12 @@ if ($resql) print ''; // Sell price print ''; // Value sell print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).''; else print $langs->trans("Variable"); print ''; ; $total += $obj->reel; @@ -782,12 +782,12 @@ print ''; print ''; // Value to sell print ''; print ""; From fd7a05490d429ac032574f4e1d64b00b55528908 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Feb 2016 20:06:07 +0100 Subject: [PATCH 053/421] DiscountOffered text was too long --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 +- .../core/modules/supplier_proposal/doc/pdf_aurore.modules.php | 2 +- htdocs/langs/en_US/bills.lang | 1 + htdocs/langs/fr_FR/bills.lang | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 7a4621cc396..796e225b268 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1253,7 +1253,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 8266efe74a5..22bfcb6e6d8 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1184,7 +1184,7 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 4a14998d0c4..cc7123bba7e 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -1051,7 +1051,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle, 0, $outputlangs), $useborder, 'R', 1); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 20f6fe0619c..392050c6cd5 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -196,6 +196,7 @@ Rest=Pending AmountExpected=Amount claimed ExcessReceived=Excess received EscompteOffered=Discount offered (payment before term) +EscompteOfferedShort=Discount SendBillRef=Submission of invoice %s SendReminderBillRef=Submission of invoice %s (reminder) StandingOrders=Standing orders diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 86019a751ab..ccd0160bf09 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -199,6 +199,7 @@ Rest=Créance AmountExpected=Montant réclamé ExcessReceived=Trop perçu EscompteOffered=Escompte (règlement avant échéance) +EscompteOfferedShort=Escompte SendBillRef=Envoi de la facture %s SendReminderBillRef=Relance de la facture %s (rappel) StandingOrders=Prélèvements From eb48e84b34217167d18d84534d2c3d353b148d17 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Fri, 5 Feb 2016 23:37:04 +0100 Subject: [PATCH 054/421] name of boxe file changed --- .../core/boxes/{box_bonsclients.php => box_goodcustomers.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename htdocs/core/boxes/{box_bonsclients.php => box_goodcustomers.php} (99%) diff --git a/htdocs/core/boxes/box_bonsclients.php b/htdocs/core/boxes/box_goodcustomers.php similarity index 99% rename from htdocs/core/boxes/box_bonsclients.php rename to htdocs/core/boxes/box_goodcustomers.php index 0f650e6775c..734d1885824 100644 --- a/htdocs/core/boxes/box_bonsclients.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -31,7 +31,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; /** * Class to manage the box to show last thirdparties */ -class box_bonsclients extends ModeleBoxes +class box_goodcustomers extends ModeleBoxes { var $boxcode="goodcustomers"; var $boximg="object_company"; From e2afe5460e1fb6210b7ae6bad8a566da88d00aa1 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Fri, 5 Feb 2016 23:37:31 +0100 Subject: [PATCH 055/421] Update modSociete.class.php --- htdocs/core/modules/modSociete.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index b8032cca13e..f0d04d30990 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -131,7 +131,7 @@ class modSociete extends DolibarrModules $this->boxes[$r][1] = "box_activity.php"; $this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)'; $r++; - $this->boxes[$r][1] = "box_bonsclients.php"; + $this->boxes[$r][1] = "box_goodcustomers.php"; $this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)'; $r++; // Permissions From 59c9d8527509cb2141118d9ac509a60826d48951 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Fri, 5 Feb 2016 23:38:04 +0100 Subject: [PATCH 056/421] Update boxes.lang --- htdocs/langs/en_US/boxes.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 6afc6d7b7b2..57bfc174ec5 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -61,7 +61,7 @@ BoxTitleLastModifiedDonations=Last %s modified donations BoxTitleLastModifiedExpenses=Last %s modified expense reports BoxGlobalActivity=Global activity (invoices, proposals, orders) BoxGoodCustomers=Good Customers -BoxTitleGoodCustomers= %s Good Customers +BoxTitleGoodCustomers=%s Good Customers FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Last successfull refresh date: %s LastRefreshDate=Last refresh date NoRecordedBookmarks=No bookmarks defined. From 9c74af63af3a56f1bad38fa6e351991679178bd2 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sat, 6 Feb 2016 12:06:05 +0100 Subject: [PATCH 057/421] Dictionnary for label sticker and card format --- htdocs/admin/dict.php | 13 +- htdocs/core/lib/format_cards.lib.php | 135 +++--------------- .../modules/member/doc/pdf_standard.class.php | 11 +- .../doc/pdf_standardlabel.class.php | 11 +- .../printsheet/doc/pdf_tcpdflabel.class.php | 11 +- .../install/mysql/migration/3.9.0-4.0.0.sql | 33 +++++ .../mysql/tables/llx_c_format_cards.sql | 39 +++++ 7 files changed, 134 insertions(+), 119 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_c_format_cards.sql diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 17033845f8c..18c112f987f 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -77,7 +77,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,0,25,0,26); +$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26); // Name of SQL tables of dictionaries $tabname=array(); @@ -110,6 +110,7 @@ $tabname[26]= MAIN_DB_PREFIX."c_units"; $tabname[27]= MAIN_DB_PREFIX."c_stcomm"; $tabname[28]= MAIN_DB_PREFIX."c_holiday_types"; $tabname[29]= MAIN_DB_PREFIX."c_lead_status"; +$tabname[30]= MAIN_DB_PREFIX."c_format_cards"; // Dictionary labels $tablib=array(); @@ -142,6 +143,7 @@ $tablib[26]= "DictionaryUnits"; $tablib[27]= "DictionaryProspectStatus"; $tablib[28]= "DictionaryHolidayTypes"; $tablib[29]= "DictionaryOpportunityStatus"; +$tablib[30]= "DictionaryFormatCards"; // Requests to extract data $tabsql=array(); @@ -174,6 +176,7 @@ $tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".M $tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newByMonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; $tabsql[29]= "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; +$tabsql[30]= "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -206,6 +209,7 @@ $tabsqlsort[26]="code ASC"; $tabsqlsort[27]="code ASC"; $tabsqlsort[28]="country ASC, code ASC"; $tabsqlsort[29]="position ASC"; +$tabsqlsort[30]="code ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); @@ -238,6 +242,7 @@ $tabfield[26]= "code,label,short_label"; $tabfield[27]= "code,libelle"; $tabfield[28]= "code,label,affect,delay,newByMonth,country_id,country"; $tabfield[29]= "code,label,percent,position"; +$tabfield[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); @@ -270,6 +275,7 @@ $tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27]= "code,libelle"; $tabfieldvalue[28]= "code,label,affect,delay,newByMonth,country"; $tabfieldvalue[29]= "code,label,percent,position"; +$tabfieldvalue[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); @@ -302,6 +308,7 @@ $tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27]= "code,libelle"; $tabfieldinsert[28]= "code,label,affect,delay,newByMonth,fk_country"; $tabfieldinsert[29]= "code,label,percent,position"; +$tabfieldinsert[30]= "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on @@ -336,6 +343,7 @@ $tabrowid[26]= ""; $tabrowid[27]= "id"; $tabrowid[28]= ""; $tabrowid[29]= ""; +$tabrowid[30]= ""; // Condition to show dictionary in setup page $tabcond=array(); @@ -368,6 +376,7 @@ $tabcond[26]= ! empty($conf->product->enabled); $tabcond[27]= ! empty($conf->societe->enabled); $tabcond[28]= ! empty($conf->holiday->enabled); $tabcond[29]= ! empty($conf->projet->enabled); +$tabcond[30]= ! empty($conf->label->enabled); // List of help for fields $tabhelp=array(); @@ -400,6 +409,7 @@ $tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newByMonth'=>$langs->trans("NbAddedAutomatically")); $tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList")); +$tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize")); // List of check for fields (NOT USED YET) $tabfieldcheck=array(); @@ -432,6 +442,7 @@ $tabfieldcheck[26] = array(); $tabfieldcheck[27] = array(); $tabfieldcheck[28] = array(); $tabfieldcheck[29] = array(); +$tabfieldcheck[30] = array(); // Complete all arrays with entries found into modules complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck); diff --git a/htdocs/core/lib/format_cards.lib.php b/htdocs/core/lib/format_cards.lib.php index b0b865c89f4..f86468aeb9f 100644 --- a/htdocs/core/lib/format_cards.lib.php +++ b/htdocs/core/lib/format_cards.lib.php @@ -1,7 +1,7 @@ * Copyright (C) 2006 Rodolphe Quiedeville - * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -31,118 +31,29 @@ global $_Avery_Labels; // To get into inch, just /25.4 // Size of pages available on: http://www.worldlabel.com/Pages/pageaverylabels.htm // _PosX = marginLeft+(_COUNTX*(width+SpaceX)); -$_Avery_Labels = array ( - '5160'=>array('name'=>'Avery-5160, WL-875WX', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>5.58165, // 0.21975 inch - 'marginTop'=>12.7, // 0.5 inch - 'NX'=>3, - 'NY'=>10, - 'SpaceX'=>3.556, // 0.14 inch - 'SpaceY'=>0, - 'width'=>65.8749, // 2.59350 inch - 'height'=>25.4, // 1 inch - 'font-size'=>7), - '5161'=>array('name'=>'Avery-5161, WL-75WX', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>4.445, // 0.175 inch - 'marginTop'=>12.7, - 'NX'=>2, - 'NY'=>10, - 'SpaceX'=>3.968, // 0.15625 inch - 'SpaceY'=>0, - 'width'=>101.6, // 4 inch - 'height'=>25.4, // 1 inch - 'font-size'=>7), - '5162'=>array('name'=>'Avery-5162, WL-100WX', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>3.8735, // 0.1525 inch - 'marginTop'=>22.352, // 0.88 inch - 'NX'=>2, - 'NY'=>7, - 'SpaceX'=>4.954, // 0.195 inch - 'SpaceY'=>0, - 'width'=>101.6, // 4 inch - 'height'=>33.781, // 1.33 inch - 'font-size'=>8), - '5163'=>array('name'=>'Avery-5163, WL-125WX', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>4.572, // 0.18 inch - 'marginTop'=>12.7, // 0.5 inch - 'NX'=>2, - 'NY'=>5, - 'SpaceX'=>3.556, // 0.14 inch - 'SpaceY'=>0, - 'width'=>101.6, // 4 inch - 'height'=>50.8, // 2 inch - 'font-size'=>10), - /* Bugged '5164'=>array('name'=>'5164 (Letter)', - 'paper-size'=>'letter', - 'metric'=>'in', - 'marginLeft'=>0.148, - 'marginTop'=>0.5, - 'NX'=>2, - 'NY'=>3, - 'SpaceX'=>0.2031, - 'SpaceY'=>0, - 'width'=>4.0, - 'height'=>3.33, - 'font-size'=>12), */ - '8600'=>array('name'=>'Avery-8600', - 'paper-size'=>'letter', - 'metric'=>'mm', - 'marginLeft'=>7.1, - 'marginTop'=>19, - 'NX'=>3, - 'NY'=>10, - 'SpaceX'=>9.5, - 'SpaceY'=>3.1, - 'width'=>66.6, - 'height'=>25.4, - 'font-size'=>7), - 'L7163'=>array('name'=>'Avery-L7163', - 'paper-size'=>'A4', - 'metric'=>'mm', - 'marginLeft'=>5, - 'marginTop'=>15, - 'NX'=>2, - 'NY'=>7, - 'SpaceX'=>2.5, - 'SpaceY'=>0, - 'width'=>99.1, - 'height'=>38.1, - 'font-size'=>8), - // 85.0 x 54.0 mm - 'AVERYC32010'=>array('name'=>'Avery-C32010', - 'paper-size'=>'A4', - 'metric'=>'mm', - 'marginLeft'=>15, - 'marginTop'=>13, - 'NX'=>2, - 'NY'=>5, - 'SpaceX'=>10, - 'SpaceY'=>0, - 'width'=>85, - 'height'=>54, - 'font-size'=>10), - 'CARD'=>array('name'=>'Dolibarr Business cards', - 'paper-size'=>'A4', - 'metric'=>'mm', - 'marginLeft'=>15, - 'marginTop'=>15, - 'NX'=>2, - 'NY'=>5, - 'SpaceX'=>0, - 'SpaceY'=>0, - 'width'=>85, - 'height'=>54, - 'font-size'=>10) - ); +$sql = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards WHERE active=1 ORDER BY code ASC"; +$resql = $db->query($sql); +while ($row = $db->fetch_array($resql)) { + $_Avery_Labels[$row['code']]['name']=$row['name']; + $_Avery_Labels[$row['code']]['paper-size']=$row['paper_size']; + $_Avery_Labels[$row['code']]['orientation']=$row['orientation']; + $_Avery_Labels[$row['code']]['metric']=$row['metric']; + $_Avery_Labels[$row['code']]['marginLeft']=$row['leftmargin']; + $_Avery_Labels[$row['code']]['marginTop']=$row['topmargin']; + $_Avery_Labels[$row['code']]['marginTop']=$row['topmargin']; + $_Avery_Labels[$row['code']]['NX']=$row['nx']; + $_Avery_Labels[$row['code']]['NY']=$row['ny']; + $_Avery_Labels[$row['code']]['SpaceX']=$row['spacex']; + $_Avery_Labels[$row['code']]['SpaceY']=$row['spacey']; + $_Avery_Labels[$row['code']]['width']=$row['width']; + $_Avery_Labels[$row['code']]['height']=$row['height']; + $_Avery_Labels[$row['code']]['font-size']=$row['font_size']; + $_Avery_Labels[$row['code']]['custom_x']=$row['custom_x']; + $_Avery_Labels[$row['code']]['custom_y']=$row['custom_y']; +} + +// we add characteristics to the name foreach($_Avery_Labels as $key => $val) { $_Avery_Labels[$key]['name'].=' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')'; diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index a768cfefc53..7d369d34b7c 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -247,7 +247,14 @@ class pdf_standard extends CommonStickerGenerator $this->Tformat = $_Avery_Labels[$this->code]; if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } $this->type = 'pdf'; - $this->format = $this->Tformat['paper-size']; + // standard format or custom + if ($this->Tformat['paper-size']!='custom') { + $this->format = $this->Tformat['paper-size']; + } else { + //custom + $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']); + $this->format = $resolution; + } if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO @@ -284,7 +291,7 @@ class pdf_standard extends CommonStickerGenerator } } - $pdf=pdf_getInstance($this->format,$this->Tformat['metric']); + $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); if (class_exists('TCPDF')) { diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index 0bfb2d849c5..09dfe2efe5e 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -241,7 +241,14 @@ class pdf_standardlabel extends CommonStickerGenerator $this->Tformat = $_Avery_Labels[$this->code]; if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } $this->type = 'pdf'; - $this->format = $this->Tformat['paper-size']; + // standard format or custom + if ($this->Tformat['paper-size']!='custom') { + $this->format = $this->Tformat['paper-size']; + } else { + //custom + $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']); + $this->format = $resolution; + } if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO @@ -268,7 +275,7 @@ class pdf_standardlabel extends CommonStickerGenerator } } - $pdf=pdf_getInstance($this->format,$this->Tformat['metric']); + $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); if (class_exists('TCPDF')) { diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index dd70c608f07..2089cf6e0b9 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -282,7 +282,14 @@ class pdf_tcpdflabel extends CommonStickerGenerator $this->Tformat = $_Avery_Labels[$this->code]; if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; } $this->type = 'pdf'; - $this->format = $this->Tformat['paper-size']; + // standard format or custom + if ($this->Tformat['paper-size']!='custom') { + $this->format = $this->Tformat['paper-size']; + } else { + //custom + $resolution= array($this->Tformat['custom_x'], $this->Tformat['custom_y']); + $this->format = $resolution; + } if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO @@ -309,7 +316,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator } } - $pdf=pdf_getInstance($this->format,$this->Tformat['metric']); + $pdf=pdf_getInstance($this->format,$this->Tformat['metric'], $this->Tformat['orientation']); if (class_exists('TCPDF')) { 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 9ac450b90f8..e43345afc60 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 @@ -76,6 +76,39 @@ ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website,pa ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); +CREATE TABLE llx_c_format_cards +( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + code varchar(50) NOT NULL, + name varchar(50) NOT NULL, + paper_size varchar(20) NOT NULL, + orientation varchar(1) NOT NULL, + metric varchar(5) NOT NULL, + leftmargin double(24,8) NOT NULL, + topmargin double(24,8) NOT NULL, + nx integer NOT NULL, + ny integer NOT NULL, + spacex double(24,8) NOT NULL, + spacey double(24,8) NOT NULL, + width double(24,8) NOT NULL, + height double(24,8) NOT NULL, + font_size integer NOT NULL, + custom_x double(24,8) NOT NULL, + custom_y double(24,8) NOT NULL, + active integer NOT NULL +) ENGINE=InnoDB; + +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (1, '5160', 'Avery-5160, WL-875WX', 'letter', 'P', 'mm', 5.58165000, 12.70000000, 3, 10, 3.55600000, 0.00000000, 65.87490000, 25.40000000, 7, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (2, '5161', 'Avery-5161, WL-75WX', 'letter', 'P', 'mm', 4.44500000, 12.70000000, 2, 10, 3.96800000, 0.00000000, 101.60000000, 25.40000000, 7, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (3, '5162', 'Avery-5162, WL-100WX', 'letter', 'P', 'mm', 3.87350000, 22.35200000, 2, 7, 4.95400000, 0.00000000, 101.60000000, 33.78100000, 8, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (4, '5163', 'Avery-5163, WL-125WX', 'letter', 'P', 'mm', 4.57200000, 12.70000000, 2, 5, 3.55600000, 0.00000000, 101.60000000, 50.80000000, 10, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (5, '5164', '5164 (Letter)', 'letter', 'P', 'in', 0.14800000, 0.50000000, 2, 3, 0.20310000, 0.00000000, 4.00000000, 3.33000000, 12, 0.00000000, 0.00000000, 0); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (6, '8600', 'Avery-8600', 'letter', 'P', 'mm', 7.10000000, 19.00000000, 3, 10, 9.50000000, 3.10000000, 66.60000000, 25.40000000, 7, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (7, '99012', 'DYMO 99012 89*36mm', 'custom', 'L', 'mm', 1.00000000, 1.00000000, 1, 1, 0.00000000, 0.00000000, 36.00000000, 89.00000000, 10, 36.00000000, 89.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (8, '99014', 'DYMO 99014 101*54mm', 'custom', 'L', 'mm', 1.00000000, 1.00000000, 1, 1, 0.00000000, 0.00000000, 54.00000000, 101.00000000, 10, 54.00000000, 101.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (9, 'AVERYC32010', 'Avery-C32010', 'A4', 'P', 'mm', 15.00000000, 13.00000000, 2, 5, 10.00000000, 0.00000000, 85.00000000, 54.00000000, 10, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (10, 'CARD', 'Dolibarr Business cards', 'A4', 'P', 'mm', 15.00000000, 15.00000000, 2, 5, 0.00000000, 0.00000000, 85.00000000, 54.00000000, 10, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (11, 'L7163', 'Avery-L7163', 'A4', 'P', 'mm', 5.00000000, 15.00000000, 2, 7, 2.50000000, 0.00000000, 99.10000000, 38.10000000, 8, 0.00000000, 0.00000000, 1); diff --git a/htdocs/install/mysql/tables/llx_c_format_cards.sql b/htdocs/install/mysql/tables/llx_c_format_cards.sql new file mode 100644 index 00000000000..b58170c0d48 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_format_cards.sql @@ -0,0 +1,39 @@ +-- ======================================================================== +-- Copyright (C) 2016 Frederic France +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +CREATE TABLE llx_c_format_cards +( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + code varchar(50) NOT NULL, + name varchar(50) NOT NULL, + paper_size varchar(20) NOT NULL, + orientation varchar(1) NOT NULL, + metric varchar(5) NOT NULL, + leftmargin double(24,8) NOT NULL, + topmargin double(24,8) NOT NULL, + nx integer NOT NULL, + ny integer NOT NULL, + spacex double(24,8) NOT NULL, + spacey double(24,8) NOT NULL, + width double(24,8) NOT NULL, + height double(24,8) NOT NULL, + font_size integer NOT NULL, + custom_x double(24,8) NOT NULL, + custom_y double(24,8) NOT NULL, + active integer NOT NULL +) ENGINE=InnoDB; From e079021de3c454f5ed53e79e542f0c01b3038425 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Sat, 6 Feb 2016 12:16:12 +0100 Subject: [PATCH 058/421] data --- .../install/mysql/data/llx_c_format_cards.sql | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 htdocs/install/mysql/data/llx_c_format_cards.sql diff --git a/htdocs/install/mysql/data/llx_c_format_cards.sql b/htdocs/install/mysql/data/llx_c_format_cards.sql new file mode 100644 index 00000000000..b235fdccc5b --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_format_cards.sql @@ -0,0 +1,34 @@ +-- ======================================================================== +-- Copyright (C) 2016 Frederic France +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +-- +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- + +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (1, '5160', 'Avery-5160, WL-875WX', 'letter', 'P', 'mm', 5.58165000, 12.70000000, 3, 10, 3.55600000, 0.00000000, 65.87490000, 25.40000000, 7, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (2, '5161', 'Avery-5161, WL-75WX', 'letter', 'P', 'mm', 4.44500000, 12.70000000, 2, 10, 3.96800000, 0.00000000, 101.60000000, 25.40000000, 7, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (3, '5162', 'Avery-5162, WL-100WX', 'letter', 'P', 'mm', 3.87350000, 22.35200000, 2, 7, 4.95400000, 0.00000000, 101.60000000, 33.78100000, 8, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (4, '5163', 'Avery-5163, WL-125WX', 'letter', 'P', 'mm', 4.57200000, 12.70000000, 2, 5, 3.55600000, 0.00000000, 101.60000000, 50.80000000, 10, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (5, '5164', '5164 (Letter)', 'letter', 'P', 'in', 0.14800000, 0.50000000, 2, 3, 0.20310000, 0.00000000, 4.00000000, 3.33000000, 12, 0.00000000, 0.00000000, 0); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (6, '8600', 'Avery-8600', 'letter', 'P', 'mm', 7.10000000, 19.00000000, 3, 10, 9.50000000, 3.10000000, 66.60000000, 25.40000000, 7, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (7, '99012', 'DYMO 99012 89*36mm', 'custom', 'L', 'mm', 1.00000000, 1.00000000, 1, 1, 0.00000000, 0.00000000, 36.00000000, 89.00000000, 10, 36.00000000, 89.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (8, '99014', 'DYMO 99014 101*54mm', 'custom', 'L', 'mm', 1.00000000, 1.00000000, 1, 1, 0.00000000, 0.00000000, 54.00000000, 101.00000000, 10, 54.00000000, 101.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (9, 'AVERYC32010', 'Avery-C32010', 'A4', 'P', 'mm', 15.00000000, 13.00000000, 2, 5, 10.00000000, 0.00000000, 85.00000000, 54.00000000, 10, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (10, 'CARD', 'Dolibarr Business cards', 'A4', 'P', 'mm', 15.00000000, 15.00000000, 2, 5, 0.00000000, 0.00000000, 85.00000000, 54.00000000, 10, 0.00000000, 0.00000000, 1); +INSERT INTO llx_c_format_cards (rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active) VALUES (11, 'L7163', 'Avery-L7163', 'A4', 'P', 'mm', 5.00000000, 15.00000000, 2, 7, 2.50000000, 0.00000000, 99.10000000, 38.10000000, 8, 0.00000000, 0.00000000, 1); From 2e1011ca0c384485177a602fa9b8338661a9241b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Feb 2016 12:26:12 +0100 Subject: [PATCH 059/421] Add hidden option MAIN_CAN_HIDE_EXTRAFIELDS to disable a feature that seems useless. --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 6 ++++-- htdocs/core/tpl/admin_extrafields_edit.tpl.php | 6 +++++- htdocs/core/tpl/admin_extrafields_view.tpl.php | 5 ++--- htdocs/install/mysql/tables/llx_extrafields.sql | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 6273ea93940..2b485f69fb9 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -117,9 +117,11 @@ - + - +global->MAIN_CAN_HIDE_EXTRAFIELDS)) { ?> + +global->MAIN_FEATURES_LEVEL >= 2) { ?> - +global->MAIN_CAN_HIDE_EXTRAFIELDS)) { ?> + +'; +}?> global->MAIN_FEATURES_LEVEL >= 2) { ?> '; print ''; print ''; print ''; -print ''; +if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print ''; print ''; print "\n"; @@ -61,11 +61,10 @@ foreach($extrafields->attribute_type as $key => $value) print '\n"; print '\n"; print '\n"; - print '\n"; + if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print '\n"; // Add hidden option on not working feature. Why hide if user can't see it. print '\n"; print ""; - // $i++; } print "
'.$langs->trans('Ref').''.$langs->trans('Invoice').''.$langs->trans('RefSupplier').''.$langs->trans('Date').''.$langs->trans('AmountTTC').''.$langs->trans('AlreadyPaid').''.$langs->trans('RemainderToPay').''.$langs->trans('Amount').''.$langs->trans('PaymentAmount').'
situation_counter > 1) print ' readonly'; print '>situation_counter > 1) print ' readonly'; print '>
'.(price2num($object->pmp)?price(price2num($object->pmp*$obj->reel,'MT')):'').''; - if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price,'MU'),1); + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price,'MU'),1); else print $langs->trans("Variable"); print ''; - if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).'
'; print $totalvalue?price(price2num($totalvalue,'MT'),1):' '; print ''; -if (empty($conf->global->PRODUIT_MULTI_PRICES)) print ($total?price($totalvaluesell/$total,1):' '); +if (empty($conf->global->PRODUIT_MULTIPRICES)) print ($total?price($totalvaluesell/$total,1):' '); else print $langs->trans("Variable"); print ''; -if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($totalvaluesell,'MT'),1); +if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalvaluesell,'MT'),1); else print $langs->trans("Variable"); print '
trans("Required"); ?>>
trans("AlwaysEditable"); ?>>
trans("AlwaysEditable"); ?>>
trans("IsHidden"); ?>>
trans("Hidden"); ?>>
trans("ByDefaultInList"); ?> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 71b81ecee0f..b79fa539d2e 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -119,7 +119,11 @@ if(($type == 'select') || ($type == 'sellist') || ($type == 'checkbox') || ($typ
trans("AlwaysEditable"); ?>>
trans("IsHidden"); ?>>
trans("Hidden"); ?>>
trans("ByDefaultInList"); ?> diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index adb04bbc540..6acc81f009f 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -44,7 +44,7 @@ print ''.$langs->trans("Size").''.$langs->trans("Unique").''.$langs->trans("Required").''.$langs->trans("AlwaysEditable").''.$langs->trans("IsHidden").''.$langs->trans("Hidden").' 
'.yn($extrafields->attribute_unique[$key])."'.yn($extrafields->attribute_required[$key])."'.yn($extrafields->attribute_alwayseditable[$key])."'.yn($extrafields->attribute_hidden[$key])."'.yn($extrafields->attribute_hidden[$key])."'.img_edit().''; print "  ".img_delete()."
"; diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index 062f20b5c9f..b7a7288980b 100644 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -33,6 +33,6 @@ create table llx_extrafields pos integer DEFAULT 0, alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status param text, -- extra parameters to define possible values of field - list integer DEFAULT 0 -- list of values for field that are combo lists - ,ishidden integer DEFAULT 0 + list integer DEFAULT 0, -- list of values for field that are combo lists + ishidden integer DEFAULT 0 -- ??? example of use case ??? )ENGINE=innodb; From 8f8c63e9c8d370e8a7bb19ec7df31ea2cd8accb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Feb 2016 12:37:48 +0100 Subject: [PATCH 060/421] FIX Delete triggers must be before delete (reverse order compared to create) --- .../compta/paiement/class/paiement.class.php | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 4fa9c5b9575..d01600a7125 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -291,12 +291,12 @@ class Paiement extends CommonObject /** - * Supprime un paiement ainsi que les lignes qu'il a genere dans comptes - * Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse - * Si le paiement porte sur au moins une facture a "payee", on refuse + * Delete a payment and generated links into account + * - Si le paiement porte sur un ecriture compte qui est rapprochee, on refuse + * - Si le paiement porte sur au moins une facture a "payee", on refuse * - * @param int $notrigger No trigger - * @return int <0 si ko, >0 si ok + * @param int $notrigger No trigger + * @return int <0 si ko, >0 si ok */ function delete($notrigger=0) { @@ -326,21 +326,43 @@ class Paiement extends CommonObject return -2; } - $accline = new AccountLine($this->db); - // Delete bank urls. If payment is on a conciliated line, return error. - if ($bank_line_id) + if ($bank_line_id > 0) { + $accline = new AccountLine($this->db); + $result=$accline->fetch($bank_line_id); if ($result == 0) $accline->rowid=$bank_line_id; // If not found, we set artificially rowid to allow delete of llx_bank_url - $result=$accline->delete_urls($user); + // Delete bank account url lines linked to payment + $result=$accline->delete_urls($user); if ($result < 0) { $this->error=$accline->error; $this->db->rollback(); return -3; } + + // Delete bank account lines linked to payment + $result=$accline->delete($user); + if ($result < 0) + { + $this->error=$accline->error; + $this->db->rollback(); + return -4; + } + } + + if (! $notrigger) + { + // Call triggers + $result=$this->call_trigger('PAYMENT_CUSTOMER_DELETE', $user); + if ($result < 0) + { + $this->db->rollback(); + return -1; + } + // End call triggers } // Delete payment (into paiement_facture and paiement) @@ -361,30 +383,6 @@ class Paiement extends CommonObject return -3; } - // Supprimer l'ecriture bancaire si paiement lie a ecriture - if ($bank_line_id) - { - $result=$accline->delete($user); - if ($result < 0) - { - $this->error=$accline->error; - $this->db->rollback(); - return -4; - } - } - - if (! $notrigger) - { - // Appel des triggers - $result=$this->call_trigger('PAYMENT_CUSTOMER_DELETE', $user); - if ($result < 0) - { - $this->db->rollback(); - return -1; - } - // Fin appel triggers - } - $this->db->commit(); return 1; } From 3828fe70261c43e26fb3729e442901af79c9d456 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Feb 2016 15:06:37 +0100 Subject: [PATCH 061/421] FIX Bad filter on opportunities --- build/debian/README.howto | 13 +++++++++++++ htdocs/core/class/html.formprojet.class.php | 9 +++++---- htdocs/langs/en_US/projects.lang | 3 +++ htdocs/projet/list.php | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/build/debian/README.howto b/build/debian/README.howto index 01f19e28ccf..5a8b7b742a2 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -137,6 +137,19 @@ With only message tag 729538 +pending +To remove status of a bug without "moreinfo" (bug can be processed) + +or replay to email 999999@bugs.debian.org + submitter of bug +With a message starting with: + +Control: tag -1 -moreinfo +Thanks. Fixed into git. + +or replay to email control@bugs.debian.org +With only message +tag 729538 -moreinfo + + ##### Testing a package into unstable env diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 4f65d5327d1..7ccb382a4a3 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -535,14 +535,14 @@ class FormProjets * Build a HTML select list of element of same thirdparty to suggest to link them to project * * @param string $htmlname HTML name - * @param int $preselected Preselected + * @param string $preselected Preselected (int or 'all' or 'none') * @param int $showempty Add an empty line * @param int $useshortlabel Use short label * @param int $showallnone Add choice "All" and "None" * @param int $showpercent Show default probability for status * @return int|string The HTML select list of element or '' if nothing or -1 if KO */ - function selectOpportunityStatus($htmlname, $preselected=0, $showempty=1, $useshortlabel=0, $showallnone=0, $showpercent=0) + function selectOpportunityStatus($htmlname, $preselected='-1', $showempty=1, $useshortlabel=0, $showallnone=0, $showpercent=0) { global $conf, $langs; @@ -560,8 +560,9 @@ class FormProjets { $sellist = ''; if ($showempty) $sellist.= ''; - if ($showallnone) $sellist.= ''; - if ($showallnone) $sellist.= ''; + if ($showallnone) $sellist.= ''; + if ($showallnone) $sellist.= ''; + if ($showallnone) $sellist.= ''; while ($i < $num) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 830219f8aeb..6fa62f96905 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -179,6 +179,9 @@ TaskAssignedToEnterTime=Task assigned. Entering time on this task should be poss IdTaskTime=Id task time YouCanCompleteRef=If you want to complete the ref with some information (to use it as search filters), it is recommanded to add a - character to separate it, so the automatic numbering will still work correctly for next projects. For example %s-ABC. You may also prefer to add search keys into label. OpenedProjectsByThirdparties=Opened projects by thirdparties +OnlyOpportunitiesShort=Only opportunities +OpenedOpportunitiesShort=Opened opportunities +NotAnOpportunityShort=Not an opportunity OpportunityTotalAmount=Opportunities total amount OpportunityPonderatedAmount=Opportunities weighted amount OpportunityPonderatedAmountDesc=Opportunities amount weighted with probability (depending on status of opportunity) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index b5fb7e31666..9ae3513fa8a 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -267,6 +267,7 @@ if ($search_opp_status) { if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status); if ($search_opp_status == 'all') $sql .= " AND p.fk_opp_status IS NOT NULL"; + if ($search_opp_status == 'openedopp') $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WIN','LOST'))"; if ($search_opp_status == 'none') $sql .= " AND p.fk_opp_status IS NULL"; } if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); From 58f728eae5b6441c37cae96aec0b368976e5b0d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Feb 2016 15:11:45 +0100 Subject: [PATCH 063/421] Prepare 3.9rc --- 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 b9a7819413f..84cb17669da 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','3.9.0-beta'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.9.0-rc'); if (! defined('EURO')) define('EURO',chr(128)); From ebd9a97bab3fb2699badd354e607082d47c54793 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Feb 2016 15:48:38 +0100 Subject: [PATCH 064/421] Prepare 3.9 --- build/debian/dolibarr.desktop | 1 + build/debian/install.forced.php.install | 2 +- build/makepack-dolibarr.pl | 52 ++++++++++++------- htdocs/custom/README.md | 2 +- .../jquery/plugins/select2/release.sh | 0 5 files changed, 37 insertions(+), 20 deletions(-) mode change 100644 => 100755 htdocs/includes/jquery/plugins/select2/release.sh diff --git a/build/debian/dolibarr.desktop b/build/debian/dolibarr.desktop index f4b471edf13..dd59be792d2 100644 --- a/build/debian/dolibarr.desktop +++ b/build/debian/dolibarr.desktop @@ -22,5 +22,6 @@ Type=Application Categories=Office StartupNotify=true InitialPreference=5 +Keywords=erp,crm,billing,customer,supplier,stock,agenda,project,order,shipment #NoDisplay=true #OnlyShowIn=GNOME diff --git a/build/debian/install.forced.php.install b/build/debian/install.forced.php.install index 099aab0675a..57ab33464bc 100644 --- a/build/debian/install.forced.php.install +++ b/build/debian/install.forced.php.install @@ -26,7 +26,7 @@ $force_install_nophpinfo='1'; $force_install_lockinstall='444'; // Value to overwrite path to use shared libraries/fonts instead of embedded one. -// If we enable/disable libraries declaration during install, we must also check they are +// If during install, we enable/disable declaration to use non embedded libraries, we must also check they are // - not removed from package (see rm in rules file), // - declared into dependencies (see Depends in control file) //$force_dolibarr_lib_TCPDF_PATH=''; diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index ac5529d7d8f..a641cf2e69c 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -523,25 +523,26 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/jqueryFileTree/connectors/jqueryFileTree.pl`; # Avoid errors into rpmlint $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/template`; # Package not valid for most linux distributions (errors reported into compile.js). Package should be embed by modules to avoid problems. $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpmailer`; # Package not valid for most linux distributions (errors reported into file LICENSE). Package should be embed by modules to avoid problems. - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/adapters`; # Keep this removal in case we embed libraries + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/adapters`; # Keep this removal in case we embed libraries + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/samples`; # Keep this removal in case we embed libraries #$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/_source`; # _source must be kept into tarball $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/datatables/extras/TableTools/swf`; # Source of this flash is not available $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt`; + $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/select2/release.sh`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/doc`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/example`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/test`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/license.txt`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PDF`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PCLZip`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/license.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/.gitattributes`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Classes/license.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/PDF`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared/PCLZip`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/Examples`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/PHPExcel/Shared/PDF`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/PHPExcel/Shared/PCLZip`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/unitTests`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpoffice/phpexcel/license.md`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils`; @@ -549,6 +550,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/savant`; } @@ -837,17 +839,28 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/rpm`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/build/zip`; # Removed duplicate license files - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/LICENSE.md`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/plugins/scayt/LICENSE.md`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source/plugins/wsc/LICENSE.md`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/LICENSE.md`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/plugins/scayt/LICENSE.md`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/plugins/wsc/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source/plugins/scayt/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source/plugins/wsc/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/plugins/scayt/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/plugins/wsc/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/php-iban/LICENSE`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/flot/LICENSE.txt`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-2.34/LICENSE`; - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tcpdf/fonts/freefont-20120503/COPYING`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/datatables/extensions/ColReorder/License.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/datatables/extensions/ColVis/License.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/datatables/extensions/FixedColumns/License.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/datatables/extensions/Responsive/License.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/datatables/license.txt`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/jquery/plugins/select2/LICENSE`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/mike42/escpos-php/LICENSE.md`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/mobiledetect/mobiledetectlib/LICENSE.txt`; + + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tecnickcom/tcpdf/fonts/dejavu-fonts-ttf-2.34/LICENSE`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-20120503/COPYING`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_2.0/COPYING`; # Removed files we don't need - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/_source`; + $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/htdocs/includes/ckeditor/ckeditor/_source`; # Rename upstream changelog to match debian rules $ret=`mv $BUILDROOT/$PROJECT.tmp/ChangeLog $BUILDROOT/$PROJECT.tmp/changelog`; @@ -909,8 +922,11 @@ if ($nboftargetok) { $ret=`chmod 755 $BUILDROOT/$PROJECT.tmp/debian/rules`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/translation/autotranslator.class.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/modMyModule.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_api_class.class.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_card.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_class.class.php`; - $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_page.php`; + $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_list.php`; + $ret=`chmod -R 755 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_script.php`; $ret=`chmod -R 644 $BUILDROOT/$PROJECT.tmp/dev/skeletons/skeleton_webservice_server.php`; $cmd="find $BUILDROOT/$PROJECT.tmp/scripts -name '*.php' -type f -exec chmod 755 {} \\; "; $ret=`$cmd`; @@ -1156,7 +1172,7 @@ if ($nboftargetok) { print "$command\n"; my $ret=`$command 2>&1`; - $command="rsync -s $OPTIONUPDATEDIST -e 'ssh' \"$file\" \"".$destFolder."\""; + $command="rsync -s -e 'ssh' \"$file\" \"".$destFolder."\""; print "$command\n"; my $ret=`$command 2>&1`; print "$ret\n"; diff --git a/htdocs/custom/README.md b/htdocs/custom/README.md index e46934902cb..5f15148f685 100644 --- a/htdocs/custom/README.md +++ b/htdocs/custom/README.md @@ -9,7 +9,7 @@ of the module. For example on Linux OS: Get the module from the command mkdir ~/git; cd ~/git -git clone https://git.doliforge.org/p/newmodule/newmodule.git +git clone https://git.framasoft.org/p/newmodule/newmodule.git Then create the symbolic link ln -fs ~/git/newmodule/htdocs /path_to_dolibarr/htdocs/custom/newmodule diff --git a/htdocs/includes/jquery/plugins/select2/release.sh b/htdocs/includes/jquery/plugins/select2/release.sh old mode 100644 new mode 100755 From c6fe8e54793feb2f7c1c215295313cb23dac4fcf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Feb 2016 17:13:24 +0100 Subject: [PATCH 065/421] Fix first install on debian. --- htdocs/install/inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index ac6f444f45e..ed0736ee9dc 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -77,7 +77,7 @@ $conffiletoshow = "htdocs/conf/conf.php"; //$conffiletoshow = "/etc/dolibarr/conf.php"; -if (! defined('DONOTLOADCONF') && file_exists($conffile)) +if (! defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) // Test on filesize is to ensure that conf file is more that an empty template with just Date: Sat, 6 Feb 2016 17:19:57 +0100 Subject: [PATCH 066/421] Fix first install on debian. --- build/debian/patches/use-etc-dolibarr-conf.patch | 4 ++-- htdocs/install/inc.php | 3 ++- htdocs/support/inc.php | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build/debian/patches/use-etc-dolibarr-conf.patch b/build/debian/patches/use-etc-dolibarr-conf.patch index f911ad18af0..3bca20ee66f 100644 --- a/build/debian/patches/use-etc-dolibarr-conf.patch +++ b/build/debian/patches/use-etc-dolibarr-conf.patch @@ -34,7 +34,7 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +$conffiletoshow = "/etc/dolibarr/conf.php"; - if (! defined('DONOTLOADCONF') && file_exists($conffile)) + // Load conf file if it is already defined --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -69,8 +69,8 @@ $conffiletoshowshort = "conf.php"; @@ -47,4 +47,4 @@ This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +$conffiletoshow = "/etc/dolibarr/conf.php"; - if (! defined('DONOTLOADCONF') && file_exists($conffile)) + // Load conf file if it is already defined diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index ed0736ee9dc..c5ebc33c56e 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -77,7 +77,8 @@ $conffiletoshow = "htdocs/conf/conf.php"; //$conffiletoshow = "/etc/dolibarr/conf.php"; -if (! defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) > 8) // Test on filesize is to ensure that conf file is more that an empty template with just 8) // Test on filesize is to ensure that conf file is more that an empty template with just 8) // Test on filesize is to ensure that conf file is more that an empty template with just Date: Sat, 6 Feb 2016 17:24:54 +0100 Subject: [PATCH 067/421] We must remove flash binary part --- build/makepack-dolibarr.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index a641cf2e69c..a057489ad04 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -527,7 +527,8 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/samples`; # Keep this removal in case we embed libraries #$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/_source`; # _source must be kept into tarball - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/datatables/extras/TableTools/swf`; # Source of this flash is not available + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/datatables/extensions/TableTools/swf`; # Source of this flash is not available + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/datatables/extras/TableTools/swf`; # Source of this flash is not available $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/multiselect/MIT-LICENSE.txt`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/select2/release.sh`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/mike42/escpos-php/doc`; From adb66eddf1c0cbc6783a59df138b433bfefa1e53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Feb 2016 17:45:02 +0100 Subject: [PATCH 068/421] Fix generation of rpm packages --- ChangeLog | 2 +- build/makepack-dolibarr.pl | 13 ++++++++----- build/rpm/dolibarr-forrpm.patch | 4 ++-- build/rpm/dolibarr_fedora.spec | 2 ++ build/rpm/dolibarr_generic.spec | 2 ++ build/rpm/dolibarr_mandriva.spec | 2 ++ build/rpm/dolibarr_opensuse.spec | 2 ++ 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index a17879fcbdd..13346d43763 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,7 +12,7 @@ Upgrading to any other version or any other database system is abolutely require make a Dolibarr upgrade. -***** ChangeLog for 3.9 compared to 3.8.* ***** +***** ChangeLog for 3.9.0 compared to 3.8.* ***** For users: NEW: A new and more modern look for "eldy" theme. NEW: Introduce a new theme called "Material Design". diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index a057489ad04..42091d0cda4 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -354,15 +354,18 @@ if ($nboftargetok) { chdir("$SOURCE"); # Test that the ChangeLog is ok - $ret=`grep "ChangeLog for $MAJOR.$MINOR\.$BUILD" "$SOURCE/ChangeLog" 2>&1`; + $TMPBUILDTOCHECKCHANGELOG=$BUILD; + $TMPBUILDTOCHECKCHANGELOG =~ s/\-rc//; + print "Check if ChangeLog is ok for version $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG\n"; + $ret=`grep "ChangeLog for $MAJOR.$MINOR\.$TMPBUILDTOCHECKCHANGELOG" "$SOURCE/ChangeLog" 2>&1`; if (! $ret) { - print "Error: The ChangeLogFile was not updated. Run the following command first:\n"; - if (! $BUILD) + print "Error: The ChangeLogFile was not updated. Run the following command before building package for $MAJOR.$MINOR.$BUILD:\n"; + if (! $BUILD || $BUILD eq '0-rc') # For a major version { - print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; + print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log `git rev-list --boundary '.$MAJOR.'.'.$MINOR.'..origin/develop | grep ^- | cut -c2- | head -n 1`.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; } - else + else # For a maintenance release { print 'cd ~/git/dolibarr_'.$MAJOR.'.'.$MINOR.'; git log '.$MAJOR.'.'.$MINOR.'.'.($BUILD-1).'.. --no-merges --pretty=short --oneline | sed -e "s/^[0-9a-z]* //" | grep -e \'^FIX\|NEW\' | sort -u | sed \'s/FIXED:/FIX:/g\' | sed \'s/FIXED :/FIX:/g\' | sed \'s/FIX :/FIX:/g\' | sed \'s/FIX /FIX: /g\' | sed \'s/NEW :/NEW:/g\' | sed \'s/NEW /NEW: /g\' > /tmp/aaa'; } diff --git a/build/rpm/dolibarr-forrpm.patch b/build/rpm/dolibarr-forrpm.patch index 41f27e3b791..6c484345be9 100644 --- a/build/rpm/dolibarr-forrpm.patch +++ b/build/rpm/dolibarr-forrpm.patch @@ -25,7 +25,7 @@ diff -up htdocs/install/inc.php.patch htdocs/install/inc.php +$conffiletoshow = "/etc/dolibarr/conf.php"; - if (! defined('DONOTLOADCONF') && file_exists($conffile)) + // Load conf file if it is already defined diff -up htdocs/support/inc.php.patch htdocs/support/inc.php --- htdocs/support/inc.php.patch 2011-09-03 02:34:39.606952000 +0200 +++ htdocs/support/inc.php 2011-09-03 02:33:59.814952000 +0200 @@ -39,4 +39,4 @@ diff -up htdocs/support/inc.php.patch htdocs/support/inc.php +$conffiletoshow = "/etc/dolibarr/conf.php"; - if (! defined('DONOTLOADCONF') && file_exists($conffile)) + // Load conf file if it is already defined diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 7189b7b6dc2..0cd72f99cdd 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -183,6 +183,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/fourn %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday +%_datadir/dolibarr/htdocs/hrm %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install @@ -200,6 +201,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 0e28ff594ea..043088bf5d6 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -263,6 +263,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/fourn %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday +%_datadir/dolibarr/htdocs/hrm %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install @@ -280,6 +281,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 639ec2b52dd..3f439bb4a9a 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -180,6 +180,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/fourn %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday +%_datadir/dolibarr/htdocs/hrm %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install @@ -197,6 +198,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 23f42adaa0a..cc21d7083b3 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -191,6 +191,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/fourn %_datadir/dolibarr/htdocs/ftp %_datadir/dolibarr/htdocs/holiday +%_datadir/dolibarr/htdocs/hrm %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install @@ -208,6 +209,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/societe +%_datadir/dolibarr/htdocs/supplier_proposal %_datadir/dolibarr/htdocs/support %_datadir/dolibarr/htdocs/theme %_datadir/dolibarr/htdocs/user From 426f6541e67d17a4b05efd585ded2a90e00e180a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 01:05:53 +0100 Subject: [PATCH 069/421] Fix: can publish on foundation ref storage --- build/makepack-dolibarr.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 42091d0cda4..c719c56ec25 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -1154,8 +1154,10 @@ if ($nboftargetok) { } else { - $destFolder="$NEWPUBLISH"; - print "Publish file ".$file." to $NEWPUBLISH\n"; + $filenameonly=$file; + $filenameonly =~ s{.*/}{}; # removes path + $destFolder="$NEWPUBLISH/$filenameonly"; + print "Publish file ".$file." to $NEWPUBLISH/".$filenameonly."\n"; } # mkdir From 38e5b773ced391b90419cc3b5d5a72742a8cae6f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 01:11:12 +0100 Subject: [PATCH 070/421] Fix: can publish on foundation ref storage --- build/makepack-dolibarr.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index c719c56ec25..1d6542eafc9 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -1155,7 +1155,7 @@ if ($nboftargetok) { else { $filenameonly=$file; - $filenameonly =~ s{.*/}{}; # removes path + $filenameonly =~ s/.*\/([^\/]+\/[^\/]+)$/$1/; # removes path $destFolder="$NEWPUBLISH/$filenameonly"; print "Publish file ".$file." to $NEWPUBLISH/".$filenameonly."\n"; } From 8a8aaf618de388cff0f74cf3cce1872ed5b66e19 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 02:22:10 +0100 Subject: [PATCH 071/421] Fix: select to add box was lost --- htdocs/core/class/html.formother.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index c89844a91db..474c07f4b0a 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -977,15 +977,19 @@ class FormOther $confuserzone='MAIN_BOXES_'.$areacode; + // $boxactivated will be array of boxes enabled into global setup + // $boxidactivatedforuser will be array of boxes choosed by user + $selectboxlist=$boxlist=''; $boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of common+user (or common only if user has no specific setup) + //var_dump($boxactivated); $boxidactivatedforuser=array(); foreach($boxactivated as $box) { if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user } - + $arrayboxtoactivatelabel=array(); if (! empty($user->conf->$confuserzone)) { @@ -1174,7 +1178,7 @@ class FormOther $boxlist.= "
"; } - return array('selectboxlist'=>$nbboxactivated?$selectboxlist:'', 'boxactivated'=>$boxactivated, 'boxlist'=>$boxlist); + return array('selectboxlist'=>count($boxactivated)?$selectboxlist:'', 'boxactivated'=>$boxactivated, 'boxlist'=>$boxlist); } From 84f4f2d40f93e79d381463c1348d76987c6b7a21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 02:55:56 +0100 Subject: [PATCH 072/421] FIX The search on user/group was not using new code. Fiels used for search was not visible. --- htdocs/core/search.php | 15 +++++++++++++-- htdocs/user/group/index.php | 20 +++++++++++++++++++- htdocs/user/home.php | 22 +++++++--------------- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/htdocs/core/search.php b/htdocs/core/search.php index ccb8838e42f..05b03064096 100644 --- a/htdocs/core/search.php +++ b/htdocs/core/search.php @@ -126,8 +126,19 @@ if (GETPOST('search_project') != '') } if (GETPOST('search_task') != '') { - header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php?mode=search&search_all='.urlencode(GETPOST('search_task'))); - exit; + header("Location: ".DOL_URL_ROOT.'/projet/tasks/list.php?mode=search&search_all='.urlencode(GETPOST('search_task'))); + exit; +} + +if (GETPOST('search_user') != '') +{ + header("Location: ".DOL_URL_ROOT.'/user/index.php?mode=search&sall='.urlencode(GETPOST('search_user'))); + exit; +} +if (GETPOST('search_group') != '') +{ + header("Location: ".DOL_URL_ROOT.'/user/group/index.php?mode=search&sall='.urlencode(GETPOST('search_group'))); + exit; } diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index f515c8307e7..af46fd39d21 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -49,6 +49,12 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield="g.nom"; if (! $sortorder) $sortorder="ASC"; +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'g.nom'=>"Group", + 'g.note'=>"Note" +); + /* * View @@ -85,7 +91,19 @@ if ($resql) $param="&search_group=".urlencode($search_group)."&sall=".urlencode($sall); if ($optioncss != '') $param.='&optioncss='.$optioncss; - print ''; + + if ($sall) + { + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + } + + $moreforfilter=''; + + //$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + //$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'; print ''; print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder); //multicompany diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 22b6d54adda..e9d9fb6c489 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2016 Laurent Destailleur * Copyright (C) 2005-2015 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -63,31 +63,23 @@ print '
'; // Search User $var=false; -print '
'; +print ''; print ''; print '
'; -print ''; +print ''; print ''; -print ''; -print "
'.$langs->trans("SearchAUser").'
'.$langs->trans("Search").'
'; -print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; -print ''; +print $langs->trans("User").':'; // Search Group if ($canreadperms) { $var=false; - print '
'; - print ''; - print ''; - print ''; print ''; - print ''; - print "
'.$langs->trans("SearchAGroup").'
'; - print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; - print '
'; + print $langs->trans("Group").':'; } +print "
\n"; +print ''; //print ''; print '
'; From 9d427d224811ca9d93a6692c02047ffdcfcc5530 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 7 Feb 2016 07:41:53 +0100 Subject: [PATCH 073/421] Fixed: Missing link in eldy menu to init accountancy --- htdocs/core/menus/standard/eldy.lib.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e72ec0d23c3..0497b50308f 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -555,6 +555,12 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { $langs->load("products"); $newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ProductVatMassChange"), 1, $user->admin); + + if (! empty($conf->accounting->enabled)) + { + $langs->load("accountancy"); + $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("InitAccountancy"), 1, $user->admin); + } } } } From eaca582cb5364257dfa2403954071891004a22e5 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 7 Feb 2016 08:47:02 +0100 Subject: [PATCH 074/421] Fixed: Problem of merging - Review page init accountancy again --- htdocs/accountancy/admin/productaccount.php | 93 ++++++++++----------- htdocs/langs/en_US/accountancy.lang | 18 +++- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 8f3e178b525..bb1ab366427 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,6 +1,6 @@ - - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Ari Elbaz (elarifr) @@ -20,13 +20,14 @@ */ /** - * \file htdocs/accountancy/admin/productaccount.php + * \file htdocs/accountancy/admin/productaccount.php * \ingroup Accounting Expert - * \brief Onglet de gestion de parametrages des ventilations + * \brief To define accounting account on product / service */ require '../../main.inc.php'; // Class +require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; @@ -40,7 +41,11 @@ $langs->load("compta"); $langs->load("main"); $langs->load("accountancy"); -// search & action GETPOST +// Security check +if (!$user->admin) accessforbidden(); +if (empty($conf->accounting->enabled)) accessforbidden(); + +// Search & action GETPOST $action = GETPOST('action'); $codeventil_buy = GETPOST('codeventil_buy', 'array'); $codeventil_sell = GETPOST('codeventil_sell', 'array'); @@ -76,8 +81,8 @@ if (! $sortfield) $sortfield = "p.ref"; if (! $sortorder) $sortorder = "ASC"; - - // sales or purchase + +// Sales or Purchase mode ? if ($action == 'update') { if (! empty($btn_changetype)) { $error = 0; @@ -129,9 +134,9 @@ if ($action == 'update') { dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG); if ($db->query($sql)) { - $msg .= '
' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '
'; + $msg .= '
' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '
'; } else { - $msg .= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $accounting->account_number . '
' . $sql . '
'; + $msg .= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '
' . $sql . '
'; } } @@ -144,13 +149,6 @@ if ($action == 'update') { } } -// Security check -if ($user->societe_id > 0) - accessforbidden(); - // TODO after adding menu - // if (! $user->rights->accounting->ventilation->dispatch) - // accessforbidden(); - $form = new FormVentilation($db); // Defaut AccountingAccount RowId Product / Service @@ -176,12 +174,11 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_desc = ''; } -// debug move header to top -llxHeader('', $langs->trans("Accounts")); - /* * View */ + +llxHeader('', $langs->trans("Accounts")); print ''."\n"; } + // Define boxlista and boxlistb $nbboxactivated=count($boxidactivatedforuser); - //print load_fiche_titre(($nbboxactivated?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes'); if ($nbboxactivated) { @@ -1102,13 +1101,13 @@ class FormOther $emptybox=new ModeleBoxes($db); - $boxlist.=''; - $boxlist.='"; + //$boxlist.= "
'."\n"; + //$boxlist.=''; + //$boxlist.='"; - $boxlist.= "
'."\n"; - $boxlist.='
'; + //$boxlist.='
'; - $boxlist.="\n\n"; - $boxlist.='
'."\n"; + $boxlista.="\n\n"; + $boxlista.='
'."\n"; // Define $box_max_lines $box_max_lines=5; @@ -1124,9 +1123,9 @@ class FormOther $ii++; //print 'box_id '.$boxactivated[$ii]->box_id.' '; //print 'box_order '.$boxactivated[$ii]->box_order.'
'; - // Affichage boite key + // Show box $box->loadBox($box_max_lines); - $boxlist.= $box->outputBox(); + $boxlista.= $box->outputBox(); } } @@ -1135,15 +1134,15 @@ class FormOther $emptybox->box_id='A'; $emptybox->info_box_head=array(); $emptybox->info_box_contents=array(); - $boxlist.= $emptybox->outputBox(array(),array()); + $boxlista.= $emptybox->outputBox(array(),array()); } - $boxlist.= "
\n"; - $boxlist.= "\n"; + $boxlista.= "
\n"; + $boxlista.= "\n"; - $boxlist.= '
'; + //$boxlist.= '
'; - $boxlist.= "\n\n"; - $boxlist.= '\n"; + $boxlistb.= "\n"; - $boxlist.= '
'; - $boxlist.= "\n"; + //$boxlist.= '
'; + //$boxlist.= "\n"; - $boxlist.= "
"; + //$boxlist.= "
"; } - return array('selectboxlist'=>count($boxactivated)?$selectboxlist:'', 'boxactivated'=>$boxactivated, 'boxlist'=>$boxlist); + return array('selectboxlist'=>count($boxactivated)?$selectboxlist:'', 'boxactivated'=>$boxactivated, 'boxlista'=>$boxlista, 'boxlistb'=>$boxlistb); } diff --git a/htdocs/index.php b/htdocs/index.php index d876b718ce8..3e2fa24eed0 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -73,7 +73,7 @@ if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$langs->trans("HomeAr llxHeader('',$title); -$resultboxes=FormOther::printBoxesArea($user,"0"); +$resultboxes=FormOther::getBoxesArea($user,"0"); print load_fiche_titre($langs->trans("HomeArea"),$resultboxes['selectboxlist'],'title_home'); @@ -107,38 +107,41 @@ print '
'; /* * Informations area */ - -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; -print "
'.$langs->trans("Informations").'
'.$langs->trans("User").''.$user->getNomUrl(0).'
'.$langs->trans("PreviousConnexion").''; -if ($user->datepreviouslogin) print dol_print_date($user->datepreviouslogin,"dayhour",'tzuser'); -else print $langs->trans("Unknown"); -print '
\n"; - +$boxinfo=''; +$boxinfo.= '
'; +$boxinfo.= ''; +$boxinfo.= ''; +$boxinfo.= ''; +$boxinfo.= ''; +$boxinfo.= ''; +$boxinfo.= ''; +$boxinfo.= "\n"; +$boxinfo.= "
'.$langs->trans("Informations").'
'.$langs->trans("User").''.$user->getNomUrl(0).'
'.$langs->trans("PreviousConnexion").''; +if ($user->datepreviouslogin) $boxinfo.= dol_print_date($user->datepreviouslogin,"dayhour",'tzuser'); +else $boxinfo.= $langs->trans("Unknown"); +$boxinfo.= '
\n"; +$boxinfo.= '
'; +print $boxinfo; /* * Dashboard Dolibarr states (statistics) * Hidden for external users */ +$boxstat=''; + $langs->load("commercial"); $langs->load("bills"); $langs->load("orders"); $langs->load("contracts"); -//print memory_get_usage(); if (empty($user->societe_id)) { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; + $boxstat.='
'.$langs->trans("DolibarrStateBoard").'
'; + $boxstat.='
'; + $boxstat.=''; + $boxstat.=''; + $boxstat.=''; + $boxstat.=''; + $boxstat.=''; - print '
'.$langs->trans("DolibarrStateBoard").'
'; $var=true; @@ -292,19 +295,21 @@ if (empty($user->societe_id)) $var=!$var; if (!empty($langfile[$key])) $langs->load($langfile[$key]); $text=$langs->trans($titres[$key]); - print ''; - print '
'; - print ''.img_object("",$icons[$key]).' '.$text.'
'; - print ''.$board->nb[$val].''; - print '
'; - print '
'; + $boxstat.=''; + $boxstat.='
'; + $boxstat.=''.img_object("",$icons[$key]).' '.$text.'
'; + $boxstat.=''.$board->nb[$val].''; + $boxstat.='
'; + $boxstat.='
'; } } } - print '
'; + $boxstat.='
'; + $boxstat.='
'; } +print $boxstat; print '
'; @@ -317,21 +322,18 @@ $showweather=empty($conf->global->MAIN_DISABLE_METEO)?1:0; //Array that contains all WorkboardResponse classes to process them $dashboardlines=array(); -print ''."\n"; -print ''; -print ''; -print ''; -print ''; -print ''; +$boxwork=''; +$boxwork.='
'.$langs->trans("DolibarrWorkBoard").''.$langs->trans("Number").''.$form->textwithpicto($langs->trans("Late"),$langs->trans("LateDesc")).' 
'."\n"; +$boxwork.=''; +$boxwork.=''; +$boxwork.=''; +$boxwork.=''; +$boxwork.=''; //print ''; -if ($showweather) print ''; -print ''."\n"; +if ($showweather) $boxwork.=''; +$boxwork.=''."\n"; - -// // Do not include sections without management permission -// - require DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php'; // Number of actions to do (late) @@ -357,7 +359,6 @@ if (! empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) { include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; $board=new Task($db); - $dashboardlines[] = $board->load_board($user); } @@ -367,7 +368,6 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $board=new Propal($db); $dashboardlines[] = $board->load_board($user,"opened"); - // Number of commercial proposals CLOSED signed (billed) $dashboardlines[] = $board->load_board($user,"signed"); } @@ -377,7 +377,6 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $board=new Commande($db); - $dashboardlines[] = $board->load_board($user); } @@ -386,7 +385,6 @@ if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->comma { include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; $board=new CommandeFournisseur($db); - $dashboardlines[] = $board->load_board($user); } @@ -396,7 +394,6 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $board=new Contrat($db); $dashboardlines[] = $board->load_board($user,"inactives"); - // Number of active services (expired) $dashboardlines[] = $board->load_board($user,"expired"); } @@ -445,7 +442,6 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->appr { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $board=new ExpenseReport($db); - $dashboardlines[] = $board->load_board($user,'toapprove'); } @@ -454,7 +450,6 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_p { include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $board=new ExpenseReport($db); - $dashboardlines[] = $board->load_board($user,'topay'); } @@ -483,55 +478,76 @@ foreach($valid_dashboardlines as $board) foreach($valid_dashboardlines as $board) { $var=!$var; - print ''; - print ''; - print ''; + $boxwork.= ''; + $boxwork.= ''; - print ''; + $boxwork.=''; + $boxwork.=''; /*print '';*/ if ($showweather) { - print ''; + $boxwork.=showWeather($totallate,$text,$options); + $boxwork.=''; $showweather=0; } - print ''; - print "\n"; + $boxwork.=''; + $boxwork.="\n"; } +$boxwork.='
'.$langs->trans("DolibarrWorkBoard").''.$langs->trans("Number").''.$form->textwithpicto($langs->trans("Late"),$langs->trans("LateDesc")).'   
 
'.$board->img.''.$board->label.''.$board->nbtodo.''; + $boxwork.= '
'.$board->img.''.$board->label.''.$board->nbtodo.''; //if ($board->nbtodolate > 0) //{ $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days"); - print ''; - print $board->nbtodolate; - print ''; + $boxwork.= ''; + $boxwork.= $board->nbtodolate; + $boxwork.= ''; //} - print ''; - if ($board->nbtodolate > 0) print img_picto($langs->trans("NActionsLate",$board->nbtodolate).' (>'.ceil($board->warning_delay).' '.$langs->trans("days").')',"warning"); - else print ' '; - print ''; + if ($board->nbtodolate > 0) $boxwork.=img_picto($langs->trans("NActionsLate",$board->nbtodolate).' (>'.ceil($board->warning_delay).' '.$langs->trans("days").')',"warning"); + else $boxwork.=' '; + $boxwork.=''; print ' (>'.ceil($board->warning_delay).' '.$langs->trans("days").')'; print ''; + $boxwork.=''; $text=''; if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')'; $options='height="64px"'; if ($rowspan <= 2) $options='height="24"'; // Weather logo is smaller if dashboard has few elements else if ($rowspan <= 3) $options='height="48"'; // Weather logo is smaller if dashboard has few elements - print showWeather($totallate,$text,$options); - print '
'; // End table array of working board -print ''; // End table array +print $boxwork; +print '
'; + +print '
'; -print '
'; /* * Show boxes */ -print $resultboxes['boxlist']; +$boxlist.=''; +$boxlist.='"; +$boxlist.= "
'."\n"; + +$boxlist.='
'; + +$boxlist.=$resultboxes['boxlista']; + +$boxlist.= '
'; + +$boxlist.=$resultboxes['boxlistb']; + +$boxlist.= '
'; +$boxlist.= "\n"; + +$boxlist.= "
"; + +print $boxlist; print '
'; + /* * Show security warnings */ From c1a6a2880b9e674379289f8262f0b022f08690f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 14:22:52 +0100 Subject: [PATCH 077/421] Debug numbering module for customer payment --- htdocs/admin/payment.php | 8 ++++++-- htdocs/compta/facture.php | 20 ++++++++++++++------ htdocs/index.php | 26 +++++++++++++++----------- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 07113231bcc..fa99e2c202b 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -39,6 +39,8 @@ $label = GETPOST('label','alpha'); $scandir = GETPOST('scandir','alpha'); $type='invoice'; +if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_payment_cicada.php'; + /* * Actions @@ -62,11 +64,13 @@ if ($action == 'updateMask') } } - if ($action == 'setmod') +if ($action == 'setmod') { dolibarr_set_const($db, "PAYMENT_ADDON",$value,'chaine',0,'',$conf->entity); } + + /* * View */ @@ -88,7 +92,7 @@ dol_fiche_head($head, 'payment', $langs->trans("Invoices"), 0, 'invoice'); * Numbering module */ -print load_fiche_titre($langs->trans("PaymentsNumberingModule")); +print load_fiche_titre($langs->trans("PaymentsNumberingModule"), '', ''); print ''; print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b3f3bd25c17..c8bc79c1928 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1827,6 +1827,7 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); $formmargin = new FormMargin($db); +$paymentstatic=new Paiement($db); $bankaccountstatic = new Account($db); if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } @@ -3125,6 +3126,7 @@ else if ($id > 0 || ! empty($ref)) // List of payments already done print ''; print ''; + print ''; print ''; if (! empty($conf->banque->enabled)) print ''; @@ -3135,10 +3137,10 @@ else if ($id > 0 || ! empty($ref)) $var = true; // Payments already done (from payment on this invoice) - $sql = 'SELECT p.datep as dp, p.num_paiement, p.rowid, p.fk_bank,'; + $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,'; $sql .= ' c.code as payment_code, c.libelle as payment_label,'; $sql .= ' pf.amount,'; - $sql .= ' ba.rowid as baid, ba.ref, ba.label'; + $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_paiement as c, ' . MAIN_DB_PREFIX . 'paiement_facture as pf, ' . MAIN_DB_PREFIX . 'paiement as p'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; @@ -3160,15 +3162,21 @@ else if ($id > 0 || ! empty($ref)) $objp = $db->fetch_object($result); $var = ! $var; print ''; + $paymentstatic->id=$objp->rowid; + $paymentstatic->datepaye=$db->jdate($objp->dp); + $paymentstatic->ref=$objp->ref; + $paymentstatic->num_paiement=$objp->num_paiement; + $paymentstatic->payment_code=$objp->payment_code; + print $paymentstatic->getNomUrl(1); + print ''; + print ''; $label = ($langs->trans("PaymentType" . $objp->payment_code) != ("PaymentType" . $objp->payment_code)) ? $langs->trans("PaymentType" . $objp->payment_code) : $objp->payment_label; print ''; if (! empty($conf->banque->enabled)) { $bankaccountstatic->id = $objp->baid; - $bankaccountstatic->ref = $objp->ref; - $bankaccountstatic->label = $objp->ref; + $bankaccountstatic->ref = $objp->baref; + $bankaccountstatic->label = $objp->baref; print ''; $boxinfo.= "\n"; $boxinfo.= "
' . ($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')) . '' . $langs->trans('Date') . '' . $langs->trans('Type') . '' . $langs->trans('BankAccount') . '
'; - print '' . img_object($langs->trans('ShowPayment'), 'payment') . ' '; - print dol_print_date($db->jdate($objp->dp), 'day') . ''.dol_print_date($db->jdate($objp->dp), 'day') . '' . $label . ' ' . $objp->num_paiement . ''; if ($bankaccountstatic->id) print $bankaccountstatic->getNomUrl(1, 'transactions'); diff --git a/htdocs/index.php b/htdocs/index.php index 3e2fa24eed0..0bb3b41ffb2 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -121,7 +121,8 @@ $boxinfo.= '
\n"; $boxinfo.= ''; -print $boxinfo; +//print $boxinfo; + /* * Dashboard Dolibarr states (statistics) @@ -309,7 +310,7 @@ if (empty($user->societe_id)) $boxstat.=''; $boxstat.=''; } -print $boxstat; +//print $boxstat; print '
'; @@ -323,6 +324,7 @@ $showweather=empty($conf->global->MAIN_DISABLE_METEO)?1:0; $dashboardlines=array(); $boxwork=''; +$boxwork.='
'; $boxwork.=''."\n"; $boxwork.=''; $boxwork.=''; @@ -514,8 +516,9 @@ foreach($valid_dashboardlines as $board) } $boxwork.='
'.$langs->trans("DolibarrWorkBoard").'
'; // End table array of working board +$boxwork.='
'; -print $boxwork; +//print $boxwork; print '
'; @@ -531,10 +534,13 @@ $boxlist.=''."\n"; $boxlist.='
'; +$boxlist.=$boxinfo; +$boxlist.=$boxstat; $boxlist.=$resultboxes['boxlista']; $boxlist.= '
'; +$boxlist.=$boxwork; $boxlist.=$resultboxes['boxlistb']; $boxlist.= '
'; @@ -592,8 +598,7 @@ $db->close(); /** * Show weather logo. Logo to show depends on $totallate and values for - * $conf->global->MAIN_METEO_OFFSET - * $conf->global->MAIN_METEO_GAP + * $conf->global->MAIN_METEO_LEVELx * * @param int $totallate Nb of element late * @param string $text Text to show on logo @@ -606,13 +611,12 @@ function showWeather($totallate,$text,$options) $out=''; $offset=0; - $cursor=10; // By default - //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET; - //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP; + $factor=10; // By default + $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0; - $level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1; - $level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; - $level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; + $level1=$offset+1*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1; + $level2=$offset+2*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2; + $level3=$offset+3*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3; if ($totallate <= $level0) $out.=img_picto_common($text,'weather/weather-clear.png',$options); if ($totallate > $level0 && $totallate <= $level1) $out.=img_picto_common($text,'weather/weather-few-clouds.png',$options); From efc2eeea8398d8c621f313e5ee70ac98138495ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 14:41:06 +0100 Subject: [PATCH 078/421] Uniformize code for filters on payments --- htdocs/compta/paiement/list.php | 40 ++++++++++----- htdocs/fourn/facture/paiement.php | 81 ++++++++++++++++--------------- 2 files changed, 68 insertions(+), 53 deletions(-) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 8cda05bec45..8ad94817699 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -56,6 +56,7 @@ $search_paymenttype=GETPOST("search_paymenttype"); $search_amount=GETPOST("search_amount",'alpha'); // alpha because we must be able to search on "< x" $search_company=GETPOST("search_company",'alpha'); $search_payment_num=GETPOST('search_payment_num','alpha'); + $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; @@ -67,6 +68,15 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="p.rowid"; +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('paymentlist')); +$extrafields = new ExtraFields($db); + + +/* + * Actions + */ + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $search_ref=""; @@ -80,10 +90,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $month=''; } -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('paymentlist')); -$extrafields = new ExtraFields($db); - /* @@ -167,11 +173,11 @@ else { $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } - if ($search_ref) $sql .=natural_search('p.ref', $search_ref); + if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($search_paymenttype != "") $sql .=" AND c.code='".$db->escape($search_paymenttype)."'"; - if ($search_payment_num != '') $sql .=" AND p.num_paiement = '".$db->escape($search_payment_num)."'"; - if ($search_amount) $sql .=" AND p.amount='".$db->escape(price2num($search_amount))."'"; + if ($search_payment_num != '') $sql .= natural_search('p.num_paiement', $search_payment_num); + if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); if ($search_company) $sql .= natural_search('s.nom', $search_company); // Add where from hooks $parameters=array(); @@ -199,10 +205,12 @@ if ($resql) $paramlist=''; $paramlist.=(GETPOST("orphelins")?"&orphelins=1":""); - $paramlist.=($search_ref?"&search_ref=".$search_ref:""); - $paramlist.=($search_company?"&search_company=".$search_company:""); - $paramlist.=($search_amount?"&search_amount=".$search_amount:""); - + $paramlist.=($search_ref?"&search_ref=".urlencode($search_ref):""); + $paramlist.=($search_company?"&search_company=".urlencode($search_company):""); + $paramlist.=($search_amount?"&search_amount=".urlencode($search_amount):""); + $paramlist.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); + if ($optioncss != '') $paramlist.='&optioncss='.urlencode($optioncss); + print_barre_liste($langs->trans("ReceivedCustomersPayments"), $page, $_SERVER["PHP_SELF"],$paramlist,$sortfield,$sortorder,'',$num, $nbtotalofrecords,'title_accountancy.png'); print '
'; @@ -273,9 +281,10 @@ if ($resql) print $paymentstatic->getNomUrl(1); print ''; + // Date print ''.dol_print_date($db->jdate($objp->dp),'day').''; - // Company + // Thirdparty print ''; if ($objp->socid) { @@ -286,7 +295,12 @@ if ($resql) else print ' '; print ''; - print ''.$langs->trans("PaymentTypeShort".$objp->paiement_code).''.$objp->num_paiement.''; + // Type + print ''.$langs->trans("PaymentTypeShort".$objp->paiement_code).''; + + // Payment number + print ''.$objp->num_paiement.''; + print ''; if ($objp->bid) { diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index c4b2e4c01f6..36f3fc2ffb3 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -46,6 +46,13 @@ $facid=GETPOST('facid','int'); $socid=GETPOST('socid','int'); $accountid = GETPOST('accountid'); +$search_ref=GETPOST("search_ref","int"); +$search_account=GETPOST("search_account","int"); +$search_paymenttype=GETPOST("search_paymenttype"); +$search_amount=GETPOST("search_amount",'alpha'); // alpha because we must be able to search on "< x" +$search_company=GETPOST("search_company",'alpha'); +$search_payment_num=GETPOST('search_payment_num','alpha'); + $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); @@ -69,6 +76,7 @@ if ($user->societe_id > 0) // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('paymentsupplier')); +$extrafields = new ExtraFields($db); @@ -76,6 +84,19 @@ $hookmanager->initHooks(array('paymentsupplier')); * Actions */ +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=""; + $search_account=""; + $search_amount=""; + $search_paymenttype=""; + $search_payment_num=""; + $search_company=""; + $day=''; + $year=''; + $month=''; +} + $parameters=array('socid'=>$socid); $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'); @@ -460,21 +481,6 @@ if (empty($action)) if (! $sortorder) $sortorder='DESC'; if (! $sortfield) $sortfield='p.datep'; - $search_ref=GETPOST('search_ref'); - $search_account=GETPOST('search_account'); - $search_paymenttype=GETPOST('search_paymenttype'); - $search_amount=GETPOST('search_amount'); - $search_company=GETPOST('search_company'); - - if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers - { - $search_ref=""; - $search_account=""; - $search_paymenttype=""; - $search_amount=""; - $search_company=""; - } - $sql = 'SELECT p.rowid as pid, p.datep as dp, p.amount as pamount, p.num_paiement,'; $sql.= ' s.rowid as socid, s.nom as name,'; $sql.= ' c.code as paiement_type, c.libelle as paiement_libelle,'; @@ -496,26 +502,12 @@ if (empty($action)) $sql .= ' AND f.fk_soc = '.$socid; } // Search criteria - if (! empty($search_ref)) - { - $sql .= ' AND p.rowid='.$db->escape($search_ref); - } - if (! empty($search_account) && $search_account > 0) - { - $sql .= ' AND b.fk_account='.$db->escape($search_account); - } - if (! empty($search_paymenttype)) - { - $sql .= " AND c.code='".$db->escape($search_paymenttype)."'"; - } - if (! empty($search_amount)) - { - $sql .= " AND p.amount='".price2num($search_amount)."'"; - } - if (! empty($search_company)) - { - $sql .= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; - } + if ($search_ref) $sql .= natural_search('p.rowid', $search_ref); + if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; + if ($search_paymenttype != "") $sql .=" AND c.code='".$db->escape($search_paymenttype)."'"; + if ($search_payment_num != '') $sql .= natural_search('p.num_paiement', $search_payment_num); + if ($search_amount) $sql .= natural_search('p.amount', $search_amount, 1); + if ($search_company) $sql .= natural_search('s.nom', $search_company); $sql.= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.code, c.libelle, ba.rowid, ba.label"; if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= $db->order($sortfield,$sortorder); @@ -529,10 +521,11 @@ if (empty($action)) $var=True; $paramlist=''; - $paramlist.=(! empty($search_ref)?"&search_ref=".$search_ref:""); - $paramlist.=(! empty($search_company)?"&search_company=".$search_company:""); - $paramlist.=(! empty($search_amount)?"&search_amount='".$search_amount:""); - if ($optioncss != '') $paramlist.='&optioncss='.$optioncss; + $paramlist.=($search_ref?"&search_ref=".urlencode($search_ref):""); + $paramlist.=($search_company?"&search_company=".urlencode($search_company):""); + $paramlist.=($search_amount?"&search_amount=".urlencode($search_amount):""); + $paramlist.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); + if ($optioncss != '') $paramlist.='&optioncss='.urlencode($optioncss); print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"],$paramlist,$sortfield,$sortorder,'',$num); @@ -544,6 +537,7 @@ if (empty($action)) print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'dp','',$paramlist,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans('ThirdParty'),$_SERVER["PHP_SELF"],'s.nom','',$paramlist,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Type'),$_SERVER["PHP_SELF"],'c.libelle','',$paramlist,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Numero"),$_SERVER["PHP_SELF"],"p.num_paiement","",$paramlist,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans('Account'),$_SERVER["PHP_SELF"],'ba.label','',$paramlist,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans('Amount'),$_SERVER["PHP_SELF"],'p.amount','',$paramlist,'align="right"',$sortfield,$sortorder); //print_liste_field_titre($langs->trans('Invoice'),$_SERVER["PHP_SELF"],'ref_supplier','',$paramlist,'',$sortfield,$sortorder); @@ -562,6 +556,9 @@ if (empty($action)) print ''; $form->select_types_paiements($search_paymenttype,'search_paymenttype','',2,1,1); print ''; + print ''; + print ''; + print ''; print ''; $form->select_comptes($search_account,'search_account',0,'',1); print ''; @@ -585,15 +582,19 @@ if (empty($action)) // Date print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; + // Thirdparty print ''; if ($objp->socid) print ''.img_object($langs->trans('ShowCompany'),'company').' '.dol_trunc($objp->name,32).''; else print ' '; print ''; + // Type $payment_type = $langs->trans("PaymentType".$objp->paiement_type)!=("PaymentType".$objp->paiement_type)?$langs->trans("PaymentType".$objp->paiement_type):$objp->paiement_libelle; - print ''.$payment_type.' '.dol_trunc($objp->num_paiement,32)."\n"; + // Payment number + print ''.$objp->num_paiement.''; + print ''; if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"),'account').' '.dol_trunc($objp->label,24).''; else print ' '; From 3a5846ea7facf271060e0e3c4253175836a64350 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 14:45:49 +0100 Subject: [PATCH 079/421] Fix bad link to bank account --- htdocs/accountancy/journal/bankjournal.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 4ca8b152202..3f62dfbe40e 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -122,7 +122,7 @@ $paymentsalstatic = new PaymentSalary($db); // Get code of finance journal $bank_code_journal = new Account($db); $result = $bank_code_journal->fetch($id_bank_account); -$journal = $bank_code_journal->accountancy_journal; +$journal = $bank_code_journal->ref; dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); $result = $db->query($sql); @@ -524,7 +524,7 @@ else { llxHeader('', $langs->trans("FinanceJournal")); - $nom = $langs->trans("FinanceJournal") . ' - ' . $journal; + $nom = $langs->trans("FinanceJournal") . ' - ' . $bank_code_journal->getNomUrl(1); $builddate = time(); $description = $langs->trans("DescFinanceJournal") . '
'; $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); From 9da0164d90252ae26238f6b83812637a2f05a0d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 15:50:48 +0100 Subject: [PATCH 080/421] Uniformize code for lists --- dev/skeletons/skeleton_list.php | 6 ++--- htdocs/accountancy/bookkeeping/listbyyear.php | 9 ++++--- htdocs/accountancy/customer/lines.php | 8 +++--- htdocs/accountancy/supplier/lines.php | 8 +++--- htdocs/adherents/cotisations.php | 10 +++++--- htdocs/adherents/list.php | 12 ++++----- htdocs/adherents/type.php | 16 ------------ htdocs/commande/list.php | 8 +++--- htdocs/commande/orderstoinvoice.php | 10 ++++---- htdocs/compta/bank/account.php | 8 +++--- htdocs/compta/bank/search.php | 15 +++++------ htdocs/compta/deplacement/list.php | 8 +++--- htdocs/compta/facture/list.php | 8 +++--- htdocs/compta/facture/mergepdftool.php | 14 +++-------- htdocs/compta/paiement/cheque/list.php | 8 +++--- htdocs/compta/paiement/list.php | 7 +++--- htdocs/compta/prelevement/list.php | 15 ++++++----- htdocs/compta/salaries/index.php | 9 ++++--- htdocs/compta/sociales/index.php | 9 ++++--- htdocs/compta/tva/reglement.php | 9 ++++--- htdocs/contrat/list.php | 11 ++++---- htdocs/contrat/services.php | 8 +++--- htdocs/core/class/html.form.class.php | 19 ++++++++++++++ htdocs/don/list.php | 11 +++++--- htdocs/expedition/list.php | 8 +++--- htdocs/expensereport/list.php | 8 +++--- htdocs/fichinter/list.php | 8 +++--- htdocs/fourn/commande/list.php | 8 +++--- htdocs/fourn/commande/orderstoinvoice.php | 6 +++-- htdocs/fourn/facture/impayees.php | 10 +++++--- htdocs/fourn/facture/list.php | 7 +++--- htdocs/fourn/facture/paiement.php | 9 ++++--- htdocs/holiday/list.php | 6 ++--- htdocs/loan/calc.php | 25 ++++++++++++------- htdocs/opensurvey/list.php | 4 +-- .../product/canvas/product/tpl/list.tpl.php | 12 ++++----- .../product/canvas/service/tpl/list.tpl.php | 12 ++++----- htdocs/product/list.php | 8 +++--- htdocs/product/price.php | 9 +++---- htdocs/product/reassort.php | 8 +++--- htdocs/product/reassortlot.php | 8 +++--- htdocs/product/stock/list.php | 8 +++--- htdocs/product/stock/replenish.php | 10 ++++---- htdocs/projet/list.php | 8 +++--- htdocs/projet/tasks/list.php | 4 +-- htdocs/societe/consumption.php | 4 +-- htdocs/societe/list.php | 12 ++++----- htdocs/societe/price.php | 3 ++- htdocs/user/hierarchy.php | 5 ++-- htdocs/user/index.php | 8 +++--- 50 files changed, 256 insertions(+), 208 deletions(-) diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 834e0b07e2f..80e3e38f438 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -352,9 +352,9 @@ if ($resql) }*/ // Action column print ''; - print ''; - print ''; - print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print ''."\n"; diff --git a/htdocs/accountancy/bookkeeping/listbyyear.php b/htdocs/accountancy/bookkeeping/listbyyear.php index d04edae3bf2..e9751e0f12e 100644 --- a/htdocs/accountancy/bookkeeping/listbyyear.php +++ b/htdocs/accountancy/bookkeeping/listbyyear.php @@ -208,9 +208,10 @@ print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, "", $sortfield, $sortorder); -print ''; -print ''; +print ''; +print ''; print "\n"; + print ''; print ''; @@ -258,7 +259,9 @@ print ''; print ''; print ''; -print ''; +print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; print ''; print "\n"; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 0d5dbc35668..7b4d597fc12 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -246,9 +246,11 @@ if ($result) { print '%'; print ''; print ' '; - print ''; - print ''; - print "\n"; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; $facture_static = new Facture($db); $product_static = new Product($db); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 6736c6a30d6..788eaa32e88 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -220,9 +220,11 @@ if ($result) { print '%'; print ''; print ' '; - print ''; - print ''; - print "\n"; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; $facturefournisseur_static = new FactureFournisseur($db); $product_static = new Product($db); diff --git a/htdocs/adherents/cotisations.php b/htdocs/adherents/cotisations.php index cc8e39d32ca..7ff98ceb503 100644 --- a/htdocs/adherents/cotisations.php +++ b/htdocs/adherents/cotisations.php @@ -196,11 +196,13 @@ if ($result) print ''; print ''; - print ''; - print ''; - print ' '; - print ''; print ''; + + // Action column + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print "\n"; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index dc7266603ca..b19c6b2e35d 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -240,7 +240,7 @@ if ($resql) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans(""),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder); print "\n"; // Line for filters fields @@ -272,11 +272,11 @@ if ($resql) // Status print ' '; - print ''; - print ''; - print '  '; - print ''; - print ''; + // Action column + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print "\n"; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index e2fc32f3bcb..f46b6d0268c 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -210,22 +210,6 @@ if (! $rowid && $action != 'create' && $action != 'edit') { dol_print_error($db); } - - //dol_fiche_end(); - - /* - * Hotbar - */ - print '
'; - - // New type - if ($user->rights->adherent->configurer) - { - print ''; - } - - print "
"; - } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 8e5e73fd6fc..5a112e60861 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -378,9 +378,11 @@ if ($resql) print ''; print $form->selectyesno('billed', $billed, 1, 0, 1); print ''; - print ''; - print ''; - print "\n"; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; $var=true; $total=0; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 79f18ad26ab..aeafb1ee67b 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -604,10 +604,11 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) //REF print ''; print ''; - //print ''; + print ''; print ''; - + print ''; + //DATE ORDER print ''; print $period; @@ -619,15 +620,14 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; //SEARCH BUTTON - print ''; + print ''; print ''; //ALL/NONE - print ''; if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; print ''; - print ''; + print ''; print ''; print '
'; diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index d6f8652d31c..0973ece78d3 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -555,10 +555,10 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print ' '; - print ''; - print ''; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print "\n"; diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index 81a1a493892..f5231a87ef8 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -178,7 +178,9 @@ if ($resql) print ''."\n"; print ''."\n"; - + print ''; + if (! empty($_REQUEST['bid'])) print ''; + $moreforfilter = ''; $moreforfilter.='
'; @@ -227,12 +229,11 @@ if ($resql) print ''; print ''; print ''; - print ''; - print ''; - if (! empty($_REQUEST['bid'])) print ''; - print ''; - print ''; - print "\n"; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; // Loop on each record $total_debit=0; diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index a5684891ca8..497de98fa72 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -164,9 +164,11 @@ if ($resql) print ''; // print ''; print ''; - print ''; - print ''; - print "\n"; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; $var=true; while ($i < min($num,$limit)) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a680886827a..1c32462b884 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -783,9 +783,11 @@ if ($resql) $liststatus=array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); print $form->selectarray('search_status', $liststatus, $search_status, 1); print ''; - print ''; - print ''; - print "\n"; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; if ($num > 0) { diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php index cff600d3a57..19c1d083018 100644 --- a/htdocs/compta/facture/mergepdftool.php +++ b/htdocs/compta/facture/mergepdftool.php @@ -814,17 +814,7 @@ if ($resql) print_liste_field_titre($langs->trans("Received"),$_SERVER["PHP_SELF"],"am","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Rest"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"fk_statut,paye,am","",$param,'align="right"',$sortfield,$sortorder); - - $searchpitco=''; - $searchpitco.=''; - if (empty($mode)) - { - print_liste_field_titre($searchpitco,$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); - } - else - { - print_liste_field_titre($searchpitco,$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); - } + print_liste_field_titre('',$_SERVER["PHP_SELF"],"","",$param,'align="center"',$sortfield,$sortorder); print "\n"; // Lignes des champs de filtre @@ -858,6 +848,8 @@ if ($resql) print $form->selectarray('filtre', $liststatus, $filter, 1); print ''; print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; if (empty($mode)) { if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 5e404a76242..2b3a7153793 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -151,9 +151,11 @@ if ($resql) print ''; print ''; print ''; - print ''; - print ''; - print "\n"; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; if ($num > 0) { diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 8ad94817699..33576328786 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -257,9 +257,10 @@ if ($resql) print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; print ''; if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index d0c6792a785..e7cef1a50ad 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -114,6 +114,7 @@ if ($result) print_barre_liste($langs->trans("WithdrawalsLines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num); print"\n\n"; + print ''; print ''; print ''; @@ -126,8 +127,7 @@ if ($result) print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"pl.amount","","",'align="right"'); print_liste_field_titre(''); print "\n"; - - print ''; + print ''; print ''; print ''; @@ -137,10 +137,10 @@ if ($result) print ''; print ''; print ''; - print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print ''; $var=True; @@ -185,6 +185,9 @@ if ($result) $i++; } print "
  '; - print ''; - print ''; - print '
"; + + print ''; + $db->free($result); } else diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 52f1938a857..18554f30de8 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -167,9 +167,12 @@ if ($result) print ''; // Amount print ''; - print ''; - print ''; - print "\n"; + + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; while ($i < min($num,$limit)) { diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 63c156609c8..2dbb3fd22d7 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -193,9 +193,12 @@ if ($resql) print ' '; // Status print ' '; - print ''; - print ''; - print "\n"; + + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; while ($i < min($num,$limit)) { diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 91140bb97ca..3dee569b0ff 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -162,9 +162,12 @@ if ($result) $form->select_types_paiements($typeid,'typeid','',0,0,1,16); print ''; print ''; - print ''; - print ''; - print "\n"; + + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; while ($i < min($num,$limit)) { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 040a623fe98..f9e7351ed87 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -254,11 +254,12 @@ if ($resql) print ''; print ''; print ' '; - //print ' '; - print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; $var=true; while ($i < min($num,$limit)) diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index b7b257ca07a..2f1c3697058 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -238,9 +238,11 @@ if ($resql) ); print $form->selectarray('search_status',$arrayofstatus,(strstr($search_status, ',')?-1:$search_status),1); print ''; - print ''; - print ''; - print "\n"; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; $contractstatic=new Contrat($db); $productstatic=new Product($db); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e60883c7149..aac6d0714f2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5676,5 +5676,24 @@ class Form return $out; } + /** + * Return HTML to show the search and clear seach button + * + * @param int $addcheckuncheckall Add the check all uncheck al button + * @return string + */ + function showFilterAndCheckAddButtons($addcheckuncheckall=0) + { + global $langs; + + $out=''; + $out.=''; + if ($addcheckuncheckall) + { + + } + $out.=''; + return $out; + } } diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 83e1db184a5..372e60b5f96 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -111,7 +111,7 @@ if (trim($search_name) != '') { $sql .= natural_search(array('d.lastname', 'd.firstname'), $search_name); } -if ($search_amount) $sql.=" AND d.amount='".$db->escape(price2num(trim($search_amount)))."'"; +if ($search_amount) $sql.= natural_search(array('d.amount'), price2num(trim($search_amount)), 1); $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit+1, $offset); @@ -188,9 +188,12 @@ if ($resql) print ''; } print ''; - print ''; - print ''; - print "\n"; + + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; $var=True; while ($i < min($num,$limit)) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 4d1764ad0cf..c8dd6445ae2 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -189,12 +189,10 @@ if ($resql) print ''; print $form->selectarray('viewstatut', array('0'=>$langs->trans('StatusSendingDraftShort'),'1'=>$langs->trans('StatusSendingValidatedShort'),'2'=>$langs->trans('StatusSendingProcessedShort')),$viewstatut,1); print ''; - // Search - print ''; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; print ''; - print "\n"; $var=True; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index efa6572dd10..b7f5be64455 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -265,10 +265,10 @@ if ($resql) select_expensereport_statut($search_status,'search_status',1,1); print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print "\n"; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 74edaf72099..cf40a285996 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -196,9 +196,11 @@ if ($result) $liststatus=$interventionstatic->statuts_short; print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1); print ''; - print ''; - print ''; - print "\n"; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; $companystatic=new Societe($db); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index a3e0d8c9c33..3f4aee09bcd 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -269,9 +269,11 @@ if ($resql) print ''; print $form->selectyesno('billed', $billed, 1, 0, 1); print ''; - print ''; - print ''; - print "\n"; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; $var=true; diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index d0502ed927a..3f75bca3a35 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -500,7 +500,8 @@ if (($action != 'create' && $action != 'add') && !$error) { // print ''; print ''; print ''; - + print ''; + // DATE ORDER print ''; print $period; @@ -512,8 +513,9 @@ if (($action != 'create' && $action != 'add') && !$error) { print ''; // SEARCH BUTTON - print ''; + print ''; print ''; + print ''; // ALL/NONE print ''; diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php index ccb6671ba3a..a5ea3b88286 100644 --- a/htdocs/fourn/facture/impayees.php +++ b/htdocs/fourn/facture/impayees.php @@ -214,10 +214,12 @@ if ($user->rights->fournisseur->facture->lire) print ''; print ''; print ''; - print ''; - print ''; - print ''; - print "\n"; + print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + print "\n"; if ($num > 0) { diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 6731c70d328..3c238a2f6f8 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -332,10 +332,11 @@ if ($resql) print ''; $liststatus=array('0'=>$langs->trans("Draft"),'1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); print $form->selectarray('filtre', $liststatus, $search_status, 1); - print ''; - print ''; - print ''; print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print "\n"; $facturestatic=new FactureFournisseur($db); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 36f3fc2ffb3..3753001cf23 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -564,10 +564,11 @@ if (empty($action)) print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print "\n"; while ($i < min($num,$limit)) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index a92945ce502..3e74c7e14f5 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -368,9 +368,9 @@ $holiday->selectStatutCP($search_statut); print ''; // ACTION -print ''; -print ''; -print ''; +print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; print ''; print "\n"; diff --git a/htdocs/loan/calc.php b/htdocs/loan/calc.php index e73b5e0f255..681d0721f0a 100644 --- a/htdocs/loan/calc.php +++ b/htdocs/loan/calc.php @@ -115,6 +115,8 @@ if (! empty($errors)) { $form_complete = false; } + + /* * View */ @@ -125,31 +127,34 @@ print load_fiche_titre($langs->trans("LoanCalc")); print $langs->trans('LoanCalcDesc'); print '
'; -print ''; -print ''; +print '
'; + +dol_fiche_head(''); + +print '
'; //print ''; //print ''; //print ''; //print ''; -print ''; +print ''; print ''; print ''; -print ''; +print ''; print ''; print '';print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; if (! empty($show_progress)) @@ -164,7 +169,9 @@ else print ''; print '
'.$langs->trans('PurchaseFinanceInfo').'
'.$langs->trans('SalePriceOfAsset').': '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans('PercentageDown').':%
'.$langs->trans('LengthOfMortgage').':years
'.$langs->trans('AnnualInterestRate').':%
'.$langs->trans('ExplainCalculations').':
'; -print '
    '; +dol_fiche_end(); + +print '
    '; print '
'; // If the form has already been calculated, the $down_payment diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index d152364929d..b440b5ee43e 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -108,8 +108,8 @@ print ''; $arraystatus=array(''=>' ','expired'=>$langs->trans("Expired"),'opened'=>$langs->trans("Opened")); print ''. $form->selectarray('status', $arraystatus, $status).''; print ''; -print ''; -print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; print ''; print ''."\n"; diff --git a/htdocs/product/canvas/product/tpl/list.tpl.php b/htdocs/product/canvas/product/tpl/list.tpl.php index c5e372cfad0..e57fd5adfab 100644 --- a/htdocs/product/canvas/product/tpl/list.tpl.php +++ b/htdocs/product/canvas/product/tpl/list.tpl.php @@ -69,12 +69,12 @@ if ($searchfield['enabled']) { if ($searchfield['search']) { ?> - - - - - - + '; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + } else { ?>   diff --git a/htdocs/product/canvas/service/tpl/list.tpl.php b/htdocs/product/canvas/service/tpl/list.tpl.php index fe860c1bf73..4fc875e15bf 100644 --- a/htdocs/product/canvas/service/tpl/list.tpl.php +++ b/htdocs/product/canvas/service/tpl/list.tpl.php @@ -69,12 +69,12 @@ if ($searchfield['enabled']) { if ($searchfield['search']) { ?> - - - - - - + '; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; + } else { ?>   diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 6451f8bdde5..088f7e73c66 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -548,10 +548,10 @@ else print $form->selectarray('tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'),'1'=>$langs->trans('ProductStatusOnBuyShort')),$tobuy,1); print ''; } - print ''; - print ''; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print ''; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 1f635a96262..b8c9222fab6 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1459,11 +1459,10 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print ''; print ' '; // Print the search button - print ''; - print ''; - print ' '; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print ''; } diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index b8a52024dfc..27f85cd90ab 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -279,10 +279,10 @@ if ($resql) print ' '; print ' '; print ' '; - print ''; - print ''; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print ''; $product_static=new Product($db); diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 87d6d4e46eb..3b77f9c5ba7 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -292,10 +292,10 @@ if ($resql) print ' '; print ' '; print ' '; - print ''; - print ''; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print ''; $product_static=new Product($db); diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 6d487de21e3..bebfc87b528 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -153,10 +153,10 @@ if ($result) print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1); print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print ''; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 94629a3e821..d29ee366bb0 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -468,11 +468,11 @@ print ' '. ' '. '' . $langs->trans('AlertOnly') . ' '. ' '. - ' '. - ''. - ''. - ''. - ''; + ' '; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print ''; $prod = new Product($db); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 6153d3b81ce..75dca94540b 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -516,10 +516,10 @@ if ($resql) print ''; } // Action column - print ''; - print ''; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print ''."\n"; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index e140ee2f672..98bbff88483 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -504,8 +504,8 @@ if ($resql) } // Action column print ''; - print ''; - print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; print ''; print ''; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 0c5e6646889..4f1f9fb05d6 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -348,8 +348,8 @@ print ''; print ''; print ''; print ''; -print ''; -print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; print ''; print ''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index d8e22b3974d..7cfc07918fd 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -718,7 +718,8 @@ if ($resql) // Type (customer/prospect/supplier) print ''; - print ''; + print ''; - print ''; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print "\n"; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 589c102c8a3..7ac093ca7dd 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -509,7 +509,8 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ' '; // Print the search button print ''; - print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; print ''; print ''; diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 8ac96a336f4..66d725b3204 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -152,8 +152,9 @@ print ' '; print ''; print $form->selectarray('search_statut', array('-1'=>'','1'=>$langs->trans('Enabled')),$search_statut); print ''; -print ''; -print ''; +print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; print ''; print ''; diff --git a/htdocs/user/index.php b/htdocs/user/index.php index d0ac0aaa66d..f0fa04327cd 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -395,10 +395,10 @@ if ($result) print ''; } // Action column - print ''; - print ''; - print ''; - print ''; + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(0); + print $searchpitco; + print ''; print "\n"; From b68047428a73a0e11065d6a5534f25559533c8bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 16:02:30 +0100 Subject: [PATCH 081/421] Fix filter on cron --- htdocs/cron/class/cronjob.class.php | 3 ++- htdocs/cron/list.php | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 9ef47c30ea7..5a3be50c738 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -395,7 +395,8 @@ class Cronjob extends CommonObject $sql.= " t.test"; $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; $sql.= " WHERE 1 = 1"; - if ($status >= 0) $sql.= " AND t.status = ".(empty($status)?'0':'1'); + if ($status >= 0 && $status < 2) $sql.= " AND t.status = ".(empty($status)?'0':'1'); + if ($status == 2) $sql.= " AND t.status = 2"; //Manage filter if (is_array($filter) && count($filter)>0) { foreach($filter as $key => $value) { diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 49f5878d436..a42feafc437 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2015 Laurent Destailleur + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013-2016 Laurent Destailleur * * 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 @@ -35,11 +35,6 @@ $langs->load("bills"); if (!$user->rights->cron->read) accessforbidden(); - -/* - * Actions - */ - $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $id=GETPOST('id','int'); @@ -57,7 +52,7 @@ if (empty($sortorder)) $sortorder="DESC"; if (empty($sortfield)) $sortfield="t.status"; if (empty($arch)) $arch = 0; if ($page == -1) { - $page = 0 ; + $page = 0 ; } $limit = $conf->global->MAIN_SIZE_LISTE_LIMIT; @@ -65,6 +60,11 @@ $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; + +/* + * Actions + */ + // Do we click on purge search criteria ? if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { @@ -79,8 +79,8 @@ if (!empty($search_label)) } // Delete jobs -if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete){ - +if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete) +{ //Delete cron task $object = new Cronjob($db); $object->id=$id; @@ -92,8 +92,8 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->del } // Execute jobs -if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute){ - +if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) +{ $object = new Cronjob($db); $job = $object->fetch($id); From baa6172ead70cb11dba7ce37b7ab3acee8ca2a64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 16:13:33 +0100 Subject: [PATCH 082/421] Fix look for first incoterm combo --- htdocs/core/class/html.form.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index aac6d0714f2..ca4d9550bcb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -645,11 +645,11 @@ class Form * @param string $page Defined the form action * @param string $htmlname Name of html select object * @param string $htmloption Options html on select object - * @param int $forcecombo Force to use combo box + * @param int $forcecombo Force to use standard combo box (no ajax use) * @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return string HTML string with select and input */ - function select_incoterms($selected='', $location_incoterms='', $page='',$htmlname='incoterm_id',$htmloption='', $forcecombo=0, $events=array()) + function select_incoterms($selected='', $location_incoterms='', $page='', $htmlname='incoterm_id', $htmloption='', $forcecombo=1, $events=array()) { global $conf,$langs; @@ -667,7 +667,7 @@ class Form $resql=$this->db->query($sql); if ($resql) { - if (!$forcecombo) + if ($conf->use_javascript_ajax && ! $forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $out .= ajax_combobox($htmlname, $events); @@ -680,8 +680,8 @@ class Form $out .= ''; } - $out.= ''; + $out.= ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) From 786f16de0204cfc975becb3165e1e6545200c608 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 16:20:07 +0100 Subject: [PATCH 083/421] Add comment --- htdocs/core/class/commondocgenerator.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 5804ab4cf9f..b8aa683097f 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -134,9 +134,8 @@ abstract class CommonDocGenerator 'mycompany_idprof6'=>$mysoc->idprof6, 'mycompany_vatnumber'=>$mysoc->tva_intra, 'mycompany_object'=>$mysoc->object, - // Only private not exists for "mysoc" 'mycompany_note_private'=>$mysoc->note_private, - + //'mycompany_note_public'=>$mysoc->note_public, // Only private not exists for "mysoc" but both for thirdparties ); } From 81aae30253ff494a4f38624238845fc632f28564 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 19:55:41 +0100 Subject: [PATCH 084/421] NEW Add a checkbox to select/unselect all lines on page that support mass actions (like invoice list page) --- htdocs/compta/facture/list.php | 4 ++-- htdocs/compta/facture/mergepdftool.php | 10 +------- htdocs/core/class/html.form.class.php | 33 ++++++++++++++++++++------ htdocs/theme/eldy/style.css.php | 8 +++++-- htdocs/theme/md/style.css.php | 5 ++++ 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 1c32462b884..1b81c3cda50 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -783,8 +783,8 @@ if ($resql) $liststatus=array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); print $form->selectarray('search_status', $liststatus, $search_status, 1); print ''; - print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); + print ''; + $searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1); print $searchpitco; print ''; print "\n"; diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php index 19c1d083018..27325bdef1d 100644 --- a/htdocs/compta/facture/mergepdftool.php +++ b/htdocs/compta/facture/mergepdftool.php @@ -848,16 +848,8 @@ if ($resql) print $form->selectarray('filtre', $liststatus, $filter, 1); print ''; print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); + $searchpitco=$form->showFilterAndCheckAddButtons(1, empty($mode)?'checkformerge':'checkforsend'); print $searchpitco; - if (empty($mode)) - { - if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; - } - else - { - if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; - } print ''; print "\n"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ca4d9550bcb..633ff76117c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -508,7 +508,6 @@ class Form $ret.=' '; return $out; } } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 30f97b557d4..4f1e049ba65 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -263,7 +263,7 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla font-size: px; font-family: ; background: #FFF; - color: #111; + /* color: #111; */ border: 1px solid #C0C0C0; margin: 0px 0px 0px 0px; } @@ -515,7 +515,11 @@ div.myavailability { padding-top: 4px; padding-bottom: 4px; } - +.checkallactions { + vertical-align: top; + margin-top: 6px; + margin-left: 4px; +} /* ============================================================================== */ /* Styles to hide objects */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 02896756c64..b60c3c5be06 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -503,6 +503,11 @@ div.myavailability { padding-top: 4px; padding-bottom: 4px; } +.checkallactions { + vertical-align: top; + margin-top: 6px; + margin-left: 4px; +} /* ============================================================================== */ /* Styles to hide objects */ From ad63d5c48db1b09cefd123ba6a946e0fdf4b2025 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 22:47:16 +0100 Subject: [PATCH 085/421] NEW Move load module to status experimental --- htdocs/core/modules/modComptabilite.class.php | 2 +- htdocs/core/modules/modLoan.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modComptabilite.class.php b/htdocs/core/modules/modComptabilite.class.php index 864c0012dec..ca49ab12f7d 100644 --- a/htdocs/core/modules/modComptabilite.class.php +++ b/htdocs/core/modules/modComptabilite.class.php @@ -58,7 +58,7 @@ class modComptabilite extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; - $this->picto=''; + $this->picto='accounting'; // Config pages $this->config_page_url = array("compta.php"); diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 19d44ca11cc..25f1b7cf2c2 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -51,7 +51,7 @@ class modLoan extends DolibarrModules $this->description = "Loans management"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'development'; + $this->version = 'experimental'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->special = 0; From cfa3b16637a9beed63f7c7d54b2277302bc07f28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 22:47:46 +0100 Subject: [PATCH 086/421] Menu entries for accountancy are shown when menu entry is selected and not all the time --- htdocs/core/menus/standard/eldy.lib.php | 46 ++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index baa73c532f8..e0da649e53b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -940,21 +940,21 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy",$langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy'); // Dispatch - $newmenu->add("/accountancy/customer/index.php?leftmenu=dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->ventilation->read, '', $mainmenu, 'dispatch_customer'); - if (empty($leftmenu) || $leftmenu=="dispatch_customer") $newmenu->add("/accountancy/customer/list.php",$langs->trans("ToDispatch"),2,$user->rights->accounting->ventilation->dispatch); - if (empty($leftmenu) || $leftmenu=="dispatch_customer") $newmenu->add("/accountancy/customer/lines.php",$langs->trans("Dispatched"),2,$user->rights->accounting->ventilation->read); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->ventilation->read, '', $mainmenu, 'dispatch_customer'); + if (preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/list.php?leftmenu=accountancy_dispatch_customer",$langs->trans("ToDispatch"),2,$user->rights->accounting->ventilation->dispatch); + if (preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/lines.php?leftmenu=accountancy_dispatch_customer",$langs->trans("Dispatched"),2,$user->rights->accounting->ventilation->read); if (! empty($conf->supplier_invoice->enabled)) { - $newmenu->add("/accountancy/supplier/index.php?leftmenu=dispatch_supplier&mainmenu=accountancy",$langs->trans("SuppliersVentilation"),1,$user->rights->accounting->ventilation->read, '', $mainmenu, 'dispatch_supplier'); - if (empty($leftmenu) || $leftmenu=="dispatch_supplier") $newmenu->add("/accountancy/supplier/list.php",$langs->trans("ToDispatch"),2,$user->rights->accounting->ventilation->dispatch); - if (empty($leftmenu) || $leftmenu=="dispatch_supplier") $newmenu->add("/accountancy/supplier/lines.php",$langs->trans("Dispatched"),2,$user->rights->accounting->ventilation->read); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&mainmenu=accountancy",$langs->trans("SuppliersVentilation"),1,$user->rights->accounting->ventilation->read, '', $mainmenu, 'dispatch_supplier'); + if (preg_match('/accountancy_dispatch_supplier/',$leftmenu)) $newmenu->add("/accountancy/supplier/list.php?leftmenu=accountancy_dispatch_supplier",$langs->trans("ToDispatch"),2,$user->rights->accounting->ventilation->dispatch); + if (preg_match('/accountancy_dispatch_supplier/',$leftmenu)) $newmenu->add("/accountancy/supplier/lines.php?leftmenu=accountancy_dispatch_supplier",$langs->trans("Dispatched"),2,$user->rights->accounting->ventilation->read); } // Journals if(! empty($conf->accounting->enabled) && ! empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') { - $newmenu->add('',$langs->trans("Journaux"),1,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add('',$langs->trans("Journaux"),1,$user->rights->accounting->comptarapport->lire); $sql = "SELECT rowid, label, accountancy_journal"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; @@ -972,7 +972,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu while ($i < $numr) { $objp = $db->fetch_object($resql); - $newmenu->add('/accountancy/journal/bankjournal.php?id_account='.$objp->rowid,$langs->trans("Journal").' - '.$objp->label,2,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/bankjournal.php?left_menu=accountancy_journal&id_account='.$objp->rowid,$langs->trans("Journal").' - '.dol_trunc($objp->label,10),2,$user->rights->accounting->comptarapport->lire); $i++; } } @@ -980,34 +980,34 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $db->free($resql); // Add other journal - $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal",$langs->trans("SellsJournal"),2,$user->rights->accounting->comptarapport->lire); - $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal",$langs->trans("PurchasesJournal"),2,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=accountancy_journal",$langs->trans("SellsJournal"),2,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=accountancy_journal",$langs->trans("PurchasesJournal"),2,$user->rights->accounting->comptarapport->lire); } // General Ledger - $newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=bookkeeping",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookkeeping'); - if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/listbyyear.php",$langs->trans("ByYear"),2,$user->rights->accounting->mouvements->lire); - if (empty($leftmenu) || preg_match('/bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balancebymonth.php",$langs->trans("AccountBalanceByMonth"),2,$user->rights->accounting->mouvements->lire); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=accountancy_bookkeeping",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookkeeping'); + if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/listbyyear.php?leftmenu=accountancy_bookkeeping",$langs->trans("ByYear"),2,$user->rights->accounting->mouvements->lire); + if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balancebymonth.php?leftmenu=accountancy_bookkeeping",$langs->trans("AccountBalanceByMonth"),2,$user->rights->accounting->mouvements->lire); // Reports $langs->load("compta"); - $newmenu->add("/compta/resultat/index.php?leftmenu=report&mainmenu=accountancy",$langs->trans("Reportings"),1,$user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca'); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report&mainmenu=accountancy",$langs->trans("Reportings"),1,$user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca'); - if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/resultat/index.php?leftmenu=report",$langs->trans("ReportInOut"),2,$user->rights->accounting->comptarapport->lire); - if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire); - if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/index.php?leftmenu=report",$langs->trans("ReportTurnover"),2,$user->rights->accounting->comptarapport->lire); - if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire); - if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=report",$langs->trans("ByUsers"),3,$user->rights->accounting->comptarapport->lire); - if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report", $langs->trans("ByProductsAndServices"),3,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report",$langs->trans("ReportInOut"),2,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report",$langs->trans("ReportTurnover"),2,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report",$langs->trans("ByUsers"),3,$user->rights->accounting->comptarapport->lire); + if (preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report", $langs->trans("ByProductsAndServices"),3,$user->rights->accounting->comptarapport->lire); // Admin $langs->load("admin"); - $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy", $langs->trans("Fiscalyear"),1,$user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear'); - $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy", $langs->trans("Chartofaccounts"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'chartofaccount'); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Fiscalyear"),1,$user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear'); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'chartofaccount'); } - // Comptabilite + // Accountancy (simple) if (! empty($conf->comptabilite->enabled)) { $langs->load("compta"); From 99c59c8c6bbf2c00743a6eaad027cdac7230767c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 23:01:21 +0100 Subject: [PATCH 087/421] Missing translation --- htdocs/admin/receiptprinter.php | 38 +++++++++++++++++--------- htdocs/langs/en_US/receiptprinter.lang | 2 ++ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 5beaacc8515..87fce1f6087 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2013-2016 Laurent Destailleur * Copyright (C) 2015 Frederic France * * This program is free software; you can redistribute it and/or modify @@ -242,10 +242,12 @@ if ($mode == 'config' && $user->admin) print ''; print "\n"; $ret = $printer->listprinters(); + $nbofprinters = count($printer->listprinters); + if ($ret > 0) { setEventMessages($printer->error, $printer->errors, 'errors'); } else { - for ($line=0; $line < count($printer->listprinters); $line++) { + for ($line=0; $line < $nbofprinters; $line++) { $var = !$var; print ''; if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid) { @@ -282,16 +284,21 @@ if ($mode == 'config' && $user->admin) } } - if ($action!='editprinter') { - print ''; - print ''.$langs->trans("Name").''; - print ''.$langs->trans("Type").''; - print ''.$langs->trans("Profile").''; - print ''.$langs->trans("Parameters").''; - print ''; - print ''; - print ''; - print "\n"; + if ($action!='editprinter') + { + if ($nbofprinters > 0) + { + print ''; + print ''.$langs->trans("Name").''; + print ''.$langs->trans("Type").''; + print ''.$langs->trans("Profile").''; + print ''.$langs->trans("Parameters").''; + print ''; + print ''; + print ''; + print "\n"; + } + print ''; print ''; $ret = $printer->selectTypePrinter(); @@ -307,6 +314,7 @@ if ($mode == 'config' && $user->admin) print ''; dol_fiche_end(); + if ($action!='editprinter') { print '
'; } else { @@ -315,7 +323,9 @@ if ($mode == 'config' && $user->admin) print ''; print '

'; + dol_fiche_head(); + print $langs->trans("ReceiptPrinterTypeDesc")."

\n"; print ''."\n"; print ''; @@ -325,7 +335,9 @@ if ($mode == 'config' && $user->admin) //print ''; print '
'.$langs->trans("CONNECTOR_DUMMY").':'.$langs->trans("CONNECTOR_DUMMY_HELP").'
'.$langs->trans("CONNECTOR_JAVA").':'.$langs->trans("CONNECTOR_JAVA_HELP").'
'; dol_fiche_end(); + print '

'; + dol_fiche_head(); print $langs->trans("ReceiptPrinterProfileDesc")."

\n"; print ''."\n"; @@ -423,13 +435,13 @@ if ($mode == 'template' && $user->admin) } // to remove after test +$object=new stdClass(); $object->date_time = '2015-11-02 22:30:25'; $object->id = 1234; $object->customer_firstname = 'John'; $object->customer_lastname = 'Deuf'; $object->vendor_firstname = 'Jim'; $object->vendor_lastname = 'Big'; - $object->barcode = '3700123862396'; //$printer->sendToPrinter($object, 1, 16); //setEventMessages($printer->error, $printer->errors, 'errors'); diff --git a/htdocs/langs/en_US/receiptprinter.lang b/htdocs/langs/en_US/receiptprinter.lang index 28b63d7de79..7b52f072eaf 100644 --- a/htdocs/langs/en_US/receiptprinter.lang +++ b/htdocs/langs/en_US/receiptprinter.lang @@ -1,8 +1,10 @@ # Dolibarr language file - Source file is en_US - receiptprinter +ReceiptPrinterSetup=Setup of module ReceiptPrinter PrinterAdded=Printer %s added PrinterUpdated=Printer %s updated PrinterDeleted=Printer %s deleted TestSentToPrinter=Test Sent To Printer %s +ReceiptPrinter=Receipt printers ReceiptPrinterDesc=Setup of printers ReceiptPrinterTemplateDesc=Setup of Templates ReceiptPrinterTypeDesc=Description of Receipt Printer's type From e28765ff69ed076e763ff0c4f992da7bacf91bdc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Feb 2016 23:07:16 +0100 Subject: [PATCH 088/421] Fix: List of employee is by default selected on employee = yes --- htdocs/user/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/index.php b/htdocs/user/index.php index f0fa04327cd..c7590bc702f 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -84,7 +84,7 @@ $arrayfields=array( 'u.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), 'u.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), 'u.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0), - 'u.employee'=>array('label'=>$langs->trans("Employee"), 'checked'=>0), + 'u.employee'=>array('label'=>$langs->trans("Employee"), 'checked'=>($mode=='employee'?1:0)), 'u.accountancy_code'=>array('label'=>$langs->trans("AccountancyCode"), 'checked'=>0), 'u.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1), 'u.fk_soc'=>array('label'=>$langs->trans("Company"), 'checked'=>1), @@ -123,6 +123,7 @@ $optioncss = GETPOST('optioncss','alpha'); // Default search if ($search_statut == '') $search_statut='1'; +if ($mode == 'employee') $search_employee=1; @@ -192,7 +193,6 @@ else { $sql.= " WHERE u.entity IN (".getEntity('user',1).")"; } -if ($mode == "employee") $sql.= " AND u.employee = 1"; if ($socid > 0) $sql.= " AND u.fk_soc = ".$socid; //if ($search_user != '') $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname'), $search_user); if ($search_supervisor > 0) $sql.= " AND u.fk_user = ".$search_supervisor; From c4c7ea2f221199b1566dad96c038d2f197184776 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Feb 2016 02:49:19 +0100 Subject: [PATCH 089/421] FIX Relative discount decimals are not saved --- htdocs/comm/remise.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 6d0d1dedb2a..224004b6735 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -30,6 +30,8 @@ $langs->load("companies"); $langs->load("orders"); $langs->load("bills"); +$id=GETPOST("id",'int'); + $socid = GETPOST('id','int'); // Security check if ($user->societe_id > 0) @@ -52,9 +54,9 @@ if (GETPOST('cancel') && ! empty($backtopage)) if (GETPOST("action") == 'setremise') { - $soc = New Societe($db); - $soc->fetch($_GET["id"]); - $result=$soc->set_remise_client($_POST["remise"],$_POST["note"],$user); + $soc = new Societe($db); + $soc->fetch($id); + $result=$soc->set_remise_client(price2num(GETPOST("remise")),GETPOST("note"),$user); if ($result > 0) { From a15d03a67644e0247a9efa00884a7c7d76c2a85f Mon Sep 17 00:00:00 2001 From: philippe grand Date: Mon, 8 Feb 2016 10:06:32 +0100 Subject: [PATCH 090/421] fix : Strict Standards: Only variables should be passed by reference --- htdocs/core/modules/modSociete.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index fb8623695e6..ab48d6807ec 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -297,7 +297,11 @@ class modSociete extends DolibarrModules case 'sellist': $tmp=''; $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null - if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); + if ($tmpparam['options'] && is_array($tmpparam['options'])) + { + $stack=array_keys($tmpparam['options']); + $tmp=array_shift($stack); + } if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; break; } From 29910840610a658e5fa8364e523bd039c84b73d0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 8 Feb 2016 10:50:40 +0100 Subject: [PATCH 091/421] fx accountancy --- htdocs/accountancy/journal/purchasesjournal.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 86232bb2029..7d9778f72b8 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -94,6 +94,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = $sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " WHERE f.fk_statut > 0 "; +$sql .= " AND fd.fk_code_ventilation > 0 "; if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")"; } From 9b10f030bf5eb5143107a7a1ecea51ba4b3d5890 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 8 Feb 2016 12:20:40 +0100 Subject: [PATCH 092/421] Fix: missing signature and uniformize code between card and script --- htdocs/comm/mailing/card.php | 15 +++++++++------ scripts/emailings/mailing-send.php | 25 +++++++++++++------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index e1d357b6c3a..dc17c68e387 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2012 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * * 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 @@ -222,6 +222,8 @@ if (empty($reshook)) $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $signature = (!empty($user->signature))?$user->signature:''; + // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) $substitutionarray=array( '__ID__' => $obj->source_id, @@ -234,6 +236,7 @@ if (empty($reshook)) '__OTHER3__' => $other3, '__OTHER4__' => $other4, '__OTHER5__' => $other5, + '__SIGNATURE__' => $signature, // Signature is empty when ran from command line or taken from user in parameter) '__CHECK_READ__' => '', '__UNSUBSCRIBE__' => ''.$langs->trans("MailUnsubcribe").'' ); @@ -1093,10 +1096,10 @@ else } print '
'; - + dol_fiche_end(); - - + + print "\n"; print '
'."\n"; @@ -1108,7 +1111,7 @@ else print_fiche_titre($langs->trans("EMail"),'',''); dol_fiche_head(); - + print ''; // Subject @@ -1175,7 +1178,7 @@ else print '
'; dol_fiche_end(); - + print '
'; print ''; print '     '; diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 9896db73352..1c25d78ba55 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -1,8 +1,9 @@ #!/usr/bin/php - * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2005-2013 Laurent Destailleur + * Copyright (C) 2005-2016 Regis Houssin * * 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 @@ -141,15 +142,15 @@ if ($resql) $sendto = str_replace(',',' ',dolGetFirstLastname($obj2->firstname, $obj2->lastname) ." <".$obj2->email.">"); // Make subtsitutions on topic and body - $other=explode(';',$obj2->other); - $other1=$other[0]; - $other2=$other[1]; - $other3=$other[2]; - $other4=$other[3]; - $other5=$other[4]; - // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) - $signature = (!empty($user->signature))?$user->signature:''; - + $other=explode(';',$obj->other); + $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); + $signature = (!empty($user->signature))?$user->signature:''; + + // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray=array( '__ID__' => $obj->source_id, '__EMAIL__' => $obj->email, @@ -251,7 +252,7 @@ if ($resql) $error++; } } - + if (!empty($conf->global->MAILING_DELAY)) { sleep($conf->global->MAILING_DELAY); } From 0b2560130758506c8bc94e01bbc5138bc92a92d9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 8 Feb 2016 12:31:40 +0100 Subject: [PATCH 093/421] Fix: wrong object name --- htdocs/comm/mailing/card.php | 2 +- scripts/emailings/mailing-send.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index dc17c68e387..3bca65a3ee7 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -222,7 +222,7 @@ if (empty($reshook)) $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $signature = (!empty($user->signature))?$user->signature:''; + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); // Array of possible substitutions (See also fie mailing-send.php that should manage same substitutions) $substitutionarray=array( diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 1c25d78ba55..8baf85ee5fe 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -142,18 +142,18 @@ if ($resql) $sendto = str_replace(',',' ',dolGetFirstLastname($obj2->firstname, $obj2->lastname) ." <".$obj2->email.">"); // Make subtsitutions on topic and body - $other=explode(';',$obj->other); + $other=explode(';',$obj2->other); $tmpfield=explode('=',$other[0],2); $other1=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[1],2); $other2=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[2],2); $other3=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[3],2); $other4=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); $tmpfield=explode('=',$other[4],2); $other5=(isset($tmpfield[1])?$tmpfield[1]:$tmpfield[0]); - $signature = (!empty($user->signature))?$user->signature:''; + $signature = ((!empty($user->signature) && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$user->signature:''); // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray=array( - '__ID__' => $obj->source_id, - '__EMAIL__' => $obj->email, + '__ID__' => $obj2->source_id, + '__EMAIL__' => $obj2->email, '__LASTNAME__' => $obj2->lastname, '__FIRSTNAME__' => $obj2->firstname, '__MAILTOEMAIL__' => ''.$obj2->email.'', From 19b333f78bda120ad34372a65900080b12ecfd4b Mon Sep 17 00:00:00 2001 From: Sof Date: Fri, 5 Feb 2016 19:46:01 +0100 Subject: [PATCH 094/421] FIX : Typo --- htdocs/product/stock/product.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 7038c745364..ba083cc1527 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -714,12 +714,12 @@ if ($resql) print ''.(price2num($object->pmp)?price(price2num($object->pmp*$obj->reel,'MT')):'').''; // Sell price print ''; - if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price,'MU'),1); + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price,'MU'),1); else print $langs->trans("Variable"); print ''; // Value sell print ''; - if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).''; else print $langs->trans("Variable"); print ''; ; $total += $obj->reel; @@ -782,12 +782,12 @@ print ''; print $totalvalue?price(price2num($totalvalue,'MT'),1):' '; print ''; print ''; -if (empty($conf->global->PRODUIT_MULTI_PRICES)) print ($total?price($totalvaluesell/$total,1):' '); +if (empty($conf->global->PRODUIT_MULTIPRICES)) print ($total?price($totalvaluesell/$total,1):' '); else print $langs->trans("Variable"); print ''; // Value to sell print ''; -if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($totalvaluesell,'MT'),1); +if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalvaluesell,'MT'),1); else print $langs->trans("Variable"); print ''; print ""; From c672ad9fed2cff80b4d501ff366db636b0b05a17 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Mon, 8 Feb 2016 15:00:49 +0100 Subject: [PATCH 095/421] Update box_goodcustomers.php --- htdocs/core/boxes/box_goodcustomers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 734d1885824..609eabdbc7a 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -83,7 +83,7 @@ class box_goodcustomers extends ModeleBoxes { $sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,"; - $sql.= " count(*) as nbfact, sum(if (f.paye=1,1,0)) as nbfactpaye"; + $sql.= " count(*) as nbfact, sum(". $db->if('f.paye=1','1','0').") as nbfactpaye"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f"; $sql.= ' WHERE s.entity IN ('.getEntity('societe', 1).')'; $sql.= ' AND s.rowid = f.fk_soc'; From 0b6bd0bc146f3e9646e4a5b05feacc8e84820689 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Feb 2016 15:49:38 +0100 Subject: [PATCH 096/421] More robust error management on barcode module. --- htdocs/barcode/codeinit.php | 2 +- htdocs/core/lib/barcode.lib.php | 17 +-- htdocs/langs/en_US/admin.lang | 2 + htdocs/product/admin/product.php | 246 ++++++++++++++++--------------- htdocs/product/card.php | 66 +++++---- htdocs/product/document.php | 1 - htdocs/viewimage.php | 2 +- 7 files changed, 177 insertions(+), 159 deletions(-) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index db662b6d9e4..e421c17a470 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -298,7 +298,7 @@ if ($conf->product->enabled || $conf->product->service) { $disabled=1; $titleno=$langs->trans("NoBarcodeNumberingTemplateDefined"); - print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").'
'; + print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").' ('.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").')
'; } if (empty($nbno)) { diff --git a/htdocs/core/lib/barcode.lib.php b/htdocs/core/lib/barcode.lib.php index 778723c5f3b..eaaa6f349c4 100644 --- a/htdocs/core/lib/barcode.lib.php +++ b/htdocs/core/lib/barcode.lib.php @@ -63,8 +63,6 @@ else $genbarcode_loc = $conf->global->GENBARCODE_LOCATION; * @param string $encoding Encoding * @param integer $scale Scale * @param string $mode 'png' or 'jpg' ... - * - * * @return array $bars array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) */ function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png") @@ -116,8 +114,7 @@ function barcode_encode($code,$encoding) global $genbarcode_loc; if ( - ((preg_match("/^ean$/i", $encoding) - && ( strlen($code)==12 || strlen($code)==13))) + (preg_match("/^ean$/i", $encoding)) || (($encoding) && (preg_match("/^isbn$/i", $encoding)) && (( strlen($code)==9 || strlen($code)==10) || @@ -140,7 +137,7 @@ function barcode_encode($code,$encoding) } else { - print "barcode_encode needs an external programm for encodings other then EAN/ISBN
\n"; + print "barcode_encode needs an external programm for encodings other then EAN/ISBN (code=".$code.", encoding=".$encoding.")
\n"; print "