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

This commit is contained in:
Laurent Destailleur 2018-02-14 21:51:55 +01:00
commit 15ab37b46e
8 changed files with 212 additions and 15 deletions

View File

@ -287,7 +287,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

@ -96,7 +96,7 @@ if ($action == 'add' && $user->rights->adherent->configurer)
$object->label = trim($label); $object->label = trim($label);
$object->subscription = (int) trim($subscription); $object->subscription = (int) trim($subscription);
$object->note = trim($comment); $object->note = trim($comment);
$object->mail_valid = (boolean) trim($mail_valid); $object->mail_valid = trim($mail_valid);
$object->vote = (boolean) 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
@ -134,7 +134,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
$object->label = trim($label); $object->label = trim($label);
$object->subscription = (int) trim($subscription); $object->subscription = (int) trim($subscription);
$object->note = trim($comment); $object->note = trim($comment);
$object->mail_valid = (boolean) trim($mail_valid); $object->mail_valid = trim($mail_valid);
$object->vote = (boolean) 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

View File

@ -2919,6 +2919,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

@ -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">&nbsp;</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

@ -1311,7 +1311,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

@ -366,14 +366,27 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09
migrate_remise_except_entity($db,$langs,$conf); migrate_remise_except_entity($db,$langs,$conf);
} }
// Scripts for last version // Scripts for last version
$afterversionarray=explode('.','5.0.9'); $afterversionarray=explode('.','5.0.9');
$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);
}
}
}
}
// Code executed only if migrate is LAST ONE. Must always be done. // Code executed only if migrate is LAST ONE. Must always be done.
if (versioncompare($versiontoarray,$versionranarray) >= 0 || versioncompare($versiontoarray,$versionranarray) <= -3) if (versioncompare($versiontoarray,$versionranarray) >= 0 || versioncompare($versiontoarray,$versionranarray) <= -3)
@ -3967,6 +3980,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

@ -193,6 +193,8 @@ MigrationCategorieAssociation=Migration of categories
MigrationEvents=Migration of events to add event owner into assignement table MigrationEvents=Migration of events to add event owner 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
ShowNotAvailableOptions=Show not available options ShowNotAvailableOptions=Show not available options
HideNotAvailableOptions=Hide not available options HideNotAvailableOptions=Hide 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');