|
@@ -2068,116 +2068,13 @@ if ($action == 'create')
|
|
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
|
|
}
|
|
|
|
|
|
- if ($action == 'presend')
|
|
|
- {
|
|
|
- $ref = dol_sanitizeFileName($object->ref);
|
|
|
- include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|
|
- $fileparams = dol_most_recent_file($conf->reception->dir_output.'/'.$ref, preg_quote($ref, '/').'[^\-]+');
|
|
|
- $file = $fileparams['fullname'];
|
|
|
- // Define output language
|
|
|
- $outputlangs = $langs;
|
|
|
- $newlang = '';
|
|
|
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id']))
|
|
|
- $newlang = $_REQUEST['lang_id'];
|
|
|
- if ($conf->global->MAIN_MULTILANGS && empty($newlang))
|
|
|
- $newlang = $object->thirdparty->default_lang;
|
|
|
- if (!empty($newlang))
|
|
|
- {
|
|
|
- $outputlangs = new Translate('', $conf);
|
|
|
- $outputlangs->setDefaultLang($newlang);
|
|
|
- $outputlangs->load('receptions');
|
|
|
- }
|
|
|
- // Build document if it not exists
|
|
|
- if (!$file || !is_readable($file))
|
|
|
- {
|
|
|
- $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);
|
|
|
- exit;
|
|
|
- }
|
|
|
- $fileparams = dol_most_recent_file($conf->reception->dir_output.'/reception/'.$ref, preg_quote($ref, '/').'[^\-]+');
|
|
|
- $file = $fileparams['fullname'];
|
|
|
- }
|
|
|
- print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
|
|
|
- print '<div class="clearboth"></div>';
|
|
|
- print '<br>';
|
|
|
- print load_fiche_titre($langs->trans('SendReceptionByEMail'));
|
|
|
- print dol_get_fiche_head('');
|
|
|
- // Cree l'objet formulaire mail
|
|
|
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
|
|
- $formmail = new FormMail($db);
|
|
|
- $formmail->param['langsmodels'] = (empty($newlang) ? $langs->defaultlang : $newlang);
|
|
|
- $formmail->fromtype = (GETPOST('fromtype') ?GETPOST('fromtype') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user'));
|
|
|
- if ($formmail->fromtype === 'user') {
|
|
|
- $formmail->fromid = $user->id;
|
|
|
- }
|
|
|
- $formmail->trackid = 'shi'.$object->id;
|
|
|
- if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
|
|
|
- {
|
|
|
- include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
|
|
- $formmail->frommail = dolAddEmailTrackId($formmail->frommail, 'shi'.$object->id);
|
|
|
- }
|
|
|
- $formmail->withfrom = 1;
|
|
|
- $liste = array();
|
|
|
- foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key] = $value;
|
|
|
- $formmail->withto = GETPOST("sendto") ?GETPOST("sendto") : $liste;
|
|
|
- $formmail->withtocc = $liste;
|
|
|
- $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
|
|
|
- $formmail->withtopic = $outputlangs->trans('SendReceptionRef', '__RECEPTIONREF__');
|
|
|
- $formmail->withfile = 2;
|
|
|
- $formmail->withbody = 1;
|
|
|
- $formmail->withdeliveryreceipt = 1;
|
|
|
- $formmail->withcancel = 1;
|
|
|
- // Tableau des substitutions
|
|
|
- $formmail->setSubstitFromObject($object, $langs);
|
|
|
- $formmail->substit['__RECEPTIONREF__'] = $object->ref;
|
|
|
- $formmail->substit['__RECEPTIONTRACKNUM__'] = $object->tracking_number;
|
|
|
- $formmail->substit['__RECEPTIONTRACKNUMURL__'] = $object->tracking_url;
|
|
|
- //Find the good contact adress
|
|
|
- if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
|
|
|
- $objectsrc = new Commande($db);
|
|
|
- $objectsrc->fetch($object->$typeobject->id);
|
|
|
- }
|
|
|
- if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
|
|
|
- $objectsrc = new Propal($db);
|
|
|
- $objectsrc->fetch($object->$typeobject->id);
|
|
|
- }
|
|
|
- $custcontact = '';
|
|
|
- $contactarr = array();
|
|
|
- if (is_object($objectsrc)) // For the case the reception was created without orders
|
|
|
- {
|
|
|
- $contactarr = $objectsrc->liste_contact(-1, 'external');
|
|
|
- }
|
|
|
- if (is_array($contactarr) && count($contactarr) > 0) {
|
|
|
- foreach ($contactarr as $contact) {
|
|
|
- if ($contact['libelle'] == $langs->trans('TypeContact_commande_external_CUSTOMER')) {
|
|
|
- require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
|
|
- $contactstatic = new Contact($db);
|
|
|
- $contactstatic->fetch($contact['id']);
|
|
|
- $custcontact = $contactstatic->getFullName($langs, 1);
|
|
|
- }
|
|
|
- }
|
|
|
- if (!empty($custcontact)) {
|
|
|
- $formmail->substit['__CONTACTCIVNAME__'] = $custcontact;
|
|
|
- }
|
|
|
- }
|
|
|
- // Tableau des parametres complementaires
|
|
|
- $formmail->param['action'] = 'send';
|
|
|
- $formmail->param['models'] = 'reception_send';
|
|
|
- $formmail->param['models_id'] = GETPOST('modelmailselected', 'int');
|
|
|
- $formmail->param['receptionid'] = $object->id;
|
|
|
- $formmail->param['returnurl'] = $_SERVER["PHP_SELF"].'?id='.$object->id;
|
|
|
- // Init list of files
|
|
|
- if (GETPOST("mode") == 'init')
|
|
|
- {
|
|
|
- $formmail->clear_attached_files();
|
|
|
- $formmail->add_attached_files($file, basename($file), dol_mimetype($file));
|
|
|
- }
|
|
|
- // Show form
|
|
|
- print $formmail->get_form();
|
|
|
- print dol_get_fiche_end();
|
|
|
- }
|
|
|
+ // Presend form
|
|
|
+ $modelmail = 'shipping_send';
|
|
|
+ $defaulttopic = 'SendReceptionRef';
|
|
|
+ $diroutput = $conf->reception->dir_output;
|
|
|
+ $trackid = 'rec'.$object->id;
|
|
|
+
|
|
|
+ include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
|
|
|
}
|
|
|
|
|
|
|