diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 6f79d58551a..d710306172c 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -252,6 +252,9 @@ if (isModEnabled('eventorganization') && $user->hasRight('eventorganization', 'r if (isModEnabled('partnership') && $user->hasRight('partnership', 'read')) { $elementList['partnership_send'] = img_picto('', 'partnership', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToPartnership')); } +if (isModEnabled('product') && !empty($user->rights->produit->lire)) { + $elementList['product_send'] = img_picto('', 'product', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('Product')); +} $parameters = array('elementList' => $elementList); $reshook = $hookmanager->executeHooks('emailElementlist', $parameters); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 21f064ba8ca..d86a8cb0fc2 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -624,7 +624,7 @@ class FormMail extends Form } elseif (!empty($this->param['models']) && in_array($this->param['models'], array( 'propal_send', 'order_send', 'facture_send', 'shipping_send', 'fichinter_send', 'supplier_proposal_send', 'order_supplier_send', - 'invoice_supplier_send', 'thirdparty', 'contract', 'user', 'recruitmentcandidature_send', 'all' + 'invoice_supplier_send', 'thirdparty', 'contract', 'user', 'recruitmentcandidature_send', 'product_send', 'all' ))) { // If list of template is empty $out .= '
'."\n"; diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 38eca727f3a..254107a725e 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -123,6 +123,10 @@ if ($action == 'presend') { } if ($forcebuilddoc) { // If there is no default value for supplier invoice, we do not generate file, even if modelpdf was set by a manual generation if ((!$file || !is_readable($file)) && method_exists($object, 'generateDocument')) { + $hidedetails = $hidedetails?$hidedetails:''; + $hidedesc = $hidedetails?$hidedetails:''; + $hideref = $hidedetails?$hidedetails:''; + $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) { dol_print_error($db, $object->error, $object->errors); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 510d35181dc..323a650bbbb 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1312,6 +1312,13 @@ if (empty($reshook)) { setEventMessages($langs->trans("WarningSelectOneDocument"), null, 'warnings'); } } + + // Actions to send emails + $triggersendname = 'PRODUCT_SENTBYMAIL'; + $paramname = 'id'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_PRODUCT_TO'; + $trackid = 'prod'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -3044,6 +3051,9 @@ if ($action != 'create' && $action != 'edit') { print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$object->id, '', $usercancreate); } + //Send + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init&token=' . newToken() . '#formmailbeforetitle'); + if (!isset($hookmanager->resArray['no_button_copy']) || $hookmanager->resArray['no_button_copy'] != 1) { if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) { $cloneProductUrl = ''; @@ -3183,6 +3193,10 @@ if (getDolGlobalString('PRODUCT_ADD_FORM_ADD_TO') && $object->id && ($action == * Generated documents */ +if (GETPOST('modelselected')) { + $action = 'presend'; +} + if ($action != 'create' && $action != 'edit' && $action != 'delete') { print '
'; print ''; // ancre @@ -3215,6 +3229,14 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') { $somethingshown = $formactions->showactions($object, 'product', 0, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for product print '
'; + + // Presend form + $modelmail = 'product_send'; + $defaulttopic = $object->label; + $diroutput = $conf->product->multidir_output[$object->entity]; + $trackid = 'prod' . $object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } // End of page