From 7fe8c7eab3080f7cc1522ed585250805b5020ca2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Apr 2020 01:37:04 +0200 Subject: [PATCH] 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 '
'.$langs->trans('SendMail').'
'; + if (empty($user->socid)) { + if ($object->statut == 1) { + print '
'.$langs->trans('SendMail').'
'; + } } // 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 '
'.$langs->trans('SendMail').'
'; - } - else - { - $langs->load("mails"); - print '
'.$langs->trans('SendMail').'
'; + if (empty($user->socid)) { + if (!empty($object->email)) + { + $langs->load("mails"); + print '
'.$langs->trans('SendMail').'
'; + } + else + { + $langs->load("mails"); + print '
'.$langs->trans('SendMail').'
'; + } } 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 '
'.$langs->trans('SendMail').'
'; - } else - print '
'.$langs->trans('SendMail').'
'; + if (empty($user->socid)) { + if ($object->statut == 1) { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { + print '
'.$langs->trans('SendMail').'
'; + } else + print '
'.$langs->trans('SendMail').'
'; + } } 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 '
'.$langs->trans('SendMail').'
'; - //} else - // print '
' . $langs->trans('SendMail') . '
'; + 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 '
'.$langs->trans('SendMail').'
'; + //} else + // print '
' . $langs->trans('SendMail') . '
'; + } } - /* 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 '
'.$langs->trans('SendMail').'
'; + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send) + { + print '
'.$langs->trans('SendMail').'
'; + } + else print '
'.$langs->trans('SendMail').'
'; } - else print '
'.$langs->trans('SendMail').'
'; } // 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 '
'.$langs->trans('SendMail').'
'; + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send) + { + print '
'.$langs->trans('SendMail').'
'; + } + 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 '
'.$langs->trans('SendMail').'
'; - } else - print '
'.$langs->trans('SendMail').'
'; + 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 '
'.$langs->trans('SendMail').'
'; + } else + print '
'.$langs->trans('SendMail').'
'; + } } // 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 '
'.$langs->trans('SendMail').'
'; - } - else - { - $langs->load("mails"); - print '
'.$langs->trans('SendMail').'
'; + if (empty($user->socid)) { + if (!empty($object->email)) + { + $langs->load("mails"); + print '
'.$langs->trans('SendMail').'
'; + } + else + { + $langs->load("mails"); + print '
'.$langs->trans('SendMail').'
'; + } } 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 '
'.$langs->trans('SendMail').'
'."\n"; + if (empty($user->socid)) { + print '
'.$langs->trans('SendMail').'
'."\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) {