Works on possibility to send shipping by mail

Fix: uniformize code
This commit is contained in:
Regis Houssin
2011-06-02 17:20:24 +00:00
parent b58e81d186
commit 857006c456
9 changed files with 631 additions and 207 deletions

View File

@@ -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');
@@ -929,7 +929,6 @@ if ($_POST['addfile'])
$mesg=dol_add_file_process($upload_dir,0,0);
$action ='presend';
$_POST["action"]='presend';
}
/*
@@ -946,7 +945,6 @@ if (! empty($_POST['removedfile']))
$mesg=dol_remove_file_process($_POST['removedfile'],0);
$action ='presend';
$_POST["action"]='presend';
}
/*
@@ -1098,8 +1096,8 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'</div>';
dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.');
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Order")).'</div>';
dol_syslog($langs->trans('ErrorFailedToReadEntity', $langs->trans("Order")));
}
}

View File

@@ -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;
}

View File

@@ -49,10 +49,6 @@ $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"):'';
if (empty($origin_id)) $origin_id = GETPOST("origin_id"); // Id of order or propal
@@ -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='<div class="error">'.$mailfile->error.'</div>';
}
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='<div class="error">';
if ($mailfile->error)
{
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
}
else
{
$mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
}
$mesg.='</div>';
}
}
}
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
$action='presend';
dol_syslog('Recipient email is empty');
}
}
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
dol_syslog('Failed to read file: '.$file);
}
}
else
{
$langs->load("other");
$mesg='<div class="error">'.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Shipping")).'</div>';
dol_syslog($langs->trans('ErrorFailedToReadEntity',$langs->trans("Shipping")));
}
}
/*
* View
@@ -656,6 +840,8 @@ else
print '<div class="error">'.$mesg.'</div>';
}
dol_htmloutput_mesg();
if (!empty($object->origin))
{
$typeobject = $object->origin;
@@ -1039,16 +1225,11 @@ else
{
print '<div class="tabsAction">';
/*if ($object->statut > 0 && $user->rights->expedition->valider)
{
print '<a class="butAction" href="fiche.php?id='.$object->id.'&amp;action=open">'.$langs->trans("Modify").'</a>';
}*/
if ($object->statut == 0 && $num_prod > 0)
{
if ($user->rights->expedition->valider)
{
print '<a class="butAction" href="fiche.php?id='.$object->id.'&amp;action=valid">'.$langs->trans("Validate").'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valid">'.$langs->trans("Validate").'</a>';
}
else
{
@@ -1056,27 +1237,48 @@ else
}
}
// TODO add alternative status
/* if ($object->statut == 1 && $user->rights->expedition->valider)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
}*/
// Send
if ($object->statut == 1)
{
$ref = dol_sanitizeFileName($object->ref);
$file = $conf->expedition->dir_output . '/sending/'.$ref.'/'.$ref.'.pdf';
if (file_exists($file))
{
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->expedition->shipping_advance->send)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendByMail').'</a>';
}
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
}
}
if ($conf->livraison_bon->enabled && $object->statut == 1 && $user->rights->expedition->livraison->creer && empty($object->linkedObjectsIds))
{
print '<a class="butAction" href="fiche.php?id='.$object->id.'&amp;action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>';
}
if ($user->rights->expedition->supprimer)
{
print '<a class="butActionDelete" href="fiche.php?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
print '</div>';
}
print "\n";
print "<table width=\"100%\" cellspacing=2><tr><td width=\"50%\" valign=\"top\">";
print '<table width="100%" cellspacing=2><tr><td width="50%" valign="top">';
/*
* 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 '</td><td valign="top" width="50%">';
// Rien a droite
// 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 '</td></tr></table>';
}
if (!empty($origin) && $object->$origin->id)
/*
* Action presend
*
*/
if ($action == 'presend')
{
$ref = dol_sanitizeFileName($object->ref);
$file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf';
print '<br>';
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 '<br>';
}
if ($action != 'presend' && ! empty($origin) && $object->$origin->id)
{
print '<br>';
//show_list_sending_receive($object->origin,$object->origin_id," AND e.rowid <> ".$object->id);
show_list_sending_receive($object->origin,$object->origin_id);
}
}
else
{

View File

@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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);
@@ -207,175 +374,115 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
}
}
// Tracking number
if (! empty($object->tracking_number))
{
$object->GetUrlTrackingStatus($object->tracking_number);
if (! empty($object->tracking_url))
{
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');
}
}
}
/**
* \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)
if ($showaddress)
{
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)
// Sender properties
$carac_emetteur='';
// Add internal contact of proposal if defined
$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
if (sizeof($arrayidcontact) > 0)
{
// Definition de $dir et $file
if ($object->specimen)
$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)
{
$dir = $conf->expedition->dir_output."/sending";
$file = $dir . "/SPECIMEN.pdf";
$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));
$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
// 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);
$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;
// 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->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);
// Show recipient information
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($posx+2,$posy+8);
$pdf->MultiCell(86,4, $carac_client, 0, 'L');
}
$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
}
/**
* \brief Show footer of page
* \param pdf PDF factory

View File

@@ -144,6 +144,14 @@ class modExpedition extends DolibarrModules
$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;
$this->rights[$r][1] = 'Supprimer les expeditions';

View File

@@ -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);
}

View File

@@ -3,7 +3,7 @@
-- Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
-- Copyright (C) 2004 Guillaume Delecourt <guillaume.delecourt@opensides.be>
-- Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
--
-- 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);
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 ( 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 ( 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);
insert into llx_c_actioncomm (id, code, type, libelle, module, position) values ( 50, 'AC_OTH', 'system', 'Other' ,NULL, 5);

View File

@@ -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

View File

@@ -3675,6 +3675,18 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
$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('/<div class=".*">/i',$out))
{
$divstart='<div class="'.$style.'">';