diff --git a/ChangeLog b/ChangeLog index 0f587f47386..803225db301 100644 --- a/ChangeLog +++ b/ChangeLog @@ -575,7 +575,9 @@ Following changes may create regression for some external modules, but were nece exists, but if an external module need action on it, it must provides itself its trigger file. * Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode. So, if you set var $multicompany_transverse_mode to 1 into your conf file, you must remove this line and a new key into - the Home - setup - other admin page. + the Home - setup - other admin page. +* If you use Multicompany transverse mode, it will be necessary to check the activation of the modules in the children + entities and to review completely the rights of the groups and the users. * Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx') * Some other change were done in the way we read permission of a user when module multicompany is enabled. You can retreive the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1. diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index eb44809178f..cc9fd872062 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -107,7 +107,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) $object->subscription = (int) trim($subscription); $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = trim($vote); + $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -160,7 +160,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) $object->subscription = (int) trim($subscription); $object->note = trim($comment); $object->mail_valid = trim($mail_valid); - $object->vote = trim($vote); + $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 35ab14454ef..12d6fa10769 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3004,6 +3004,9 @@ class Facture extends CommonInvoice $line->total_ttc = $tabprice[2]; $line->total_localtax1 = $tabprice[9]; $line->total_localtax2 = $tabprice[10]; + $line->multicurrency_total_ht = $tabprice[16]; + $line->multicurrency_total_tva = $tabprice[17]; + $line->multicurrency_total_ttc = $tabprice[18]; $line->update($user); $this->update_price(1); $this->db->commit(); diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 5bede6be358..108fb6d4403 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -75,7 +75,7 @@ $opclotureyear=GETPOST('opclotureyear'); $filter_opcloture=GETPOST('filter_opcloture'); // Initialize context for list -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'servicelist'.$mode; +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'contractservicelist'.$mode; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array($contextpage)); @@ -483,7 +483,6 @@ if (! empty($arrayfields['cd.date_cloture']['checked'])) print ''; } // Extra fields -// Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index e0b76ba689b..a44f20679b8 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,10 +51,22 @@ foreach($linkedObjectBlock as $key => $objectlink) getNomUrl(1); ?> date_contrat,'day'); ?> - total_ttc); ?> + rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE)) + { + $totalcontrat = 0; + foreach ($objectlink->lines as $linecontrat) { + $totalcontrat = $totalcontrat + $linecontrat->total_ht; + $total = $total + $linecontrat->total_ht; + } + echo price($totalcontrat); + } ?> getLibStatut(7); ?> ">transnoentitiesnoconv("RemoveLink")); ?> - \ No newline at end of file + diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 59a2d82ffc7..7c24e49e89b 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1320,7 +1320,17 @@ class pdf_einstein extends ModelePDFCommandes if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + $carac_emetteur=''; + // Add internal contact of proposal if defined + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); + if (count($arrayidcontact) > 0) + { + $object->fetch_user($arrayidcontact[0]); + $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name")); + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + } + + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender $posy=42+$top_shift; diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 9b3f4e16e9b..b18f8bebf62 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -172,7 +172,7 @@ class modBlockedLog extends DolibarrModules // If already used, we add an entry to show we enable module require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $object=new stdClass; + $object=new stdClass(); $object->id = 1; $object->element = 'module'; $object->ref = 'systemevent'; @@ -215,7 +215,7 @@ class modBlockedLog extends DolibarrModules // If already used, we add an entry to show we enable module require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $object=new stdClass; + $object=new stdClass(); $object->id = 1; $object->element = 'module'; $object->ref = 'systemevent'; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 6dbcae4cd24..d20357dd20c 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -377,7 +377,20 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 $beforeversionarray=explode('.','6.0.9'); if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) { - // No particular code + if (! empty($conf->multicompany->enabled)) + { + global $multicompany_transverse_mode; + + // Only if the transverse mode is not used + if (empty($multicompany_transverse_mode)) + { + // Migrate to add entity value into llx_user_rights + migrate_user_rights_entity($db, $langs, $conf); + + // Migrate to add entity value into llx_usergroup_rights + migrate_usergroup_rights_entity($db, $langs, $conf); + } + } } // Scripts for last version @@ -3946,7 +3959,7 @@ function migrate_reset_blocked_log($db,$langs,$conf) else { // Add set line - $object=new stdClass; + $object=new stdClass(); $object->id = 1; $object->element = 'module'; $object->ref = 'systemevent'; @@ -4188,6 +4201,158 @@ function migrate_remise_except_entity($db,$langs,$conf) print ''; } +/** + * Migrate to add entity value into llx_user_rights + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void + */ +function migrate_user_rights_entity($db,$langs,$conf) +{ + print ''; + + print ''.$langs->trans('MigrationUserRightsEntity')."
\n"; + + $error = 0; + + dolibarr_install_syslog("upgrade2::migrate_user_rights_entity"); + + $db->begin(); + + $sqlSelect = "SELECT u.rowid, u.entity"; + $sqlSelect.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sqlSelect.= " WHERE u.entity > 1"; + //print $sqlSelect; + + $resql = $db->query($sqlSelect); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); + + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."user_rights SET"; + $sqlUpdate.= " entity = " . $obj->entity; + $sqlUpdate.= " WHERE fk_user = " . $obj->rowid; + + $result=$db->query($sqlUpdate); + if (! $result) + { + $error++; + dol_print_error($db); + } + + print ". "; + $i++; + } + } + else + { + print $langs->trans('AlreadyDone')."
\n"; + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db); + $db->rollback(); + } + + + print ''; +} + +/** + * Migrate to add entity value into llx_usergroup_rights + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @return void + */ +function migrate_usergroup_rights_entity($db,$langs,$conf) +{ + print ''; + + print ''.$langs->trans('MigrationUserGroupRightsEntity')."
\n"; + + $error = 0; + + dolibarr_install_syslog("upgrade2::migrate_usergroup_rights_entity"); + + $db->begin(); + + $sqlSelect = "SELECT u.rowid, u.entity"; + $sqlSelect.= " FROM ".MAIN_DB_PREFIX."usergroup as u"; + $sqlSelect.= " WHERE u.entity > 1"; + //print $sqlSelect; + + $resql = $db->query($sqlSelect); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); + + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."usergroup_rights SET"; + $sqlUpdate.= " entity = " . $obj->entity; + $sqlUpdate.= " WHERE fk_usergroup = " . $obj->rowid; + + $result=$db->query($sqlUpdate); + if (! $result) + { + $error++; + dol_print_error($db); + } + + print ". "; + $i++; + } + } + else + { + print $langs->trans('AlreadyDone')."
\n"; + } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db); + $db->rollback(); + } + + + print ''; +} + /** * Migration directory * diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 87ef7d79b13..27a2edd1fda 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -196,6 +196,8 @@ MigrationEvents=Migration of events to add event owner into assignement table MigrationEventsContact=Migration of events to add event contact into assignement table MigrationRemiseEntity=Update entity field value of llx_societe_remise MigrationRemiseExceptEntity=Update entity field value of llx_societe_remise_except +MigrationUserRightsEntity=Update entity field value of llx_user_rights +MigrationUserGroupRightsEntity=Update entity field value of llx_usergroup_rights MigrationReloadModule=Reload module %s MigrationResetBlockedLog=Reset module BlockedLog for v7 algorithm ShowNotAvailableOptions=Show not available options diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 21d29a8ce89..5219291e8af 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -63,7 +63,9 @@ if (! empty($_REQUEST['search_fourn_id'])) $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'produit|service&fournisseur',$fieldvalue,'product&product','','',$fieldtype); +$result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); + +if (empty($user->rights->fournisseur->lire)) accessforbidden(); $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha');