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

This commit is contained in:
Laurent Destailleur 2022-06-23 12:35:24 +02:00
commit 4b79d91437
8 changed files with 129 additions and 72 deletions

View File

@ -499,8 +499,9 @@ if ($nboftargetok) {
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/cache.manifest`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php.mysql`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php.nova*`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php.old`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php.postgres`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf.php.pgsql`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/conf/conf*sav*`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/install/mssql/README`;

View File

@ -39,6 +39,9 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
if (!empty($conf->ficheinter->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
}
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager = new HookManager($db);
@ -100,6 +103,10 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$supplierorderstatic = new CommandeFournisseur($db);
}
if (!empty($conf->ficheinter->enabled)) {
$fichinterstatic = new Fichinter($db);
}
llxHeader("", $langs->trans("CommercialArea"));
print load_fiche_titre($langs->trans("CommercialArea"), '', 'commercial');
@ -508,7 +515,12 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
* Draft interventionals
*/
if (!empty($conf->ficheinter->enabled)) {
$sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid";
$sql = "SELECT f.rowid, f.ref, s.nom as name, f.fk_statut";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
$sql .= ", s.logo, s.email, s.entity";
$sql .= ", s.canvas";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (empty($user->rights->societe->client->voir) && !$socid) {
@ -524,22 +536,46 @@ if (!empty($conf->ficheinter->enabled)) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$nbofloop = min($num, $maxofloop);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>';
$langs->load("fichinter");
$num = $db->num_rows($resql);
if ($num) {
$i = 0;
while ($i < $num) {
while ($i < $nbofloop) {
$obj = $db->fetch_object($resql);
$fichinterstatic->id=$obj->rowid;
$fichinterstatic->ref=$obj->ref;
$fichinterstatic->statut=$obj->fk_statut;
$companystatic->id = $obj->socid;
$companystatic->name = $obj->name;
$companystatic->name_alias = $obj->name_alias;
$companystatic->code_client = $obj->code_client;
$companystatic->code_compta = $obj->code_compta;
$companystatic->client = $obj->client;
$companystatic->code_fournisseur = $obj->code_fournisseur;
$companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
$companystatic->fournisseur = $obj->fournisseur;
$companystatic->logo = $obj->logo;
$companystatic->email = $obj->email;
$companystatic->entity = $obj->entity;
$companystatic->canvas = $obj->canvas;
print '<tr class="oddeven">';
print '<td class="nowrap">';
print "<a href=\"card.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowFichinter"), "intervention").' '.$obj->ref."</a></td>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.dol_trunc($obj->name, 24).'</a></td></tr>';
print '<td class="nowrap tdoverflowmax100">';
print $fichinterstatic->getNomUrl(1);
print "</td>";
print '<td class="nowrap tdoverflowmax100">';
print $companystatic->getNomUrl(1, 'customer');
print '</td></tr>';
$i++;
}
}

View File

@ -53,7 +53,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
echo '</td>';
echo '<td class="linkedcol-name nowraponall" >'.$objectlink->getNomUrl(1).'</td>';
echo '<td class="linkedcol-ref">'.$objectlink->ref_client.'</td>';
echo '<td class="linkedcol-date">'.dol_print_date($objectlink->date, 'day').'</td>';
echo '<td class="linkedcol-date center">'.dol_print_date($objectlink->date, 'day').'</td>';
echo '<td class="linkedcol-amount right">';
if ($user->rights->commande->lire) {
$total = $total + $objectlink->total_ht;

View File

@ -1055,6 +1055,8 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == '
if (in_array($objecttmp->element, array('societe', 'member'))) {
$result = $objecttmp->delete($objecttmp->id, $user, 1);
} elseif (in_array($objecttmp->element, array('action'))) {
$result = $objecttmp->delete();
} else {
$result = $objecttmp->delete($user);
}

View File

@ -745,7 +745,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
// - posted value not empty, or
// - if posted value is empty and a default value exists that is not empty (it means we did a filter to an empty value when default was not).
if ($out != '') { // $out = '0' or 'abc', it is a search criteria to keep
if ($out != '' && isset($user)) {// $out = '0' or 'abc', it is a search criteria to keep
$user->lastsearch_values_tmp[$relativepathstring][$paramname] = $out;
}
}

View File

@ -89,7 +89,6 @@ $sql .= " GROUP BY f.fk_statut";
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
$totalinprocess = 0;
@ -97,38 +96,28 @@ if ($resql) {
$vals = array();
$bool = false;
// -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not)
while ($i < $num) {
$row = $db->fetch_row($resql);
if ($row) {
//if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
{
$bool = (!empty($row[2]) ?true:false);
if (!isset($vals[$row[1].$bool])) {
$vals[$row[1].$bool] = 0;
}
$vals[$row[1].$bool] += $row[0];
$totalinprocess += $row[0];
if ($num>0) {
while ($row = $db->fetch_row($resql)) {
if (!isset($vals[$row[1]])) {
$vals[$row[1]] = 0;
}
$vals[$row[1]] += $row[0];
$totalinprocess += $row[0];
$total += $row[0];
}
$i++;
}
$db->free($resql);
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Interventions").'</th></tr>'."\n";
$listofstatus = array(0, 1, 3);
$bool = false;
$listofstatus = array(Fichinter::STATUS_DRAFT, Fichinter::STATUS_VALIDATED);
if (!empty($conf->global->FICHINTER_CLASSIFY_BILLED)) $listofstatus[] = Fichinter::STATUS_BILLED;
foreach ($listofstatus as $status) {
$dataseries[] = array($fichinterstatic->LibStatut($status, $bool, 1), (isset($vals[$status.$bool]) ? (int) $vals[$status.$bool] : 0));
if ($status == 3 && !$bool) {
$bool = true;
} else {
$bool = false;
}
$dataseries[] = array($fichinterstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
if ($status == Fichinter::STATUS_DRAFT) {
$colorseries[$status] = '-'.$badgeStatus0;
@ -139,10 +128,8 @@ if ($resql) {
if ($status == Fichinter::STATUS_BILLED) {
$colorseries[$status] = $badgeStatus4;
}
if ($status == Fichinter::STATUS_CLOSED) {
$colorseries[$status] = $badgeStatus6;
}
}
if ($conf->use_javascript_ajax) {
print '<tr class="impair"><td class="center" colspan="2">';
@ -159,21 +146,15 @@ if ($resql) {
print '</td></tr>';
}
$bool = false;
foreach ($listofstatus as $status) {
if (!$conf->use_javascript_ajax) {
print '<tr class="oddeven">';
print '<td>'.$fichinterstatic->LibStatut($status, $bool, 0).'</td>';
print '<td class="right"><a href="list.php?search_status='.$status.'">'.(isset($vals[$status.$bool]) ? $vals[$status.$bool] : 0).' ';
print $fichinterstatic->LibStatut($status, $bool, 3);
print '<td class="right"><a href="list.php?search_status='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).' ';
print $fichinterstatic->LibStatut($status, 3);
print '</a>';
print '</td>';
print "</tr>\n";
if ($status == 3 && !$bool) {
$bool = true;
} else {
$bool = false;
}
}
}
//if ($totalinprocess != $total)

View File

@ -700,14 +700,13 @@ class User extends CommonObject
public function hasRight($module, $permlevel1, $permlevel2 = '')
{
global $conf;
// For compatibility with bad naming permissions on module
$moduletomoduletouse = array(
'contract' => 'contrat',
'member' => 'adherent', // We must check $user->rights->adherent...
'mo' => 'mrp',
'order' => 'commande',
'product' => 'produit', // We must check $user->rights->produit...
//'product' => 'produit', // We must check $user->rights->produit...
'project' => 'projet',
'shipping' => 'expedition',
'task' => 'task@projet',
@ -721,14 +720,24 @@ class User extends CommonObject
'position@hrm' => 'all@hrm', // skill / job / position objects rights are for the moment grouped into right level "all"
'facturerec' => 'facture'
);
if (!empty($moduletomoduletouse[$module])) {
$module = $moduletomoduletouse[$module];
}
$moduleRightsMapping = array(
'product' => 'produit', // We must check $user->rights->produit...
);
$rightsPath = $module;
if (!empty($moduleRightsMapping[$rightsPath])) {
$rightsPath = $moduleRightsMapping[$rightsPath];
}
// If module is abc@module, we check permission user->rights->module->abc->permlevel1
$tmp = explode('@', $module, 2);
$tmp = explode('@', $rightsPath, 2);
if (! empty($tmp[1])) {
$module = $tmp[1];
$rightsPath = $tmp[1];
$permlevel2 = $permlevel1;
$permlevel1 = $tmp[0];
}
@ -749,49 +758,49 @@ class User extends CommonObject
if ($permlevel1 == 'recruitmentcandidature') {
$permlevel1 = 'recruitmentjobposition';
}
//var_dump($module.' '.$permlevel1.' '.$permlevel2);
if (empty($module) || empty($this->rights) || empty($this->rights->$module) || empty($permlevel1)) {
//var_dump($module.' '.$permlevel1.' '.$permlevel2. ' '. $rightsPath);
//var_dump($this->rights);
if (empty($rightsPath) || empty($this->rights) || empty($this->rights->$rightsPath) || empty($permlevel1)) {
return 0;
}
if ($permlevel2) {
if (!empty($this->rights->$module->$permlevel1)) {
if (!empty($this->rights->$module->$permlevel1->$permlevel2)) {
return $this->rights->$module->$permlevel1->$permlevel2;
if (!empty($this->rights->$rightsPath->$permlevel1)) {
if (!empty($this->rights->$rightsPath->$permlevel1->$permlevel2)) {
return $this->rights->$rightsPath->$permlevel1->$permlevel2;
}
// For backward compatibility with old permissions called "lire", "creer", "create", "supprimer"
// instead of "read", "write", "delete"
if ($permlevel2 == 'read' && !empty($this->rights->$module->$permlevel1->lire)) {
return $this->rights->$module->lire;
if ($permlevel2 == 'read' && !empty($this->rights->$rightsPath->$permlevel1->lire)) {
return $this->rights->$rightsPath->lire;
}
if ($permlevel2 == 'write' && !empty($this->rights->$module->$permlevel1->creer)) {
return $this->rights->$module->create;
if ($permlevel2 == 'write' && !empty($this->rights->$rightsPath->$permlevel1->creer)) {
return $this->rights->$rightsPath->create;
}
if ($permlevel2 == 'write' && !empty($this->rights->$module->$permlevel1->create)) {
return $this->rights->$module->create;
if ($permlevel2 == 'write' && !empty($this->rights->$rightsPath->$permlevel1->create)) {
return $this->rights->$rightsPath->create;
}
if ($permlevel2 == 'delete' && !empty($this->rights->$module->$permlevel1->supprimer)) {
return $this->rights->$module->supprimer;
if ($permlevel2 == 'delete' && !empty($this->rights->$rightsPath->$permlevel1->supprimer)) {
return $this->rights->$rightsPath->supprimer;
}
}
} else {
if (!empty($this->rights->$module->$permlevel1)) {
return $this->rights->$module->$permlevel1;
if (!empty($this->rights->$rightsPath->$permlevel1)) {
return $this->rights->$rightsPath->$permlevel1;
}
// For backward compatibility with old permissions called "lire", "creer", "create", "supprimer"
// instead of "read", "write", "delete"
if ($permlevel1 == 'read' && !empty($this->rights->$module->lire)) {
return $this->rights->$module->lire;
if ($permlevel1 == 'read' && !empty($this->rights->$rightsPath->lire)) {
return $this->rights->$rightsPath->lire;
}
if ($permlevel1 == 'write' && !empty($this->rights->$module->creer)) {
return $this->rights->$module->create;
if ($permlevel1 == 'write' && !empty($this->rights->$rightsPath->creer)) {
return $this->rights->$rightsPath->create;
}
if ($permlevel1 == 'write' && !empty($this->rights->$module->create)) {
return $this->rights->$module->create;
if ($permlevel1 == 'write' && !empty($this->rights->$rightsPath->create)) {
return $this->rights->$rightsPath->create;
}
if ($permlevel1 == 'delete' && !empty($this->rights->$module->supprimer)) {
return $this->rights->$module->supprimer;
if ($permlevel1 == 'delete' && !empty($this->rights->$rightsPath->supprimer)) {
return $this->rights->$rightsPath->supprimer;
}
}

View File

@ -261,12 +261,40 @@ class UserTest extends PHPUnit\Framework\TestCase
return $localobject;
}
/**
* testUserHasRight
* @param User $localobject User
* @return User $localobject User
* @depends testUserOther
*/
public function testUserHasRight($localobject)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
/*$result=$localobject->setstatus(0);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
*/
print __METHOD__." id=". $localobject->id ."\n";
//$this->assertNotEquals($user->date_creation, '');
$localobject->addrights(0, 'supplier_proposal');
$this->assertEquals($localobject->hasRight('member', ''), 0);
$this->assertEquals($localobject->hasRight('member', 'member'), 0);$this->assertEquals($localobject->hasRight('product', 'member', 'read'), 0);
$this->assertEquals($localobject->hasRight('member', 'member'), 0);$this->assertEquals($localobject->hasRight('produit', 'member', 'read'), 0);
return $localobject;
}
/**
* testUserSetPassword
*
* @param User $localobject User
* @return void
* @depends testUserOther
* @depends testUserHasRight
* The depends says test is run only if previous is ok
*/
public function testUserSetPassword($localobject)