Example #1
0
}
else
/* *************************************************************************** */
/*                                                                             */
/* Mode vue et edition                                                         */
/*                                                                             */
/* *************************************************************************** */
{
	if ($_GET["id"] > 0)
	{
		$delivery = new Livraison($db);
		$result = $delivery->fetch($_GET["id"]);
		$delivery->fetch_thirdparty();

		$expedition=new Expedition($db);
		$result = $expedition->fetch($delivery->origin_id);
		$typeobject = $expedition->origin;

		if ($delivery->origin_id)
		{
			$delivery->fetch_origin();
		}

		if ( $delivery->id > 0)
		{
			$soc = new Societe($db);
			$soc->fetch($delivery->socid);

			$head=delivery_prepare_head($delivery);
			dol_fiche_head($head, 'delivery', $langs->trans("Sending"), 0, 'sending');
 /**
  *	Function to build a document on disk using the generic odt module.
  *
  *	@param		Expedition	$object				Object source to build document
  *	@param		Translate	$outputlangs		Lang output object
  * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
  *  @param		int			$hidedetails		Do not show line details
  *  @param		int			$hidedesc			Do not show desc
  *  @param		int			$hideref			Do not show ref
  *	@return		int         					1 if OK, <=0 if KO
  */
 function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 {
     global $user, $langs, $conf, $mysoc, $hookmanager;
     if (empty($srctemplatepath)) {
         dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
         return -1;
     }
     // Add odtgeneration hook
     if (!is_object($hookmanager)) {
         include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
         $hookmanager = new HookManager($this->db);
     }
     $hookmanager->initHooks(array('odtgeneration'));
     global $action;
     if (!is_object($outputlangs)) {
         $outputlangs = $langs;
     }
     $sav_charset_output = $outputlangs->charset_output;
     $outputlangs->charset_output = 'UTF-8';
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("companies");
     $outputlangs->load("bills");
     if ($conf->expedition->dir_output . "/sending") {
         // If $object is id instead of object
         if (!is_object($object)) {
             $id = $object;
             $object = new Expedition($this->db);
             $result = $object->fetch($id);
             if ($result < 0) {
                 dol_print_error($this->db, $object->error);
                 return -1;
             }
         }
         $dir = $conf->expedition->dir_output . "/sending";
         $objectref = dol_sanitizeFileName($object->ref);
         if (!preg_match('/specimen/i', $objectref)) {
             $dir .= "/" . $objectref;
         }
         $file = $dir . "/" . $objectref . ".odt";
         if (!file_exists($dir)) {
             if (dol_mkdir($dir) < 0) {
                 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
                 return -1;
             }
         }
         if (file_exists($dir)) {
             //print "srctemplatepath=".$srctemplatepath;	// Src filename
             $newfile = basename($srctemplatepath);
             $newfiletmp = preg_replace('/\\.od(t|s)/i', '', $newfile);
             $newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
             $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
             $newfiletmp = $objectref . '_' . $newfiletmp;
             //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
             // Get extension (ods or odt)
             $newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
             if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
                 $filename = $newfiletmp . '.' . dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '.' . $newfileformat;
             } else {
                 $filename = $newfiletmp . '.' . $newfileformat;
             }
             $file = $dir . '/' . $filename;
             //print "newdir=".$dir;
             //print "newfile=".$newfile;
             //print "file=".$file;
             //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
             dol_mkdir($conf->expedition->dir_temp);
             // If BILLING contact defined on invoice, we use it
             $usecontact = false;
             $arrayidcontact = $object->getIdContact('external', 'BILLING');
             if (count($arrayidcontact) > 0) {
                 $usecontact = true;
                 $result = $object->fetch_contact($arrayidcontact[0]);
             }
             // Recipient name
             if (!empty($usecontact)) {
                 // On peut utiliser le nom de la societe du contact
                 if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                     $socobject = $object->contact;
                 } else {
                     $socobject = $object->client;
                 }
             } else {
                 $socobject = $object->client;
             }
             // Make substitution
             $substitutionarray = array('__FROM_NAME__' => $this->emetteur->nom, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, '__TOTAL_HT__' => $object->total_ht, '__TOTAL_VAT__' => $object->total_vat);
             complete_substitutions_array($substitutionarray, $langs, $object);
             // Call the ODTSubstitution hook
             $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$substitutionarray);
             $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action);
             // Note that $action and $object may have been modified by some hooks
             // Line of free text
             $newfreetext = '';
             $paramfreetext = 'EXPEDITION_FREE_TEXT';
             if (!empty($conf->global->{$paramfreetext})) {
                 $newfreetext = make_substitutions($conf->global->{$paramfreetext}, $substitutionarray);
             }
             // Open and load template
             require_once ODTPHP_PATH . 'odf.php';
             try {
                 $odfHandler = new odf($srctemplatepath, array('PATH_TO_TMP' => $conf->expedition->dir_temp, 'ZIP_PROXY' => 'PclZipProxy', 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}'));
             } catch (Exception $e) {
                 $this->error = $e->getMessage();
                 return -1;
             }
             // After construction $odfHandler->contentXml contains content and
             // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
             // [!-- BEGIN lines --]*[!-- END lines --]
             //print html_entity_decode($odfHandler->__toString());
             //print exit;
             // Make substitutions into odt of freetext
             try {
                 $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
             } catch (OdfException $e) {
             }
             // Make substitutions into odt of user info
             $tmparray = $this->get_substitutionarray_user($user, $outputlangs);
             //var_dump($tmparray); exit;
             foreach ($tmparray as $key => $value) {
                 try {
                     if (preg_match('/logo$/', $key)) {
                         //var_dump($value);exit;
                         if (file_exists($value)) {
                             $odfHandler->setImage($key, $value);
                         } else {
                             $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
                         }
                     } else {
                         $odfHandler->setVars($key, $value, true, 'UTF-8');
                     }
                 } catch (OdfException $e) {
                 }
             }
             // Make substitutions into odt of mysoc
             $tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
             //var_dump($tmparray); exit;
             foreach ($tmparray as $key => $value) {
                 try {
                     if (preg_match('/logo$/', $key)) {
                         //var_dump($value);exit;
                         if (file_exists($value)) {
                             $odfHandler->setImage($key, $value);
                         } else {
                             $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
                         }
                     } else {
                         $odfHandler->setVars($key, $value, true, 'UTF-8');
                     }
                 } catch (OdfException $e) {
                 }
             }
             // Make substitutions into odt of thirdparty
             $tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
             foreach ($tmparray as $key => $value) {
                 try {
                     if (preg_match('/logo$/', $key)) {
                         if (file_exists($value)) {
                             $odfHandler->setImage($key, $value);
                         } else {
                             $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
                         }
                     } else {
                         $odfHandler->setVars($key, $value, true, 'UTF-8');
                     }
                 } catch (OdfException $e) {
                 }
             }
             // Replace tags of object + external modules
             $tmparray = $this->get_substitutionarray_shipment($object, $outputlangs);
             complete_substitutions_array($tmparray, $outputlangs, $object);
             // Call the ODTSubstitution hook
             $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray);
             $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action);
             // Note that $action and $object may have been modified by some hooks
             foreach ($tmparray as $key => $value) {
                 try {
                     if (preg_match('/logo$/', $key)) {
                         if (file_exists($value)) {
                             $odfHandler->setImage($key, $value);
                         } else {
                             $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
                         }
                     } else {
                         $odfHandler->setVars($key, $value, true, 'UTF-8');
                     }
                 } catch (OdfException $e) {
                 }
             }
             // Replace tags of lines
             try {
                 $listlines = $odfHandler->setSegment('lines');
                 foreach ($object->lines as $line) {
                     $tmparray = $this->get_substitutionarray_shipment_lines($line, $outputlangs);
                     complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
                     // Call the ODTSubstitutionLine hook
                     $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray, 'line' => $line);
                     $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action);
                     // Note that $action and $object may have been modified by some hooks
                     foreach ($tmparray as $key => $val) {
                         try {
                             $listlines->setVars($key, $val, true, 'UTF-8');
                         } catch (OdfException $e) {
                         } catch (SegmentException $e) {
                         }
                     }
                     $listlines->merge();
                 }
                 $odfHandler->mergeSegment($listlines);
             } catch (OdfException $e) {
                 $this->error = $e->getMessage();
                 dol_syslog($this->error, LOG_WARNING);
                 return -1;
             }
             // Replace labels translated
             $tmparray = $outputlangs->get_translations_for_substitutions();
             foreach ($tmparray as $key => $value) {
                 try {
                     $odfHandler->setVars($key, $value, true, 'UTF-8');
                 } catch (OdfException $e) {
                 }
             }
             // Call the beforeODTSave hook
             $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs);
             $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action);
             // Note that $action and $object may have been modified by some hooks
             // Write new file
             if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
                 try {
                     $odfHandler->exportAsAttachedPDF($file);
                 } catch (Exception $e) {
                     $this->error = $e->getMessage();
                     return -1;
                 }
             } else {
                 try {
                     $odfHandler->saveToDisk($file);
                 } catch (Exception $e) {
                     $this->error = $e->getMessage();
                     return -1;
                 }
             }
             if (!empty($conf->global->MAIN_UMASK)) {
                 @chmod($file, octdec($conf->global->MAIN_UMASK));
             }
             $odfHandler = null;
             // Destroy object
             return 1;
             // Success
         } else {
             $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
             return -1;
         }
     }
     return -1;
 }
Example #3
0
 }
 if ($element == 'inter') {
     $element = $subelement = 'ficheinter';
 }
 if ($element == 'shipping') {
     $element = $subelement = 'expedition';
 }
 $object->origin = $origin;
 $object->origin_id = $originid;
 // Possibility to add external linked objects with hooks
 $object->linked_objects[$object->origin] = $object->origin_id;
 // link with order if it is a shipping invoice
 if ($object->origin == 'shipping') {
     require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
     $exp = new Expedition($db);
     $exp->fetch($object->origin_id);
     $exp->fetchObjectLinked();
     if (count($exp->linkedObjectsIds['commande']) > 0) {
         foreach ($exp->linkedObjectsIds['commande'] as $key => $value) {
             $object->linked_objects['commande'] = $value;
         }
     }
 }
 if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) {
     $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
 }
 $id = $object->create($user);
 if ($id > 0) {
     // If deposit invoice
     if ($_POST['type'] == Facture::TYPE_DEPOSIT) {
         $typeamount = GETPOST('typedeposit', 'alpha');
Example #4
0
 /**
  *	Fonction generant le bon de livraison sur le disque
  *
  *	@param	Object		$object   		Object livraison a generer
  *	@param	Translate	$outputlangs	Lang output object
  *	@return	int         				1 if OK, <=0 if KO
  */
 function write_file($object, $outputlangs)
 {
     global $user, $langs, $conf;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     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 (!empty($conf->global->MAIN_USE_FPDF)) {
         $outputlangs->charset_output = 'ISO-8859-1';
     }
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("companies");
     $outputlangs->load("bills");
     $outputlangs->load("products");
     $outputlangs->load("deliveries");
     $outputlangs->load("sendings");
     if ($conf->expedition->dir_output . "/receipt") {
         $object->fetch_thirdparty();
         $nblines = count($object->lines);
         $objectref = dol_sanitizeFileName($object->ref);
         $dir = $conf->expedition->dir_output . "/receipt";
         if (!preg_match('/specimen/i', $objectref)) {
             $dir .= "/" . $objectref;
         }
         $file = $dir . "/" . $objectref . ".pdf";
         if (!file_exists($dir)) {
             if (dol_mkdir($dir) < 0) {
                 $this->error = $langs->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));
             // Set path to the background PDF File
             if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
                 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND);
                 $tplidx = $pdf->importPage(1);
             }
             // Complete object by loading several other informations
             $expedition = new Expedition($this->db);
             $result = $expedition->fetch($object->expedition_id);
             $commande = new Commande($this->db);
             if ($expedition->origin == 'commande') {
                 $commande->fetch($expedition->origin_id);
             }
             $object->commande = $commande;
             $pdf->Open();
             $pagenb = 0;
             $pdf->SetDrawColor(128, 128, 128);
             $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
             $pdf->SetSubject($outputlangs->transnoentities("DeliveryOrder"));
             $pdf->SetCreator("Dolibarr " . DOL_VERSION);
             $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
             $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
             $pdf->SetAutoPageBreak(1, 0);
             /*
             // Positionne $this->atleastonediscount si on a au moins une remise
             for ($i = 0 ; $i < $nblignes ; $i++)
             {
             if ($object->lines[$i]->remise_percent)
             {
             $this->atleastonediscount++;
             }
             }
             */
             // New page
             $pdf->AddPage();
             if (!empty($tplidx)) {
                 $pdf->useTemplate($tplidx);
             }
             $pagenb++;
             $this->_pagehead($pdf, $object, 1, $outputlangs);
             $pdf->SetFont('', '', $default_font_size - 1);
             $pdf->MultiCell(0, 3, '');
             // Set interline to 3
             $pdf->SetTextColor(0, 0, 0);
             $tab_top = 90;
             $tab_top_newpage = 50;
             $tab_height = 110;
             $tab_height_newpage = 150;
             // Affiche notes
             if (!empty($object->note_public)) {
                 $tab_top = 88;
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // Dans boucle pour gerer multi-page
                 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
                 $nexY = $pdf->GetY();
                 $height_note = $nexY - $tab_top;
                 // Rect prend une longueur en 3eme param
                 $pdf->SetDrawColor(192, 192, 192);
                 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
                 $tab_height = $tab_height - $height_note;
                 $tab_top = $nexY + 6;
             } else {
                 $height_note = 0;
             }
             $iniY = $tab_top + 7;
             $curY = $tab_top + 7;
             $nexY = $tab_top + 7;
             // Boucle sur les lignes
             for ($i = 0; $i < $nblines; $i++) {
                 $curY = $nexY;
                 $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, 108, 3, $this->posxdesc - 1, $curY);
                 //$pdf->writeHTMLCell(108, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // On repositionne la police par defaut
                 $nexY = $pdf->GetY();
                 /*
                 // TVA
                 $pdf->SetXY($this->posxtva, $curY);
                 $pdf->MultiCell(10, 4, ($object->lines[$i]->tva_tx < 0 ? '*':'').abs($object->lines[$i]->tva_tx), 0, 'R');
                 
                 // Prix unitaire HT avant remise
                 $pdf->SetXY($this->posxup, $curY);
                 $pdf->MultiCell(20, 4, price($object->lines[$i]->subprice), 0, 'R', 0);
                 */
                 // Quantity
                 $pdf->SetXY($this->posxqty, $curY);
                 $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'R');
                 /*
                 // Remise sur ligne
                 $pdf->SetXY($this->posxdiscount, $curY);
                 if ($object->lines[$i]->remise_percent)
                 {
                 $pdf->MultiCell(14, 3, $object->lines[$i]->remise_percent."%", 0, 'R');
                 }
                 
                 // Total HT ligne
                 $pdf->SetXY($this->postotalht, $curY);
                 $total = price($object->lines[$i]->price * $object->lines[$i]->qty);
                 $pdf->MultiCell(23, 3, $total, 0, 'R', 0);
                 
                 // Collecte des totaux par valeur de tva
                 // dans le tableau tva["taux"]=total_tva
                 $tvaligne=$object->lines[$i]->price * $object->lines[$i]->qty;
                 if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
                 $this->tva[ (string) $object->lines[$i]->tva_tx ] += $tvaligne;
                 */
                 $nexY += 2;
                 // Passe espace entre les lignes
                 // Cherche nombre de lignes a venir pour savoir si place suffisante
                 if ($i < $nblines - 1 && empty($hidedesc)) {
                     //on recupere la description du produit suivant
                     $follow_descproduitservice = $object->lines[$i + 1]->desc;
                     //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
                     $nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice, 52, $outputlangs->charset_output) * 4;
                 } else {
                     $nblineFollowDesc = 0;
                 }
                 // Test if a new page is required
                 if ($pagenb == 1) {
                     $tab_top_in_current_page = $tab_top;
                     $tab_height_in_current_page = $tab_height;
                 } else {
                     $tab_top_in_current_page = $tab_top_newpage;
                     $tab_height_in_current_page = $tab_height_newpage;
                 }
                 if ($nexY + $nblineFollowDesc > $tab_top_in_current_page + $tab_height_in_current_page && $i < $nblines - 1) {
                     if ($pagenb == 1) {
                         $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
                     } else {
                         $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
                     }
                     $this->_pagefoot($pdf, $object, $outputlangs);
                     // New page
                     $pdf->AddPage();
                     $pagenb++;
                     $this->_pagehead($pdf, $object, 0, $outputlangs);
                     $pdf->SetFont('', '', $default_font_size - 1);
                     $pdf->MultiCell(0, 3, '');
                     // Set interline to 3
                     $pdf->SetTextColor(0, 0, 0);
                     $nexY = $tab_top_newpage + 7;
                 }
             }
             // Show square
             if ($pagenb == 1) {
                 $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
                 $bottomlasttab = $tab_top + $tab_height + 1;
             } else {
                 $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
                 $bottomlasttab = $tab_top_newpage + $tab_height_newpage + 1;
             }
             /*
              * Pied de page
              */
             $this->_pagefoot($pdf, $object, $outputlangs);
             // Check product remaining to be delivered
             // TODO doit etre modifie
             //$waitingDelivery = $object->getRemainingDelivered();
             $waitingDelivery = '';
             if (is_array($waitingDelivery) & !empty($waitingDelivery)) {
                 $pdf->AddPage('P', 'A4');
                 $this->_pagehead($pdf, $object, 1, $outputlangs);
                 $pdf->SetY(90);
                 $w = array(40, 100, 50);
                 $header = array($outputlangs->transnoentities('Reference'), $outputlangs->transnoentities('Label'), $outputlangs->transnoentities('Qty'));
                 // Header
                 $num = count($header);
                 for ($i = 0; $i < $num; $i++) {
                     $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C');
                 }
                 $pdf->Ln();
                 // Data
                 foreach ($waitingDelivery as $value) {
                     $pdf->Cell($w[0], 6, $value['ref'], 1, 0, 'L');
                     $pdf->Cell($w[1], 6, $value['label'], 1, 0, 'L');
                     $pdf->Cell($w[2], 6, $value['qty'], 1, 1, 'R');
                     if ($pdf->GetY() > 250) {
                         $this->_pagefoot($pdf, $object, $outputlangs);
                         $pdf->AddPage('P', 'A4');
                         $pdf->SetFont('', '', $default_font_size - 1);
                         $this->_pagehead($pdf, $object, 0, $outputlangs);
                         $pdf->SetY(40);
                         $num = count($header);
                         for ($i = 0; $i < $num; $i++) {
                             $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C');
                         }
                         $pdf->Ln();
                     }
                 }
                 $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;
             // Pas d'erreur
         } else {
             $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
             return 0;
         }
     }
     $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR");
     return 0;
 }
Example #5
0
    }
}
if ($action == 'setdate_livraison' && $user->rights->expedition->creer) {
    //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
    $datedelivery = dol_mktime($_POST['liv_hour'], $_POST['liv_min'], 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']);
    $object->fetch($id);
    $result = $object->set_date_livraison($user, $datedelivery);
    if ($result < 0) {
        $mesg = '<div class="error">' . $object->error . '</div>';
    }
}
// Action update description of emailing
if ($action == 'settrackingnumber' || $action == 'settrackingurl' || $action == 'settrueWeight' || $action == 'settrueWidth' || $action == 'settrueHeight' || $action == 'settrueDepth' || $action == 'setexpedition_method_id') {
    $error = 0;
    $shipping = new Expedition($db);
    $result = $shipping->fetch($id);
    if ($result < 0) {
        dol_print_error($db, $shipping->error);
    }
    if ($action == 'settrackingnumber') {
        $shipping->tracking_number = trim($_REQUEST["trackingnumber"]);
    }
    if ($action == 'settrackingurl') {
        $shipping->tracking_url = trim($_REQUEST["trackingurl"]);
    }
    if ($action == 'settrueWeight') {
        $shipping->trueWeight = trim($_REQUEST["trueWeight"]);
    }
    if ($action == 'settrueWidth') {
        $shipping->trueWidth = trim($_REQUEST["trueWidth"]);
    }
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
$langs->load("orders");
$langs->load("sendings");
$langs->load("companies");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'expedition', $id, '');
$object = new Expedition($db);
if ($id > 0 || !empty($ref)) {
    $object->fetch($id, $ref);
    $object->fetch_thirdparty();
    if (!empty($object->origin)) {
        $typeobject = $object->origin;
        $origin = $object->origin;
        $object->fetch_origin();
    }
    // Linked documents
    if ($typeobject == 'commande' && $object->{$typeobject}->id && !empty($conf->commande->enabled)) {
        $objectsrc = new Commande($db);
        $objectsrc->fetch($object->{$typeobject}->id);
    }
    if ($typeobject == 'propal' && $object->{$typeobject}->id && !empty($conf->propal->enabled)) {
        $objectsrc = new Propal($db);
        $objectsrc->fetch($object->{$typeobject}->id);
    }
Example #7
0
     print '<table width="100%" cellspacing="2"><tr><td width="50%" valign="top">';
     /*
      * Documents generated
      */
     $objectref = dol_sanitizeFileName($object->ref);
     $filedir = $conf->expedition->dir_output . "/receipt/" . $objectref;
     $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
     $genallowed = $user->rights->expedition->livraison->creer;
     $delallowed = $user->rights->expedition->livraison->supprimer;
     $somethingshown = $formfile->show_documents('livraison', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
     /*
      * Linked object block (of linked shipment)
      */
     if ($object->origin == 'expedition') {
         $shipment = new Expedition($db);
         $shipment->fetch($object->origin_id);
         $somethingshown = $shipment->showLinkedObjectBlock();
     }
     if ($genallowed && !$somethingshown) {
         $somethingshown = 1;
     }
     print '</td><td valign="top" width="50%">';
     // Rien a droite
     print '</td></tr></table>';
     if ($expedition->origin_id) {
         print '<br>';
         //show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id);
         show_list_sending_receive($expedition->origin, $expedition->origin_id);
     }
 } else {
     /* Expedition non trouvee */
 /**
  * 	Cree le bon de livraison depuis une expedition existante
  *
  *	@param	User	$user            Utilisateur qui cree
  *	@param  int		$sending_id      Id de l'expedition qui sert de modele
  *	@return	void
  */
 function create_from_sending($user, $sending_id)
 {
     $expedition = new Expedition($this->db);
     $result = $expedition->fetch($sending_id);
     $this->lines = array();
     $num = count($expedition->lines);
     for ($i = 0; $i < $num; $i++) {
         $line = new LivraisonLigne($this->db);
         $line->origin_line_id = $expedition->lines[$i]->origin_line_id;
         $line->libelle = $expedition->lines[$i]->libelle;
         $line->description = $expedition->lines[$i]->description;
         $line->qty = $expedition->lines[$i]->qty_shipped;
         $line->fk_product = $expedition->lines[$i]->fk_product;
         $line->ref = $expedition->lines[$i]->ref;
         $this->lines[$i] = $line;
     }
     $this->origin = $expedition->element;
     $this->origin_id = $expedition->id;
     $this->note_private = $expedition->note_private;
     $this->note_public = $expedition->note_public;
     $this->fk_project = $expedition->fk_project;
     $this->date_delivery = $expedition->date_delivery;
     $this->fk_delivery_address = $expedition->fk_delivery_address;
     $this->socid = $expedition->socid;
     $this->ref_customer = $expedition->ref_customer;
     return $this->create($user);
 }
Example #9
0
 /**
  *  Show top header of page.
  *
  *  @param	PDF			$pdf     		Object PDF
  *  @param  Object		$object     	Object to show
  *  @param  int	    	$showaddress    0=no, 1=yes
  *  @param  Translate	$outputlangs	Object lang for output
  *  @return	void
  */
 function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
 {
     global $conf, $langs, $hookmanager;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
     // Show Draft Watermark
     if ($object->statut == 0 && !empty($conf->global->COMMANDE_DRAFT_WATERMARK)) {
         pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
     }
     $pdf->SetTextColor(0, 0, 60);
     $pdf->SetFont('', 'B', $default_font_size + 3);
     $posy = $this->marge_haute;
     $posx = $this->page_largeur - $this->marge_droite - 100;
     $pdf->SetXY($this->marge_gauche, $posy);
     // Logo
     $logo = $conf->mycompany->dir_output . '/logos/' . $this->emetteur->logo;
     if ($this->emetteur->logo) {
         if (is_readable($logo)) {
             $height = pdf_getHeightForLogo($logo);
             $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
             // width=0 (auto)
         } else {
             $pdf->SetTextColor(200, 0, 0);
             $pdf->SetFont('', 'B', $default_font_size - 2);
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
             $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
         }
     } else {
         $pdf->MultiCell(100, 4, $this->emetteur->name, 0, 'L');
     }
     $pdf->SetFont('', 'B', $default_font_size + 2);
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DeliveryOrder") . " " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
     $pdf->SetFont('', '', $default_font_size + 2);
     $posy += 5;
     $pdf->SetXY($posx, $posy);
     $pdf->SetTextColor(0, 0, 60);
     if ($object->date_valid) {
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date") . " : " . dol_print_date($object->date_delivery, "%d %b %Y", false, $outputlangs, true), '', 'R');
     } else {
         $pdf->SetTextColor(255, 0, 0);
         $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DeliveryNotValidated"), '', 'R');
         $pdf->SetTextColor(0, 0, 60);
     }
     if ($object->client->code_client) {
         $posy += 5;
         $pdf->SetXY($posx, $posy);
         $pdf->SetTextColor(0, 0, 60);
         $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode") . " : " . $outputlangs->transnoentities($object->client->code_client), '', 'R');
     }
     $pdf->SetTextColor(0, 0, 60);
     $posy += 2;
     // Add list of linked orders on shipment
     // Currently not supported by pdf_writeLinkedObjects, link for delivery to order is done through shipment)
     if ($object->origin == 'expedition' || $object->origin == 'shipping') {
         $Yoff = $posy - 5;
         include_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
         $shipment = new Expedition($this->db);
         $shipment->fetch($object->origin_id);
         $origin = $shipment->origin;
         $origin_id = $shipment->origin_id;
         if ($conf->{$origin}->enabled) {
             $outputlangs->load('orders');
             $classname = ucfirst($origin);
             $linkedobject = new $classname($this->db);
             $result = $linkedobject->fetch($origin_id);
             if ($result >= 0) {
                 $pdf->SetFont('', '', $default_font_size - 2);
                 $text = $linkedobject->ref;
                 if ($linkedobject->ref_client) {
                     $text .= ' (' . $linkedobject->ref_client . ')';
                 }
                 $Yoff = $Yoff + 8;
                 $pdf->SetXY($this->page_largeur - $this->marge_droite - 100, $Yoff);
                 $pdf->MultiCell(100, 2, $outputlangs->transnoentities("RefOrder") . " : " . $outputlangs->transnoentities($text), 0, 'R');
                 $Yoff = $Yoff + 3;
                 $pdf->SetXY($this->page_largeur - $this->marge_droite - 60, $Yoff);
                 $pdf->MultiCell(60, 2, $outputlangs->transnoentities("OrderDate") . " : " . dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
             }
         }
         $posy = $Yoff;
     }
     // Show list of linked objects
     $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
     if ($showaddress) {
         // Sender properties
         $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur);
         // Show sender
         $posy = 42;
         $posx = $this->marge_gauche;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->page_largeur - $this->marge_droite - 80;
         }
         $hautcadre = 40;
         // 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("BillFrom") . ":", 0, 'L');
         $pdf->SetXY($posx, $posy);
         $pdf->SetFillColor(230, 230, 230);
         $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
         $pdf->SetTextColor(0, 0, 60);
         // Show sender name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
         $posy = $pdf->getY();
         // Show sender information
         $pdf->SetXY($posx + 2, $posy);
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
         // Client destinataire
         $posy = 42;
         $posx = 102;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx, $posy - 5);
         $pdf->MultiCell(80, 5, $outputlangs->transnoentities("DeliveryAddress") . ":", 0, 'L');
         // If SHIPPING contact defined on order, we use it
         $usecontact = false;
         $arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING');
         if (count($arrayidcontact) > 0) {
             $usecontact = true;
             $result = $object->fetch_contact($arrayidcontact[0]);
         }
         // Recipient name
         if (!empty($usecontact)) {
             // On peut utiliser le nom de la societe du contact
             if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
                 $socname = $object->contact->socname;
             } else {
                 $socname = $object->client->name;
             }
             $carac_client_name = $outputlangs->convToOutputCharset($socname);
         } else {
             $carac_client_name = $outputlangs->convToOutputCharset($object->client->name);
         }
         $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->client, $usecontact ? $object->contact : '', $usecontact, 'target');
         // Show recipient
         $widthrecbox = 100;
         if ($this->page_largeur < 210) {
             $widthrecbox = 84;
         }
         // To work with US executive format
         $posy = 42;
         $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
         if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
             $posx = $this->marge_gauche;
         }
         // Show recipient frame
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('', '', $default_font_size - 2);
         $pdf->SetXY($posx + 2, $posy - 5);
         //$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
         $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
         // Show recipient name
         $pdf->SetXY($posx + 2, $posy + 3);
         $pdf->SetFont('', 'B', $default_font_size);
         $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
         // Show recipient information
         $pdf->SetFont('', '', $default_font_size - 1);
         $pdf->SetXY($posx + 2, $posy + 4 + dol_nboflines_bis($carac_client_name, 50) * 4);
         $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
     }
     $pdf->SetTextColor(0, 0, 60);
 }
     print '<table width="100%" cellspacing="2"><tr><td width="50%" valign="top">';
     /*
      * Documents generated
      */
     $deliveryref = dol_sanitizeFileName($delivery->ref);
     $filedir = $conf->expedition->dir_output . "/receipt/" . $deliveryref;
     $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $delivery->id;
     $genallowed = $user->rights->expedition->livraison->creer;
     $delallowed = $user->rights->expedition->livraison->supprimer;
     $somethingshown = $formfile->show_documents('livraison', $deliveryref, $filedir, $urlsource, $genallowed, $delallowed, $delivery->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
     /*
      * Linked object block (of linked shipment)
      */
     if ($delivery->origin == 'expedition') {
         $shipment = new Expedition($db);
         $shipment->fetch($delivery->origin_id);
         $somethingshown = $shipment->showLinkedObjectBlock();
     }
     if ($genallowed && !$somethingshown) {
         $somethingshown = 1;
     }
     print '</td><td valign="top" width="50%">';
     // Rien a droite
     print '</td></tr></table>';
     if ($expedition->origin_id) {
         print '<br>';
         //show_list_sending_receive($expedition->origin,$expedition->origin_id," AND e.rowid <> ".$expedition->id);
         show_list_sending_receive($expedition->origin, $expedition->origin_id);
     }
 } else {
     /* Expedition non trouvee */
<?php

require 'config.php';
dol_include_once('/expedition/class/expedition.class.php');
dol_include_once('/dispatch/class/dispatchdetail.class.php');
dol_include_once('/product/class/html.formproduct.class.php');
dol_include_once('/core/lib/admin.lib.php');
dol_include_once('/core/lib/sendings.lib.php');
dol_include_once('/core/lib/product.lib.php');
dol_include_once('/asset/class/asset.class.php');
global $langs, $user, $db;
$langs->load('orders');
$PDOdb = new TPDOdb();
$id = GETPOST('id');
$expedition = new Expedition($db);
$expedition->fetch($id);
$action = GETPOST('action');
$TImport = _loadDetail($PDOdb, $expedition);
if (isset($_FILES['file1']) && $_FILES['file1']['name'] != '') {
    $f1 = file($_FILES['file1']['tmp_name']);
    $TImport = array();
    foreach ($f1 as $line) {
        list($ref, $numserie, $imei, $firmware) = str_getcsv($line, ';', '"');
        $TImport = _addExpeditiondetLine($PDOdb, $TImport, $expedition, $numserie);
    }
} else {
    if ($action == 'DELETE_LINE') {
        unset($TImport[(int) GETPOST('k')]);
        $rowid = GETPOST('rowid');
        $dispatchdetail = new TDispatchDetail();
        $dispatchdetail->load($PDOdb, $rowid);
            break;
        case -3:
            return "g";
            break;
        case 0:
            return "kg";
            break;
    }
}
if (isset($_REQUEST['modele'])) {
    //Récupération des parametres transmis
    $nbVides = !empty($_REQUEST['startpos']) ? $_REQUEST['startpos'] - 1 : 0;
    $nbCopies = !empty($_REQUEST['copie']) ? $_REQUEST['copie'] : 1;
    $modele = $_REQUEST['modele'];
    $expedition = new Expedition($db);
    $expedition->fetch($_REQUEST['expedition']);
    $expedition->fetch_lines();
    $TetiquettesVides = array();
    $Tetiquettes = array();
    //création des div vides
    for ($i = 0; $i < $nbVides; $i++) {
        $TetiquettesVides[$i] = array($i);
    }
    $TPDOdb = new TPDOdb();
    //création des div pleines
    foreach ($expedition->lines as $ligne) {
        $TPDOdb->Execute("SELECT rowid FROM " . MAIN_DB_PREFIX . "expeditiondet_asset WHERE fk_expeditiondet = " . $ligne->rowid);
        $TidExepeditiondetAsset = array();
        while ($TPDOdb->Get_line()) {
            $TidExepeditiondetAsset[] = $TPDOdb->Get_field('rowid');
        }
Example #13
0
 /**
  *	Fonction generant le bon de livraison sur le disque
  *
  *	@param	Object		$object   		Object livraison a generer
  *	@param	Translate	$outputlangs	Lang output object
  *	@return	int         				1 if OK, <=0 if KO
  */
 function write_file($object, $outputlangs)
 {
     global $user, $conf, $langs;
     $default_font_size = pdf_getPDFFontSize($outputlangs);
     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 (!empty($conf->global->MAIN_USE_FPDF)) {
         $outputlangs->charset_output = 'ISO-8859-1';
     }
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("bills");
     $outputlangs->load("products");
     $outputlangs->load("deliveries");
     $outputlangs->load("sendings");
     if ($conf->expedition->dir_output . "/receipt") {
         $object->fetch_thirdparty();
         $nblines = count($object->lines);
         $objectref = dol_sanitizeFileName($object->ref);
         $dir = $conf->expedition->dir_output . "/receipt";
         if (!preg_match('/specimen/i', $objectref)) {
             $dir .= "/" . $objectref;
         }
         $file = $dir . "/" . $objectref . ".pdf";
         if (!file_exists($dir)) {
             if (dol_mkdir($dir) < 0) {
                 $this->error = $langs->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));
             // Set path to the background PDF File
             if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
                 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output . '/' . $conf->global->MAIN_ADD_PDF_BACKGROUND);
                 $tplidx = $pdf->importPage(1);
             }
             // Complete object by loading several other informations
             $expedition = new Expedition($this->db);
             $result = $expedition->fetch($object->expedition_id);
             $commande = new Commande($this->db);
             if ($expedition->origin == 'commande') {
                 $commande->fetch($expedition->origin_id);
             }
             $object->commande = $commande;
             $pdf->Open();
             $pagenb = 0;
             $pdf->SetDrawColor(128, 128, 128);
             $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
             $pdf->SetSubject($outputlangs->transnoentities("DeliveryOrder"));
             $pdf->SetCreator("Dolibarr " . DOL_VERSION);
             $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
             $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
             $pdf->SetAutoPageBreak(1, 0);
             // New page
             $pdf->AddPage();
             if (!empty($tplidx)) {
                 $pdf->useTemplate($tplidx);
             }
             $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 = 100;
             $tab_top_newpage = 50;
             $tab_height = 140;
             $tab_height_newpage = 190;
             $iniY = $tab_top + 7;
             $curY = $tab_top + 7;
             $nexY = $tab_top + 7;
             for ($i = 0; $i < $nblines; $i++) {
                 $curY = $nexY;
                 $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, 100, 3, 30, $curY, 1);
                 //$pdf->writeHTMLCell(100, 3, 30, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // Dans boucle pour gerer multi-page
                 $nexY = $pdf->GetY();
                 $pdf->SetXY(10, $curY);
                 $pdf->MultiCell(20, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'C');
                 // TODO Field not yet saved in database
                 //$pdf->SetXY(133, $curY );
                 //$pdf->MultiCell(10, 5, $object->lines[$i]->tva_tx, 0, 'C');
                 $pdf->SetXY(145, $curY);
                 $pdf->MultiCell(10, 3, $object->lines[$i]->qty_shipped, 0, 'C');
                 // TODO Field not yet saved in database
                 //$pdf->SetXY(156, $curY );
                 //$pdf->MultiCell(20, 3, price($object->lines[$i]->price), 0, 'R', 0);
                 // TODO Field not yet saved in database
                 //$pdf->SetXY(174, $curY );
                 //$total = price($object->lines[$i]->price * $object->lines[$i]->qty_shipped);
                 //$pdf->MultiCell(26, 3, $total, 0, 'R', 0);
                 $pdf->line(10, $curY - 1, 200, $curY - 1);
                 $nexY += 2;
                 // Passe espace entre les lignes
                 // Cherche nombre de lignes a venir pour savoir si place suffisante
                 if ($i < $nblines - 1 && empty($hidedesc)) {
                     //on recupere la description du produit suivant
                     $follow_descproduitservice = $object->lines[$i + 1]->desc;
                     //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
                     $nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice, 52, $outputlangs->charset_output) * 4;
                 } else {
                     $nblineFollowDesc = 0;
                 }
                 // Test if a new page is required
                 if ($pagenb == 1) {
                     $tab_top_in_current_page = $tab_top;
                     $tab_height_in_current_page = $tab_height;
                 } else {
                     $tab_top_in_current_page = $tab_top_newpage;
                     $tab_height_in_current_page = $tab_height_newpage;
                 }
                 if ($nexY + $nblineFollowDesc > $tab_top_in_current_page + $tab_height_in_current_page && $i < $nblines - 1) {
                     if ($pagenb == 1) {
                         $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs);
                     } else {
                         $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
                     }
                     $this->_pagefoot($pdf, $object, $outputlangs);
                     // New page
                     $pdf->AddPage();
                     $pagenb++;
                     $this->_pagehead($pdf, $object, 0, $outputlangs);
                     $pdf->SetFont('', '', $default_font_size - 1);
                     $pdf->MultiCell(0, 3, '');
                     // Set interline to 3
                     $pdf->SetTextColor(0, 0, 0);
                     $nexY = $tab_top_newpage + 7;
                 }
             }
             // Show square
             if ($pagenb == 1) {
                 $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
                 $bottomlasttab = $tab_top + $tab_height + 1;
             } else {
                 $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
                 $bottomlasttab = $tab_top_newpage + $tab_height_newpage + 1;
             }
             /*
              * 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("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR");
         return 0;
     }
 }
// Security check
$socid = '';
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, $origin, $origin_id);
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
//PDF
$hidedetails = GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0);
$hidedesc = GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0);
$hideref = GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0);
$object = new Expedition($db);
// Load object
if ($id > 0 || !empty($ref)) {
    $ret = $object->fetch($id, $ref);
}
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('expeditioncard'));
/*
 * Actions
 */
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
// Note that $action and $object may have been modified by some hooks
if ($action == 'add') {
    $error = 0;
    $db->begin();
    $object->note = GETPOST('note', 'alpha');
    $object->origin = $origin;
    $object->origin_id = $origin_id;