From e32ac7644d475e31d73b5a785d7eb18d61331709 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Apr 2020 15:26:16 +0200 Subject: [PATCH 1/7] FIX Send email from bulk action of list of thirdparties --- htdocs/core/actions_massactions.inc.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index e5734547a95..9211c771fab 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -236,7 +236,11 @@ if (! $error && $massaction == 'confirm_presend') // Test recipient if (empty($sendto)) // For the case, no recipient were set (multi thirdparties send) { - if ($objectobj->element == 'expensereport') + if ($objectobj->element == 'societe') + { + $sendto = $objectobj->email; + } + elseif ($objectobj->element == 'expensereport') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user_author); @@ -257,6 +261,10 @@ if (! $error && $massaction == 'confirm_presend') if (empty($sendto)) { + if ($objectobj->element == 'societe') { + $objectobj->thirdparty = $objectobj; // Hack so following code is comaptible when objectobj is a thirdparty + } + //print "No recipient for thirdparty ".$objectobj->thirdparty->name; $nbignored++; if (empty($thirdpartywithoutemail[$objectobj->thirdparty->id])) From 9950295e4132480783922f43a5f4be171271dea8 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 6 Apr 2020 10:12:27 +0200 Subject: [PATCH 2/7] FIX author search supplier proposal list --- htdocs/supplier_proposal/list.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index fe010c95e9c..5d6d2d2e0c3 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -59,7 +59,7 @@ $search_user=GETPOST('search_user', 'int'); $search_sale=GETPOST('search_sale', 'int'); $search_ref=GETPOST('sf_ref')?GETPOST('sf_ref', 'alpha'):GETPOST('search_ref', 'alpha'); $search_societe=GETPOST('search_societe', 'alpha'); -$search_author=GETPOST('search_author', 'alpha'); +$search_login=GETPOST('search_login', 'alpha'); $search_town=GETPOST('search_town', 'alpha'); $search_zip=GETPOST('search_zip', 'alpha'); $search_state=trim(GETPOST("search_state")); @@ -196,7 +196,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_type=''; $search_country=''; $search_type_thirdparty=''; - $search_author=''; + $search_login=''; $yearvalid=''; $monthvalid=''; $dayvalid=''; @@ -282,7 +282,7 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_ref) $sql .= natural_search('sp.ref', $search_ref); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_author) $sql .= natural_search('u.login', $search_author); +if ($search_login) $sql .= natural_search('u.login', $search_login); if ($search_montant_ht) $sql.= natural_search('sp.total_ht=', $search_montant_ht, 1); if ($search_montant_vat != '') $sql.= natural_search("sp.tva", $search_montant_vat, 1); if ($search_montant_ttc != '') $sql.= natural_search("sp.total", $search_montant_ttc, 1); @@ -366,7 +366,7 @@ if ($resql) if ($search_user > 0) $param.='&search_user='.$search_user; if ($search_sale > 0) $param.='&search_sale='.$search_sale; if ($search_montant_ht) $param.='&search_montant_ht='.$search_montant_ht; - if ($search_author) $param.='&search_author='.$search_author; + if ($search_login) $param.='&search_login='.$search_login; if ($search_town) $param.='&search_town='.$search_town; if ($search_zip) $param.='&search_zip='.$search_zip; if ($socid > 0) $param.='&socid='.$socid; @@ -549,7 +549,7 @@ if ($resql) { // Author print ''; - print ''; + print ''; print ''; } // Extra fields From 34e434a17e8751f6e76ab20d8f7a6053dbc48fc8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 6 Apr 2020 16:36:11 +0200 Subject: [PATCH 3/7] FIX missing member entity --- htdocs/societe/class/societe.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 87c4956e48e..5ea844a7320 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3275,6 +3275,7 @@ class Societe extends CommonObject $this->phone=$member->phone; // Prof phone $this->email=$member->email; $this->skype=$member->skype; + $this->entity=$member->entity; $this->client = 1; // A member is a customer by default $this->code_client = ($customercode?$customercode:-1); @@ -3778,7 +3779,7 @@ class Societe extends CommonObject $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; } - + //if credit note is converted but not used if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed())$outstandingOpened-=$tmpobject->getSumFromThisCreditNotesNotUsed(); From 3327f1c0742bf9a08eed8d77f206c3ae700f23e9 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 9 Apr 2020 11:53:03 +0200 Subject: [PATCH 4/7] FIX : IHM, unexpected quote --- htdocs/langs/fr_FR/exports.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/exports.lang b/htdocs/langs/fr_FR/exports.lang index 58242dfaa1a..b76d78ea09d 100644 --- a/htdocs/langs/fr_FR/exports.lang +++ b/htdocs/langs/fr_FR/exports.lang @@ -109,7 +109,7 @@ Separator=Séparateur de champs Enclosure=Encadrement des chaînes de textes SpecialCode=Code spécial ExportStringFilter=%% permet de remplacer 1 ou plusieurs caractères dans le texte -ExportDateFilter=AAAA, AAAAMM, AAAAMMJJ: filtre pour une année/mois/jour
AAAA+AAAA, AAAAMM+AAAAMM, AAAAMMJJ+AAAAMMJJ: filtre pour une plage année/mois/jour
> AAAA, > AAAAMM, > AAAAMMJJ': filtre pour une date supérieure à une année/mois/jour donné
< AAAA, < AAAAMM, < AAAAMMJJ: filtre pour une date inférieure à une année/mois/jour donné +ExportDateFilter=AAAA, AAAAMM, AAAAMMJJ: filtre pour une année/mois/jour
AAAA+AAAA, AAAAMM+AAAAMM, AAAAMMJJ+AAAAMMJJ: filtre pour une plage année/mois/jour
> AAAA, > AAAAMM, > AAAAMMJJ: filtre pour une date supérieure à une année/mois/jour donné
< AAAA, < AAAAMM, < AAAAMMJJ: filtre pour une date inférieure à une année/mois/jour donné ExportNumericFilter=NNNNN filtre une seule valeur
NNNNN+NNNNN filtre une plage de valeurs
< NNNNN filtre les valeurs inférieures
> NNNNN filtre les valeurs supérieures ImportFromLine=Début d'import à la ligne numéro EndAtLineNb=Fin à la ligne numéro From 273443550e48df84bca66c8726fde374e25b660e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2020 01:21:59 +0200 Subject: [PATCH 5/7] Fix list in warehouse --- htdocs/product/stock/list.php | 159 ++++++++++++++++++++-------------- 1 file changed, 92 insertions(+), 67 deletions(-) diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index b84ddf9aad2..7074a6d2ba8 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -49,12 +50,12 @@ $search_status = GETPOST("search_status", "int"); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "e.ref"; +if (!$sortfield) $sortfield = "t.ref"; if (!$sortorder) $sortorder = "ASC"; // Security check @@ -77,38 +78,55 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'e.ref'=>"Ref", - 'e.lieu'=>"LocationSummary", - 'e.description'=>"Description", - 'e.address'=>"Address", - 'e.zip'=>'Zip', - 'e.town'=>'Town', + 't.ref'=>"Ref", + 't.lieu'=>"LocationSummary", + 't.description'=>"Description", + 't.address'=>"Address", + 't.zip'=>'Zip', + 't.town'=>'Town', + 't.phone'=>'Phone', + 't.fax'=>'Fax', ); +// Initialize array of search criterias +$search_all=trim(GETPOST("search_all", 'alpha')); +$search=array(); +foreach($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key]=GETPOST('search_'.$key, 'alpha'); +} + // Definition of fields for list $arrayfields = array( 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'position'=>70), 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>-2, 'position'=>71), 'estimatedstockvaluesell'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'visible'=>-2, 'position'=>72), ); -foreach ($object->fields as $key => $val) +foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['e.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { + $arrayfields["ef.".$key] = array( + 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], + 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), + 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], + 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) + ); + } } } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); + /* * Actions */ @@ -128,12 +146,12 @@ if (empty($reshook)) // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $search_ref = ""; - $sall = ""; - $search_label = ""; - $search_status = ""; - $toselect = ''; - $search_array_options = array(); + foreach ($object->fields as $key => $val) + { + $search[$key] = ''; + } + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) @@ -167,31 +185,38 @@ $title = $langs->trans("ListOfWarehouses"); // Build and execute select // -------------------------------------------------------------------- -$sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,"; -$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; -$sqlGroupBy = ''; +$sql = 'SELECT '; +foreach ($object->fields as $key => $val) +{ + $sql .= 't.'.$key.', '; +} // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); - $sqlGroupBy .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); } +$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); -$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; +$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON t.rowid = ps.fk_entrepot"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c_dep ON c_dep.rowid = e.fk_departement"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as ccount ON ccount.rowid = e.fk_pays"; -$sql .= " WHERE e.entity IN (".getEntity('stock').")"; -if ($search_ref) $sql .= natural_search("e.ref", $search_ref); // ref -if ($search_label) $sql .= natural_search("e.lieu", $search_label); // label -if ($search_status != '' && $search_status >= 0) $sql .= " AND e.statut = ".$search_status; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c_dep ON c_dep.rowid = t.fk_departement"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as ccount ON ccount.rowid = t.fk_pays"; +$sql .= " WHERE t.entity IN (".getEntity('stock').")"; +foreach ($search as $key => $val) +{ + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if (strpos($object->fields[$key]['type'], 'integer:') === 0) { + if ($search[$key] == '-1') $search[$key] = ''; + $mode_search = 2; + } + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); +} if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -199,12 +224,25 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent".$sqlGroupBy; +$sql.= " GROUP BY "; +foreach($object->fields as $key => $val) +{ + $sql.='t.'.$key.', '; +} +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +} +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/,\s*$/','', $sql); $totalnboflines = 0; $result = $db->query($sql); if ($result) { - $totalnboflines = $db->num_rows($result); + $totalnboflines = $db->num_rows($result); // fetch totals $line = $total = $totalsell = $totalStock = 0; while ($line < $totalnboflines) @@ -272,10 +310,11 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); -if ($search_label) $param .= "&search_label=".urlencode($search_label); -if ($search_status) $param .= "&search_status=".urlencode($search_status); -if ($search_all) $param .= "&search_all=".urlencode($search_all); +foreach ($search as $key => $val) +{ + if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); + else $param .= '&search_'.$key.'='.urlencode($search[$key]); +} if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -339,7 +378,7 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- @@ -353,7 +392,7 @@ foreach ($object->fields as $key => $val) elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['e.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; @@ -410,9 +450,9 @@ foreach ($object->fields as $key => $val) elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['e.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['e.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 'e.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } @@ -430,13 +470,14 @@ if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -if (!empty($arrayfields["e.statut"]['checked'])) { - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['t.statut']['checked'])) { + print_liste_field_titre($arrayfields['t.statut']['label'], $_SERVER["PHP_SELF"], "t.statut", '', $param, '', $sortfield, $sortorder, 'right '); } // Action column @@ -482,7 +523,7 @@ if ($num) if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['e.'.$key]['checked'])) + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if ($key == 'statut') print $warehouse->getLibStatut(5); @@ -491,8 +532,8 @@ if ($num) if (!$i) $totalarray['nbfield']++; if (!empty($val['isameasure'])) { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'e.'.$key; - $totalarray['val']['e.'.$key] += $warehouse->$key; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['val']['t.'.$key] += $warehouse->$key; } } } @@ -535,7 +576,7 @@ if ($num) print $hookmanager->resPrint; // Status - if (!empty($arrayfields["e.statut"]['checked'])) { + if (!empty($arrayfields['t.statut']['checked'])) { print ''; if (!$i) $totalarray['nbfield']++; } @@ -561,22 +602,6 @@ if ($num) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - - /*print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n";*/ } } From 7fe8c7eab3080f7cc1522ed585250805b5020ca2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2020 01:37:04 +0200 Subject: [PATCH 6/7] FIX #11855 --- htdocs/adherents/card.php | 6 +++-- htdocs/asset/card.php | 4 +++- htdocs/bom/bom_card.php | 4 +++- htdocs/comm/propal/card.php | 12 +++++----- htdocs/commande/card.php | 12 +++++----- htdocs/compta/facture/card.php | 18 ++++++++------- htdocs/contact/card.php | 20 +++++++++-------- htdocs/contrat/card.php | 12 +++++----- htdocs/expedition/card.php | 12 +++++----- htdocs/expensereport/card.php | 13 ++++++----- htdocs/fichinter/card.php | 12 +++++----- htdocs/fourn/commande/card.php | 10 +++++---- htdocs/fourn/facture/card.php | 12 +++++----- .../modulebuilder/template/myobject_card.php | 4 +++- htdocs/mrp/mo_card.php | 4 +++- htdocs/product/inventory/card.php | 4 +++- htdocs/projet/card.php | 8 ++++--- htdocs/reception/card.php | 12 +++++----- htdocs/societe/card.php | 22 ++++++++++--------- htdocs/supplier_proposal/card.php | 12 +++++----- htdocs/user/card.php | 20 +++++++++-------- htdocs/website/websiteaccount_card.php | 4 +++- htdocs/zapier/hook_card.php | 3 --- 23 files changed, 140 insertions(+), 100 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 1b68d910f0d..7d24b330d3e 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1773,8 +1773,10 @@ else if ($action != 'editlogin' && $action != 'editthirdparty') { // Send - if ($object->statut == 1) { - print ''; + if (empty($user->socid)) { + if ($object->statut == 1) { + print ''; + } } // Send card by email diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index b4ff4ebac68..0292559c33c 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -281,7 +281,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send - print ''.$langs->trans('SendMail').''."\n"; + if (empty($user->socid)) { + print ''.$langs->trans('SendMail').''."\n"; + } if ($user->rights->asset->write) { diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 3320c160fc2..9851aea96e7 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -601,7 +601,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send - //print '' . $langs->trans('SendMail') . ''."\n"; + //if (empty($user->socid)) { + // print '' . $langs->trans('SendMail') . ''."\n"; + //} // Back to draft if ($object->status == $object::STATUS_VALIDATED) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 1f5927f260a..32994e816de 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2498,11 +2498,13 @@ if ($action == 'create') } // Send - if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED || !empty($conf->global->PROPOSAL_SENDBYEMAIL_FOR_ALL_STATUS)) { - if ($usercansend) { - print ''.$langs->trans('SendMail').''; - } else - print ''.$langs->trans('SendMail').''; + if (empty($user->socid)) { + if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED || !empty($conf->global->PROPOSAL_SENDBYEMAIL_FOR_ALL_STATUS)) { + if ($usercansend) { + print ''.$langs->trans('SendMail').''; + } else + print ''.$langs->trans('SendMail').''; + } } // Create a sale order diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 9b389bccb5b..5b046ecf536 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2548,11 +2548,13 @@ if ($action == 'create' && $usercancreate) } // Send - if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { - if ($usercansend) { - print ''.$langs->trans('SendMail').''; - } else - print ''.$langs->trans('SendMail').''; + if (empty($user->socid)) { + if ($object->statut > Commande::STATUS_DRAFT || !empty($conf->global->COMMANDE_SENDBYEMAIL_FOR_ALL_STATUS)) { + if ($usercansend) { + print ''.$langs->trans('SendMail').''; + } else + print ''.$langs->trans('SendMail').''; + } } // Valid diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index bf03ad2c3d6..03ef9ac03a5 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5052,14 +5052,16 @@ elseif ($id > 0 || !empty($ref)) } // Send by mail - if (($object->statut == Facture::STATUS_VALIDATED || $object->statut == Facture::STATUS_CLOSED) || !empty($conf->global->FACTURE_SENDBYEMAIL_FOR_ALL_STATUS)) { - if ($objectidnext) { - print ''.$langs->trans('SendMail').''; - } else { - if ($usercansend) { - print ''.$langs->trans('SendMail').''; - } else - print ''.$langs->trans('SendMail').''; + if (empty($user->socid)) { + if (($object->statut == Facture::STATUS_VALIDATED || $object->statut == Facture::STATUS_CLOSED) || !empty($conf->global->FACTURE_SENDBYEMAIL_FOR_ALL_STATUS)) { + if ($objectidnext) { + print ''.$langs->trans('SendMail').''; + } else { + if ($usercansend) { + print ''.$langs->trans('SendMail').''; + } else + print ''.$langs->trans('SendMail').''; + } } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index ed58d976d7c..e7fb6469869 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1449,15 +1449,17 @@ else $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook) && $action != 'presend') { - if (!empty($object->email)) - { - $langs->load("mails"); - print ''; - } - else - { - $langs->load("mails"); - print ''; + if (empty($user->socid)) { + if (!empty($object->email)) + { + $langs->load("mails"); + print ''; + } + else + { + $langs->load("mails"); + print ''; + } } if ($user->rights->societe->contact->creer) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index c80dda1da91..9581d625f80 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -2106,11 +2106,13 @@ else if (empty($reshook)) { // Send - if ($object->statut == 1) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { - print ''; - } else - print ''; + if (empty($user->socid)) { + if ($object->statut == 1) { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { + print ''; + } else + print ''; + } } if ($object->statut == 0 && $nbofservices) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index cc9111fc813..5f5e653bff2 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2529,13 +2529,15 @@ elseif ($id || $ref) } // Send - if ($object->statut > 0) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send) + if (empty($user->socid)) { + if ($object->statut > 0) { - print ''.$langs->trans('SendMail').''; + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send) + { + print ''.$langs->trans('SendMail').''; + } + else print ''.$langs->trans('SendMail').''; } - else print ''.$langs->trans('SendMail').''; } // Create bill diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index cbca46576a1..48b318620c9 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2643,14 +2643,15 @@ if ($action != 'create' && $action != 'edit') $object->fetch($id, $ref); // Send - if ($object->fk_statut > ExpenseReport::STATUS_DRAFT) { - //if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expensereport->expensereport_advance->send)) { - print ''; - //} else - // print ''; + if (empty($user->socid)) { + if ($object->fk_statut > ExpenseReport::STATUS_DRAFT) { + //if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expensereport->expensereport_advance->send)) { + print ''; + //} else + // print ''; + } } - /* Si l'état est "Brouillon" * ET user à droit "creer/supprimer" * ET fk_user_author == user courant diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index faf7943107f..ed6d7996eff 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1628,13 +1628,15 @@ elseif ($id > 0 || !empty($ref)) } // Send - if ($object->statut > Fichinter::STATUS_DRAFT) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) + if (empty($user->socid)) { + if ($object->statut > Fichinter::STATUS_DRAFT) { - print ''; + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) + { + print ''; + } + else print ''; } - else print ''; } // create intervention model diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index a9503fa2162..981279db9dc 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2442,11 +2442,13 @@ elseif (!empty($object->id)) } // Send - if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || !empty($conf->global->SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS)) - { - if ($user->rights->fournisseur->commande->commander) + if (empty($user->socid)) { + if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || !empty($conf->global->SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS)) { - print ''.$langs->trans('SendMail').''; + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans('SendMail').''; + } } } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 703a97fe11a..948fd389b60 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3134,13 +3134,15 @@ else } // Send by mail - if (($object->statut == FactureFournisseur::STATUS_VALIDATED || $object->statut == FactureFournisseur::STATUS_CLOSED)) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send) + if (empty($user->socid)) { + if (($object->statut == FactureFournisseur::STATUS_VALIDATED || $object->statut == FactureFournisseur::STATUS_CLOSED)) { - print ''; + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send) + { + print ''; + } + else print '
'.$langs->trans('SendMail').'
'; } - else print '
'.$langs->trans('SendMail').'
'; } // Make payments diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 97adff0558f..f44caa119a9 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -456,7 +456,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send - print ''.$langs->trans('SendMail').''."\n"; + if (empty($user->socid)) { + print ''.$langs->trans('SendMail').''."\n"; + } // Back to draft if ($object->status == $object::STATUS_VALIDATED) diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index e16a19ea482..21558c257ec 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -574,7 +574,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send - //print '' . $langs->trans('SendMail') . ''."\n"; + //if (empty($user->socid)) { + // print '' . $langs->trans('SendMail') . ''."\n"; + //} // Back to draft if ($object->status == $object::STATUS_VALIDATED) diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 3d389cf7eb2..df872491ae1 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -329,7 +329,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send - print ''.$langs->trans('SendMail').''."\n"; + if (empty($user->socid)) { + print ''.$langs->trans('SendMail').''."\n"; + } if ($permissiontoadd) { diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 48777ceb1e4..16cf9032731 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1191,9 +1191,11 @@ elseif ($object->id > 0) }*/ // Send - if ($object->statut != 2) - { - print ''.$langs->trans('SendMail').''; + if (empty($user->socid)) { + if ($object->statut != 2) + { + print ''.$langs->trans('SendMail').''; + } } // Modify diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 83a28d55f48..4a76631dc17 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -2056,13 +2056,15 @@ elseif ($id || $ref) } // Send - if ($object->statut > 0) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->reception->reception_advance->send) + if (empty($user->socid)) { + if ($object->statut > 0) { - print ''.$langs->trans('SendByMail').''; + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->reception->reception_advance->send) + { + print ''.$langs->trans('SendByMail').''; + } + else print ''.$langs->trans('SendByMail').''; } - else print ''.$langs->trans('SendByMail').''; } // Create bill diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 318e6dec614..9cc5febc2ca 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2714,16 +2714,18 @@ else } } - if (!empty($object->email) || $at_least_one_email_contact) - { - $langs->load("mails"); - print ''.$langs->trans('SendMail').''; - } - else - { - $langs->load("mails"); - print ''.$langs->trans('SendMail').''; - } + if (empty($user->socid)) { + if (!empty($object->email) || $at_least_one_email_contact) + { + $langs->load("mails"); + print ''.$langs->trans('SendMail').''; + } + else + { + $langs->load("mails"); + print ''.$langs->trans('SendMail').''; + } + } if ($user->rights->societe->creer) { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index e998f909d06..a3fdd48b04e 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1869,11 +1869,13 @@ if ($action == 'create') } // Send - if ($object->statut == SupplierProposal::STATUS_VALIDATED || $object->statut == SupplierProposal::STATUS_SIGNED) { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance) { - print ''; - } else - print ''; + if (empty($user->socid)) { + if ($object->statut == SupplierProposal::STATUS_VALIDATED || $object->statut == SupplierProposal::STATUS_SIGNED) { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance) { + print ''; + } else + print ''; + } } // Create an order diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 152103cc5db..4bedd36fc3c 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1884,15 +1884,17 @@ else $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - if (!empty($object->email)) - { - $langs->load("mails"); - print ''; - } - else - { - $langs->load("mails"); - print ''; + if (empty($user->socid)) { + if (!empty($object->email)) + { + $langs->load("mails"); + print ''; + } + else + { + $langs->load("mails"); + print ''; + } } if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 36eb72dd916..046a5005e51 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -306,7 +306,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send - print ''."\n"; + if (empty($user->socid)) { + print ''."\n"; + } if ($user->rights->website->write) { diff --git a/htdocs/zapier/hook_card.php b/htdocs/zapier/hook_card.php index d4dec007d86..c2755892716 100644 --- a/htdocs/zapier/hook_card.php +++ b/htdocs/zapier/hook_card.php @@ -334,9 +334,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { - // Send - print ''.$langs->trans('SendMail').''."\n"; - // Modify if ($user->rights->mymodule->write) { From 5a366767fb26d10a6e213a9d71fc45f0d79675ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2020 01:47:50 +0200 Subject: [PATCH 7/7] Fix phpcs --- htdocs/product/stock/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 7074a6d2ba8..e4ad265c793 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -235,9 +235,9 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { } // Add where from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/','', $sql); +$sql=preg_replace('/,\s*$/', '', $sql); $totalnboflines = 0; $result = $db->query($sql); if ($result)
'; if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); @@ -379,13 +418,14 @@ if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status -if (!empty($arrayfields["e.statut"]['checked'])) { +if (!empty($arrayfields['t.statut']['checked'])) { print ''; print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1); print '' . $warehouse->LibStatut($obj->statut, 5) . '
'.$langs->trans("Total").''.price2num($totalStock, 5).''.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency); - else - { - $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); - print $form->textwithtooltip($langs->trans("Variable"), $htmltext); - } - print '