Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into 7.0

Conflicts:
	htdocs/adherents/type.php
	htdocs/contrat/services.php
	htdocs/contrat/tpl/linkedobjectblock.tpl.php
	htdocs/install/upgrade2.php
This commit is contained in:
Laurent Destailleur 2018-02-14 22:08:18 +01:00
commit 7f8cbc0f62
10 changed files with 209 additions and 13 deletions

View File

@ -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. 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 * 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 $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') * 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 * 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. retreive the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1.

View File

@ -107,7 +107,7 @@ if ($action == 'add' && $user->rights->adherent->configurer)
$object->subscription = (int) trim($subscription); $object->subscription = (int) trim($subscription);
$object->note = trim($comment); $object->note = trim($comment);
$object->mail_valid = trim($mail_valid); $object->mail_valid = trim($mail_valid);
$object->vote = trim($vote); $object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@ -160,7 +160,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
$object->subscription = (int) trim($subscription); $object->subscription = (int) trim($subscription);
$object->note = trim($comment); $object->note = trim($comment);
$object->mail_valid = trim($mail_valid); $object->mail_valid = trim($mail_valid);
$object->vote = trim($vote); $object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);

View File

@ -3004,6 +3004,9 @@ class Facture extends CommonInvoice
$line->total_ttc = $tabprice[2]; $line->total_ttc = $tabprice[2];
$line->total_localtax1 = $tabprice[9]; $line->total_localtax1 = $tabprice[9];
$line->total_localtax2 = $tabprice[10]; $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); $line->update($user);
$this->update_price(1); $this->update_price(1);
$this->db->commit(); $this->db->commit();

View File

@ -75,7 +75,7 @@ $opclotureyear=GETPOST('opclotureyear');
$filter_opcloture=GETPOST('filter_opcloture'); $filter_opcloture=GETPOST('filter_opcloture');
// Initialize context for list // 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 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array($contextpage)); $hookmanager->initHooks(array($contextpage));
@ -483,7 +483,6 @@ if (! empty($arrayfields['cd.date_cloture']['checked']))
print '</td>'; print '</td>';
} }
// Extra fields // Extra fields
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook // Fields from hook

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com> /* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2018 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -50,10 +51,22 @@ foreach($linkedObjectBlock as $key => $objectlink)
<td><?php echo $objectlink->getNomUrl(1); ?></td> <td><?php echo $objectlink->getNomUrl(1); ?></td>
<td></td> <td></td>
<td align="center"><?php echo dol_print_date($objectlink->date_contrat,'day'); ?></td> <td align="center"><?php echo dol_print_date($objectlink->date_contrat,'day'); ?></td>
<td align="right"><?php // var_dump($objectlink->total_ttc); ?></td> <td align="right"><?php
// Price of contract is not shown by default because a contract is a list of service with
// start and end date that change with time andd that may be different that the period of reference for price.
// So price of a contract does often means nothing. Prices is on the different invoices done on same contract.
if ($user->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);
} ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(7); ?></td> <td align="right"><?php echo $objectlink->getLibStatut(7); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td> <td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
</tr> </tr>
<?php } ?> <?php } ?>
<!-- END PHP TEMPLATE --> <!-- END PHP TEMPLATE -->

View File

@ -1320,7 +1320,17 @@ class pdf_einstein extends ModelePDFCommandes
if ($showaddress) if ($showaddress)
{ {
// Sender properties // 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 // Show sender
$posy=42+$top_shift; $posy=42+$top_shift;

View File

@ -172,7 +172,7 @@ class modBlockedLog extends DolibarrModules
// If already used, we add an entry to show we enable module // If already used, we add an entry to show we enable module
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
$object=new stdClass; $object=new stdClass();
$object->id = 1; $object->id = 1;
$object->element = 'module'; $object->element = 'module';
$object->ref = 'systemevent'; $object->ref = 'systemevent';
@ -215,7 +215,7 @@ class modBlockedLog extends DolibarrModules
// If already used, we add an entry to show we enable module // If already used, we add an entry to show we enable module
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
$object=new stdClass; $object=new stdClass();
$object->id = 1; $object->id = 1;
$object->element = 'module'; $object->element = 'module';
$object->ref = 'systemevent'; $object->ref = 'systemevent';

View File

@ -377,7 +377,20 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09
$beforeversionarray=explode('.','6.0.9'); $beforeversionarray=explode('.','6.0.9');
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) 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 // Scripts for last version
@ -3946,7 +3959,7 @@ function migrate_reset_blocked_log($db,$langs,$conf)
else else
{ {
// Add set line // Add set line
$object=new stdClass; $object=new stdClass();
$object->id = 1; $object->id = 1;
$object->element = 'module'; $object->element = 'module';
$object->ref = 'systemevent'; $object->ref = 'systemevent';
@ -4188,6 +4201,158 @@ function migrate_remise_except_entity($db,$langs,$conf)
print '</td></tr>'; print '</td></tr>';
} }
/**
* 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 '<tr><td colspan="4">';
print '<b>'.$langs->trans('MigrationUserRightsEntity')."</b><br>\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')."<br>\n";
}
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
}
else
{
dol_print_error($db);
$db->rollback();
}
print '</td></tr>';
}
/**
* 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 '<tr><td colspan="4">';
print '<b>'.$langs->trans('MigrationUserGroupRightsEntity')."</b><br>\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')."<br>\n";
}
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
}
else
{
dol_print_error($db);
$db->rollback();
}
print '</td></tr>';
}
/** /**
* Migration directory * Migration directory
* *

View File

@ -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 MigrationEventsContact=Migration of events to add event contact into assignement table
MigrationRemiseEntity=Update entity field value of llx_societe_remise MigrationRemiseEntity=Update entity field value of llx_societe_remise
MigrationRemiseExceptEntity=Update entity field value of llx_societe_remise_except 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 MigrationReloadModule=Reload module %s
MigrationResetBlockedLog=Reset module BlockedLog for v7 algorithm MigrationResetBlockedLog=Reset module BlockedLog for v7 algorithm
ShowNotAvailableOptions=Show not available options ShowNotAvailableOptions=Show not available options

View File

@ -63,7 +63,9 @@ if (! empty($_REQUEST['search_fourn_id']))
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
if ($user->societe_id) $socid=$user->societe_id; 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; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');