mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: Maxi debug on sending document by email. Works now with odt too.
This commit is contained in:
parent
bc94ec9cd6
commit
245edb8596
|
|
@ -695,7 +695,7 @@ else
|
|||
$formmail->param["returnurl"]=$_SERVER["PHP_SELF"];
|
||||
|
||||
// Init list of files
|
||||
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
|
||||
if (GETPOST("mode")=='init')
|
||||
{
|
||||
$formmail->clear_attached_files();
|
||||
}
|
||||
|
|
@ -741,7 +741,7 @@ else
|
|||
$formmail->param["returnurl"]=$_SERVER["PHP_SELF"];
|
||||
|
||||
// Init list of files
|
||||
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
|
||||
if (GETPOST("mode")=='init')
|
||||
{
|
||||
$formmail->clear_attached_files();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -498,11 +498,11 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
|
|||
|
||||
if ($result > 0)
|
||||
{
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->propale->dir_output . '/' . $objectref . '/' . $objectref . '.pdf';
|
||||
// $objectref = dol_sanitizeFileName($object->ref);
|
||||
// $file = $conf->propale->dir_output . '/' . $objectref . '/' . $objectref . '.pdf';
|
||||
|
||||
if (is_readable($file))
|
||||
{
|
||||
// if (is_readable($file))
|
||||
// {
|
||||
if ($_POST['sendto'])
|
||||
{
|
||||
// Le destinataire a ete fourni via le champ libre
|
||||
|
|
@ -624,13 +624,13 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
|
|||
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
|
||||
dol_syslog('Recipient email is empty');
|
||||
}
|
||||
}
|
||||
/* }
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
|
||||
dol_syslog('Failed to read file: '.$file);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1483,26 +1483,30 @@ if ($id > 0 || ! empty($ref))
|
|||
|
||||
// Statut
|
||||
print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans('Notes').'</td></tr>';
|
||||
|
||||
// Public note
|
||||
print '<tr><td valign="top">';
|
||||
print $form->editfieldkey("NotePublic",'note_public',$object->note_public,$object,$user->rights->propale->creer,'textarea');
|
||||
print '</td><td colspan="3">';
|
||||
print $form->editfieldval("NotePublic",'note_public',$object->note_public,$object,$user->rights->propale->creer,'textarea');
|
||||
print "</td></tr>";
|
||||
|
||||
// Private note
|
||||
if (! $user->societe_id)
|
||||
{
|
||||
print '<tr><td valign="top">';
|
||||
print $form->editfieldkey("NotePrivate",'note',$object->note_private,$object,$user->rights->propale->creer,'textarea');
|
||||
print '</td><td colspan="3">';
|
||||
print $form->editfieldval("NotePrivate",'note',$object->note_private,$object,$user->rights->propale->creer,'textarea');
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans('Notes').'</td></tr>';
|
||||
|
||||
// Public note
|
||||
print '<tr><td valign="top">';
|
||||
print $form->editfieldkey("NotePublic",'note_public',$object->note_public,$object,$user->rights->propale->creer,'textarea');
|
||||
print '</td><td colspan="3">';
|
||||
print $form->editfieldval("NotePublic",'note_public',$object->note_public,$object,$user->rights->propale->creer,'textarea');
|
||||
print "</td></tr>";
|
||||
|
||||
// Private note
|
||||
if (! $user->societe_id)
|
||||
{
|
||||
print '<tr><td valign="top">';
|
||||
print $form->editfieldkey("NotePrivate",'note',$object->note_private,$object,$user->rights->propale->creer,'textarea');
|
||||
print '</td><td colspan="3">';
|
||||
print $form->editfieldval("NotePrivate",'note',$object->note_private,$object,$user->rights->propale->creer,'textarea');
|
||||
print "</td></tr>";
|
||||
}
|
||||
}
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
/*
|
||||
|
|
@ -1617,16 +1621,11 @@ if ($id > 0 || ! empty($ref))
|
|||
// Send
|
||||
if ($object->statut == 1 || $object->statut == 2)
|
||||
{
|
||||
$propref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->propale->dir_output . '/'.$propref.'/'.$propref.'.pdf';
|
||||
if (file_exists($file))
|
||||
{
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propale->propal_advance->send)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propale->propal_advance->send)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
|
||||
// Create an order
|
||||
|
|
@ -1722,7 +1721,33 @@ if ($id > 0 || ! empty($ref))
|
|||
if ($action == 'presend')
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->propale->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||
$fileparams = dol_most_recent_file($conf->propale->dir_output . '/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
if (! $file || ! is_readable($file))
|
||||
{
|
||||
// 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->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->propale->dir_output . '/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print_titre($langs->trans('SendPropalByMail'));
|
||||
|
|
@ -1756,10 +1781,10 @@ if ($id > 0 || ! empty($ref))
|
|||
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
|
||||
|
||||
// Init list of files
|
||||
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
|
||||
if (GETPOST("mode")=='init')
|
||||
{
|
||||
$formmail->clear_attached_files();
|
||||
$formmail->add_attached_files($file,dol_sanitizeFilename($object->ref).'.pdf','application/pdf');
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
$formmail->show_form();
|
||||
|
|
|
|||
|
|
@ -1034,11 +1034,11 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
|
|||
|
||||
if ($result > 0)
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
// $ref = dol_sanitizeFileName($object->ref);
|
||||
// $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
|
||||
if (is_readable($file))
|
||||
{
|
||||
// if (is_readable($file))
|
||||
// {
|
||||
if ($_POST['sendto'])
|
||||
{
|
||||
// Le destinataire a ete fourni via le champ libre
|
||||
|
|
@ -1153,14 +1153,14 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
|
|||
$mesg.='</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
|
||||
$action='presend';
|
||||
dol_syslog('Recipient email is empty');
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1243,7 +1243,7 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
|
||||
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
|
||||
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
|
||||
|
||||
|
||||
$note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : ''));
|
||||
$note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : '');
|
||||
|
||||
|
|
@ -2008,16 +2008,11 @@ else
|
|||
// Send
|
||||
if ($object->statut > 0)
|
||||
{
|
||||
$comref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->commande->dir_output . '/'.$comref.'/'.$comref.'.pdf';
|
||||
if (file_exists($file))
|
||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send))
|
||||
{
|
||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send))
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
|
||||
// Ship
|
||||
|
|
@ -2147,7 +2142,33 @@ else
|
|||
if ($action == 'presend')
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
if (! $file || ! is_readable($file))
|
||||
{
|
||||
// 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->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$result=commande_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print_titre($langs->trans('SendOrderByMail'));
|
||||
|
|
@ -2180,10 +2201,10 @@ else
|
|||
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
|
||||
|
||||
// Init list of files
|
||||
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
|
||||
if (GETPOST("mode")=='init')
|
||||
{
|
||||
$formmail->clear_attached_files();
|
||||
$formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf');
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
// Show form
|
||||
|
|
|
|||
|
|
@ -1307,11 +1307,11 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||
|
||||
if ($result > 0)
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
// $ref = dol_sanitizeFileName($object->ref);
|
||||
// $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
|
||||
if (is_readable($file))
|
||||
{
|
||||
// if (is_readable($file))
|
||||
// {
|
||||
if ($_POST['sendto'])
|
||||
{
|
||||
// Le destinataire a ete fourni via le champ libre
|
||||
|
|
@ -1440,13 +1440,13 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
|||
$mesg.='</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').'</div>';
|
||||
dol_syslog('Recipient email is empty');
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3048,10 +3048,12 @@ else
|
|||
}
|
||||
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Construit PDF si non existant
|
||||
if (! is_readable($file))
|
||||
// Build document if it not exists
|
||||
if (! $file || ! is_readable($file))
|
||||
{
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
|
|
@ -3063,12 +3065,15 @@ else
|
|||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$result=facture_pdf_create($db, $object, $_REQUEST['model'], $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||
|
||||
$result=facture_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
|
@ -3102,10 +3107,10 @@ else
|
|||
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
|
||||
|
||||
// Init list of files
|
||||
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
|
||||
if (GETPOST("mode")=='init')
|
||||
{
|
||||
$formmail->clear_attached_files();
|
||||
$formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf');
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
$formmail->show_form();
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class FormMail
|
|||
|
||||
/**
|
||||
* Clear list of attached files in send mail form (stored in session)
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function clear_attached_files()
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
* @param string $types Can be "directories", "files", or "all"
|
||||
* @param int $recursive Determines whether subdirectories are searched
|
||||
* @param string $filter Regex for include filter
|
||||
* @param string $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.')
|
||||
* @param string $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.'))
|
||||
* @param string $sortcriteria Sort criteria ("","fullname","name","date","size")
|
||||
* @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
|
||||
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
|
||||
|
|
@ -1047,4 +1047,18 @@ function dol_compress_file($inputfile, $outputfile, $mode="gz")
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return most recent file
|
||||
*
|
||||
* @param string $dir Directory to scan
|
||||
* @param string $regexfilter Regexfilter
|
||||
* @param string $excludefilter Array of Regex for exclude filter (example: array('\.meta$','^\.'))
|
||||
* @return strnig Full path to most recent file
|
||||
*/
|
||||
function dol_most_recent_file($dir,$regexfilter='',$excludefilter=array('\.meta$','^\.'))
|
||||
{
|
||||
$tmparray=dol_dir_list($dir,'files',0,$regexfilter,$excludefilter,'date',SORT_DESC);
|
||||
return $tmparray[0];
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@
|
|||
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
|
@ -359,11 +359,11 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile'
|
|||
|
||||
if ($result > 0)
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf';
|
||||
// $ref = dol_sanitizeFileName($object->ref);
|
||||
// $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf';
|
||||
|
||||
if (is_readable($file))
|
||||
{
|
||||
// if (is_readable($file))
|
||||
// {
|
||||
if (GETPOST('sendto','alpha'))
|
||||
{
|
||||
// Le destinataire a ete fourni via le champ libre
|
||||
|
|
@ -488,13 +488,13 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile'
|
|||
$action='presend';
|
||||
dol_syslog('Recipient email is empty');
|
||||
}
|
||||
}
|
||||
/* }
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
|
||||
dol_syslog('Failed to read file: '.$file);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1280,16 +1280,11 @@ else
|
|||
// Send
|
||||
if ($object->statut > 0)
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->expedition->dir_output . '/sending/'.$ref.'/'.$ref.'.pdf';
|
||||
if (file_exists($file))
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send)
|
||||
{
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
|
||||
// Create bill and Classify billed
|
||||
|
|
@ -1362,12 +1357,37 @@ else
|
|||
|
||||
/*
|
||||
* Action presend
|
||||
*
|
||||
*/
|
||||
*/
|
||||
if ($action == 'presend')
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf';
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
if (! $file || ! is_readable($file))
|
||||
{
|
||||
// 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->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$result=expedition_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print_titre($langs->trans('SendShippingByEMail'));
|
||||
|
|
@ -1400,10 +1420,10 @@ else
|
|||
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
|
||||
|
||||
// Init list of files
|
||||
if (GETPOST('mode','alpha')=='init')
|
||||
if (GETPOST("mode")=='init')
|
||||
{
|
||||
$formmail->clear_attached_files();
|
||||
$formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf');
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
// Show form
|
||||
|
|
|
|||
|
|
@ -482,11 +482,11 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
|
|||
|
||||
if ($object->fetch($id) > 0)
|
||||
{
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->ficheinter->dir_output . '/' . $objectref . '/' . $objectref . '.pdf';
|
||||
// $objectref = dol_sanitizeFileName($object->ref);
|
||||
// $file = $conf->ficheinter->dir_output . '/' . $objectref . '/' . $objectref . '.pdf';
|
||||
|
||||
if (is_readable($file))
|
||||
{
|
||||
// if (is_readable($file))
|
||||
// {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
if (GETPOST('sendto','alpha'))
|
||||
|
|
@ -610,13 +610,13 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
|
|||
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
|
||||
dol_syslog('Recipient email is empty');
|
||||
}
|
||||
}
|
||||
/* }
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
|
||||
dol_syslog('Failed to read file: '.$file);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1099,16 +1099,11 @@ else if ($id > 0 || ! empty($ref))
|
|||
// Send
|
||||
if ($object->statut > 0)
|
||||
{
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->ficheinter->dir_output . '/'.$objectref.'/'.$objectref.'.pdf';
|
||||
if (file_exists($file))
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send)
|
||||
{
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
|
||||
// Invoicing
|
||||
|
|
@ -1184,7 +1179,33 @@ else if ($id > 0 || ! empty($ref))
|
|||
if ($action == 'presend')
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->ficheinter->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||
$fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
if (! $file || ! is_readable($file))
|
||||
{
|
||||
// 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->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$result=fichinter_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print_titre($langs->trans('SendInterventionByMail'));
|
||||
|
|
@ -1218,10 +1239,10 @@ else if ($id > 0 || ! empty($ref))
|
|||
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
|
||||
|
||||
// Init list of files
|
||||
if (GETPOST('mode','alpha')=='init')
|
||||
if (GETPOST("mode")=='init')
|
||||
{
|
||||
$formmail->clear_attached_files();
|
||||
$formmail->add_attached_files($file,$object->ref.'.pdf','application/pdf');
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
$formmail->show_form();
|
||||
|
|
|
|||
|
|
@ -658,11 +658,11 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
|
|||
|
||||
if ($result > 0)
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->fournisseur->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
// $ref = dol_sanitizeFileName($object->ref);
|
||||
// $file = $conf->fournisseur->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
|
||||
if (is_readable($file))
|
||||
{
|
||||
// if (is_readable($file))
|
||||
// {
|
||||
if ($_POST['sendto'])
|
||||
{
|
||||
// Le destinataire a ete fourni via le champ libre
|
||||
|
|
@ -777,14 +777,14 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
|
|||
$mesg.='</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }
|
||||
else
|
||||
{
|
||||
$langs->load("other");
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
|
||||
$action='presend';
|
||||
dol_syslog('Recipient email is empty');
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1393,12 +1393,7 @@ if ($id > 0 || ! empty($ref))
|
|||
{
|
||||
if ($user->rights->fournisseur->commande->commander)
|
||||
{
|
||||
$comref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->fournisseur->commande->dir_output . '/'.$comref.'/'.$comref.'.pdf';
|
||||
if (file_exists($file))
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1550,7 +1545,33 @@ if ($id > 0 || ! empty($ref))
|
|||
if ($action == 'presend')
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->fournisseur->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
if (! $file || ! is_readable($file))
|
||||
{
|
||||
// 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->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$result=supplier_order_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref);
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print_titre($langs->trans('SendOrderByMail'));
|
||||
|
|
@ -1583,10 +1604,10 @@ if ($id > 0 || ! empty($ref))
|
|||
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
|
||||
|
||||
// Init list of files
|
||||
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
|
||||
if (GETPOST("mode")=='init')
|
||||
{
|
||||
$formmail->clear_attached_files();
|
||||
$formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf');
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
// Show form
|
||||
|
|
|
|||
|
|
@ -629,11 +629,11 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
|
|||
$result=$object->fetch_thirdparty();
|
||||
if ($result > 0)
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref.'/'.$ref.'.pdf';
|
||||
// $ref = dol_sanitizeFileName($object->ref);
|
||||
// $file = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref.'/'.$ref.'.pdf';
|
||||
|
||||
if (is_readable($file))
|
||||
{
|
||||
// if (is_readable($file))
|
||||
// {
|
||||
if ($_POST['sendto'])
|
||||
{
|
||||
// Le destinataire a ete fourni via le champ libre
|
||||
|
|
@ -758,13 +758,13 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
|
|||
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').'</div>';
|
||||
dol_syslog('Recipient email is empty');
|
||||
}
|
||||
}
|
||||
/* }
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
|
||||
dol_syslog('Failed to read file: '.$file);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1792,7 +1792,33 @@ else
|
|||
if ($action == 'presend')
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
$file = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref.'/'.$ref.'.pdf';
|
||||
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref);
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
if (! $file || ! is_readable($file))
|
||||
{
|
||||
// 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->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
$result=supplier_invoice_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, GETPOST('hidedetails'), GETPOST('hidedesc'), GETPOST('hideref'), $hookmanager);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref);
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print_titre($langs->trans('SendBillByMail'));
|
||||
|
|
@ -1825,10 +1851,10 @@ else
|
|||
$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
|
||||
|
||||
// Init list of files
|
||||
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
|
||||
if (GETPOST("mode")=='init')
|
||||
{
|
||||
$formmail->clear_attached_files();
|
||||
$formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf');
|
||||
$formmail->add_attached_files($file,basename($file),dol_mimetype($file));
|
||||
}
|
||||
|
||||
// Show form
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user