New: Add ref to linked objects on PDF

This commit is contained in:
Laurent Destailleur 2009-06-04 20:29:45 +00:00
parent bdd943d6e8
commit 01af1c5bf8
8 changed files with 216 additions and 102 deletions

View File

@ -822,8 +822,8 @@ class CommonObject
// Links beetween objects are stored in this table // Links beetween objects are stored in this table
$sql = 'SELECT sourceid, sourcetype, targetid, targettype'; $sql = 'SELECT sourceid, sourcetype, targetid, targettype';
$sql.= ' FROM '.MAIN_DB_PREFIX.'element_element'; $sql.= ' FROM '.MAIN_DB_PREFIX.'element_element';
$sql.= " WHERE (source_id = '.$this->id.' AND source_type = 'invoice')"; $sql.= " WHERE (sourceid = '".$this->id."' AND sourcetype = 'invoice')";
$sql.= " OR (target_id = '.$this->id.' AND target_id = 'invoice')"; $sql.= " OR (targetid = '".$this->id."' AND targetid = 'invoice')";
dol_syslog("CommonObject::load_object_linked sql=".$sql); dol_syslog("CommonObject::load_object_linked sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -844,6 +844,10 @@ class CommonObject
$i++; $i++;
} }
} }
else
{
dol_print_error($this->db);
}
// For backward compatibility, read other old link tables co_fa (will be moved later) // For backward compatibility, read other old link tables co_fa (will be moved later)
@ -912,6 +916,28 @@ class CommonObject
} }
} }
} }
// For backward compatibility, read other old link tables co_exp (will be moved later)
if ($this->element == 'commande' || $this->element == 'expedition')
{
if ($this->element == 'commande') $sql = "SELECT fk_expedition as sourceid";
if ($this->element == 'expedition') $sql = "SELECT fk_commande as sourceid";
$sql.= ' FROM '.MAIN_DB_PREFIX.'co_exp';
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
dol_syslog("CommonObject::load_object_linked sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($this->element == 'commande') $this->linked_object[]=array('linkid'=>$obj->sourceid, 'type'=>'sending');
if ($this->element == 'expedition') $this->linked_object[]=array('linkid'=>$obj->sourceid, 'type'=>'order');
$i++;
}
}
}
} }
} }

View File

@ -39,6 +39,7 @@ class Expedition extends CommonObject
var $db; var $db;
var $error; var $error;
var $element="expedition"; var $element="expedition";
var $fk_element="fk_expedition";
var $table_element="expedition"; var $table_element="expedition";
var $id; var $id;

View File

@ -74,7 +74,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
* \param outputlangs Lang output object * \param outputlangs Lang output object
* \return int 1=ok, 0=ko * \return int 1=ok, 0=ko
*/ */
function write_file(&$obj, $outputlangs) function write_file(&$object, $outputlangs)
{ {
global $user,$conf,$langs; global $user,$conf,$langs;
@ -93,14 +93,14 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$outputlangs->setPhpLang(); $outputlangs->setPhpLang();
//Generation de la fiche //Generation de la fiche
$this->expe = $obj; $this->expe = $object;
//Verification de la configuration //Verification de la configuration
if ($conf->expedition_bon->dir_output) if ($conf->expedition_bon->dir_output)
{ {
//Creation du Client //Creation du Client
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->fetch($this->expe->commande->socid); $soc->fetch($object->commande->socid);
//Creation de l expediteur //Creation de l expediteur
$this->expediteur = $mysoc; $this->expediteur = $mysoc;
@ -109,24 +109,24 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$this->destinataire = new Contact($this->db); $this->destinataire = new Contact($this->db);
// $pdf->expe->commande->fetch($pdf->commande->id); // $pdf->expe->commande->fetch($pdf->commande->id);
//print_r($pdf->expe); //print_r($pdf->expe);
$idcontact = $this->expe->commande->getIdContact('external','SHIPPING'); $idcontact = $object->commande->getIdContact('external','SHIPPING');
$this->destinataire->fetch($idcontact[0]); $this->destinataire->fetch($idcontact[0]);
//Creation du livreur //Creation du livreur
$idcontact = $this->expe->commande->getIdContact('internal','LIVREUR'); $idcontact = $object->commande->getIdContact('internal','LIVREUR');
$this->livreur = new User($this->db,$idcontact[0]); $this->livreur = new User($this->db,$idcontact[0]);
if ($idcontact[0]) $this->livreur->fetch(); if ($idcontact[0]) $this->livreur->fetch();
// Definition de $dir et $file // Definition de $dir et $file
if ($this->expe->specimen) if ($object->specimen)
{ {
$dir = $conf->expedition_bon->dir_output; $dir = $conf->expedition_bon->dir_output;
$file = $dir . "/SPECIMEN.pdf"; $file = $dir . "/SPECIMEN.pdf";
} }
else else
{ {
$expref = dol_sanitizeFileName($this->expe->ref); $expref = dol_sanitizeFileName($object->ref);
$dir = $conf->expedition_bon->dir_output . "/" . $expref; $dir = $conf->expedition_bon->dir_output . "/" . $expref;
$file = $dir . "/" . $expref . ".pdf"; $file = $dir . "/" . $expref . ".pdf";
} }
@ -160,11 +160,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
//Generation de l entete du fichier //Generation de l entete du fichier
$pdf->SetTitle($outputlangs->convToOutputCharset($this->expe->ref)); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("Sending")); $pdf->SetSubject($outputlangs->transnoentities("Sending"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname)); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($this->expe->ref)." ".$outputlangs->transnoentities("Sending")); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Sending"));
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins(10, 10, 10); $pdf->SetMargins(10, 10, 10);
@ -194,14 +194,14 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
//Recuperation des produits de la commande. //Recuperation des produits de la commande.
$Produits = $this->expe->commande->lignes; $Produits = $object->commande->lignes;
$nblignes = sizeof($Produits); $nblignes = sizeof($Produits);
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
{ {
// Description de la ligne produit // Description de la ligne produit
$libelleproduitservice=pdf_getlinedesc($this->expe->commande->lignes[$i],$outputlangs); $libelleproduitservice=pdf_getlinedesc($object->commande->lignes[$i],$outputlangs);
//if ($i==1) { print $this->expe->commande->lignes[$i]->libelle.' - '.$libelleproduitservice; exit; } //if ($i==1) { print $object->commande->lignes[$i]->libelle.' - '.$libelleproduitservice; exit; }
//Creation des cases a cocher //Creation des cases a cocher
$pdf->rect(10+3, $curY+1, 3, 3); $pdf->rect(10+3, $curY+1, 3, 3);
@ -209,7 +209,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
//Insertion de la reference du produit //Insertion de la reference du produit
$pdf->SetXY (30, $curY+1 ); $pdf->SetXY (30, $curY+1 );
$pdf->SetFont('Arial','B', 7); $pdf->SetFont('Arial','B', 7);
$pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($this->expe->commande->lignes[$i]->ref), 0, 'L', 0); $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->commande->lignes[$i]->ref), 0, 'L', 0);
//Insertion du libelle //Insertion du libelle
$pdf->SetFont('Arial','', 7); $pdf->SetFont('Arial','', 7);
$pdf->SetXY (50, $curY+1 ); $pdf->SetXY (50, $curY+1 );
@ -217,11 +217,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition
//Insertion de la quantite commandee //Insertion de la quantite commandee
$pdf->SetFont('Arial','', 7); $pdf->SetFont('Arial','', 7);
$pdf->SetXY (140, $curY+1 ); $pdf->SetXY (140, $curY+1 );
$pdf->MultiCell(30, 3, $this->expe->lignes[$i]->qty_asked, 0, 'C', 0); $pdf->MultiCell(30, 3, $object->lignes[$i]->qty_asked, 0, 'C', 0);
//Insertion de la quantite a envoyer //Insertion de la quantite a envoyer
$pdf->SetFont('Arial','', 7); $pdf->SetFont('Arial','', 7);
$pdf->SetXY (170, $curY+1 ); $pdf->SetXY (170, $curY+1 );
$pdf->MultiCell(30, 3, $this->expe->lignes[$i]->qty_shipped, 0, 'C', 0); $pdf->MultiCell(30, 3, $object->lignes[$i]->qty_shipped, 0, 'C', 0);
//Generation de la page 2 //Generation de la page 2
$curY += (dol_nboflines_bis($libelleproduitservice)*3+1); $curY += (dol_nboflines_bis($libelleproduitservice)*3+1);
@ -369,20 +369,38 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '' , 'L'); // Bordereau expedition $pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '' , 'L'); // Bordereau expedition
//Num Expedition //Num Expedition
$Yoff = $Yoff+7; $Yoff = $Yoff+7;
$Xoff = 154; $Xoff = 142;
// $pdf->rect($Xoff, $Yoff, 85, 8); // $pdf->rect($Xoff, $Yoff, 85, 8);
$pdf->SetXY($Xoff,$Yoff); $pdf->SetXY($Xoff,$Yoff);
$pdf->SetFont('Arial','',8); $pdf->SetFont('Arial','',8);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '' , 'L'); $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '' , 'R');
//$this->Code39($Xoff+43, $Yoff+1, $this->expe->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
//Num Commande
$Yoff = $Yoff+4; // Add list of linked orders
// $pdf->rect($Xoff, $Yoff, 85, 8); $object->load_object_linked();
$pdf->SetXY($Xoff,$Yoff);
$pdf->SetFont('Arial','',8); if ($conf->commande->enabled)
$pdf->SetTextColor(0,0,0); {
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefOrder").': '.$outputlangs->convToOutputCharset($object->commande->ref), '' , 'L'); $outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
if ($val['type'] == 'order')
{
$newobject=new Commande($this->db);
$result=$newobject->fetch($val['linkid']);
if ($result >= 0)
{
$Yoff = $Yoff+4;
$pdf->SetXY($Xoff,$Yoff);
$pdf->SetFont('Arial','',8);
$text=$newobject->ref;
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
}
}
}
}
//$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
//Definition Emplacement du bloc Societe //Definition Emplacement du bloc Societe

View File

@ -73,7 +73,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
* \param showadress 0=non, 1=oui * \param showadress 0=non, 1=oui
* \param outputlang Objet lang cible * \param outputlang Objet lang cible
*/ */
function _pagehead(&$pdf, $exp, $showadress=1, $outputlangs) function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
{ {
global $conf; global $conf;
@ -90,7 +90,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
if ($conf->barcode->enabled) if ($conf->barcode->enabled)
{ {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $this->expe->ref // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24); //$pdf->Image($logo,10, 5, 0, 24);
} }
@ -99,31 +99,56 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->SetFont('Arial','', 14); $pdf->SetFont('Arial','', 14);
$pdf->Text($posx, 16, $outputlangs->transnoentities("SendingSheet")); // Bordereau expedition $pdf->Text($posx, 16, $outputlangs->transnoentities("SendingSheet")); // Bordereau expedition
$pdf->Text($posx, 22, $outputlangs->transnoentities("Ref") ." : ".$this->expe->ref); $pdf->Text($posx, 22, $outputlangs->transnoentities("Ref") ." : ".$object->ref);
$pdf->Text($posx, 28, $outputlangs->transnoentities("Date")." : ".dol_print_date($this->expe->date,"%d %b %Y",false,$outputlangs,true)); $pdf->Text($posx, 28, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true));
$pdf->Text($posx, 34, $outputlangs->transnoentities("Page")." : ".$pdf->PageNo() ."/{nb}", 0); $pdf->Text($posx, 34, $outputlangs->transnoentities("Page")." : ".$pdf->PageNo() ."/{nb}", 0);
if ($conf->barcode->enabled) if ($conf->barcode->enabled)
{ {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $this->expe->ref // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24); //$pdf->Image($logo,10, 5, 0, 24);
} }
$pdf->SetFont('Arial','', 14); $pdf->SetFont('Arial','', 14);
$pdf->Text($posx, 48, $outputlangs->transnoentities("Order")); $Yoff=40;
$pdf->Text($posx, 54, $outputlangs->transnoentities("Ref") ." : ".$this->expe->commande->ref);
$pdf->Text($posx, 60, $outputlangs->transnoentities("Date")." : ".dol_print_date($this->expe->commande->date,"%d %b %Y",false,$outputlangs,true)); // Add list of linked orders
$object->load_object_linked();
if ($conf->commande->enabled)
{
$outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
if ($val['type'] == 'order')
{
$newobject=new Commande($this->db);
$result=$newobject->fetch($val['linkid']);
if ($result >= 0)
{
$Yoff = $Yoff+8;
$pdf->SetXY($Xoff,$Yoff);
$pdf->SetFont('Arial','',8);
$text=$newobject->ref;
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
$pdf->Text($posx, $Yoff, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text));
$pdf->Text($posx, $Yoff+4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"%d %b %Y",false,$outputlangs,true));
}
}
}
}
} }
/** /**
* \brief Fonction g<EFBFBD>n<EFBFBD>rant le document sur le disque * \brief Fonction generant le document sur le disque
* \param obj Objet expedition <EFBFBD> g<EFBFBD>n<EFBFBD>rer (ou id si ancienne methode) * \param obj Objet expedition a generer (ou id si ancienne methode)
* \param outputlangs Lang output object * \param outputlangs Lang output object
* \return int 1=ok, 0=ko * \return int 1=ok, 0=ko
*/ */
function write_file(&$obj, $outputlangs) function write_file(&$object, $outputlangs)
{ {
global $user,$conf,$langs; global $user,$conf,$langs;
@ -142,17 +167,15 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
if ($conf->expedition_bon->dir_output) if ($conf->expedition_bon->dir_output)
{ {
$this->expe = $obj; // Definition de $dir et $file
if ($object->specimen)
// D<>finition de $dir et $file
if ($this->expe->specimen)
{ {
$dir = $conf->expedition_bon->dir_output; $dir = $conf->expedition_bon->dir_output;
$file = $dir . "/SPECIMEN.pdf"; $file = $dir . "/SPECIMEN.pdf";
} }
else else
{ {
$expref = dol_sanitizeFileName($this->expe->ref); $expref = dol_sanitizeFileName($object->ref);
$dir = $conf->expedition_bon->dir_output . "/" . $expref; $dir = $conf->expedition_bon->dir_output . "/" . $expref;
$file = $dir . "/" . $expref . ".pdf"; $file = $dir . "/" . $expref . ".pdf";
} }
@ -169,8 +192,6 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=new ModelePdfExpedition(); $pdf=new ModelePdfExpedition();
//$this = new ModelePdfExpedition();
//$this->expe = &$this->expe;
$pdf->Open(); $pdf->Open();
$pagenb=0; $pagenb=0;
@ -178,7 +199,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->SetTitle($outputlangs->convToOutputCharset($this->expe->ref)); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("Sending")); $pdf->SetSubject($outputlangs->transnoentities("Sending"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname)); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname));
@ -191,7 +212,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $this->exp, 1, $outputlangs); $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('Arial','', 9); $pdf->SetFont('Arial','', 9);
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -220,17 +241,17 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$nexY = $this->tableau_top + 14; $nexY = $this->tableau_top + 14;
for ($i = 0 ; $i < sizeof($this->expe->lignes) ; $i++) for ($i = 0 ; $i < sizeof($object->lignes) ; $i++)
{ {
$curY = $nexY; $curY = $nexY;
if ($this->barcode->enabled) if ($this->barcode->enabled)
{ {
$pdf->i25($this->marge_gauche+3, ($curY - 2), "000000".$this->expe->lignes[$i]->fk_product, 1, 8); $pdf->i25($this->marge_gauche+3, ($curY - 2), "000000".$object->lignes[$i]->fk_product, 1, 8);
} }
// Description de la ligne produit // Description de la ligne produit
$libelleproduitservice=pdf_getlinedesc($this->expe->lignes[$i],$outputlangs); $libelleproduitservice=pdf_getlinedesc($object->lignes[$i],$outputlangs);
$pdf->SetFont('Arial','', 9); // Dans boucle pour g<>rer multi-page $pdf->SetFont('Arial','', 9); // Dans boucle pour g<>rer multi-page
$pdf->writeHTMLCell(150, 3, $this->posxdesc, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); $pdf->writeHTMLCell(150, 3, $this->posxdesc, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
@ -239,17 +260,17 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pdf->SetXY (160, $curY); $pdf->SetXY (160, $curY);
$pdf->MultiCell(30, 3, $this->expe->lignes[$i]->qty_asked); $pdf->MultiCell(30, 3, $object->lignes[$i]->qty_asked);
$pdf->SetXY (186, $curY); $pdf->SetXY (186, $curY);
$pdf->MultiCell(30, 3, $this->expe->lignes[$i]->qty_shipped); $pdf->MultiCell(30, 3, $object->lignes[$i]->qty_shipped);
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
} }
// Pied de page // Pied de page
$this->_pagefoot($pdf,$this->expe,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();

View File

@ -83,12 +83,12 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
/** /**
* \brief Fonction g<EFBFBD>n<EFBFBD>rant le bon de livraison sur le disque * \brief Fonction generant le bon de livraison sur le disque
* \param delivery Object livraison <EFBFBD> g<EFBFBD>n<EFBFBD>rer * \param delivery Object livraison a generer
* \param outputlangs Lang output object * \param outputlangs Lang output object
* \return int 1 if OK, <=0 if KO * \return int 1 if OK, <=0 if KO
*/ */
function write_file($delivery,$outputlangs) function write_file($object,$outputlangs)
{ {
global $user,$conf,$langs; global $user,$conf,$langs;
@ -108,25 +108,25 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
if ($conf->livraison_bon->dir_output) if ($conf->livraison_bon->dir_output)
{ {
// If $delivery is id instead of object // If $object is id instead of object
if (! is_object($delivery)) if (! is_object($object))
{ {
$id = $delivery; $id = $object;
$delivery = new Livraison($this->db); $object = new Livraison($this->db);
$delivery->fetch($id); $object->fetch($id);
$delivery->id = $id; $object->id = $id;
if ($result < 0) if ($result < 0)
{ {
dol_print_error($db,$delivery->error); dol_print_error($db,$object->error);
} }
} }
$nblignes = sizeof($delivery->lignes); $nblignes = sizeof($object->lignes);
$deliveryref = dol_sanitizeFileName($delivery->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->livraison_bon->dir_output; $dir = $conf->livraison_bon->dir_output;
if (! eregi('specimen',$deliveryref)) $dir.= "/" . $deliveryref; if (! eregi('specimen',$objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $deliveryref . ".pdf"; $file = $dir . "/" . $objectref . ".pdf";
if (! file_exists($dir)) if (! file_exists($dir))
{ {
@ -157,11 +157,11 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$pagenb=0; $pagenb=0;
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
$pdf->SetTitle($outputlangs->convToOutputCharset($delivery->ref)); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("DeliveryOrder")); $pdf->SetSubject($outputlangs->transnoentities("DeliveryOrder"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname)); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($delivery->ref)." ".$outputlangs->transnoentities("DeliveryOrder")); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("DeliveryOrder"));
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); 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->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
@ -170,7 +170,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $delivery, 1, $outputlangs); $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('Arial','', 9); $pdf->SetFont('Arial','', 9);
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -189,7 +189,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$curY = $nexY; $curY = $nexY;
// Description de la ligne produit // Description de la ligne produit
$libelleproduitservice=pdf_getlinedesc($delivery->lignes[$i],$outputlangs); $libelleproduitservice=pdf_getlinedesc($object->lignes[$i],$outputlangs);
$pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page $pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page
@ -200,22 +200,22 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$pdf->SetXY (10, $curY ); $pdf->SetXY (10, $curY );
$pdf->MultiCell(20, 3, $outputlangs->convToOutputCharset($delivery->lignes[$i]->ref), 0, 'C'); $pdf->MultiCell(20, 3, $outputlangs->convToOutputCharset($object->lignes[$i]->ref), 0, 'C');
// \TODO Field not yet saved in database // \TODO Field not yet saved in database
//$pdf->SetXY (133, $curY ); //$pdf->SetXY (133, $curY );
//$pdf->MultiCell(10, 5, $delivery->lignes[$i]->tva_tx, 0, 'C'); //$pdf->MultiCell(10, 5, $object->lignes[$i]->tva_tx, 0, 'C');
$pdf->SetXY (145, $curY ); $pdf->SetXY (145, $curY );
$pdf->MultiCell(10, 3, $delivery->lignes[$i]->qty_shipped, 0, 'C'); $pdf->MultiCell(10, 3, $object->lignes[$i]->qty_shipped, 0, 'C');
// \TODO Field not yet saved in database // \TODO Field not yet saved in database
//$pdf->SetXY (156, $curY ); //$pdf->SetXY (156, $curY );
//$pdf->MultiCell(18, 3, price($delivery->lignes[$i]->price), 0, 'R', 0); //$pdf->MultiCell(18, 3, price($object->lignes[$i]->price), 0, 'R', 0);
// \TODO Field not yet saved in database // \TODO Field not yet saved in database
//$pdf->SetXY (174, $curY ); //$pdf->SetXY (174, $curY );
//$total = price($delivery->lignes[$i]->price * $delivery->lignes[$i]->qty_shipped); //$total = price($object->lignes[$i]->price * $object->lignes[$i]->qty_shipped);
//$pdf->MultiCell(26, 3, $total, 0, 'R', 0); //$pdf->MultiCell(26, 3, $total, 0, 'R', 0);
$pdf->line(10, $curY-1, 200, $curY-1); $pdf->line(10, $curY-1, 200, $curY-1);
@ -227,7 +227,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
if ($i < ($nblignes - 1)) // If it's not last line if ($i < ($nblignes - 1)) // If it's not last line
{ {
//on r<>cup<75>re la description du produit suivant //on r<>cup<75>re la description du produit suivant
$follow_descproduitservice = $delivery->lignes[$i+1]->desc; $follow_descproduitservice = $object->lignes[$i+1]->desc;
//on compte le nombre de ligne afin de v<>rifier la place disponible (largeur de ligne 52 caracteres) //on compte le nombre de ligne afin de v<>rifier la place disponible (largeur de ligne 52 caracteres)
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52)*4); $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52)*4);
} }
@ -264,7 +264,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $delivery, 0, $outputlangs); $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->SetFont('Arial','', 9); $pdf->SetFont('Arial','', 9);
$pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -346,9 +346,9 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
* \param delivery object delivery * \param delivery object delivery
* \param showadress 0=non, 1=oui * \param showadress 0=non, 1=oui
*/ */
function _pagehead(&$pdf, $delivery, $showadress=1, $outputlangs) function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
{ {
global $langs; global $langs,$conf,$mysoc;
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',13); $pdf->SetFont('Arial','B',13);
@ -397,29 +397,50 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
} }
else else
{ {
$client->fetch($delivery->socid); $client->fetch($object->socid);
} }
$delivery->client = $client; $object->client = $client;
$pdf->SetXY(102,42); $pdf->SetXY(102,42);
$pdf->MultiCell(96,5, $outputlangs->convToOutputCharset($delivery->client->nom)); $pdf->MultiCell(96,5, $outputlangs->convToOutputCharset($object->client->nom));
$pdf->SetFont('Arial','B',11); $pdf->SetFont('Arial','B',11);
$pdf->SetXY(102,47); $pdf->SetXY(102,47);
$pdf->MultiCell(96,5, $outputlangs->convToOutputCharset($delivery->client->adresse) . "\n" . $outputlangs->convToOutputCharset($delivery->client->cp) . " " . $outputlangs->convToOutputCharset($delivery->client->ville)); $pdf->MultiCell(96,5, $outputlangs->convToOutputCharset($object->client->adresse) . "\n" . $outputlangs->convToOutputCharset($object->client->cp) . " " . $outputlangs->convToOutputCharset($object->client->ville));
$pdf->rect(100, 40, 100, 40); $pdf->rect(100, 40, 100, 40);
$pdf->SetTextColor(200,0,0); $pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',12); $pdf->SetFont('Arial','B',12);
$pdf->Text(11, 88, $outputlangs->transnoentities("Date")." : " . dol_print_date($delivery->date_valid,"day",false,$outputlangs,true)); $pdf->Text(11, 88, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_valid,"day",false,$outputlangs,true));
$pdf->Text(11, 94, $outputlangs->transnoentities("DeliveryOrder")." ".$outputlangs->convToOutputCharset($delivery->ref)); $pdf->Text(11, 94, $outputlangs->transnoentities("DeliveryOrder")." ".$outputlangs->convToOutputCharset($object->ref));
$pdf->SetFont('Arial','B',9); $pdf->SetFont('Arial','B',9);
$commande = new Commande ($this->db);
if ($commande->fetch($delivery->commande_id) >0) // Add list of linked orders
$object->load_object_linked();
if ($conf->commande->enabled)
{ {
$pdf->Text(11, 98, $outputlangs->transnoentities("RefOrder")." ".$outputlangs->convToOutputCharset($commande->ref)); $outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
if ($val['type'] == 'order')
{
$newobject=new Commande($this->db);
$result=$newobject->fetch($val['linkid']);
if ($result >= 0)
{
$posy+=4;
$pdf->SetXY(102,$posy);
$pdf->SetFont('Arial','',9);
$text=$newobject->ref;
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
$pdf->Text(11, 94, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
}
}
}
} }
} }
/** /**

View File

@ -290,9 +290,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder
// Cherche nombre de lignes a venir pour savoir si place suffisante // Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1)) // If it's not last line if ($i < ($nblignes - 1)) // If it's not last line
{ {
//on récupère la description du produit suivant //on r<EFBFBD>cup<EFBFBD>re la description du produit suivant
$follow_descproduitservice = $delivery->lignes[$i+1]->desc; $follow_descproduitservice = $delivery->lignes[$i+1]->desc;
//on compte le nombre de ligne afin de vérifier la place disponible (largeur de ligne 52 caracteres) //on compte le nombre de ligne afin de v<EFBFBD>rifier la place disponible (largeur de ligne 52 caracteres)
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52)*4); $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52)*4);
} }
else // If it's last line else // If it's last line
@ -479,12 +479,31 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
} }
$posy+=6;
$pdf->SetXY(100,$posy);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$commande = new Commande ($this->db);
if ($commande->fetch($object->origin_id) >0) { // Add list of linked orders
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->convToOutputCharset($commande->ref), '' , 'R'); $object->load_object_linked();
if ($conf->commande->enabled)
{
$outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
if ($val['type'] == 'order')
{
$newobject=new Commande($this->db);
$result=$newobject->fetch($val['linkid']);
if ($result >= 0)
{
$posy+=4;
$pdf->SetXY(100,$posy);
$pdf->SetFont('Arial','',9);
$text=$newobject->ref;
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
}
}
}
} }
if ($showadress) if ($showadress)

View File

@ -52,3 +52,7 @@ SendingMethodCOLSUI=Colissimo
# NumRef # NumRef
NumRefModelJade=Return a reference number with format BLYY00001, ... where YY is year. Number at end is never reset to zero. NumRefModelJade=Return a reference number with format BLYY00001, ... where YY is year. Number at end is never reset to zero.
# ModelDocument
DocumentModelSirocco=Simple document model for delivery receipts
DocumentModelTyphon=More complete document model for delivery receipts (logo...)

View File

@ -40,8 +40,12 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande
class Livraison extends CommonObject class Livraison extends CommonObject
{ {
var $db; var $db;
var $id; var $error;
var $element="delivery";
var $fk_element="fk_livraison";
var $table_element="livraison";
var $id;
var $brouillon; var $brouillon;
var $origin; var $origin;
var $origin_id; var $origin_id;
@ -116,7 +120,7 @@ class Livraison extends CommonObject
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."livraison"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."livraison");
$numref = "(PROV".$this->id.")"; $numref = "(PROV".$this->id.")";
$sql = "UPDATE ".MAIN_DB_PREFIX."livraison "; $sql = "UPDATE ".MAIN_DB_PREFIX."livraison ";
$sql.= "SET ref = '".addslashes($numref)."'"; $sql.= "SET ref = '".addslashes($numref)."'";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
@ -736,13 +740,13 @@ class Livraison extends CommonObject
// Charge tableau des id de societe socids // Charge tableau des id de societe socids
$socids = array(); $socids = array();
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."societe"; $sql.= " FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE client = 1"; $sql.= " WHERE client = 1";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
$sql.= " LIMIT 10"; $sql.= " LIMIT 10";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -759,12 +763,12 @@ class Livraison extends CommonObject
// Charge tableau des produits prodids // Charge tableau des produits prodids
$prodids = array(); $prodids = array();
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " FROM ".MAIN_DB_PREFIX."product";
$sql.= " WHERE envente = 1"; $sql.= " WHERE envente = 1";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {