diff --git a/htdocs/commonobject.class.php b/htdocs/commonobject.class.php index 84680bebda13269a1d86da653b842cc6ced83dd8..a253a68be4ff6f21e26eddef07e5364616756cfa 100644 --- a/htdocs/commonobject.class.php +++ b/htdocs/commonobject.class.php @@ -822,8 +822,8 @@ class CommonObject // Links beetween objects are stored in this table $sql = 'SELECT sourceid, sourcetype, targetid, targettype'; $sql.= ' FROM '.MAIN_DB_PREFIX.'element_element'; - $sql.= " WHERE (source_id = '.$this->id.' AND source_type = 'invoice')"; - $sql.= " OR (target_id = '.$this->id.' AND target_id = 'invoice')"; + $sql.= " WHERE (sourceid = '".$this->id."' AND sourcetype = 'invoice')"; + $sql.= " OR (targetid = '".$this->id."' AND targetid = 'invoice')"; dol_syslog("CommonObject::load_object_linked sql=".$sql); $resql = $this->db->query($sql); if ($resql) @@ -844,6 +844,10 @@ class CommonObject $i++; } } + else + { + dol_print_error($this->db); + } // 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++; + } + } + } } } diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index b07a16b668310b66bddeacdbe4bd0a786590aa2f..f41f8a4d4bba5c3e8f00add43f054889160a0077 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -39,6 +39,7 @@ class Expedition extends CommonObject var $db; var $error; var $element="expedition"; + var $fk_element="fk_expedition"; var $table_element="expedition"; var $id; diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php index 0a53303dd66cc02e39e400bc5db7a9a39b909e32..979e504d32568cfa56006e435d5e28a530e2668b 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php @@ -74,7 +74,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition * \param outputlangs Lang output object * \return int 1=ok, 0=ko */ - function write_file(&$obj, $outputlangs) + function write_file(&$object, $outputlangs) { global $user,$conf,$langs; @@ -93,14 +93,14 @@ Class pdf_expedition_merou extends ModelePdfExpedition $outputlangs->setPhpLang(); //Generation de la fiche - $this->expe = $obj; + $this->expe = $object; //Verification de la configuration if ($conf->expedition_bon->dir_output) { //Creation du Client $soc = new Societe($this->db); - $soc->fetch($this->expe->commande->socid); + $soc->fetch($object->commande->socid); //Creation de l expediteur $this->expediteur = $mysoc; @@ -109,24 +109,24 @@ Class pdf_expedition_merou extends ModelePdfExpedition $this->destinataire = new Contact($this->db); // $pdf->expe->commande->fetch($pdf->commande->id); //print_r($pdf->expe); - $idcontact = $this->expe->commande->getIdContact('external','SHIPPING'); + $idcontact = $object->commande->getIdContact('external','SHIPPING'); $this->destinataire->fetch($idcontact[0]); //Creation du livreur - $idcontact = $this->expe->commande->getIdContact('internal','LIVREUR'); + $idcontact = $object->commande->getIdContact('internal','LIVREUR'); $this->livreur = new User($this->db,$idcontact[0]); if ($idcontact[0]) $this->livreur->fetch(); // Definition de $dir et $file - if ($this->expe->specimen) + if ($object->specimen) { $dir = $conf->expedition_bon->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { - $expref = dol_sanitizeFileName($this->expe->ref); + $expref = dol_sanitizeFileName($object->ref); $dir = $conf->expedition_bon->dir_output . "/" . $expref; $file = $dir . "/" . $expref . ".pdf"; } @@ -160,11 +160,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition $pdf->SetDrawColor(128,128,128); //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->SetCreator("Dolibarr ".DOL_VERSION); $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); $pdf->SetMargins(10, 10, 10); @@ -194,14 +194,14 @@ Class pdf_expedition_merou extends ModelePdfExpedition $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); //Recuperation des produits de la commande. - $Produits = $this->expe->commande->lignes; + $Produits = $object->commande->lignes; $nblignes = sizeof($Produits); for ($i = 0 ; $i < $nblignes ; $i++) { // Description de la ligne produit - $libelleproduitservice=pdf_getlinedesc($this->expe->commande->lignes[$i],$outputlangs); - //if ($i==1) { print $this->expe->commande->lignes[$i]->libelle.' - '.$libelleproduitservice; exit; } + $libelleproduitservice=pdf_getlinedesc($object->commande->lignes[$i],$outputlangs); + //if ($i==1) { print $object->commande->lignes[$i]->libelle.' - '.$libelleproduitservice; exit; } //Creation des cases a cocher $pdf->rect(10+3, $curY+1, 3, 3); @@ -209,7 +209,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Insertion de la reference du produit $pdf->SetXY (30, $curY+1 ); $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 $pdf->SetFont('Arial','', 7); $pdf->SetXY (50, $curY+1 ); @@ -217,11 +217,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Insertion de la quantite commandee $pdf->SetFont('Arial','', 7); $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 $pdf->SetFont('Arial','', 7); $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 $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 //Num Expedition $Yoff = $Yoff+7; - $Xoff = 154; + $Xoff = 142; // $pdf->rect($Xoff, $Yoff, 85, 8); $pdf->SetXY($Xoff,$Yoff); $pdf->SetFont('Arial','',8); $pdf->SetTextColor(0,0,0); - $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '' , 'L'); - //$this->Code39($Xoff+43, $Yoff+1, $this->expe->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); - //Num Commande - $Yoff = $Yoff+4; - // $pdf->rect($Xoff, $Yoff, 85, 8); - $pdf->SetXY($Xoff,$Yoff); - $pdf->SetFont('Arial','',8); - $pdf->SetTextColor(0,0,0); - $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefOrder").': '.$outputlangs->convToOutputCharset($object->commande->ref), '' , 'L'); + $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '' , 'R'); + //$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = 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+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); //Definition Emplacement du bloc Societe 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 a23c3052fd4920fb6d081825fa0a722b7187405f..15245a33e59da8c6cca3353140eb23731119159b 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php @@ -73,7 +73,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition * \param showadress 0=non, 1=oui * \param outputlang Objet lang cible */ - function _pagehead(&$pdf, $exp, $showadress=1, $outputlangs) + function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) { global $conf; @@ -90,7 +90,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition 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->Image($logo,10, 5, 0, 24); } @@ -99,31 +99,56 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $pdf->SetFont('Arial','', 14); $pdf->Text($posx, 16, $outputlangs->transnoentities("SendingSheet")); // Bordereau expedition - $pdf->Text($posx, 22, $outputlangs->transnoentities("Ref") ." : ".$this->expe->ref); - $pdf->Text($posx, 28, $outputlangs->transnoentities("Date")." : ".dol_print_date($this->expe->date,"%d %b %Y",false,$outputlangs,true)); + $pdf->Text($posx, 22, $outputlangs->transnoentities("Ref") ." : ".$object->ref); + $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); 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->Image($logo,10, 5, 0, 24); } $pdf->SetFont('Arial','', 14); - $pdf->Text($posx, 48, $outputlangs->transnoentities("Order")); - $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)); + $Yoff=40; + + // 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�n�rant le document sur le disque - * \param obj Objet expedition � g�n�rer (ou id si ancienne methode) + * \brief Fonction generant le document sur le disque + * \param obj Objet expedition a generer (ou id si ancienne methode) * \param outputlangs Lang output object * \return int 1=ok, 0=ko */ - function write_file(&$obj, $outputlangs) + function write_file(&$object, $outputlangs) { global $user,$conf,$langs; @@ -142,17 +167,15 @@ Class pdf_expedition_rouget extends ModelePdfExpedition if ($conf->expedition_bon->dir_output) { - $this->expe = $obj; - - // D�finition de $dir et $file - if ($this->expe->specimen) + // Definition de $dir et $file + if ($object->specimen) { $dir = $conf->expedition_bon->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { - $expref = dol_sanitizeFileName($this->expe->ref); + $expref = dol_sanitizeFileName($object->ref); $dir = $conf->expedition_bon->dir_output . "/" . $expref; $file = $dir . "/" . $expref . ".pdf"; } @@ -169,8 +192,6 @@ Class pdf_expedition_rouget extends ModelePdfExpedition if (file_exists($dir)) { $pdf=new ModelePdfExpedition(); - //$this = new ModelePdfExpedition(); - //$this->expe = &$this->expe; $pdf->Open(); $pagenb=0; @@ -178,7 +199,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $pdf->AliasNbPages(); - $pdf->SetTitle($outputlangs->convToOutputCharset($this->expe->ref)); + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Sending")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname)); @@ -191,7 +212,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $this->exp, 1, $outputlangs); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('Arial','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -220,17 +241,17 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $nexY = $this->tableau_top + 14; - for ($i = 0 ; $i < sizeof($this->expe->lignes) ; $i++) + for ($i = 0 ; $i < sizeof($object->lignes) ; $i++) { $curY = $nexY; 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 - $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->writeHTMLCell(150, 3, $this->posxdesc, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); @@ -239,17 +260,17 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $nexY = $pdf->GetY(); $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->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 } // Pied de page - $this->_pagefoot($pdf,$this->expe,$outputlangs); + $this->_pagefoot($pdf,$object,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php index 2ddd1721209a01514d164c279356cc56dbec2299..91a95656e8a513711be5155b3a1e616488f3154c 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php @@ -83,12 +83,12 @@ class pdf_sirocco extends ModelePDFDeliveryOrder /** - * \brief Fonction g�n�rant le bon de livraison sur le disque - * \param delivery Object livraison � g�n�rer + * \brief Fonction generant le bon de livraison sur le disque + * \param delivery Object livraison a generer * \param outputlangs Lang output object * \return int 1 if OK, <=0 if KO */ - function write_file($delivery,$outputlangs) + function write_file($object,$outputlangs) { global $user,$conf,$langs; @@ -108,25 +108,25 @@ class pdf_sirocco extends ModelePDFDeliveryOrder if ($conf->livraison_bon->dir_output) { - // If $delivery is id instead of object - if (! is_object($delivery)) + // If $object is id instead of object + if (! is_object($object)) { - $id = $delivery; - $delivery = new Livraison($this->db); - $delivery->fetch($id); - $delivery->id = $id; + $id = $object; + $object = new Livraison($this->db); + $object->fetch($id); + $object->id = $id; 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; - if (! eregi('specimen',$deliveryref)) $dir.= "/" . $deliveryref; - $file = $dir . "/" . $deliveryref . ".pdf"; + if (! eregi('specimen',$objectref)) $dir.= "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; if (! file_exists($dir)) { @@ -157,11 +157,11 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $pagenb=0; $pdf->SetDrawColor(128,128,128); - $pdf->SetTitle($outputlangs->convToOutputCharset($delivery->ref)); + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("DeliveryOrder")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $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); $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 $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $delivery, 1, $outputlangs); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('Arial','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -189,7 +189,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $curY = $nexY; // 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 @@ -200,22 +200,22 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $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 //$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->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 //$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 //$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->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 { //on r�cup�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) $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52)*4); } @@ -264,7 +264,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $delivery, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('Arial','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -346,9 +346,9 @@ class pdf_sirocco extends ModelePDFDeliveryOrder * \param delivery object delivery * \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->SetFont('Arial','B',13); @@ -397,29 +397,50 @@ class pdf_sirocco extends ModelePDFDeliveryOrder } else { - $client->fetch($delivery->socid); + $client->fetch($object->socid); } - $delivery->client = $client; + $object->client = $client; $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->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->SetTextColor(200,0,0); $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, 94, $outputlangs->transnoentities("DeliveryOrder")." ".$outputlangs->convToOutputCharset($delivery->ref)); + $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($object->ref)); $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'); + } + } + } } + } /** diff --git a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php index 15deaed9e1c91f6723c135d66be47a9fbb5a88a4..3dd718afc5a220631b873204f08e3cb2b87a31a7 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php @@ -290,9 +290,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Cherche nombre de lignes a venir pour savoir si place suffisante if ($i < ($nblignes - 1)) // If it's not last line { - //on r�cup�re la description du produit suivant + //on r�cup�re la description du produit suivant $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�rifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52)*4); } else // If it's last line @@ -479,12 +479,31 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetTextColor(0,0,60); } - $posy+=6; - $pdf->SetXY(100,$posy); $pdf->SetTextColor(0,0,60); - $commande = new Commande ($this->db); - if ($commande->fetch($object->origin_id) >0) { - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->convToOutputCharset($commande->ref), '' , 'R'); + + // 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) + { + $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) diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 2d11cb67d6b2ac5ff846dff3bed8416adff4b1da..8c0ae2e05b7bfbfe4c52ce0de146568e01a3bd2b 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -52,3 +52,7 @@ SendingMethodCOLSUI=Colissimo # NumRef 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...) diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index 192dcea1b0b3b733629b2d28e1e9b8687b6adac2..9f1b633320138f9307b5ec176df6ee315351b62a 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -40,8 +40,12 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande class Livraison extends CommonObject { var $db; - var $id; + var $error; + var $element="delivery"; + var $fk_element="fk_livraison"; + var $table_element="livraison"; + var $id; var $brouillon; var $origin; var $origin_id; @@ -116,7 +120,7 @@ class Livraison extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."livraison"); $numref = "(PROV".$this->id.")"; - + $sql = "UPDATE ".MAIN_DB_PREFIX."livraison "; $sql.= "SET ref = '".addslashes($numref)."'"; $sql.= " WHERE rowid = ".$this->id; @@ -736,13 +740,13 @@ class Livraison extends CommonObject // Charge tableau des id de societe socids $socids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE client = 1"; $sql.= " AND entity = ".$conf->entity; $sql.= " LIMIT 10"; - + $resql = $this->db->query($sql); if ($resql) { @@ -759,12 +763,12 @@ class Livraison extends CommonObject // Charge tableau des produits prodids $prodids = array(); - + $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " WHERE envente = 1"; $sql.= " AND entity = ".$conf->entity; - + $resql = $this->db->query($sql); if ($resql) {