Fix: Pb envoie mail sur facture si fichier PDF n'a pas été généré avant

This commit is contained in:
Laurent Destailleur 2006-05-04 22:58:14 +00:00
parent 1bcc4169b2
commit 74af35f9dd
3 changed files with 51 additions and 6 deletions

View File

@ -488,8 +488,8 @@ if ($_POST['action'] == 'send' || $_POST['action'] == 'relance')
$facref = sanitize_string($fac->ref); $facref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf'; $file = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf';
if (is_readable($file)) if (! is_readable($file))
{ {
$soc = new Societe($db, $fac->socidp); $soc = new Societe($db, $fac->socidp);
if ($_POST['sendto']) { if ($_POST['sendto']) {
@ -587,23 +587,29 @@ if ($_POST['action'] == 'send' || $_POST['action'] == 'relance')
} }
else else
{ {
$langs->load("other");
$msg='<div class="error">'.$langs->trans('ErrorFailedToSendMail',$from,$sendto).' !</div>'; $msg='<div class="error">'.$langs->trans('ErrorFailedToSendMail',$from,$sendto).' !</div>';
} }
} }
else else
{ {
$langs->load("other");
$msg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').'</div>'; $msg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').'</div>';
dolibarr_syslog('Le mail du destinataire est vide'); dolibarr_syslog('Recipient email is empty');
} }
} }
else else
{ {
dolibarr_syslog('Impossible de lire :'.$file); $langs->load("other");
$msg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
dolibarr_syslog('Failed to read file: '.$file);
} }
} }
else else
{ {
$langs->load("other");
$msg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'</div>';
dolibarr_syslog('Impossible de lire les données de la facture. Le fichier facture n\'a peut-être pas été généré.'); dolibarr_syslog('Impossible de lire les données de la facture. Le fichier facture n\'a peut-être pas été généré.');
} }
} }
@ -618,6 +624,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
$result=facture_pdf_create($db, $_REQUEST['facid'], '', $_REQUEST['model'], $outputlangs); $result=facture_pdf_create($db, $_REQUEST['facid'], '', $_REQUEST['model'], $outputlangs);
if ($result <= 0) if ($result <= 0)
{ {
dolibarr_print_error($db,$result);
exit; exit;
} }
} }
@ -2137,6 +2144,22 @@ else
*/ */
if ($_GET['action'] == 'presend') if ($_GET['action'] == 'presend')
{ {
$facref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf';
// Construit PDF si non existant
if (! is_readable($file))
{
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs");
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
$result=facture_pdf_create($db, $_REQUEST['facid'], '', $_REQUEST['model'], $outputlangs);
if ($result <= 0)
{
dolibarr_print_error($db,$result);
exit;
}
}
print '<br>'; print '<br>';
print_titre($langs->trans('SendBillByMail')); print_titre($langs->trans('SendBillByMail'));
@ -2172,6 +2195,22 @@ else
if ($_GET['action'] == 'prerelance') if ($_GET['action'] == 'prerelance')
{ {
$facref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf';
// Construit PDF si non existant
if (! is_readable($file))
{
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs");
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
$result=facture_pdf_create($db, $_REQUEST['facid'], '', $_REQUEST['model'], $outputlangs);
if ($result <= 0)
{
dolibarr_print_error($db,$result);
exit;
}
}
print '<br>'; print '<br>';
print_titre($langs->trans('SendReminderBillByMail')); print_titre($langs->trans('SendReminderBillByMail'));

View File

@ -1,11 +1,14 @@
# Dolibarr language file - en_US - other # Dolibarr language file - en_US - other
Calendar=Calendar
ErrorPasswordDiffers=Passwords differs, please type them again. ErrorPasswordDiffers=Passwords differs, please type them again.
ErrorForbidden=Access forbidden.<br>You try to access to a page, area or feature without being in an authenticated session or that is not allowed to your user. ErrorForbidden=Access forbidden.<br>You try to access to a page, area or feature without being in an authenticated session or that is not allowed to your user.
ErrorForbidden2=Permission for this login can be defined by your Dolibarr administrator from menu %s->%s. ErrorForbidden2=Permission for this login can be defined by your Dolibarr administrator from menu %s->%s.
ErrorForbidden3=It seems that Dolibarr is not used through an authenticated session. Take a look at Dolibarr setup documentation to know how to manage authentications (htaccess, mod_auth or other...). ErrorForbidden3=It seems that Dolibarr is not used through an authenticated session. Take a look at Dolibarr setup documentation to know how to manage authentications (htaccess, mod_auth or other...).
ErrorNoImagickReadimage=Function imagick_readimage is not found in this PHP. No preview can be available. ErrorNoImagickReadimage=Function imagick_readimage is not found in this PHP. No preview can be available.
ErrorRecordAlreadyExists=Record already exists ErrorRecordAlreadyExists=Record already exists
ErrorCantReadFile=Failed to read file '%s'
ErrorCantReadDir=Failed to read directory '%s'
ErrorFailedToFindEntity=Failed to read entity '%s'
Calendar=Calendar
AddTrip=Add trip AddTrip=Add trip
Tools=Tools Tools=Tools
Birthday=Birthday Birthday=Birthday

View File

@ -1,11 +1,14 @@
# Dolibarr language file - fr_FR - other # Dolibarr language file - fr_FR - other
Calendar=Calendrier
ErrorPasswordDiffers=Les mots de passe ne sont pas identiques, veuillez les saisir à nouveau ErrorPasswordDiffers=Les mots de passe ne sont pas identiques, veuillez les saisir à nouveau
ErrorForbidden=Accès non autorisé.<br>Vous essayez d'accéder à une page, zone ou fonction sans être au sein d'une session authentifiée ou qui n'est pas autorisée pour votre compte utilisateur. ErrorForbidden=Accès non autorisé.<br>Vous essayez d'accéder à une page, zone ou fonction sans être au sein d'une session authentifiée ou qui n'est pas autorisée pour votre compte utilisateur.
ErrorForbidden2=Les permissions pour ce login peuvent être attribuées par l'administrateur Dolibarr via le menu %s -> %s. ErrorForbidden2=Les permissions pour ce login peuvent être attribuées par l'administrateur Dolibarr via le menu %s -> %s.
ErrorForbidden3=Dolibarr ne semble pas fonctionner au sein d'une session authentifiée. Consultez la documentation d'installation de Dolibarr pour savoir comment gérer les authentifications (htaccess, mod_auth ou autre...). ErrorForbidden3=Dolibarr ne semble pas fonctionner au sein d'une session authentifiée. Consultez la documentation d'installation de Dolibarr pour savoir comment gérer les authentifications (htaccess, mod_auth ou autre...).
ErrorNoImagickReadimage=La fonction imagick_readimage n'est pas présente sur cette installation de PHP. L'aperçu n'est donc pas disponible. ErrorNoImagickReadimage=La fonction imagick_readimage n'est pas présente sur cette installation de PHP. L'aperçu n'est donc pas disponible.
ErrorRecordAlreadyExists=Enregistrement déjà existant ErrorRecordAlreadyExists=Enregistrement déjà existant
ErrorCantReadFile=Echec de lecture du fichier '%s'
ErrorCantReadDir=Echec de lecture du répertoire '%s'
ErrorFailedToFindEntity=Echec de lecture de l'entité '%s'
Calendar=Calendrier
AddTrip=Créer déplacement AddTrip=Créer déplacement
Tools=Outils Tools=Outils
Birthday=Anniversaire Birthday=Anniversaire