Merge remote-tracking branch 'Dolibarr/13.0' into 13

This commit is contained in:
Francis Appels 2021-01-31 15:04:44 +01:00
commit 313a4a8c0c
16 changed files with 102 additions and 84 deletions

View File

@ -248,9 +248,9 @@ Following changes may create regressions for some external modules, but were nec
* Function showStripePaymentUrl, getStripePaymentUrl, showPaypalPaymentUrl and getPaypalPaymentUrl has been removed. The generic one showOnlinePaymentUrl and getOnlinePaymentUrl are always used.
* Context for hook showSocinfoOnPrint has been moved from "showsocinfoonprint" to "main"
* Library htdocs/includes/phpoffice/phpexcel as been removed (replaced with htdocs/includes/phpoffice/PhpSpreadsheet)
* Databse transaction in your triggers must be correctly balanced (one close for one open). If not, an error will be returned by the trigger, even if trigger did return error code.
* Database transaction in your triggers must be correctly balanced (one close for one open). If not, an error will be returned by the trigger, even if trigger did return error code.
* Dolibarr v13 is still compatible with any PHP version between 5.6.0 and 7.4.*; Unit tests are OK with PHP 8.0 but some warnings or troubles may appears with PHP 8.0.
* All your Ajax services must contains such a line at begin of file: if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
***** ChangeLog for 12.0.4 compared to 12.0.3 *****
FIX: make formConfirm an addreplace-type hook

View File

@ -370,7 +370,7 @@ class BookKeeping extends CommonObject
$sql .= ", ".(!empty($this->subledger_account) ? ("'".$this->db->escape($this->subledger_account)."'") : "NULL");
$sql .= ", ".(!empty($this->subledger_label) ? ("'".$this->db->escape($this->subledger_label)."'") : "NULL");
$sql .= ", '".$this->db->escape($this->numero_compte)."'";
$sql .= ", ".(!empty($this->label_operation) ? ("'".$this->db->escape($this->label_operation)."'") : "NULL");
$sql .= ", ".(!empty($this->label_compte) ? ("'".$this->db->escape($this->label_compte)."'") : "NULL");
$sql .= ", '".$this->db->escape($this->label_operation)."'";
$sql .= ", ".$this->debit;
$sql .= ", ".$this->credit;

View File

@ -425,7 +425,7 @@ class Documents extends DolibarrApi
throw new RestException(500, 'Error while fetching object: '.$object->error);
}
$upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
$upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product');
}
elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event')
{

View File

@ -277,7 +277,7 @@ $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'
//llxHeader('',$langs->trans('Proposal'),$help_url);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
$sql .= " typent.code as typent_code,";
$sql .= " ava.rowid as availability,";

View File

@ -271,7 +271,7 @@ $help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_P
// llxHeader('',$title,$help_url);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
$sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";

View File

@ -413,7 +413,7 @@ $formcompany = new FormCompany($db);
$thirdpartystatic = new Societe($db);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
$sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,';
$sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
$sql .= ' f.fk_user_author,';

View File

@ -44,12 +44,12 @@ $nbofyear = 4;
$year = GETPOST('year', 'int');
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
$month_current = strftime("%m", dol_now());
$year_current = dol_print_date(dol_now(), "%Y");
$month_current = dol_print_date(dol_now(), "%m");
$year_start = $year_current - ($nbofyear - 1);
} else {
$year_current = $year;
$month_current = strftime("%m", dol_now());
$month_current = dol_print_date(dol_now(), "%m");
$year_start = $year - ($nbofyear - 1);
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
@ -58,12 +58,12 @@ $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
// We define date_start and date_end
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q = GETPOST("q") ?GETPOST("q") : 0;
$q = GETPOST("q") ? GETPOST("q") : 0;
if ($q == 0)
{
// We define date_start and date_end
$year_end = $year_start + ($nbofyear - 1);
$month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$month_start = GETPOSTISSET("month") ? GETPOST("month", 'int') : ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1);
if (!GETPOST('month'))
{
if (!GETPOST("year") && $month_start > $month_current)
@ -86,8 +86,10 @@ $userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int');
$tmps = dol_getdate($date_start);
$mothn_start = $tmps['mon'];
$year_start = $tmps['year'];
$tmpe = dol_getdate($date_end);
$month_end = $tmpe['mon'];
$year_end = $tmpe['year'];
$nbofyear = ($year_end - $year_start) + 1;
@ -306,7 +308,7 @@ $now = dol_now();
$casenow = dol_print_date($now, "%Y-%m");
// Loop on each month
$nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START - 1) : 0;
$nb_mois_decalage = GETPOSTISSET('date_startmonth') ? (GETPOST('date_startmonth', 'int') - 1) : (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 0 : ($conf->global->SOCIETE_FISCAL_MONTH_START - 1));
for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++)
{
$mois_modulo = $mois; // ajout
@ -338,68 +340,75 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++)
if ($annee >= $year_start) // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output.
{
if ($modecompta == 'CREANCES-DETTES') {
// Valeur CA du mois w/o VAT
// Value turnover of month w/o VAT
print '<td class="right">';
if ($cum_ht[$case])
{
$now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre.
print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta ? '&modecompta='.$modecompta : '').'">'.price($cum_ht[$case], 1).'</a>';
} else {
if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print '&nbsp;'; }
if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) {
if ($cum_ht[$case]) {
$now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre.
print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta ? '&modecompta='.$modecompta : '').'">'.price($cum_ht[$case], 1).'</a>';
} else {
if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print '&nbsp;'; }
}
}
print "</td>";
}
// Valeur CA du mois
// Value turnover of month
print '<td class="right">';
if ($cum[$case])
{
$now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre.
if ($modecompta != 'BOOKKEEPING') print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta ? '&modecompta='.$modecompta : '').'">';
print price($cum[$case], 1);
if ($modecompta != 'BOOKKEEPING') print '</a>';
} else {
if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print '&nbsp;'; }
if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) {
if ($cum[$case]) {
$now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre.
if ($modecompta != 'BOOKKEEPING') print '<a href="casoc.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta ? '&modecompta='.$modecompta : '').'">';
print price($cum[$case], 1);
if ($modecompta != 'BOOKKEEPING') print '</a>';
} else {
if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; } else { print '&nbsp;'; }
}
}
print "</td>";
// Pourcentage du mois
if ($annee_decalage > $minyear && $case <= $casenow)
{
if ($cum[$caseprev] && $cum[$case])
// Percentage of month
print '<td class="borderrightlight right">';
//var_dump($annee.' '.$year_end.' '.$mois.' '.$month_end);
if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) {
if ($annee_decalage > $minyear && $case <= $casenow)
{
$percent = (round(($cum[$case] - $cum[$caseprev]) / $cum[$caseprev], 4) * 100);
//print "X $cum[$case] - $cum[$caseprev] - $cum[$caseprev] - $percent X";
print '<td class="borderrightlight right">'.($percent >= 0 ? "+$percent" : "$percent").'%</td>';
if ($cum[$caseprev] && $cum[$case])
{
$percent = (round(($cum[$case] - $cum[$caseprev]) / $cum[$caseprev], 4) * 100);
//print "X $cum[$case] - $cum[$caseprev] - $cum[$caseprev] - $percent X";
print ($percent >= 0 ? "+$percent" : "$percent").'%';
}
if ($cum[$caseprev] && !$cum[$case])
{
print '-100%';
}
if (!$cum[$caseprev] && $cum[$case])
{
//print '<td class="right">+Inf%</td>';
print '-';
}
if (isset($cum[$caseprev]) && !$cum[$caseprev] && !$cum[$case])
{
print '+0%';
}
if (!isset($cum[$caseprev]) && !$cum[$case])
{
print '-';
}
} else {
if ($minyearmonth <= $case && $case <= $maxyearmonth) { print '-'; } else { print '&nbsp;'; }
}
if ($cum[$caseprev] && !$cum[$case])
{
print '<td class="borderrightlight right">-100%</td>';
}
if (!$cum[$caseprev] && $cum[$case])
{
//print '<td class="right">+Inf%</td>';
print '<td class="borderrightlight right">-</td>';
}
if (isset($cum[$caseprev]) && !$cum[$caseprev] && !$cum[$case])
{
print '<td class="borderrightlight right">+0%</td>';
}
if (!isset($cum[$caseprev]) && !$cum[$case])
{
print '<td class="borderrightlight right">-</td>';
}
} else {
print '<td class="borderrightlight right">';
if ($minyearmonth <= $case && $case <= $maxyearmonth) { print '-'; } else { print '&nbsp;'; }
print '</td>';
}
print '</td>';
if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) print '<td width="15">&nbsp;</td>';
}
$total_ht[$annee] += ((!empty($cum_ht[$case])) ? $cum_ht[$case] : 0);
$total[$annee] += $cum[$case];
if ($annee < $year_end || ($annee == $year_end && $mois <= $month_end)) {
$total_ht[$annee] += ((!empty($cum_ht[$case])) ? $cum_ht[$case] : 0);
$total[$annee] += $cum[$case];
}
}
print '</tr>';
@ -470,34 +479,37 @@ for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++)
}
*/
// Affiche total
// Show total
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td>';
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
if ($modecompta == 'CREANCES-DETTES') {
// Montant total HT
if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear)))
{
print '<td class="nowrap right">'.($total_ht[$annee] ?price($total_ht[$annee]) : "0")."</td>";
if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) {
print '<td class="nowrap right">';
print ($total_ht[$annee] ?price($total_ht[$annee]) : "0");
print "</td>";
} else {
print '<td>&nbsp;</td>';
}
}
// Montant total
if ($total[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear)))
{
print '<td class="nowrap right">'.($total[$annee] ?price($total[$annee]) : "0")."</td>";
// Total amount
if ($total[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) {
print '<td class="nowrap right">';
print ($total[$annee] ?price($total[$annee]) : "0");
print "</td>";
} else {
print '<td>&nbsp;</td>';
}
// Pourcentage total
if ($annee > $minyear && $annee <= max($nowyear, $maxyear))
{
if ($annee > $minyear && $annee <= max($nowyear, $maxyear)) {
if ($total[$annee - 1] && $total[$annee]) {
$percent = (round(($total[$annee] - $total[$annee - 1]) / $total[$annee - 1], 4) * 100);
print '<td class="nowrap borderrightlight right">'.($percent >= 0 ? "+$percent" : "$percent").'%</td>';
print '<td class="nowrap borderrightlight right">';
print ($percent >= 0 ? "+$percent" : "$percent").'%';
print '</td>';
}
if ($total[$annee - 1] && !$total[$annee])
{

View File

@ -5652,7 +5652,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart = '
$arrayforoldpath = array('cheque', 'category', 'holiday', 'supplier_invoice', 'invoice_supplier', 'mailing', 'supplier_payment');
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[] = 'product';
if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
// This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided.
// This part should be removed once all code is using "get_exdir" to forge path, with parameter $object and $modulepart provided.
if (empty($alpha)) $num = preg_replace('/([^0-9])/i', '', $num);
else $num = preg_replace('/^.*\-/i', '', $num);
$num = substr("000".$num, -$level);

View File

@ -243,7 +243,7 @@ class pdf_azur extends ModelePDFPropales
$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
$pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
} else {
$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
$pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
}

View File

@ -242,7 +242,7 @@ class pdf_cyan extends ModelePDFPropales
$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
$pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
} else {
$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
$pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
$pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
}

View File

@ -211,8 +211,9 @@ $helpurl = 'EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Ex
llxHeader('', $langs->trans('ListOfSendings'), $helpurl);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as delivery_date, l.date_delivery as date_reception, e.fk_statut, e.billed, e.tracking_number,";
if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
$sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as delivery_date, e.fk_statut, e.billed, e.tracking_number,";
$sql .= " l.date_delivery as date_reception,";
$sql .= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ";
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
@ -242,11 +243,12 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid =
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as ee ON e.rowid = ee.fk_source AND ee.sourcetype = 'shipping' AND ee.targettype = 'delivery'";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON e.fk_user_author = u.rowid';
if ($search_user > 0) { // Get link to order to get the order id in eesource.fk_source
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as eesource ON eesource.fk_target = e.rowid AND eesource.targettype = 'shipping' AND eesource.sourcetype = 'commande'";
}
// We'll need this table joined to the select in order to filter by sale
if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if ($search_user > 0)
{
if ($search_user > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
}
@ -274,6 +276,11 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
if ($search_tracking) $sql .= natural_search("e.tracking_number", $search_tracking);
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
if ($search_user > 0)
{
// The contact on a shipment is also the contact of the order.
$sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = eesource.fk_source AND ec.fk_socpeople = ".$db->escape($search_user);
}
if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp);
if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv);
if ($search_company) $sql .= natural_search('s.nom', $search_company);

View File

@ -521,7 +521,7 @@ $help_url = '';
// llxHeader('',$title,$help_url);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,';
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";

View File

@ -554,4 +554,3 @@ INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES
ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging varchar(64);
ALTER TABLE llx_projet ADD COLUMN fk_opp_status_end integer DEFAULT NULL;

View File

@ -16,7 +16,7 @@
CREATE TABLE llx_mrp_production(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
fk_mo integer NOT NULL,
fk_mo integer NOT NULL,
position integer NOT NULL DEFAULT 0,
fk_product integer NOT NULL,
fk_warehouse integer,

View File

@ -106,7 +106,7 @@ class Mo extends CommonObject
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'notnull'=>-1,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>-1,),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,),
'date_valid' => array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-2, 'position'=>502,),
'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'user.rowid',),
'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,),
@ -1352,7 +1352,7 @@ class Mo extends CommonObject
*/
public static function replaceThirdparty($db, $origin_id, $dest_id)
{
$tables = array('mrp_production');
$tables = array('mrp_mo');
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}

View File

@ -249,7 +249,7 @@ $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
//llxHeader('',$langs->trans('CommRequest'),$help_url);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";