diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 23a87b900e3..58f1dcff7c5 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -56,24 +56,66 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update') exit; } -// Action envoi test mailing -if ($_POST["action"] == 'send' && ! $_POST["cancel"]) -{ - $filepath = array(); - $mimetype = array(); - $filename = array(); +/* + * Add file + */ +if ($_POST['addfile']) +{ + // Set tmp user directory + $conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id; + $upload_dir = $conf->users->dir_tmp.'/temp/'; + + if (! empty($_FILES['addedfile']['tmp_name'])) + { + if (! is_dir($upload_dir)) create_exdir($upload_dir); + + if (is_dir($upload_dir)) + { + if (dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0) > 0) + { + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); + + include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); + $formmail = new FormMail($db); + $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']); + } + else + { + // Echec transfert (fichier dépassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); + } + } + } + $_GET["action"]='test'; +} + +/* + * Send mail + */ +if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) +{ $email_from = $conf->global->MAIN_MAIL_EMAIL_FROM; $errors_to = $_POST["errorstomail"]; $sendto = $_POST["sendto"]; $subject = $_POST['subject']; $body = $_POST['message']; - if ($_FILES['addedfile']['tmp_name']) + + // Get list of attached files + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=split(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=split(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=split(';',$_SESSION["listofmimes"]); + if (! empty($_FILES['addedfile']['tmp_name'])) { - $filepath[0] = $_FILES['addedfile']['tmp_name']; - $mimetype[0] = $_FILES['addedfile']['type']; - $filename[0] = $_FILES['addedfile']['name']; - } + $listofpaths[] = $_FILES['addedfile']['tmp_name']; + $listofnames[] = $_FILES['addedfile']['name']; + $listofmimes[] = $_FILES['addedfile']['type']; + } if (! $sendto) { @@ -91,7 +133,7 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"]) require_once(DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php"); $mailfile = new CMailFile($subject,$sendto,$email_from,$body, - $filepath,$mimetype,$filename, + $listofpaths,$listofmimes,$listofnames, '', '', 0, $msgishtml,$errors_to); $result=$mailfile->sendfile(); @@ -197,7 +239,7 @@ else { print ''.$langs->trans("DoTestServerAvailability").''; } - print ''.$langs->trans("DoTestSend").''; + print ''.$langs->trans("DoTestSend").''; print ''.$langs->trans("Modify").''; print ''; @@ -224,37 +266,44 @@ else // Affichage formulaire de TEST if ($_GET["action"] == 'test') - { - print '
'; - print_titre($langs->trans("DoTestSend")); - - // Cree l'objet formulaire mail - include_once(DOL_DOCUMENT_ROOT."/html.formmail.class.php"); - $formmail = new FormMail($db); - $formmail->fromname = $conf->global->MAIN_MAIL_EMAIL_FROM; - $formmail->frommail = $conf->global->MAIN_MAIL_EMAIL_FROM; - $formmail->withsubstit=0; - $formmail->withfrom=1; - $formmail->witherrorsto=1; - $formmail->withto=$user->email?$user->email:1; - $formmail->withtocc=1; - $formmail->withtopic=$langs->trans("Test"); - $formmail->withtopicreadonly=0; - $formmail->withfile=1; - $formmail->withbody=$langs->trans("Test"); - $formmail->withbodyreadonly=0; - $formmail->withcancel=1; - // Tableau des substitutions - $formmail->substit=$substitutionarrayfortest; - // Tableau des parametres complementaires du post - $formmail->param["action"]="send"; - $formmail->param["models"]="body"; - $formmail->param["mailid"]=$mil->id; - $formmail->param["returnurl"]=DOL_URL_ROOT."/admin/mails.php"; - - $formmail->show_form(); - - print '
'; + { + print '
'; + print_titre($langs->trans("DoTestSend")); + + // Cree l'objet formulaire mail + include_once(DOL_DOCUMENT_ROOT."/html.formmail.class.php"); + $formmail = new FormMail($db); + $formmail->fromname = $conf->global->MAIN_MAIL_EMAIL_FROM; + $formmail->frommail = $conf->global->MAIN_MAIL_EMAIL_FROM; + $formmail->withsubstit=0; + $formmail->withfrom=1; + $formmail->witherrorsto=1; + $formmail->withto=$user->email?$user->email:1; + $formmail->withtocc=1; + $formmail->withtopic=$langs->trans("Test"); + $formmail->withtopicreadonly=0; + $formmail->withfile=2; + $formmail->withbody=$langs->trans("Test"); + $formmail->withbodyreadonly=0; + $formmail->withcancel=1; + $formmail->withdeliveryreceipt=1; + // Tableau des substitutions + $formmail->substit=$substitutionarrayfortest; + // Tableau des parametres complementaires du post + $formmail->param["action"]="send"; + $formmail->param["models"]="body"; + $formmail->param["mailid"]=$mil->id; + $formmail->param["returnurl"]=DOL_URL_ROOT."/admin/mails.php"; + + // Init list of files + if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + { + $formmail->clear_attached_files(); + } + + $formmail->show_form(); + + print '
'; } } diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 3bc3226283a..a020b0a517c 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -616,6 +616,7 @@ else $formmail->withbody=0; $formmail->withbodyreadonly=1; $formmail->withcancel=1; + $formmail->withdeliveryreceipt=0; // Tableau des substitutions $formmail->substit=$substitutionarrayfortest; // Tableau des paramètres complémentaires du post @@ -624,6 +625,12 @@ else $formmail->param["mailid"]=$mil->id; $formmail->param["returnurl"]=DOL_URL_ROOT."/comm/mailing/fiche.php?id=".$mil->id; + // Init list of files + if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + { + $formmail->clear_attached_files(); + } + $formmail->show_form(); print '
'; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 4ef13e13735..79b01b0ca88 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -292,17 +292,54 @@ if ($_REQUEST['action'] == 'setstatut' && $user->rights->propale->cloturer) { $propal = new Propal($db); $propal->fetch($_GET['propalid']); - // prevent browser refresh from closing proposal several times - if ($propal->statut==1) { - $propal->cloture($user, $_REQUEST['statut'], $_REQUEST['note']); - } + // prevent browser refresh from closing proposal several times + if ($propal->statut==1) + { + $propal->cloture($user, $_REQUEST['statut'], $_REQUEST['note']); + } + } } + + +/* + * Add file + */ +if ($_POST['addfile']) +{ + // Set tmp user directory + $conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id; + $upload_dir = $conf->users->dir_tmp.'/temp/'; + + if (! empty($_FILES['addedfile']['tmp_name'])) + { + if (! is_dir($upload_dir)) create_exdir($upload_dir); + + if (is_dir($upload_dir)) + { + if (dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0) > 0) + { + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); + + include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); + $formmail = new FormMail($db); + $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']); + } + else + { + // Echec transfert (fichier dépassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); + } + } + } + $_GET["action"]='presend'; } /* - * Envoi de la propale par mail + * Send mail */ -if ($_POST['action'] == 'send') +if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) { $langs->load('mails'); @@ -1571,145 +1608,150 @@ if ($_GET['propalid'] > 0) /* * Boutons Actions */ - print '
'; - - if ($_GET['action'] != 'statut' && $_GET['action'] <> 'editline') + if ($_GET['action'] != 'presend') { - - // Valid - if ($propal->statut == 0 && $propal->total_ttc > 0 && $user->rights->propale->valider) + print '
'; + + if ($_GET['action'] != 'statut' && $_GET['action'] <> 'editline') { - print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) + + // Valid + if ($propal->statut == 0 && $propal->total_ttc > 0 && $user->rights->propale->valider) { - $url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=confirm_validate&confirm=yes'; - print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmValidateProp').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'validate\')"'; + print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) + { + $url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=confirm_validate&confirm=yes'; + print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmValidateProp').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'validate\')"'; + } + else + { + print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=validate"'; + } + print '>'.$langs->trans('Validate').''; } - else + + // Edit + if ($propal->statut == 1 && $user->rights->propale->creer) { - print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=validate"'; + print ''.$langs->trans('Modify').''; } - print '>'.$langs->trans('Validate').''; + + // Send + if ($propal->statut == 1 && $user->rights->propale->envoyer) + { + $propref = sanitize_string($propal->ref); + $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; + if (file_exists($file)) + { + print ''.$langs->trans('SendByMail').''; + } + } + + // Close + if ($propal->statut == 1 && $user->rights->propale->cloturer) + { + print ''."\n"; + + print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) + { + print 'href="#" onClick="dialogInfo($(\'confirm_close\').innerHTML)"'."\n"; + } + else + { + print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=statut"'; + } + print '>'.$langs->trans('Close').''; + } + + // Delete + if ($propal->statut == 0 && $user->rights->propale->supprimer) + { + print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) + { + $url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=confirm_delete&confirm=yes'; + print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmDeleteProp').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'delete\')"'; + } + else + { + print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=delete"'; + } + print '>'.$langs->trans('Delete').''; + } + } - - // Edit - if ($propal->statut == 1 && $user->rights->propale->creer) - { - print ''.$langs->trans('Modify').''; - } - - // Send - if ($propal->statut == 1 && $user->rights->propale->envoyer) - { - $propref = sanitize_string($propal->ref); - $file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf'; - if (file_exists($file)) - { - print ''.$langs->trans('SendByMail').''; - } - } - - // Close - if ($propal->statut == 1 && $user->rights->propale->cloturer) - { - print ''."\n"; - - print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) - { - print 'href="#" onClick="dialogInfo($(\'confirm_close\').innerHTML)"'."\n"; - } - else - { - print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=statut"'; - } - print '>'.$langs->trans('Close').''; - } - - // Delete - if ($propal->statut == 0 && $user->rights->propale->supprimer) - { - print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) - { - $url = $_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=confirm_delete&confirm=yes'; - print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmDeleteProp').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'delete\')"'; - } - else - { - print 'href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=delete"'; - } - print '>'.$langs->trans('Delete').''; - } - + + print '
'; + print "
\n"; } - print '
'; - print "
\n"; - - - print '
'; - print ''; // ancre - - - /* - * Documents generes - */ - $filename=sanitize_string($propal->ref); - $filedir=$conf->propal->dir_output . "/" . sanitize_string($propal->ref); - $urlsource=$_SERVER["PHP_SELF"]."?propalid=".$propal->id; - $genallowed=$user->rights->propale->creer; - $delallowed=$user->rights->propale->supprimer; - - $var=true; - - $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf); - - - /* - * Commandes rattachees - */ - if($conf->commande->enabled) + if ($_GET['action'] != 'presend') { - $propal->loadOrders(); - $coms = $propal->commandes; - if (sizeof($coms) > 0) + print '
'; + print ''; // ancre + + + /* + * Documents generes + */ + $filename=sanitize_string($propal->ref); + $filedir=$conf->propal->dir_output . "/" . sanitize_string($propal->ref); + $urlsource=$_SERVER["PHP_SELF"]."?propalid=".$propal->id; + $genallowed=$user->rights->propale->creer; + $delallowed=$user->rights->propale->supprimer; + + $var=true; + + $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf); + + + /* + * Commandes rattachees + */ + if($conf->commande->enabled) { - if ($somethingshown) { print '
'; $somethingshown=1; } - print_titre($langs->trans('RelatedOrders')); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $var=true; - for ($i = 0 ; $i < sizeof($coms) ; $i++) + $propal->loadOrders(); + $coms = $propal->commandes; + if (sizeof($coms) > 0) { - $var=!$var; - print '\n"; - print ''; - print ''; - print ''; - print "\n"; + if ($somethingshown) { print '
'; $somethingshown=1; } + print_titre($langs->trans('RelatedOrders')); + print '
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Price").''.$langs->trans("Status").'
'; - print ''.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."'.dolibarr_print_date($coms[$i]->date,'day').''.price($coms[$i]->total_ttc).''.$coms[$i]->getLibStatut(3).'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=true; + for ($i = 0 ; $i < sizeof($coms) ; $i++) + { + $var=!$var; + print '\n"; + print ''; + print ''; + print ''; + print "\n"; + } + print '
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("Price").''.$langs->trans("Status").'
'; + print ''.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."'.dolibarr_print_date($coms[$i]->date,'day').''.price($coms[$i]->total_ttc).''.$coms[$i]->getLibStatut(3).'
'; } - print '
'; } + + print '
'; + + // List of actions on element + include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($propal,'propal',$socid); + + print '
'; } - - print ''; - - // List of actions on element - include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); - $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($propal,'propal',$socid); - - print ''; - + /* * Action presend @@ -1717,6 +1759,9 @@ if ($_GET['propalid'] > 0) */ if ($_GET['action'] == 'presend') { + $ref = sanitize_string($propal->ref); + $file = $conf->propal->dir_output . '/' . $ref . '/' . $ref . '.pdf'; + print '
'; print_titre($langs->trans('SendPropalByMail')); @@ -1748,6 +1793,13 @@ if ($_GET['propalid'] > 0) $formmail->param['propalid']=$propal->id; $formmail->param['returnurl']=DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; + // Init list of files + if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,$propal->ref.'.pdf','application/pdf'); + } + $formmail->show_form(); print '
'; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 7b2652f8c3b..5dae2e39a19 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -525,7 +525,7 @@ if ($_REQUEST['action'] == 'builddoc') // In get or post // Sauvegarde le dernier modele choisi pour generer un document $commande = new Commande($db, 0, $_REQUEST['id']); - $commande->fetch($_REQUEST['id']); + $result=$commande->fetch($_REQUEST['id']); if ($_REQUEST['model']) { $commande->setDocModel($user, $_REQUEST['model']); @@ -565,17 +565,53 @@ if ($_REQUEST['action'] == 'remove_file') } /* - * Envoi de la commande par mail + * Add file */ -if ($_POST['action'] == 'send') +if ($_POST['addfile']) +{ + // Set tmp user directory + $conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id; + $upload_dir = $conf->users->dir_tmp.'/temp/'; + + if (! empty($_FILES['addedfile']['tmp_name'])) + { + if (! is_dir($upload_dir)) create_exdir($upload_dir); + + if (is_dir($upload_dir)) + { + if (dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0) > 0) + { + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); + + include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); + $formmail = new FormMail($db); + $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']); + } + else + { + // Echec transfert (fichier dépassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); + } + } + } + $_GET["action"]='presend'; +} + +/* + * Send mail + */ +if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['cancel']) { $langs->load('mails'); $commande= new Commande($db); - if ( $commande->fetch($_POST['orderid']) ) + $result=$commande->fetch($_POST['orderid']); + if ($result) { - $orderref = sanitize_string($commande->ref); - $file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf'; + $ref = sanitize_string($commande->ref); + $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; if (is_readable($file)) { @@ -627,19 +663,23 @@ if ($_POST['action'] == 'send') $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); } - $filepath[0] = $file; - $filename[0] = $commande->ref.'.pdf'; - $mimetype[0] = 'application/pdf'; - if ($_FILES['addedfile']['tmp_name']) + // Get list of attached files + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=split(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=split(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=split(';',$_SESSION["listofmimes"]); + if (! empty($_FILES['addedfile']['tmp_name'])) { - $filepath[1] = $_FILES['addedfile']['tmp_name']; - $filename[1] = $_FILES['addedfile']['name']; - $mimetype[1] = $_FILES['addedfile']['type']; + $listofpaths[] = $_FILES['addedfile']['tmp_name']; + $listofnames[] = $_FILES['addedfile']['name']; + $listofmimes[] = $_FILES['addedfile']['type']; } - - // Envoi de la commande + + // Send mail require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php'); - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); + $mailfile = new CMailFile($subject,$sendto,$from,$message,$listofpaths,$listofmimes,$listofnames,$sendtocc,'',$deliveryreceipt); if ($mailfile->error) { $mesg='
'.$mailfile->error.'
'; @@ -699,6 +739,7 @@ if ($_POST['action'] == 'send') { $langs->load("other"); $mesg='
'.$langs->trans('ErrorMailRecipientIsEmpty').' !
'; + $_GET["action"]='presend'; dolibarr_syslog('Recipient email is empty'); } } @@ -1679,207 +1720,213 @@ else print ''; print ''; + /* * Boutons actions */ - if ($user->societe_id == 0 && $_GET['action'] <> 'editline') + if ($_GET['action'] != 'presend') { - print '
'; - - // Valid - if ($commande->statut == 0 && $commande->total_ttc >= 0 && $numlines > 0 && $user->rights->commande->valider) + if ($user->societe_id == 0 && $_GET['action'] <> 'editline') { - print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) - { - // on verifie si la commande est en numerotation provisoire - $ref = substr($commande->ref, 1, 4); - if ($ref == 'PROV') - { - $num = $commande->getNextNumRef($soc); - } - else - { - $num = $commande->ref; - } - $url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_validate&confirm=yes'; - print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmValidateOrder',$num).'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'validate\')"'; - } - else - { - print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=validate"'; - } - print '>'.$langs->trans('Validate').''; - } - - // Edit - if ($commande->statut == 1) - { - if ($user->rights->commande->creer) - { - print ''.$langs->trans('Modify').''; - } - } - - // Send - if ($commande->statut > 0) - { - if ($user->rights->commande->envoyer) - { - $comref = sanitize_string($commande->ref); - $file = $conf->commande->dir_output . '/'.$comref.'/'.$comref.'.pdf'; - if (file_exists($file)) - { - print ''.$langs->trans('SendByMail').''; - } - } - } - - // Ship - if ($commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer - && $commande->getNbOfProductsLines() > 0) - { - - // Chargement des permissions - $error = $user->load_entrepots(); - if (sizeof($user->entrepots) === 1) - { - print ''; - print $langs->trans('ShipProduct').''; - - } - else - { - print ''.$langs->trans('ShipProduct').''; - } - } - - // Cloturer - if ($commande->statut == 1 || $commande->statut == 2) - { - if ($user->rights->commande->cloturer) + print '
'; + + // Valid + if ($commande->statut == 0 && $commande->total_ttc >= 0 && $numlines > 0 && $user->rights->commande->valider) { print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) { - $url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_close&confirm=yes'; - print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmCloseOrder').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'close\')"'; + // on verifie si la commande est en numerotation provisoire + $ref = substr($commande->ref, 1, 4); + if ($ref == 'PROV') + { + $num = $commande->getNextNumRef($soc); + } + else + { + $num = $commande->ref; + } + $url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_validate&confirm=yes'; + print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmValidateOrder',$num).'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'validate\')"'; } else { - print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=close"'; + print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=validate"'; } - print '>'.$langs->trans('Close').''; + print '>'.$langs->trans('Validate').''; } - } - - // Annuler commande - if ($commande->statut == 1) - { - $nb_expedition = $commande->nb_expedition(); - if ($user->rights->commande->annuler && $nb_expedition == 0) + + // Edit + if ($commande->statut == 1) + { + if ($user->rights->commande->creer) + { + print ''.$langs->trans('Modify').''; + } + } + + // Send + if ($commande->statut > 0) + { + if ($user->rights->commande->envoyer) + { + $comref = sanitize_string($commande->ref); + $file = $conf->commande->dir_output . '/'.$comref.'/'.$comref.'.pdf'; + if (file_exists($file)) + { + print ''.$langs->trans('SendByMail').''; + } + } + } + + // Ship + if ($commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer + && $commande->getNbOfProductsLines() > 0) + { + + // Chargement des permissions + $error = $user->load_entrepots(); + if (sizeof($user->entrepots) === 1) + { + print ''; + print $langs->trans('ShipProduct').''; + + } + else + { + print ''.$langs->trans('ShipProduct').''; + } + } + + // Cloturer + if ($commande->statut == 1 || $commande->statut == 2) + { + if ($user->rights->commande->cloturer) + { + print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) + { + $url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_close&confirm=yes'; + print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmCloseOrder').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'close\')"'; + } + else + { + print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=close"'; + } + print '>'.$langs->trans('Close').''; + } + } + + // Annuler commande + if ($commande->statut == 1) + { + $nb_expedition = $commande->nb_expedition(); + if ($user->rights->commande->annuler && $nb_expedition == 0) + { + print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) + { + $url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_cancel&confirm=yes'; + print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmCancelOrder').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'cancel\')"'; + } + else + { + print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=cancel"'; + } + print '>'.$langs->trans('CancelOrder').''; + } + } + + // Supprimer commande + if ($commande->statut == 0 && $user->rights->commande->supprimer) { print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) { - $url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_cancel&confirm=yes'; - print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmCancelOrder').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'cancel\')"'; + $url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_delete&confirm=yes'; + print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmDeleteOrder').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'delete\')"'; } else { - print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=cancel"'; + print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=delete"'; } - print '>'.$langs->trans('CancelOrder').''; + print '>'.$langs->trans('Delete').''; } + + print '
'; } - - // Supprimer commande - if ($commande->statut == 0 && $user->rights->commande->supprimer) - { - print 'use_javascript_ajax && $conf->global->MAIN_CONFIRM_AJAX) - { - $url = $_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=confirm_delete&confirm=yes'; - print 'href="#" onClick="dialogConfirm(\''.$url.'\',\''.$langs->trans('ConfirmDeleteOrder').'\',\''.$langs->trans("Yes").'\',\''.$langs->trans("No").'\',\'delete\')"'; - } - else - { - print 'href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&action=delete"'; - } - print '>'.$langs->trans('Delete').''; - } - - print '
'; + print '
'; } - print '
'; - - print '
'; - print ''; // ancre - - /* - * Documents generes - * - */ - $comref = sanitize_string($commande->ref); - $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; - $relativepath = $comref.'/'.$comref.'.pdf'; - $filedir = $conf->commande->dir_output . '/' . $comref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id; - $genallowed=$user->rights->commande->creer; - $delallowed=$user->rights->commande->supprimer; - - $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); - - /* - * Liste des factures - */ - $sql = 'SELECT f.rowid,f.facnumber, f.total_ttc, '.$db->pdate('f.datef').' as df'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'co_fa as cf'; - $sql .= ' WHERE f.rowid = cf.fk_facture AND cf.fk_commande = '. $commande->id; - - $result = $db->query($sql); - if ($result) + + if ($_GET['action'] != 'presend') { - $num = $db->num_rows($result); - if ($num) + print '
'; + print ''; // ancre + + /* + * Documents generes + * + */ + $comref = sanitize_string($commande->ref); + $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; + $relativepath = $comref.'/'.$comref.'.pdf'; + $filedir = $conf->commande->dir_output . '/' . $comref; + $urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id; + $genallowed=$user->rights->commande->creer; + $delallowed=$user->rights->commande->supprimer; + + $somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); + + /* + * Liste des factures + */ + $sql = 'SELECT f.rowid,f.facnumber, f.total_ttc, '.$db->pdate('f.datef').' as df'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'co_fa as cf'; + $sql .= ' WHERE f.rowid = cf.fk_facture AND cf.fk_commande = '. $commande->id; + + $result = $db->query($sql); + if ($result) { - print '
'; - print_titre($langs->trans('RelatedBills')); - $i = 0; $total = 0; - print ''; - print '"; - print ''; - print ''; - print ''; - - $var=True; - while ($i < $num) + $num = $db->num_rows($result); + if ($num) { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ''; - print ''; - $i++; + print '
'; + print_titre($langs->trans('RelatedBills')); + $i = 0; $total = 0; + print '
'.$langs->trans('Ref')."'.$langs->trans('Date').''.$langs->trans('Price').'
'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->facnumber.''.dolibarr_print_date($objp->df,'day').''.$objp->total_ttc.'
'; + print '"; + print ''; + print ''; + print ''; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ''; + print ''; + print ''; + print ''; + $i++; + } + print '
'.$langs->trans('Ref')."'.$langs->trans('Date').''.$langs->trans('Price').'
'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->facnumber.''.dolibarr_print_date($objp->df,'day').''.$objp->total_ttc.'
'; } - print '
'; } + else + { + dolibarr_print_error($db); + } + print '
'; + + // List of actions on element + include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($commande,'order',$socid); + + print '
'; } - else - { - dolibarr_print_error($db); - } - print ''; - - // List of actions on element - include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); - $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($commande,'order',$socid); - - print ''; - /* @@ -1888,24 +1935,8 @@ else */ if ($_GET['action'] == 'presend') { - $orderref = sanitize_string($commande->ref); - $file = $conf->commande->dir_output . '/' . $orderref . '/' . $orderref . '.pdf'; - - // Construit PDF si non existant - if (! is_readable($file)) - { - if ($_REQUEST['lang_id']) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - $result=commande_pdf_create($db, $_REQUEST['id'], '', $_REQUEST['model'], $outputlangs); - if ($result <= 0) - { - dolibarr_print_error($db,$result); - exit; - } - } + $ref = sanitize_string($commande->ref); + $file = $conf->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf'; print '
'; print_titre($langs->trans('SendOrderByMail')); @@ -1920,7 +1951,7 @@ else } // Cree l'objet formulaire mail - include_once('../html.formmail.class.php'); + include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); $formmail = new FormMail($db); $formmail->fromtype = 'user'; $formmail->fromid = $user->id; @@ -1933,6 +1964,7 @@ else $formmail->withfile=1; $formmail->withbody=1; $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; // Tableau des substitutions $formmail->substit['__ORDERREF__']=$commande->ref; // Tableau des parametres complementaires @@ -1941,8 +1973,16 @@ else $formmail->param['orderid']=$commande->id; $formmail->param['returnurl']=DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id; + // Init list of files + if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,$ref.'.pdf','application/pdf'); + } + + // Show form $formmail->show_form(); - + print '
'; } } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index e5e7a117f76..7e9df565fb2 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -950,17 +950,53 @@ if ($_GET['action'] == 'down' && $user->rights->facture->creer) } /* - * Action envoi de mail + * Add file */ -if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['cancel']) +if ($_POST['addfile']) +{ + // Set tmp user directory + $conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id; + $upload_dir = $conf->users->dir_tmp.'/temp/'; + + if (! empty($_FILES['addedfile']['tmp_name'])) + { + if (! is_dir($upload_dir)) create_exdir($upload_dir); + + if (is_dir($upload_dir)) + { + if (dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'],0) > 0) + { + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); + + include_once(DOL_DOCUMENT_ROOT.'/html.formmail.class.php'); + $formmail = new FormMail($db); + $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']); + } + else + { + // Echec transfert (fichier dépassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); + } + } + } + $_GET["action"]='presend'; +} + +/* + * Send mail + */ +if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['addfile'] && ! $_POST['cancel']) { $langs->load('mails'); $fac = new Facture($db,'',$_POST['facid']); - if ( $fac->fetch($_POST['facid']) ) + $result=$fac->fetch($_POST['facid']); + if ($result) { - $facref = sanitize_string($fac->ref); - $file = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf'; + $ref = sanitize_string($fac->ref); + $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; if (is_readable($file)) { @@ -2684,257 +2720,210 @@ else print "\n"; - /* - * Boutons actions - */ - if ($user->societe_id == 0 && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline') - { - print '
'; - - // Editer une facture déjà validée, sans paiement effectué et pas exporté en compta - if ($fac->statut == 1) + /* + * Boutons actions + */ + if ($_GET['action'] != 'prerelance' && $_GET['action'] != 'presend') + { + if ($user->societe_id == 0 && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline') { - // On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées - $ventilExportCompta = $fac->getVentilExportCompta(); - - if ($conf->global->FACTURE_ENABLE_EDITDELETE && $user->rights->facture->modifier - && ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0)) + print '
'; + + // Editer une facture déjà validée, sans paiement effectué et pas exporté en compta + if ($fac->statut == 1) { - print ''.$langs->trans('Modify').''; - } - } - - // Récurrente - if (! $conf->global->FACTURE_DISABLE_RECUR && $fac->type == 0) - { - if (! $facidnext) - { - print ''.$langs->trans("ChangeIntoRepeatableInvoice").''; - } - } - - // Valider - if ($fac->statut == 0 && $num_lignes > 0 && (($fac->type < 2 && $fac->total_ttc >= 0) || ($fac->type == 2 && $fac->total_ttc <= 0))) - { - if ($user->rights->facture->valider) - { - print ''.$langs->trans('Validate').''; - } - } - - // Envoyer - if (($fac->statut == 1 || $fac->statut == 2) && $user->rights->facture->envoyer) - { - if ($facidnext) - { - print ''.$langs->trans('SendByMail').''; - } - else - { - print ''.$langs->trans('SendByMail').''; - } - } - - // Envoyer une relance - if (($fac->statut == 1 || $fac->statut == 2) && $resteapayer > 0 && $user->rights->facture->envoyer) - { - if ($facidnext) - { - print ''.$langs->trans('SendRemindByMail').''; - } - else - { - print ''.$langs->trans('SendRemindByMail').''; - } - } - - // Emettre paiement - if ($fac->type != 2 && $fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement) - { - if ($facidnext) - { - print ''.$langs->trans('DoPayment').''; - } - else - { - if ($resteapayer == 0) + // On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées + $ventilExportCompta = $fac->getVentilExportCompta(); + + if ($conf->global->FACTURE_ENABLE_EDITDELETE && $user->rights->facture->modifier + && ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0)) { - print ''.$langs->trans('DoPayment').''; - } - else - { - print ''.$langs->trans('DoPayment').''; + print ''.$langs->trans('Modify').''; } } - } - - // Emettre remboursement ou Convertir en reduc - if ($fac->type == 2) - { - if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement) + + // Récurrente + if (! $conf->global->FACTURE_DISABLE_RECUR && $fac->type == 0) { - print ''.$langs->trans('DoPaymentBack').''; + if (! $facidnext) + { + print ''.$langs->trans("ChangeIntoRepeatableInvoice").''; + } } - - if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->creer && $fac->getSommePaiement() == 0) + + // Valider + if ($fac->statut == 0 && $num_lignes > 0 && (($fac->type < 2 && $fac->total_ttc >= 0) || ($fac->type == 2 && $fac->total_ttc <= 0))) { - print ''.$langs->trans('ConvertToReduc').''; + if ($user->rights->facture->valider) + { + print ''.$langs->trans('Validate').''; + } } - } - - // Classer 'payé' - if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement && - (($fac->type != 2 && $resteapayer <= 0) || ($fac->type == 2 && $resteapayer >= 0)) ) - { - print ''.$langs->trans('ClassifyPayed').''; - } - - // Classer 'fermée' (possible si validée et pas encore classée payée) - if ($fac->statut == 1 && $fac->paye == 0 && $resteapayer > 0 - && $user->rights->facture->paiement) - { - if ($totalpaye > 0 || $totalavoir > 0) - { - // If one payment or one credit note was linked to this invoice - print ''.$langs->trans('ClassifyPayedPartially').''; - } - else + + // Envoyer + if (($fac->statut == 1 || $fac->statut == 2) && $user->rights->facture->envoyer) { if ($facidnext) { - print ''.$langs->trans('ClassifyCanceled').''; + print ''.$langs->trans('SendByMail').''; } else { - print ''.$langs->trans('ClassifyCanceled').''; + print ''.$langs->trans('SendByMail').''; } } - } - - // Supprimer - if ($fac->is_erasable() && $user->rights->facture->supprimer && $_GET['action'] != 'delete') - { - if ($facidnext) + + // Envoyer une relance + if (($fac->statut == 1 || $fac->statut == 2) && $resteapayer > 0 && $user->rights->facture->envoyer) { - print ''.$langs->trans('Delete').''; + if ($facidnext) + { + print ''.$langs->trans('SendRemindByMail').''; + } + else + { + print ''.$langs->trans('SendRemindByMail').''; + } } - else + + // Emettre paiement + if ($fac->type != 2 && $fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement) { - print ''.$langs->trans('Delete').''; + if ($facidnext) + { + print ''.$langs->trans('DoPayment').''; + } + else + { + if ($resteapayer == 0) + { + print ''.$langs->trans('DoPayment').''; + } + else + { + print ''.$langs->trans('DoPayment').''; + } + } } - } - - print '
'; - } - - print '
'; - print ''; // ancre - - /* - * Documents générés - */ - $filename=sanitize_string($fac->ref); - $filedir=$conf->facture->dir_output . '/' . sanitize_string($fac->ref); - $urlsource=$_SERVER['PHP_SELF'].'?facid='.$fac->id; - $genallowed=$user->rights->facture->creer; - $delallowed=$user->rights->facture->supprimer; - - $var=true; - - print '
'; - $somethingshown=$formfile->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$fac->modelpdf); - - /* - * Propales rattachées - */ - $sql = 'SELECT '.$db->pdate('p.datep').' as dp, p.total_ht, p.ref, p.ref_client, p.rowid as propalid'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'propal as p'; - $sql .= ", ".MAIN_DB_PREFIX."fa_pr as fp"; - $sql .= " WHERE fp.fk_propal = p.rowid AND fp.fk_facture = ".$fac->id; - - dolibarr_syslog("facture.php: sql=".$sql); - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - if ($num) - { - $i = 0; $total = 0; - if ($somethingshown) print '
'; - $somethingshown=1; - print_titre($langs->trans('RelatedCommercialProposals')); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $var=True; - while ($i < $num) + + // Emettre remboursement ou Convertir en reduc + if ($fac->type == 2) { - $objp = $db->fetch_object($resql); - $var=!$var; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $total = $total + $objp->total_ht; - $i++; + if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement) + { + print ''.$langs->trans('DoPaymentBack').''; + } + + if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->creer && $fac->getSommePaiement() == 0) + { + print ''.$langs->trans('ConvertToReduc').''; + } } - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans('Ref').''.$langs->trans('RefCustomer').''.$langs->trans('Date').''.$langs->trans('AmountHT').'
'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref.''.$objp->ref_client.''.dolibarr_print_date($objp->dp,'day').''.price($objp->total_ht).'
'.$langs->trans('TotalHT').'  '.price($total).'
'; + + // Classer 'payé' + if ($fac->statut == 1 && $fac->paye == 0 && $user->rights->facture->paiement && + (($fac->type != 2 && $resteapayer <= 0) || ($fac->type == 2 && $resteapayer >= 0)) ) + { + print ''.$langs->trans('ClassifyPayed').''; + } + + // Classer 'fermée' (possible si validée et pas encore classée payée) + if ($fac->statut == 1 && $fac->paye == 0 && $resteapayer > 0 + && $user->rights->facture->paiement) + { + if ($totalpaye > 0 || $totalavoir > 0) + { + // If one payment or one credit note was linked to this invoice + print ''.$langs->trans('ClassifyPayedPartially').''; + } + else + { + if ($facidnext) + { + print ''.$langs->trans('ClassifyCanceled').''; + } + else + { + print ''.$langs->trans('ClassifyCanceled').''; + } + } + } + + // Supprimer + if ($fac->is_erasable() && $user->rights->facture->supprimer && $_GET['action'] != 'delete') + { + if ($facidnext) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans('Delete').''; + } + } + + print ''; } } - else + + + if ($_GET['action'] != 'prerelance' && $_GET['action'] != 'presend') { - dolibarr_print_error($db); - } - - /* - * Commandes rattachées - */ - if($conf->commande->enabled) - { - $sql = 'SELECT '.$db->pdate('c.date_commande').' as date_commande, c.total_ht, c.ref, c.ref_client, c.rowid as id'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'co_fa as co_fa WHERE co_fa.fk_commande = c.rowid AND co_fa.fk_facture = '.$fac->id; + print '
'; + print ''; // ancre + + /* + * Documents générés + */ + $filename=sanitize_string($fac->ref); + $filedir=$conf->facture->dir_output . '/' . sanitize_string($fac->ref); + $urlsource=$_SERVER['PHP_SELF'].'?facid='.$fac->id; + $genallowed=$user->rights->facture->creer; + $delallowed=$user->rights->facture->supprimer; + + $var=true; + + print '
'; + $somethingshown=$formfile->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$fac->modelpdf); + + /* + * Propales rattachées + */ + $sql = 'SELECT '.$db->pdate('p.datep').' as dp, p.total_ht, p.ref, p.ref_client, p.rowid as propalid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'propal as p'; + $sql .= ", ".MAIN_DB_PREFIX."fa_pr as fp"; + $sql .= " WHERE fp.fk_propal = p.rowid AND fp.fk_facture = ".$fac->id; + + dolibarr_syslog("facture.php: sql=".$sql); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) { - $langs->load("orders"); - $i = 0; $total = 0; if ($somethingshown) print '
'; $somethingshown=1; - print_titre($langs->trans('RelatedOrders')); + print_titre($langs->trans('RelatedCommercialProposals')); print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - $var=true; + + $var=True; while ($i < $num) { $objp = $db->fetch_object($resql); $var=!$var; - print '\n"; + print ''; + print ''; print ''; - print ''; + print ''; print ''; - print "\n"; + print ''; $total = $total + $objp->total_ht; $i++; } @@ -2950,27 +2939,80 @@ else { dolibarr_print_error($db); } + + /* + * Commandes rattachées + */ + if($conf->commande->enabled) + { + $sql = 'SELECT '.$db->pdate('c.date_commande').' as date_commande, c.total_ht, c.ref, c.ref_client, c.rowid as id'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'co_fa as co_fa WHERE co_fa.fk_commande = c.rowid AND co_fa.fk_facture = '.$fac->id; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num) + { + $langs->load("orders"); + + $i = 0; $total = 0; + if ($somethingshown) print '
'; + $somethingshown=1; + print_titre($langs->trans('RelatedOrders')); + print '
'.$langs->trans('Ref').''.$langs->trans('RefCustomerOrderShort').''.$langs->trans('RefCustomer').''.$langs->trans('Date').''.$langs->trans('AmountHT').'
'; - print ''.img_object($langs->trans('ShowOrder'), 'order').' '.$objp->ref."
'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref.''.$objp->ref_client.''.dolibarr_print_date($objp->date_commande,'day').''.dolibarr_print_date($objp->dp,'day').''.price($objp->total_ht).'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print '\n"; + print ''; + print ''; + print ''; + print "\n"; + $total = $total + $objp->total_ht; + $i++; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans('Ref').''.$langs->trans('RefCustomerOrderShort').''.$langs->trans('Date').''.$langs->trans('AmountHT').'
'; + print ''.img_object($langs->trans('ShowOrder'), 'order').' '.$objp->ref."'.$objp->ref_client.''.dolibarr_print_date($objp->date_commande,'day').''.price($objp->total_ht).'
'.$langs->trans('TotalHT').'  '.price($total).'
'; + } + } + else + { + dolibarr_print_error($db); + } + } + + print '
'; + + print '
'; + + // List of actions on element + include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($fac,'invoice',$socid); + + print '
'; } - print '
'; - - print '
'; - - // List of actions on element - include_once(DOL_DOCUMENT_ROOT.'/html.formactions.class.php'); - $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($fac,'invoice',$socid); - - print '
'; - - /* * Affiche formulaire mail */ if ($_GET['action'] == 'presend') { - $facref = sanitize_string($fac->ref); - $file = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf'; + $ref = sanitize_string($fac->ref); + $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; // Construit PDF si non existant if (! is_readable($file)) @@ -3021,6 +3063,13 @@ else $formmail->param['facid']=$fac->id; $formmail->param['returnurl']=DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id; + // Init list of files + if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,$ref.'.pdf','application/pdf'); + } + $formmail->show_form(); print '
'; @@ -3028,8 +3077,8 @@ else if ($_GET['action'] == 'prerelance') { - $facref = sanitize_string($fac->ref); - $file = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf'; + $ref = sanitize_string($fac->ref); + $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf'; // Construit PDF si non existant if (! is_readable($file)) @@ -3068,6 +3117,7 @@ else $formmail->withfile=1; $formmail->withbody=1; $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; // Tableau des substitutions $formmail->substit['__FACREF__']=$fac->ref; // Tableau des paramètres complémentaires @@ -3076,6 +3126,13 @@ else $formmail->param['facid']=$fac->id; $formmail->param['returnurl']=DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id; + // Init list of files + if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,$ref.'.pdf','application/pdf'); + } + $formmail->show_form(); print '
'; diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index 8b0b5c6b720..a0f68f3ba5f 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -141,7 +141,7 @@ class Conf * Autres parametres globaux de configurations */ $this->users->dir_output=DOL_DATA_ROOT."/users"; - + /* * Autorisation globale d'uploader (necessaire pour desactiver dans la demo) * conf->upload peut etre ecrasee dans main.inc.php (selon user) diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php index 819af96fbdc..108440f7ff1 100644 --- a/htdocs/html.formfile.class.php +++ b/htdocs/html.formfile.class.php @@ -436,69 +436,6 @@ class FormFile } - /** - * \brief Show list of documents in a directory - * \param upload_dir Dir to scan - * \param object Object on which document is linked to - * \param modulepart Value for modulepart used by download wrapper - * \return int <0 if KO, nb of files shown if OK - */ - function list_of_documents2($upload_dir,$object,$modulepart) - { - global $user, $conf, $langs; - global $bc; - - // List of documents - $errorlevel=error_reporting(); - error_reporting(0); - $handle=opendir($upload_dir); - error_reporting($errorlevel); - - // Affiche liste des documents existant - print_titre($langs->trans("AttachedFiles")); - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $var=true; - - if ($handle) - { - while (($file = readdir($handle))!==false) - { - if (!is_dir($dir.$file) - && $file != '.' - && $file != '..' - && $file != 'CVS' - && ! eregi('\.meta$',$file) - ) - { - // Define relative path used to store the file - $morepath=$object->ref.'/'; - if ($modulepart == 'facture_fournisseur') $morepath=get_exdir($object->id,2).$morepath; - - $var=!$var; - print ''; - print '\n"; - print ''; - print ''; - print '\n"; - } - } - closedir($handle); - } - print '
'.$langs->trans('Document').''.$langs->trans('Size').''.$langs->trans('Date').' 
'; - print img_mime($file).' '; - print ''.$file.''; - print "'.filesize($upload_dir.'/'.$file). ' '.$langs->trans('bytes').''.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').''; - print ''.img_delete($langs->trans('Delete')).''; - print "
'; - } } ?> diff --git a/htdocs/html.formmail.class.php b/htdocs/html.formmail.class.php index 96b9de2e0b1..aa8ec32665c 100644 --- a/htdocs/html.formmail.class.php +++ b/htdocs/html.formmail.class.php @@ -32,7 +32,6 @@ require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"); \remarks $formmail->proprietes=1 ou chaine ou tableau de valeurs \remarks $formmail->show_form() affiche le formulaire */ - class FormMail { var $db; @@ -49,7 +48,7 @@ class FormMail var $withto; var $withtocc; var $withtopic; - var $withfile; + var $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files var $withbody; var $withfromreadonly; @@ -95,9 +94,51 @@ class FormMail return 1; } + /** + * Clear list of attached files (store in SECTION array) + */ + function clear_attached_files() + { + global $conf,$user; + + $conf->users->dir_tmp=DOL_DATA_ROOT."/users/".$user->id; + $upload_dir = $conf->users->dir_tmp.'/temp'; + if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir); + + unset($_SESSION["listofpaths"]); + unset($_SESSION["listofnames"]); + unset($_SESSION["listofmimes"]); + } + + /** + * Add a file into the list of attached files (stored in SECTION array) + * + * @param unknown_type $path + * @param unknown_type $file + * @param unknown_type $type + */ + function add_attached_files($path,$file,$type) + { + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=split(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=split(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=split(';',$_SESSION["listofmimes"]); + if (! in_array($file,$listofnames)) + { + $listofpaths[]=$path; + $listofnames[]=$file; + $listofmimes[]=$type; + $_SESSION["listofpaths"]=join(';',$listofpaths); + $_SESSION["listofnames"]=join(';',$listofnames); + $_SESSION["listofmimes"]=join(';',$listofmimes); + } + } - /* - * \brief Affiche la partie de formulaire pour saisie d'un mail en fonction des propriétés + /** + * \brief Affiche la partie de formulaire pour saisie d'un mail en fonction des propriétés + * \remarks this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files */ function show_form() { @@ -106,6 +147,15 @@ class FormMail $langs->load("other"); $langs->load("mails"); + // Define list of attached files + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + if (! empty($_SESSION["listofpaths"])) $listofpaths=split(';',$_SESSION["listofpaths"]); + if (! empty($_SESSION["listofnames"])) $listofnames=split(';',$_SESSION["listofnames"]); + if (! empty($_SESSION["listofmimes"])) $listofmimes=split(';',$_SESSION["listofmimes"]); + + $form=new Form($DB); print "\n\n"; @@ -294,13 +344,32 @@ class FormMail print "\n"; } - // Si fichier joint + // Attached files if ($this->withfile) { print ""; - print "".$langs->trans("MailFile").""; + print ''.$langs->trans("MailFile").""; print ""; - print "trans("Upload")."\"/>"; + //print '
'; + if (sizeof($listofpaths)) + { + foreach($listofpaths as $key => $val) + { + print img_mime($listofnames[$key]).' '.$listofnames[$key].'
'; + } + } + else + { + print $langs->trans("NoAttachedFiles").'
'; + } + if ($this->withfile == 2) // Can add other files + { + //print '
'; + print "trans("Upload")."\"/>"; + print ' '; + print ''; + //print '
'; + } print "\n"; } diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index cc166adcfcf..43d1a7bcf6d 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -16,7 +16,7 @@ MailCC=Copy to MailCCC=Cached copy to MailTopic=EMail topic MailText=Message -MailFile=Attach a file +MailFile=Attached files MailMessage=EMail body ListOfEMailings=List of emailings NewMailing=New emailing @@ -54,6 +54,8 @@ RemoveRecipient=Remove recipient CommonSubstitutions=Common substitutions YouCanAddYourOwnPredefindedListHere=To create your email selector module, see htdocs/includes/modules/mailings/README. EMailTestSubstitutionReplacedByGenericValues=When using test mode, substitutions variables are replaced by generic values +MailingAddFile=Attach this file +NoAttachedFiles=No attached files # Libelle des modules de liste de destinataires mailing MailingModuleDescContactCompanies=Unique contacts of all third parties diff --git a/htdocs/langs/es_ES/mails.lang b/htdocs/langs/es_ES/mails.lang index 6b75d700f0b..189814b844f 100644 --- a/htdocs/langs/es_ES/mails.lang +++ b/htdocs/langs/es_ES/mails.lang @@ -1,90 +1,90 @@ -# Dolibarr language file - es_ES - mails -Mailing=Mailing -EMailing=Mailing -Mailings=Mailings -EMailings=Mailings -MailCard=Ficha mailing -MailTargets=Destinatarios -MailRecipients=Dsetinatarios -MailRecipient=Destinatario -MailTitle=Titulo -MailFrom=Remitente -MailErrorsTo=Errores a -MailReply=Responder a -MailTo=Destinatario(s) -MailCC=Copia a -MailTopic=Asunto del e-mail -MailText=Mensaje -MailFile=Adjuntar un archivo -MailMessage=Mensaje del e-mail -ListOfEMailings=Listado de mailings -NewMailing=Nuevo mailing -EditMailing=Editar mailing -DeleteMailing=Eliminar mailing -DeleteAMailing=Eliminar un mailing -PreviewMailing=Previsualizar un mailing -PrepareMailing=Preparar mailing -CreateMailing=Crear mailing -MailingDesc=Esta página le permite enviar e-mails a un grupo de personas. -MailingResult=Resultado del envío de e-mails -TestMailing=Probar mailing -ValidMailing=Validar mailing -ApproveMailing=Aprobar mailing -MailingStatusDraft=Borrador -MailingStatusValidated=Validado -MailingStatusApproved=Aprovado -MailingStatusSent=Enviado -MailingStatusSentPartialy=Enviado parcialmente -MailingStatusSentCompletely=Enviado completamente -MailingStatusError=Error -MailingStatusNotSent=No enviado -MailSuccessfulySent=E-mail enviado correctamente (de %s a %s) -ErrorMailRecipientIsEmpty=La dirección del destinatario está vacía -WarningNoEMailsAdded=Ningún nuevo e-mail a añadir a la lista destinatarios. -ConfirmValidMailing=¿Confirma la validación del mailing? -ConfirmDeleteMailing=¿Confirma la eliminación del mailing? -NbOfRecipients=Número de destinatarios -NbOfUniqueEMails=Nº de e-mails únicos -NbOfEMails=Nº de E-mails -TotalNbOfDistinctRecipients=Número de destinatarios únicos -NoTargetYet=Ningún destinatario definido -AddRecipients=Añadir destinatarios -RemoveRecipient=Eliminar destinatario -CommonSubstitutions=Substituciones comunes -YouCanAddYourOwnPredefindedListHere=Para crear su módulo de selección e-mails, vea htdocs/includes/modules/mailings/README. -EMailTestSubstitutionReplacedByGenericValues=En modo prueba, las variables de sustitución son sustituidas por valores genéricos - -# Libelle des modules de liste de destinataires mailing - -MailingModuleDescContactCompanies=Contactos de terceros (clientes potenciales, clientes, proveedores...) -MailingModuleDescDolibarrUsers=Usuarios de Dolibarr que tienen e-mail -MailingModuleDescFundationMembers=Miembros que tienen e-mail - - -RecipientSelectionModules=Módulos de selección de los destinatarios -MailSelectedRecipients=Destinatarios seleccionados -MailingArea=Area mailings -LastMailings=Los %s últimos mailings -TargetsStatistics=Estadísticas destinatarios -NbOfCompaniesContacts=Contactos únicos de empresas -MailNoChangePossible=Destinatarios de un mailing validado no modificables -SearchAMailing=Buscar un mailing -SendMailing=Enviar mailing -SendMail=Enviar e-mail -SentBy=Enviado por -MailingNeedCommand=Por razones de seguridad, el envío de un mailing en masa puede realizarse en línea de comandos. Pida a su administrador que lance el comando siguiente para para enviar la correspondencia a a todos los destinatarios: -TargetsReset=Vaciar lista -ToClearAllRecipientsClickHere=Para vaciar la lista de los destinatarios de este mailing, haga click en el botón -ToAddRecipientsChooseHere=Para añadir destinatarios, escoja los que figuran en las listas a continuación -NbOfEMailingsReceived=Mailings en masa recibidos -IdRecord=ID registro -DeliveryReceipt=Acuso de recibo - -# Module Notifications - -Notifications=Notificaciones -NoNotificationsWillBeSent=Ninguna notificación por e-mail está prevista para este evento y empresa -ANotificationsWillBeSent=1 notificación va a ser enviada por e-mail -SomeNotificationsWillBeSent=%s notificaciones van a ser enviadas por e-mail -AddNewNotification=Activar una nueva solicitud de notificación -ListOfActiveNotifications=Lista de las solicitudes de notificaciones activas +# Dolibarr language file - es_ES - mails +Mailing=Mailing +EMailing=Mailing +Mailings=Mailings +EMailings=Mailings +MailCard=Ficha mailing +MailTargets=Destinatarios +MailRecipients=Dsetinatarios +MailRecipient=Destinatario +MailTitle=Titulo +MailFrom=Remitente +MailErrorsTo=Errores a +MailReply=Responder a +MailTo=Destinatario(s) +MailCC=Copia a +MailTopic=Asunto del e-mail +MailText=Mensaje +MailFile=Archivo +MailMessage=Mensaje del e-mail +ListOfEMailings=Listado de mailings +NewMailing=Nuevo mailing +EditMailing=Editar mailing +DeleteMailing=Eliminar mailing +DeleteAMailing=Eliminar un mailing +PreviewMailing=Previsualizar un mailing +PrepareMailing=Preparar mailing +CreateMailing=Crear mailing +MailingDesc=Esta página le permite enviar e-mails a un grupo de personas. +MailingResult=Resultado del envío de e-mails +TestMailing=Probar mailing +ValidMailing=Validar mailing +ApproveMailing=Aprobar mailing +MailingStatusDraft=Borrador +MailingStatusValidated=Validado +MailingStatusApproved=Aprovado +MailingStatusSent=Enviado +MailingStatusSentPartialy=Enviado parcialmente +MailingStatusSentCompletely=Enviado completamente +MailingStatusError=Error +MailingStatusNotSent=No enviado +MailSuccessfulySent=E-mail enviado correctamente (de %s a %s) +ErrorMailRecipientIsEmpty=La dirección del destinatario está vacía +WarningNoEMailsAdded=Ningún nuevo e-mail a añadir a la lista destinatarios. +ConfirmValidMailing=¿Confirma la validación del mailing? +ConfirmDeleteMailing=¿Confirma la eliminación del mailing? +NbOfRecipients=Número de destinatarios +NbOfUniqueEMails=Nº de e-mails únicos +NbOfEMails=Nº de E-mails +TotalNbOfDistinctRecipients=Número de destinatarios únicos +NoTargetYet=Ningún destinatario definido +AddRecipients=Añadir destinatarios +RemoveRecipient=Eliminar destinatario +CommonSubstitutions=Substituciones comunes +YouCanAddYourOwnPredefindedListHere=Para crear su módulo de selección e-mails, vea htdocs/includes/modules/mailings/README. +EMailTestSubstitutionReplacedByGenericValues=En modo prueba, las variables de sustitución son sustituidas por valores genéricos + +# Libelle des modules de liste de destinataires mailing + +MailingModuleDescContactCompanies=Contactos de terceros (clientes potenciales, clientes, proveedores...) +MailingModuleDescDolibarrUsers=Usuarios de Dolibarr que tienen e-mail +MailingModuleDescFundationMembers=Miembros que tienen e-mail + + +RecipientSelectionModules=Módulos de selección de los destinatarios +MailSelectedRecipients=Destinatarios seleccionados +MailingArea=Area mailings +LastMailings=Los %s últimos mailings +TargetsStatistics=Estadísticas destinatarios +NbOfCompaniesContacts=Contactos únicos de empresas +MailNoChangePossible=Destinatarios de un mailing validado no modificables +SearchAMailing=Buscar un mailing +SendMailing=Enviar mailing +SendMail=Enviar e-mail +SentBy=Enviado por +MailingNeedCommand=Por razones de seguridad, el envío de un mailing en masa puede realizarse en línea de comandos. Pida a su administrador que lance el comando siguiente para para enviar la correspondencia a a todos los destinatarios: +TargetsReset=Vaciar lista +ToClearAllRecipientsClickHere=Para vaciar la lista de los destinatarios de este mailing, haga click en el botón +ToAddRecipientsChooseHere=Para añadir destinatarios, escoja los que figuran en las listas a continuación +NbOfEMailingsReceived=Mailings en masa recibidos +IdRecord=ID registro +DeliveryReceipt=Acuso de recibo + +# Module Notifications + +Notifications=Notificaciones +NoNotificationsWillBeSent=Ninguna notificación por e-mail está prevista para este evento y empresa +ANotificationsWillBeSent=1 notificación va a ser enviada por e-mail +SomeNotificationsWillBeSent=%s notificaciones van a ser enviadas por e-mail +AddNewNotification=Activar una nueva solicitud de notificación +ListOfActiveNotifications=Lista de las solicitudes de notificaciones activas diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 63f7d132e3a..be3bce2990a 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -16,7 +16,7 @@ MailCC=Copie MailCCC=Copie cachée à MailTopic=Sujet du mail MailText=Message -MailFile=Joindre un fichier +MailFile=Fichiers joints MailMessage=Message du mail ListOfEMailings=Liste des mailings NewMailing=Nouveau mailing @@ -54,6 +54,8 @@ RemoveRecipient=Supprime destinataire CommonSubstitutions=Substitutions communes YouCanAddYourOwnPredefindedListHere=Pour créer votre module sélection mails, voir htdocs/includes/modules/mailings/README. EMailTestSubstitutionReplacedByGenericValues=En mode test, les variables de substitution sont remplacées par des valeurs génériques +MailingAddFile=Joindre ce fichier +NoAttachedFiles=Aucun fichier joint # Libelle des modules de liste de destinataires mailing MailingModuleDescContactCompanies=Contacts des tiers (prospects, clients, fournisseurs...) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 54712857a84..4d4c0ef674a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -404,10 +404,11 @@ if ($user->admin) $user->rights->user->self->password=1; } -/** +/* * Overwrite configs global par configs perso * ------------------------------------------ */ +// Set liste_limite if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) // Can be 0 { $conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT; diff --git a/htdocs/telephonie/client/facture.php b/htdocs/telephonie/client/facture.php index f135002bfeb..ad109f64e7e 100644 --- a/htdocs/telephonie/client/facture.php +++ b/htdocs/telephonie/client/facture.php @@ -474,14 +474,14 @@ if ($_GET["facid"] > 0) // Envoyer if ($fac->statut == 1 && $user->rights->facture->envoyer) { - print " id&action=presend\">".$langs->trans("Send")."\n"; + print " id&action=presend&mode=init\">".$langs->trans("Send")."\n"; } // Envoyer une relance /* if ($fac->statut == 1 && price($resteapayer) > 0 && $user->rights->facture->envoyer) { - print " id&action=prerelance\">".$langs->trans("SendRemind")."\n"; + print " id&action=prerelance&mode=init\">".$langs->trans("SendRemind")."\n"; } */ @@ -665,6 +665,12 @@ if ($_GET["facid"] > 0) $formmail->param["facid"]=$fac->id; $formmail->param["returnurl"]=DOL_URL_ROOT."/telephonie/client/facture.php?facid=$fac->id"; + // Init list of files + if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + { + $formmail->clear_attached_files(); + } + $formmail->show_form(); print '
'; @@ -700,7 +706,13 @@ if ($_GET["facid"] > 0) $formmail->param["facid"]=$fac->id; $formmail->param["returnurl"]=DOL_URL_ROOT."/compta/facture.php?facid=$fac->id"; - $formmail->show_form(); + // Init list of files + if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init') + { + $formmail->clear_attached_files(); + } + + $formmail->show_form(); print '
'; }