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

This commit is contained in:
Laurent Destailleur 2018-03-18 20:01:27 +01:00
commit af44af0235
9 changed files with 137 additions and 89 deletions

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
*
* 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
@ -20,7 +21,7 @@
/**
* \file htdocs/core/boxes/box_contacts.php
* \ingroup societes
* \ingroup contacts
* \brief Module to show box of contacts
*/
@ -57,7 +58,7 @@ class box_contacts extends ModeleBoxes
$this->db=$db;
$this->hidden=! ($user->rights->societe->lire);
$this->hidden=! ($user->rights->societe->lire && $user->rights->societe->contact->lire);
}
/**
@ -75,12 +76,12 @@ class box_contacts extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts",$max));
if ($user->rights->societe->lire)
if ($user->rights->societe->lire && $user->rights->societe->contact->lire)
{
$sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status";
$sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile";
$sql.= ", s.nom as socname, s.name_alias";
$sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur";
$sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid";
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -91,98 +92,97 @@ class box_contacts extends ModeleBoxes
$sql.= $db->plimit($max, 0);
$result = $db->query($sql);
if ($result) {
if ($result) {
$num = $db->num_rows($result);
$contactstatic=new Contact($db);
$societestatic=new Societe($db);
$line = 0;
while ($line < $num)
{
while ($line < $num)
{
$objp = $db->fetch_object($result);
$datec=$db->jdate($objp->datec);
$datem=$db->jdate($objp->tms);
$contactstatic->id=$objp->id;
$contactstatic->id=$objp->id;
$contactstatic->lastname=$objp->lastname;
$contactstatic->firstname=$objp->firstname;
$contactstatic->civility_id=$objp->civility_id;
$contactstatic->firstname=$objp->firstname;
$contactstatic->civility_id=$objp->civility_id;
$contactstatic->statut=$objp->status;
$contactstatic->phone_pro = $objp->phone;
$contactstatic->phone_perso = $objp->phone_perso;
$contactstatic->phone_mobile = $objp->phone_mobile;
$contactstatic->address = $objp->address;
$contactstatic->zip = $objp->zip;
$contactstatic->town = $objp->town;
$contactstatic->phone_pro = $objp->phone;
$contactstatic->phone_perso = $objp->phone_perso;
$contactstatic->phone_mobile = $objp->phone_mobile;
$contactstatic->address = $objp->address;
$contactstatic->zip = $objp->zip;
$contactstatic->town = $objp->town;
$societestatic->id = $objp->fk_soc;
$societestatic->name = $objp->socname;
$societestatic->name_alias = $objp->name_alias;
$societestatic->code_client = $objp->code_client;
$societestatic->code_fournisseur = $objp->code_fournisseur;
$societestatic->client = $objp->client;
$societestatic->fournisseur = $objp->fournisseur;
$societestatic->name = $objp->socname;
$societestatic->name_alias = $objp->name_alias;
$societestatic->code_client = $objp->code_client;
$societestatic->code_fournisseur = $objp->code_fournisseur;
$societestatic->client = $objp->client;
$societestatic->fournisseur = $objp->fournisseur;
$this->info_box_contents[$line][] = array(
'td' => '',
'text' => $contactstatic->getNomUrl(1),
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => '',
'text' => $contactstatic->getNomUrl(1),
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => '',
'text' => ($objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : ''),
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => '',
'text' => ($objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : ''),
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => dol_print_date($datem, "day"),
);
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => dol_print_date($datem, "day"),
);
$this->info_box_contents[$line][] = array(
'td' => 'align="right" class="nowrap" width="18"',
'text' => $contactstatic->getLibStatut(3),
'asis'=>1,
);
$this->info_box_contents[$line][] = array(
'td' => 'align="right" class="nowrap" width="18"',
'text' => $contactstatic->getLibStatut(3),
'asis'=>1,
);
$line++;
}
$line++;
}
if ($num==0)
$this->info_box_contents[$line][0] = array(
'td' => 'align="center"',
'text'=>$langs->trans("NoRecordedContacts"),
);
if ($num==0)
$this->info_box_contents[$line][0] = array(
'td' => 'align="center"',
'text'=>$langs->trans("NoRecordedContacts"),
);
$db->free($result);
} else {
$this->info_box_contents[0][0] = array(
'td' => '',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql),
);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left" class="nohover opacitymedium"',
'text' => $langs->trans("ReadPermissionNotAllowed")
);
}
}
$db->free($result);
} else {
$this->info_box_contents[0][0] = array(
'td' => '',
'maxlength'=>500,
'text' => ($db->error().' sql='.$sql),
);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'align="left" class="nohover opacitymedium"',
'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
* @param int $nooutput No print, only return string
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
* @return string
*/
function showBox($head = null, $contents = null, $nooutput=0)
{
function showBox($head = null, $contents = null, $nooutput=0)
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}

View File

@ -46,11 +46,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
function __construct($db)
{
global $conf,$langs,$mysoc;
$langs->load("main");
$langs->load("bank");
$langs->load("withdrawals");
$langs->load("companies");
// Translations
$langs->loadLangs(array("main", "bank", "withdrawals", "companies"));
$this->db = $db;
$this->name = "sepamandate";
@ -104,13 +102,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
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
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("projects");
$outputlangs->load("withdrawals");
$outputlangs->load("bills");
// Translations
$outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills"));
if (! empty($conf->bank->dir_output))
{

View File

@ -320,7 +320,7 @@ class modProduct extends DolibarrModules
'sp.unitprice'=>'50',
'sp.remise_percent'=>'0'
);
$this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef');
$this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier');
}
if (! empty($conf->global->PRODUIT_MULTIPRICES))

View File

@ -222,4 +222,6 @@ NoAssignedTasks=No assigned tasks (assign project/tasks the current user from th
# Comments trans
AllowCommentOnTask=Allow user comments on tasks
AllowCommentOnProject=Allow user comments on projects
DontHavePermissionForCloseProject=You do not have permissions to close the project %s
DontHaveTheValidateStatus=The project %s must be open to be closed
RecordsClosed=%s project(s) closed

View File

@ -272,7 +272,7 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
* Last modified products
*/
$max=15;
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.fk_price_expression,";
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,";
$sql.= " p.entity,";
$sql.= " p.tms as datem";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
@ -336,7 +336,8 @@ if ($result)
$product_static->ref=$objp->ref;
$product_static->label = $objp->label;
$product_static->type=$objp->fk_product_type;
$product_static->entity = $objp->entity;
$product_static->entity = $objp->entity;
$product_static->status_batch = $objp->tobatch;
print $product_static->getNomUrl(1,'',16);
print "</td>\n";
print '<td>'.dol_trunc($objp->label,32).'</td>';

View File

@ -698,6 +698,7 @@ else
$product_static->type = $obj->fk_product_type;
$product_static->status_buy = $obj->tobuy;
$product_static->status = $obj->tosell;
$product_static->status_batch = $obj->tobatch;
$product_static->entity = $obj->entity;
$product_static->pmp = $obj->pmp;

View File

@ -446,7 +446,7 @@ else
$totalunit=0;
$totalvalue=$totalvaluesell=0;
$sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,";
$sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,";
$sql.= " ps.reel as value";
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
$sql.= " WHERE ps.fk_product = p.rowid";
@ -487,10 +487,11 @@ else
print '<tr class="oddeven">';
print "<td>";
$productstatic->id=$objp->rowid;
$productstatic->ref = $objp->ref;
$productstatic->label = $objp->produit;
$productstatic->ref = $objp->ref;
$productstatic->label = $objp->produit;
$productstatic->type=$objp->type;
$productstatic->entity=$objp->entity;
$productstatic->status_batch=$objp->tobatch;
print $productstatic->getNomUrl(1,'stock',16);
print '</td>';

View File

@ -415,7 +415,7 @@ $formother=new FormOther($db);
$formproduct=new FormProduct($db);
if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db);
$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type, p.entity,";
$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
$sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,";
$sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
$sql.= " m.batch, m.price,";
@ -891,6 +891,7 @@ if ($resql)
$productstatic->label=$objp->produit;
$productstatic->type=$objp->type;
$productstatic->entity=$objp->entity;
$productstatic->status_batch=$objp->tobatch;
$productlot->id = $objp->lotid;
$productlot->batch= $objp->batch;

View File

@ -195,6 +195,52 @@ if (empty($reshook))
$permtodelete = $user->rights->projet->supprimer;
$uploaddir = $conf->projet->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Close records
if (! $error && $massaction == 'close' && $user->rights->projet->creer)
{
$db->begin();
$objecttmp=new $objectclass($db);
$nbok = 0;
foreach($toselect as $toselectid)
{
$result=$objecttmp->fetch($toselectid);
if ($result > 0)
{
$userWrite = $object->restrictedProjectArea($user,'write');
if ($userWrite > 0 && $objecttmp->statut == 1) {
$result = $objecttmp->setClose($user);
if ($result <= 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
} else $nbok++;
} elseif($userWrite <= 0) {
setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings');
} else {
setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings');
}
}
else
{
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
}
}
if (! $error)
{
if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
$db->commit();
}
else
{
$db->rollback();
}
}
}
@ -390,7 +436,9 @@ $arrayofmassactions = array(
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
if ($user->rights->projet->creer) $arrayofmassactions['close']=$langs->trans("Close");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';