diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 68dc1b2aa0b..de8b31f900c 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -51,7 +51,7 @@ $langs->load('propal');
$langs->load('deliveries');
$langs->load('products');
-$id =(GETPOST("id")?GETPOST("id"):GETPOST("orderid"));
+$id = (GETPOST("id")?GETPOST("id"):GETPOST("orderid"));
$ref = GETPOST('ref');
$socid = GETPOST('socid');
$action = GETPOST('action');
@@ -928,8 +928,7 @@ if ($_POST['addfile'])
$mesg=dol_add_file_process($upload_dir,0,0);
- $action ='presend';
- $_POST["action"]='presend';
+ $action ='presend';
}
/*
@@ -945,8 +944,7 @@ if (! empty($_POST['removedfile']))
$mesg=dol_remove_file_process($_POST['removedfile'],0);
- $action ='presend';
- $_POST["action"]='presend';
+ $action ='presend';
}
/*
@@ -1098,8 +1096,8 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
else
{
$langs->load("other");
- $mesg='
'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'
';
- dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.');
+ $mesg=''.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Order")).'
';
+ dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Order")));
}
}
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 2c2f4fd0792..6cf50f2390a 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -141,7 +141,7 @@ class Expedition extends CommonObject
*/
function create($user)
{
- global $conf;
+ global $conf, $langs;
require_once DOL_DOCUMENT_ROOT ."/product/stock/class/mouvementstock.class.php";
$error = 0;
@@ -234,6 +234,13 @@ class Expedition extends CommonObject
if (! $error)
{
+ // Appel des triggers
+ include_once(DOL_DOCUMENT_ROOT."/core/class/interfaces.class.php");
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers('SHIPPING_CREATE',$this,$user,$langs,$conf);
+ if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // Fin appel triggers
+
$this->db->commit();
return $this->id;
}
@@ -745,6 +752,8 @@ class Expedition extends CommonObject
*/
function delete()
{
+ global $conf, $langs, $user;
+
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$this->db->begin();
@@ -789,6 +798,14 @@ class Expedition extends CommonObject
}
}
}
+
+ // Call triggers
+ include_once(DOL_DOCUMENT_ROOT."/core/class/interfaces.class.php");
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers('SHIPPING_DELETE',$this,$user,$langs,$conf);
+ if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // End call triggers
+
// TODO il faut incrementer le stock si on supprime une expedition validee
return 1;
}
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 8ac7b0fb2ff..a4d2ce767e3 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -49,12 +49,8 @@ $langs->load('stocks');
$langs->load('other');
$langs->load('propal');
-
-$action = GETPOST("action");
-$confirm = GETPOST("confirm");
-
-$origin = GETPOST("origin")?GETPOST("origin"):'expedition'; // Example: commande, propal
-$origin_id = GETPOST("id")?GETPOST("id"):'';
+$origin = GETPOST("origin")?GETPOST("origin"):'expedition'; // Example: commande, propal
+$origin_id = GETPOST("id")?GETPOST("id"):'';
if (empty($origin_id)) $origin_id = GETPOST("origin_id"); // Id of order or propal
if (empty($origin_id)) $origin_id = GETPOST("object_id"); // Id of order or propal
$id = $origin_id;
@@ -63,6 +59,9 @@ $id = $origin_id;
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,$origin,$origin_id);
+$action = GETPOST("action");
+$confirm = GETPOST("confirm");
+
$object = new Expedition($db);
/*
@@ -188,7 +187,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expeditio
}
}
-if ($action == 'open' && $user->rights->expedition->valider)
+if ($action == 'reopen' && $user->rights->expedition->valider)
{
$object->fetch($id);
$result = $object->setStatut(0);
@@ -284,6 +283,191 @@ if ($action == 'builddoc') // En get ou en post
}
}
+/*
+ * Add file in email form
+ */
+if ($_POST['addfile'])
+{
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
+
+ // Set tmp user directory TODO Use a dedicated directory for temp mails files
+ $vardir=$conf->user->dir_output."/".$user->id;
+ $upload_dir = $vardir.'/temp/';
+
+ $mesg=dol_add_file_process($upload_dir,0,0);
+
+ $action ='presend';
+}
+
+/*
+ * Remove file in email form
+ */
+if (! empty($_POST['removedfile']))
+{
+ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
+
+ // Set tmp user directory
+ $vardir=$conf->user->dir_output."/".$user->id;
+ $upload_dir = $vardir.'/temp/';
+
+ $mesg=dol_remove_file_process($_POST['removedfile'],0);
+
+ $action ='presend';
+}
+
+/*
+ * Send mail
+ */
+if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
+{
+ $langs->load('mails');
+
+ $result=$object->fetch($id);
+ $result=$object->fetch_thirdparty();
+
+ if ($result > 0)
+ {
+ $ref = dol_sanitizeFileName($object->ref);
+ $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf';
+
+ if (is_readable($file))
+ {
+ if ($_POST['sendto'])
+ {
+ // Le destinataire a ete fourni via le champ libre
+ $sendto = $_POST['sendto'];
+ $sendtoid = 0;
+ }
+ elseif ($_POST['receiver'])
+ {
+ // Le destinataire a ete fourni via la liste deroulante
+ if ($_POST['receiver'] < 0) // Id du tiers
+ {
+ $sendto = $object->client->email;
+ $sendtoid = 0;
+ }
+ else // Id du contact
+ {
+ $sendto = $object->client->contact_get_property($_POST['receiver'],'email');
+ $sendtoid = $_POST['receiver'];
+ }
+ }
+
+ if (dol_strlen($sendto))
+ {
+ $langs->load("commercial");
+
+ $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
+ $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
+ $message = $_POST['message'];
+ $sendtocc = $_POST['sendtocc'];
+ $deliveryreceipt = $_POST['deliveryreceipt'];
+
+ if ($_POST['action'] == 'send')
+ {
+ if (dol_strlen($_POST['subject'])) $subject=$_POST['subject'];
+ else $subject = $langs->transnoentities('Shipping').' '.$object->ref;
+ $actiontypecode='AC_SHIP';
+ $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
+ if ($message)
+ {
+ $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
+ $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
+ $actionmsg.=$message;
+ }
+ $actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
+ }
+
+ // Create form object
+ include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
+ $formmail = new FormMail($db);
+
+ $attachedfiles=$formmail->get_attached_files();
+ $filepath = $attachedfiles['paths'];
+ $filename = $attachedfiles['names'];
+ $mimetype = $attachedfiles['mimes'];
+
+ // Send mail
+ require_once(DOL_DOCUMENT_ROOT.'/lib/CMailFile.class.php');
+ $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
+ if ($mailfile->error)
+ {
+ $mesg=''.$mailfile->error.'
';
+ }
+ else
+ {
+ $result=$mailfile->sendfile();
+ if ($result)
+ {
+ $_SESSION['mesg']=$langs->trans('MailSuccessfulySent',$from,$sendto);
+
+ $error=0;
+
+ // Initialisation donnees
+ $object->sendtoid=$sendtoid;
+ $object->actiontypecode=$actiontypecode;
+ $object->actionmsg = $actionmsg;
+ $object->actionmsg2= $actionmsg2;
+ $object->shippingrowid=$object->id;
+
+ // Appel des triggers
+ include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+ $interface=new Interfaces($db);
+ $result=$interface->run_triggers('SHIPPING_SENTBYMAIL',$object,$user,$langs,$conf);
+ if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // Fin appel triggers
+
+ if ($error)
+ {
+ dol_print_error($db);
+ }
+ else
+ {
+ // Redirect here
+ // This avoid sending mail twice if going out and then back to page
+ Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
+ exit;
+ }
+ }
+ else
+ {
+ $langs->load("other");
+ $mesg='';
+ if ($mailfile->error)
+ {
+ $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
+ $mesg.='
'.$mailfile->error;
+ }
+ else
+ {
+ $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
+ }
+ $mesg.='
';
+ }
+ }
+ }
+ else
+ {
+ $langs->load("other");
+ $mesg=''.$langs->trans('ErrorMailRecipientIsEmpty').' !
';
+ $action='presend';
+ dol_syslog('Recipient email is empty');
+ }
+ }
+ else
+ {
+ $langs->load("other");
+ $mesg=''.$langs->trans('ErrorCantReadFile',$file).'
';
+ dol_syslog('Failed to read file: '.$file);
+ }
+ }
+ else
+ {
+ $langs->load("other");
+ $mesg=''.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Shipping")).'
';
+ dol_syslog($langs->trans('ErrorFailedToReadEntity',$langs->trans("Shipping")));
+ }
+}
/*
* View
@@ -655,6 +839,8 @@ else
{
print ''.$mesg.'
';
}
+
+ dol_htmloutput_mesg();
if (!empty($object->origin))
{
@@ -1039,44 +1225,60 @@ else
{
print '';
}
print "\n";
- print "";
+ print '| ';
/*
* Documents generated
*/
- if ($conf->expedition_bon->enabled)
+ if ($action != 'presend')
{
$objectref = dol_sanitizeFileName($object->ref);
$filedir = $conf->expedition->dir_output . "/sending/" .$objectref;
@@ -1090,21 +1292,77 @@ else
$somethingshown=$formfile->show_documents('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
if ($genallowed && ! $somethingshown) $somethingshown=1;
+
+ print ' | ';
+
+ // List of actions on element
+ /*
+ include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php');
+ $formactions=new FormActions($db);
+ $somethingshown=$formactions->showactions($object,'shipping',$socid);
+ */
+
+ print ' | ';
+ }
+
+ /*
+ * Action presend
+ *
+ */
+ if ($action == 'presend')
+ {
+ $ref = dol_sanitizeFileName($object->ref);
+ $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf';
+
+ print ' ';
+ print_titre($langs->trans('SendShippingByMail'));
+
+ // Cree l'objet formulaire mail
+ include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
+ $formmail = new FormMail($db);
+ $formmail->fromtype = 'user';
+ $formmail->fromid = $user->id;
+ $formmail->fromname = $user->getFullName($langs);
+ $formmail->frommail = $user->email;
+ $formmail->withfrom=1;
+ $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"];
+ $formmail->withtosocid=$soc->id;
+ $formmail->withtocc=1;
+ $formmail->withtoccsocid=0;
+ $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
+ $formmail->withtocccsocid=0;
+ $formmail->withtopic=$langs->trans('SendShippingRef','__SHIPPINGREF__');
+ $formmail->withfile=2;
+ $formmail->withbody=1;
+ $formmail->withdeliveryreceipt=1;
+ $formmail->withcancel=1;
+ // Tableau des substitutions
+ $formmail->substit['__SHIPPINGREF__']=$object->ref;
+ // Tableau des parametres complementaires
+ $formmail->param['action']='send';
+ $formmail->param['models']='shipping_send';
+ $formmail->param['shippingid']=$object->id;
+ $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
+
+ // Init list of files
+ if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
+ {
+ $formmail->clear_attached_files();
+ $formmail->add_attached_files($file,dol_sanitizeFilename($ref.'.pdf'),'application/pdf');
+ }
+
+ // Show form
+ $formmail->show_form();
+
+ print ' ';
}
- print ' | ';
-
- // Rien a droite
-
- print ' |
';
-
- if (!empty($origin) && $object->$origin->id)
+ if ($action != 'presend' && ! empty($origin) && $object->$origin->id)
{
print '
';
//show_list_sending_receive($object->origin,$object->origin_id," AND e.rowid <> ".$object->id);
show_list_sending_receive($object->origin,$object->origin_id);
}
-
}
else
{
diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php
index 376f2d5640f..d5eeecc6873 100644
--- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php
+++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2005-2009 Laurent Destailleur
+ * Copyright (C) 2005-2009 Laurent Destailleur
+ * Copyright (C) 2005-2011 Regis Houssin
*
* 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
@@ -68,12 +69,178 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
}
/**
- * \param pdf Objet PDF
- * \param exp Objet expedition
- * \param showadress 0=non, 1=oui
- * \param outputlang Objet lang cible
+ * \brief Fonction generant le document sur le disque
+ * \param object Objet expedition a generer (ou id si ancienne methode)
+ * \param outputlangs Lang output object
+ * \return int 1=ok, 0=ko
*/
- function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
+ function write_file(&$object, $outputlangs)
+ {
+ global $user,$conf,$langs;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ $object->fetch_thirdparty();
+
+ if (! is_object($outputlangs)) $outputlangs=$langs;
+ // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
+ if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
+
+ $outputlangs->load("main");
+ $outputlangs->load("dict");
+ $outputlangs->load("companies");
+ $outputlangs->load("bills");
+ $outputlangs->load("products");
+ $outputlangs->load("propal");
+ $outputlangs->load("deliveries");
+ $outputlangs->load("sendings");
+
+ if ($conf->expedition->dir_output)
+ {
+ // Definition de $dir et $file
+ if ($object->specimen)
+ {
+ $dir = $conf->expedition->dir_output."/sending";
+ $file = $dir . "/SPECIMEN.pdf";
+ }
+ else
+ {
+ $expref = dol_sanitizeFileName($object->ref);
+ $dir = $conf->expedition->dir_output."/sending/" . $expref;
+ $file = $dir . "/" . $expref . ".pdf";
+ }
+
+ if (! file_exists($dir))
+ {
+ if (create_exdir($dir) < 0)
+ {
+ $this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
+ return 0;
+ }
+ }
+
+ if (file_exists($dir))
+ {
+ $pdf=pdf_getInstance($this->format);
+
+ if (class_exists('TCPDF'))
+ {
+ $pdf->setPrintHeader(false);
+ $pdf->setPrintFooter(false);
+ }
+ $pdf->SetFont(pdf_getPDFFont($outputlangs));
+
+ $pdf->Open();
+ $pagenb=0;
+ $pdf->SetDrawColor(128,128,128);
+
+ $pdf->AliasNbPages();
+
+ $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
+ $pdf->SetSubject($outputlangs->transnoentities("Sending"));
+ $pdf->SetCreator("Dolibarr ".DOL_VERSION);
+ $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
+ $pdf->SetKeyWords($outputlangs->convToOutputCharset($fac->ref)." ".$outputlangs->transnoentities("Sending"));
+ if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
+
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+ $pdf->SetAutoPageBreak(1,0);
+
+ // New page
+ $pdf->AddPage();
+ $pagenb++;
+ $this->_pagehead($pdf, $object, 1, $outputlangs);
+ $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->SetTextColor(0,0,0);
+
+ $tab_top = 95;
+ $height_note = 180;
+ $pdf->Rect($this->marge_gauche, $tab_top-10, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+10);
+ $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note);
+ if ($this->barcode->enabled)
+ {
+ $this->posxdesc=$this->marge_gauche+35;
+ }
+ else
+ {
+ $this->posxdesc=$this->marge_gauche+1;
+ }
+ $this->tableau_top = 85;
+
+ $pdf->SetFont('','', $default_font_size);
+ $curY = $this->tableau_top + 4;
+ $pdf->writeHTMLCell(100, 3, 12, $curY, $outputlangs->trans("Description"), 0, 0);
+ $curY = $this->tableau_top + 4;
+ $pdf->writeHTMLCell(30, 3, 140, $curY, $outputlangs->trans("QtyOrdered"), 0, 0);
+ $curY = $this->tableau_top + 4;
+ $pdf->writeHTMLCell(30, 3, 170, $curY, $outputlangs->trans("QtyToShip"), 0, 0);
+
+ $nexY = $this->tableau_top + 14;
+
+ for ($i = 0 ; $i < sizeof($object->lines) ; $i++)
+ {
+ $curY = $nexY;
+
+ if ($this->barcode->enabled)
+ {
+ $pdf->i25($this->marge_gauche+3, ($curY - 2), "000000".$object->lines[$i]->fk_product, 1, 8);
+ }
+
+ $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
+
+ // Description de la ligne produit
+ //$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs);
+ pdf_writelinedesc($pdf,$object,$i,$outputlangs,150,3,$this->posxdesc,$curY);
+ //$pdf->writeHTMLCell(150, 3, $this->posxdesc, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
+
+ $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
+ $nexY = $pdf->GetY();
+
+ $pdf->SetXY (160, $curY);
+ $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked);
+
+ $pdf->SetXY (186, $curY);
+ $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped);
+
+ $nexY+=2; // Passe espace entre les lignes
+ }
+
+
+ // Pied de page
+ $this->_pagefoot($pdf,$object,$outputlangs);
+ $pdf->AliasNbPages();
+
+ $pdf->Close();
+
+ $pdf->Output($file,'F');
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
+
+ return 1;
+ }
+ else
+ {
+ $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
+ return 0;
+ }
+ }
+ else
+ {
+ $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
+ return 0;
+ }
+ $this->error=$langs->transnoentities("ErrorUnknown");
+ return 0; // Erreur par defaut
+ }
+
+ /**
+ * Show header of document
+ * @param pdf Object PDF
+ * @param object Object commercial proposal
+ * @param showaddress 0=no, 1=yes
+ * @param outputlangs Object lang for output
+ */
+ function _pagehead(&$pdf, $object, $showaddress=1, $outputlangs)
{
global $conf,$langs,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -206,176 +373,116 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->MultiCell(60, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"%d %b %Y",false,$outputlangs,true), 0, 'R');
}
}
-
- }
-
-
- /**
- * \brief Fonction generant le document sur le disque
- * \param object Objet expedition a generer (ou id si ancienne methode)
- * \param outputlangs Lang output object
- * \return int 1=ok, 0=ko
- */
- function write_file(&$object, $outputlangs)
- {
- global $user,$conf,$langs;
- $default_font_size = pdf_getPDFFontSize($outputlangs);
-
- $object->fetch_thirdparty();
-
- if (! is_object($outputlangs)) $outputlangs=$langs;
- // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1';
-
- $outputlangs->load("main");
- $outputlangs->load("dict");
- $outputlangs->load("companies");
- $outputlangs->load("bills");
- $outputlangs->load("products");
- $outputlangs->load("propal");
- $outputlangs->load("deliveries");
- $outputlangs->load("sendings");
-
- if ($conf->expedition->dir_output)
+
+ // Tracking number
+ if (! empty($object->tracking_number))
{
- // Definition de $dir et $file
- if ($object->specimen)
+ $object->GetUrlTrackingStatus($object->tracking_number);
+ if (! empty($object->tracking_url))
{
- $dir = $conf->expedition->dir_output."/sending";
- $file = $dir . "/SPECIMEN.pdf";
+ if ($object->expedition_method_id > 0)
+ {
+ // Get code using getLabelFromKey
+ $code=$outputlangs->getLabelFromKey($this->db,$object->expedition_method_id,'c_shipment_mode','rowid','code');
+ $label=$outputlangs->trans("SendingMethod".strtoupper($code))." :";
+ $pdf->SetFont('','', $default_font_size - 2);
+ $posy=$pdf->GetY()+2;
+ $pdf->writeHTMLCell(60, 4, 140, $posy, $label." ".$object->tracking_url, 0, 1, false, true, 'R');
+ }
+ }
+ }
+
+ if ($showaddress)
+ {
+ // Sender properties
+ $carac_emetteur='';
+ // Add internal contact of proposal if defined
+ $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
+ if (sizeof($arrayidcontact) > 0)
+ {
+ $object->fetch_user($arrayidcontact[0]);
+ $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+ }
+
+ $carac_emetteur .= pdf_build_address($outputlangs,$this->emetteur);
+
+ // Show sender
+ $posx=$this->marge_gauche;
+ $posy=42;
+ $hautcadre=40;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118;
+
+ // Show sender frame
+ $pdf->SetTextColor(0,0,0);
+ $pdf->SetFont('','', $default_font_size - 2);
+ $pdf->SetXY($posx,$posy-5);
+ $pdf->MultiCell(66,5, $outputlangs->transnoentities("Sender").":", 0, 'L');
+ $pdf->SetXY($posx,$posy);
+ $pdf->SetFillColor(230,230,230);
+ $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
+
+ // Show sender name
+ $pdf->SetXY($posx+2,$posy+3);
+ $pdf->SetTextColor(0,0,60);
+ $pdf->SetFont('','B',$default_font_size);
+ $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+
+ // Show sender information
+ $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->SetXY($posx+2,$posy+8);
+ $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
+
+
+ // If CUSTOMER contact defined, we use it
+ $usecontact=false;
+ $arrayidcontact=$object->getIdContact('external','CUSTOMER');
+ if (sizeof($arrayidcontact) > 0)
+ {
+ $usecontact=true;
+ $result=$object->fetch_contact($arrayidcontact[0]);
+ }
+
+ // Recipient name
+ if (! empty($usecontact))
+ {
+ // On peut utiliser le nom de la societe du contact
+ if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname;
+ else $socname = $object->client->nom;
+ $carac_client_name=$outputlangs->convToOutputCharset($socname);
}
else
{
- $expref = dol_sanitizeFileName($object->ref);
- $dir = $conf->expedition->dir_output."/sending/" . $expref;
- $file = $dir . "/" . $expref . ".pdf";
+ $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
}
- if (! file_exists($dir))
- {
- if (create_exdir($dir) < 0)
- {
- $this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
- return 0;
- }
- }
+ $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
- if (file_exists($dir))
- {
- $pdf=pdf_getInstance($this->format);
+ // Show recipient
+ $posy=42;
+ $posx=100;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
- if (class_exists('TCPDF'))
- {
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- }
- $pdf->SetFont(pdf_getPDFFont($outputlangs));
+ // Show recipient frame
+ $pdf->SetTextColor(0,0,0);
+ $pdf->SetFont('','', $default_font_size - 2);
+ $pdf->SetXY($posx,$posy-5);
+ $pdf->MultiCell(80, 4, $outputlangs->transnoentities("Recipient").":", 0, 'L');
+ $pdf->rect($posx, $posy, 100, $hautcadre);
+ $pdf->SetTextColor(0,0,0);
- $pdf->Open();
- $pagenb=0;
- $pdf->SetDrawColor(128,128,128);
+ // Show recipient name
+ $pdf->SetXY($posx+2,$posy+3);
+ $pdf->SetFont('','B', $default_font_size);
+ $pdf->MultiCell(96,4, $carac_client_name, 0, 'L');
- $pdf->AliasNbPages();
-
- $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
- $pdf->SetSubject($outputlangs->transnoentities("Sending"));
- $pdf->SetCreator("Dolibarr ".DOL_VERSION);
- $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
- $pdf->SetKeyWords($outputlangs->convToOutputCharset($fac->ref)." ".$outputlangs->transnoentities("Sending"));
- if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
-
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
- $pdf->SetAutoPageBreak(1,0);
-
- // New page
- $pdf->AddPage();
- $pagenb++;
- $this->_pagehead($pdf, $object, 1, $outputlangs);
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
- $pdf->SetTextColor(0,0,0);
-
- $tab_top = 90;
- $height_note = 180;
- $pdf->Rect($this->marge_gauche, $tab_top-10, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+10);
- $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note);
- if ($this->barcode->enabled)
- {
- $this->posxdesc=$this->marge_gauche+35;
- }
- else
- {
- $this->posxdesc=$this->marge_gauche+1;
- }
- $this->tableau_top = 80;
-
- $pdf->SetFont('','', $default_font_size);
- $curY = $this->tableau_top + 4;
- $pdf->writeHTMLCell(100, 3, 12, $curY, $outputlangs->trans("Description"), 0, 0);
- $curY = $this->tableau_top + 4;
- $pdf->writeHTMLCell(30, 3, 140, $curY, $outputlangs->trans("QtyOrdered"), 0, 0);
- $curY = $this->tableau_top + 4;
- $pdf->writeHTMLCell(30, 3, 170, $curY, $outputlangs->trans("QtyToShip"), 0, 0);
-
- $nexY = $this->tableau_top + 14;
-
- for ($i = 0 ; $i < sizeof($object->lines) ; $i++)
- {
- $curY = $nexY;
-
- if ($this->barcode->enabled)
- {
- $pdf->i25($this->marge_gauche+3, ($curY - 2), "000000".$object->lines[$i]->fk_product, 1, 8);
- }
-
- $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page
-
- // Description de la ligne produit
- //$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs);
- pdf_writelinedesc($pdf,$object,$i,$outputlangs,150,3,$this->posxdesc,$curY);
- //$pdf->writeHTMLCell(150, 3, $this->posxdesc, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
-
- $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
- $nexY = $pdf->GetY();
-
- $pdf->SetXY (160, $curY);
- $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked);
-
- $pdf->SetXY (186, $curY);
- $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped);
-
- $nexY+=2; // Passe espace entre les lignes
- }
-
-
- // Pied de page
- $this->_pagefoot($pdf,$object,$outputlangs);
- $pdf->AliasNbPages();
-
- $pdf->Close();
-
- $pdf->Output($file,'F');
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($file, octdec($conf->global->MAIN_UMASK));
-
- return 1;
- }
- else
- {
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
- return 0;
- }
+ // Show recipient information
+ $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->SetXY($posx+2,$posy+8);
+ $pdf->MultiCell(86,4, $carac_client, 0, 'L');
}
- else
- {
- $this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
- return 0;
- }
- $this->error=$langs->transnoentities("ErrorUnknown");
- return 0; // Erreur par defaut
+
}
-
/**
* \brief Show footer of page
* \param pdf PDF factory
diff --git a/htdocs/includes/modules/modExpedition.class.php b/htdocs/includes/modules/modExpedition.class.php
index 4a6b1813390..546cd800cd5 100644
--- a/htdocs/includes/modules/modExpedition.class.php
+++ b/htdocs/includes/modules/modExpedition.class.php
@@ -143,6 +143,14 @@ class modExpedition extends DolibarrModules
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'valider';
+
+ $r++;
+ $this->rights[$r][0] = 105; // id de la permission
+ $this->rights[$r][1] = 'Envoyer les expeditions aux clients'; // libelle de la permission
+ $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
+ $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
+ $this->rights[$r][4] = 'shipping_advance';
+ $this->rights[$r][5] = 'send';
$r++;
$this->rights[$r][0] = 109;
diff --git a/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN b/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN
index b2b1668dc7a..f6a533a4aed 100644
--- a/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN
+++ b/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN
@@ -456,6 +456,28 @@ class InterfaceDemo
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'TASK_TIMESPENT_DELETE')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
+
+ // Shipping
+ elseif ($action == 'SHIPPING_CREATE')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
+ elseif ($action == 'SHIPPING_MODIFY')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
+ elseif ($action == 'SHIPPING_VALIDATE')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
+ elseif ($action == 'SHIPPING_SENTBYMAIL')
+ {
+ dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ }
+ elseif ($action == 'SHIPPINGL_DELETE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
diff --git a/htdocs/install/mysql/data/llx_c_actioncomm.sql b/htdocs/install/mysql/data/llx_c_actioncomm.sql
index 0f5342cdfb8..dcbaf2faaf4 100644
--- a/htdocs/install/mysql/data/llx_c_actioncomm.sql
+++ b/htdocs/install/mysql/data/llx_c_actioncomm.sql
@@ -3,7 +3,7 @@
-- Copyright (C) 2004-2009 Laurent Destailleur
-- Copyright (C) 2004 Benoit Mortier
-- Copyright (C) 2004 Guillaume Delecourt
--- Copyright (C) 2005-2009 Regis Houssin
+-- Copyright (C) 2005-2011 Regis Houssin
-- Copyright (C) 2007 Patrick Raguin
--
-- This program is free software; you can redistribute it and/or modify
@@ -32,14 +32,15 @@
-- Types action comm
--
-delete from llx_c_actioncomm where id in (1,2,3,4,5,8,9,50);
-insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 1, 'AC_TEL', 'system', 'Phone call' ,NULL, 2);
-insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 2, 'AC_FAX', 'system', 'Send Fax' ,NULL, 3);
-insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 3, 'AC_PROP', 'system', 'Send commercial proposal by email','propal', 10);
-insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 4, 'AC_EMAIL', 'system', 'Send Email' ,NULL, 4);
-insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 5, 'AC_RDV', 'system', 'Rendez-vous' ,NULL, 1);
-insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 8, 'AC_COM', 'system', 'Send customer order by email' ,'order', 8);
-insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 9, 'AC_FAC', 'system', 'Send customer invoice by email' ,'invoice', 6);
-insert into llx_c_actioncomm (id, code, type, libelle, module, position) values (30, 'AC_SUP_ORD', 'system', 'Send supplier order by email' ,'order_supplier', 9);
-insert into llx_c_actioncomm (id, code, type, libelle, module, position) values (31, 'AC_SUP_INV', 'system', 'Send supplier invoice by email' ,'invoice_supplier', 7);
-insert into llx_c_actioncomm (id, code, type, libelle, module, position) values (50, 'AC_OTH', 'system', 'Other' ,NULL, 5);
+delete from llx_c_actioncomm where id in (1,2,3,4,5,8,9,10,30,31,50);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 1, 'AC_TEL', 'system', 'Phone call' ,NULL, 2);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 2, 'AC_FAX', 'system', 'Send Fax' ,NULL, 3);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 3, 'AC_PROP', 'system', 'Send commercial proposal by email' ,'propal', 10);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 4, 'AC_EMAIL', 'system', 'Send Email' ,NULL, 4);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 5, 'AC_RDV', 'system', 'Rendez-vous' ,NULL, 1);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 8, 'AC_COM', 'system', 'Send customer order by email' ,'order', 8);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 9, 'AC_FAC', 'system', 'Send customer invoice by email' ,'invoice', 6);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 10, 'AC_SHIP', 'system', 'Send shipping by email' ,'shipping', 11);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 30, 'AC_SUP_ORD', 'system', 'Send supplier order by email' ,'order_supplier', 9);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values (31, 'AC_SUP_INV', 'system', 'Send supplier invoice by email' ,'invoice_supplier', 7);
+insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 50, 'AC_OTH', 'system', 'Other' ,NULL, 5);
diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql
index 4a4e781fd60..d7f7b95a71e 100755
--- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql
+++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql
@@ -133,6 +133,7 @@ ALTER TABLE llx_livraison ADD COLUMN ref_ext varchar(30) AFTER fk_soc;
ALTER TABLE llx_livraison ADD COLUMN ref_int varchar(30) AFTER ref_ext;
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (4,'LETTREMAX','Lettre Max','Courrier Suivi et Lettre Max',0);
+INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, position) VALUES ( 10, 'AC_SHIP', 'system', 'Send shipping by email' ,'shipping', 11);
--Add Chile data (id pays=67)
-- Regions Chile
diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php
index 3764cf62077..1c42417573c 100644
--- a/htdocs/lib/functions.lib.php
+++ b/htdocs/lib/functions.lib.php
@@ -3674,6 +3674,18 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
$ret='';
$out='';
$divstart=$divend='';
+
+ if (isset($_SESSION['mesg']))
+ {
+ $mesgstring=$_SESSION['mesg'];
+ unset($_SESSION['mesg']);
+ }
+
+ if (isset($_SESSION['mesgarray']))
+ {
+ $mesgarray=$_SESSION['mesgarray'];
+ unset($_SESSION['mesgarray']);
+ }
if (! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! preg_match('//i',$out))
{