public static function FromDatabase(array $row) { $expedition = new Expedition(); $fleet = ShipFleet::FromDatabaseByID($row['fleetID']); $expedition->Fleet($fleet); $coordinates = new Coordinates($row['galaxy_position'], $row['system_position'], $row['planet_position']); $expedition->Target($coordinates); $expedition->ScheduledTime($row['scheduled_time']); return $expedition; }
public function initContent() { $admin_seur = new AdminSeur(false); if (!$admin_seur->module_enabled_and_configured) { $admin_seur->displayModuleConfigurationWarning(); $this->content = $admin_seur->content; return parent::initContent(); } $this->display = 'view'; $this->module_instance = Module::getInstanceByName('seur'); Context::getContext()->controller->addJqueryUI('ui.datepicker'); if (Tools::getValue('verDetalle')) { $response = Expedition::getExpeditions($admin_seur->getExpeditionData()); $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries($response, true)); } elseif (Tools::getValue('createPickup')) { $error_response = Pickup::createPickup(); if (!empty($error_response)) { $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries(null, null, $error_response)); } else { $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries()); } } elseif (Tools::getValue('submitFilter')) { $response = Expedition::getExpeditions($admin_seur->getExpeditionData()); $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries($response, false)); } else { $this->tpl_view_vars = array('datos' => $admin_seur->displayFormDeliveries()); } $this->content = $admin_seur->content; $this->fields_list = $admin_seur->fields_list; parent::initContent(); }
/** * * @param unknown $object */ static function createShippingFromOrderOnBillPayed(&$object) { global $conf, $langs, $db, $user; if (empty($conf->global->GRAPEFRUIT_SHIPPING_CREATE_FROM_ORDER_WHERE_BILL_PAID) || $object->element != 'facture') { return true; } if (empty($object->linked_objects)) { $object->fetchObjectLinked(null, null, $object->id, 'facture'); } if (empty($object->linkedObjects['commande'])) { return false; } dol_include_once('/expedition/class/expedition.class.php'); $TNotCopy = array('db', 'element', 'table_element', 'fk_element'); foreach ($object->linkedObjects['commande'] as &$commande) { $expedition = new Expedition($db); foreach ($commande as $k => $v) { if (!in_array($k, $TNotCopy)) { $expedition->{$k} = $commande->{$k}; } } $expedition->tracking_number = ''; $expedition->size = 0; $expedition->weight = 0; $expedition->sizeS = $expedition->sizeH = $expedition->sizeW = 0; // TODO Should use this->trueDepth $expedition->width = 0; $expedition->height = 0; $expedition->weight_units = 0; $expedition->size_units = 0; if (empty($conf->global->GRAPEFRUIT_SHIPPING_CREATE_FROM_ORDER_WHERE_BILL_PAID_WAREHOUSE)) { setEventMessage($langs->trans('DefaultWarehouseRequired')); return false; } foreach ($expedition->lines as &$line) { $line->entrepot_id = (int) $conf->global->GRAPEFRUIT_SHIPPING_CREATE_FROM_ORDER_WHERE_BILL_PAID_WAREHOUSE; $line->origin_line_id = $line->id; } $res = $expedition->create($user); if ($res > 0) { $expedition->add_object_linked($commande->element, $commande->id); setEventMessage($langs->trans('ShippingCreated')); } else { var_dump($expedition); exit; } } return true; }
$form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); $product_static = new Product($db); if ($action == 'setdate_livraison' && $user->rights->expedition->creer) { //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); $object->fetch($id); $result = $object->set_date_livraison($user, $datedelivery); if ($result < 0) { $mesg = '<div class="error">' . $object->error . '</div>'; } } else { if ($action == 'settrackingnumber' || $action == 'settrackingurl' || $action == 'settrueWeight' || $action == 'settrueWidth' || $action == 'settrueHeight' || $action == 'settrueDepth' || $action == 'setshipping_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(GETPOST('trackingnumber', 'alpha')); } if ($action == 'settrackingurl') { $shipping->tracking_url = trim(GETPOST('trackingurl', 'int')); } if ($action == 'settrueWeight') { $shipping->trueWeight = trim(GETPOST('trueWeight', 'int')); } if ($action == 'settrueWidth') { $shipping->trueWidth = trim(GETPOST('trueWidth', 'int'));
$element = $subelement = 'contrat'; } 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) {
/** * 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; }
} } /* * View */ llxHeader('', $langs->trans('Sending'), 'Expedition'); $html = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); /********************************************************************* * * Mode creation * *********************************************************************/ if ($action == 'create') { $expe = new Expedition($db); print_fiche_titre($langs->trans("CreateASending")); if (!$origin) { $mesg = '<div class="error">' . $langs->trans("ErrorBadParameters") . '</div>'; } if ($mesg) { print $mesg . '<br>'; } if ($origin) { $classname = ucfirst($origin); $object = new $classname($db); if ($object->fetch($origin_id)) { //var_dump($object); $soc = new Societe($db); $soc->fetch($object->socid); $author = new User($db);
/** * 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; }
print "\n"; 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 {
$langs->load('deliveries'); $langs->load('orders'); $langs->load('stocks'); $langs->load('other'); $langs->load('propal'); $id = GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int'); // For backward compatibility $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); // Security check $socid = ''; if ($user->societe_id) { $socid = $user->societe_id; } $result = restrictedArea($user, $origin, $origin_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);
public function initContent() { $this->display = 'view'; if (Tools::getValue('verDetalle')) { $response = Expedition::getExpeditions($this->getExpeditionData()); $this->tpl_view_vars = array('datos' => $this->displayFormDeliveries($response, true)); } elseif (Tools::getValue('createPickup')) { $error_response = Pickup::createPickup(); if (!empty($error_response)) { $this->tpl_view_vars = array('datos' => $this->displayFormDeliveries(null, null, $error_response)); } else { $this->tpl_view_vars = array('datos' => $this->displayFormDeliveries()); } } elseif (Tools::getValue('submitFilter')) { $response = Expedition::getExpeditions($this->getExpeditionData()); $this->tpl_view_vars = array('datos' => $this->displayFormDeliveries($response, false)); } else { $this->tpl_view_vars = array('datos' => $this->displayFormDeliveries()); } }
/** * 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; } }
print '<td align="right" style="min-width: 60px" class="nowrap">' . $commande_static->LibStatut($objp->fk_statut, $objp->facture, 5) . '</td></tr>'; $i++; } $db->free($resql); if ($num > 0) { print "</table>"; } } else { dol_print_error($db); } } /* * Last sendings */ if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) { $sendingstatic = new Expedition($db); $sql = 'SELECT e.rowid as id'; $sql .= ', e.ref'; $sql .= ', e.date_creation'; $sql .= ', e.fk_statut as statut'; $sql .= ', s.nom'; $sql .= ', s.rowid as socid'; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "expedition as e"; $sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = " . $object->id; $sql .= " AND e.entity IN (" . getEntity('expedition', 1) . ")"; $sql .= ' GROUP BY e.rowid'; $sql .= ', e.ref'; $sql .= ', e.date_creation'; $sql .= ', e.fk_statut'; $sql .= ', s.nom'; $sql .= ', s.rowid';
/** * testExpeditionBuild * * @return int */ public function testExpeditionBuild() { global $conf,$user,$langs,$db; $conf=$this->savconf; $user=$this->savuser; $langs=$this->savlangs; $db=$this->savdb; $conf->expedition->dir_output.='/temp'; $localobject=new Expedition($this->savdb); $localobject->initAsSpecimen(); // Soleil $localobject->modelpdf='merou'; $result=expedition_pdf_create($db, $localobject, $localobject->modelpdf, $langs); $this->assertLessThan($result, 0); print __METHOD__." result=".$result."\n"; // Soleil $localobject->modelpdf='rouget'; $result=expedition_pdf_create($db, $localobject, $localobject->modelpdf, $langs); $this->assertLessThan($result, 0); print __METHOD__." result=".$result."\n"; return 0; }
/** * Création automatique des expéditions à partir de la liste des expédiables, uniquement avec les quantité expédiables */ function createShipping($TIDCommandes, $TEnt_comm) { global $user, $langs, $conf; $db =& $this->db; dol_include_once('/expedition/class/expedition.class.php'); dol_include_once('/core/modules/expedition/modules_expedition.php'); // Option pour la génération PDF $hidedetails = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0; $hidedesc = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0; $hideref = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0; $nbShippingCreated = 0; if (count($TIDCommandes) > 0) { $TIDCommandes = $this->orderCommandeByClient($TIDCommandes); foreach ($TIDCommandes as $id_commande) { $this->isOrderShippable($id_commande); $shipping = new Expedition($db); $shipping->origin = 'commande'; $shipping->origin_id = $id_commande; $shipping->date_delivery = $this->order->date_livraison; $shipping->note_public = $this->order->note_public; $shipping->note_private = $this->order->note_private; $shipping->weight_units = 0; $shipping->weight = "NULL"; $shipping->sizeW = "NULL"; $shipping->sizeH = "NULL"; $shipping->sizeS = "NULL"; $shipping->size_units = 0; $shipping->socid = $this->order->socid; $shipping->modelpdf = !empty($conf->global->SHIPPABLEORDER_GENERATE_SHIPMENT_PDF) ? $conf->global->SHIPPABLEORDER_GENERATE_SHIPMENT_PDF : 'rouget'; foreach ($this->order->lines as $line) { if ($this->TlinesShippable[$line->id]['stock'] > 0) { $shipping->addline($TEnt_comm[$this->order->id], $line->id, $this->TlinesShippable[$line->id]['qty_shippable'] > $this->TlinesShippable[$line->id]['to_ship'] ? $this->TlinesShippable[$line->id]['to_ship'] : $this->TlinesShippable[$line->id]['qty_shippable']); } } $nbShippingCreated++; $shipping->create($user); // Valider l'expédition if (!empty($conf->global->SHIPPABLE_ORDER_AUTO_VALIDATE_SHIPPING)) { $shipping->statut = 0; $shipping->valid($user); } // Génération du PDF if (!empty($conf->global->SHIPPABLEORDER_GENERATE_SHIPMENT_PDF)) { $TFiles[] = $this->shipment_generate_pdf($shipping, $hidedetails, $hidedesc, $hideref); } } if ($nbShippingCreated > 0) { if ($conf->global->SHIPPABLEORDER_GENERATE_SHIPMENT_PDF) { $this->generate_global_pdf($TFiles); } setEventMessage($langs->trans('NbShippingCreated', $nbShippingCreated)); $dol_version = (double) DOL_VERSION; if ($conf->global->SHIPPABLE_ORDER_DISABLE_AUTO_REDIRECT) { header("Location: " . $_SERVER["PHP_SELF"]); } else { if ($dol_version <= 3.6) { header("Location: " . dol_buildpath('/expedition/liste.php', 2)); } else { header("Location: " . dol_buildpath('/expedition/list.php', 2)); } exit; } } else { setEventMessage($langs->trans('NoOrderSelectedOrAlreadySent'), 'warnings'); $dol_version = (double) DOL_VERSION; if ($conf->global->SHIPPABLE_ORDER_DISABLE_AUTO_REDIRECT) { header("Location: " . $_SERVER["PHP_SELF"]); } else { if ($dol_version <= 3.6) { header("Location: " . dol_buildpath('/expedition/liste.php', 2)); } else { header("Location: " . dol_buildpath('/expedition/list.php', 2)); } exit; } } } else { setEventMessage($langs->trans('NoOrderSelectedOrAlreadySent'), 'warnings'); $dol_version = (double) DOL_VERSION; if ($conf->global->SHIPPABLE_ORDER_DISABLE_AUTO_REDIRECT) { header("Location: " . $_SERVER["PHP_SELF"]); } else { if ($dol_version <= 3.6) { header("Location: " . dol_buildpath('/expedition/liste.php', 2)); } else { header("Location: " . dol_buildpath('/expedition/list.php', 2)); } exit; } } }
} elseif ($tmp == 'NotConfigured') { print $langs->trans($tmp); } else { print $tmp; } print '</td>' . "\n"; print '<td align="center">'; if ($conf->global->EXPEDITION_ADDON_NUMBER == "{$file}") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmodel&value=' . $file . '&scandir=' . $module->scandir . '&label=' . urlencode($module->name) . '">'; print img_picto($langs->trans("Disabled"), 'switch_off'); print '</a>'; } print '</td>'; $expedition = new Expedition($db); $expedition->initAsSpecimen(); // Info $htmltooltip = ''; $htmltooltip .= '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>'; $nextval = $module->getNextValue($mysoc, $expedition); if ("{$nextval}" != $langs->trans("NotAvailable")) { $htmltooltip .= '' . $langs->trans("NextValue") . ': '; if ($nextval) { $htmltooltip .= $nextval . '<br>'; } else { $htmltooltip .= $langs->trans($module->error) . '<br>'; } } print '<td align="center">'; print $form->textwithpicto('', $htmltooltip, 1, 0);
/** * Create a document onto disk according to template module. * * @param DoliDB $db Objet base de donnee * @param Object $object Object expedition * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs Objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref * @return int 1 if OK -1 if KO * @deprecated Use the new function generateDocument of Expedition class */ function expedition_pdf_create(DoliDB $db, Expedition $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); }
/** * Create a document onto disk according to template module. * * @param DoliDB $db Objet base de donnee * @param Object $object Object expedition * @param string $modele Force le modele a utiliser ('' to not force) * @param Translate $outputlangs Objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref * @return int 1 if OK -1 if KO * @deprecated Use the new function generateDocument of Expedition class * @see Expedition::generateDocument() */ function expedition_pdf_create(DoliDB $db, Expedition $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); }
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/sendings.lib.php'; 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);
return "mg"; 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');
/** * List sendings and receive receipts * * @param string $origin Origin ('commande', ...) * @param int $origin_id Origin id * @param string $filter Filter * @return int <0 if KO, >0 if OK */ function show_list_sending_receive($origin, $origin_id, $filter = '') { global $db, $conf, $langs, $bc; global $form; $product_static = new Product($db); $expedition = new Expedition($db); $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end"; $sql .= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line"; $sql .= ", e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,"; //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,"; $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; $sql .= ' p.description as product_desc'; $sql .= " FROM " . MAIN_DB_PREFIX . "expeditiondet as ed"; $sql .= ", " . MAIN_DB_PREFIX . "expedition as e"; $sql .= ", " . MAIN_DB_PREFIX . $origin . "det as obj"; //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON obj.fk_product = p.rowid"; $sql .= " WHERE e.entity = " . $conf->entity; $sql .= " AND obj.fk_" . $origin . " = " . $origin_id; $sql .= " AND obj.rowid = ed.fk_origin_line"; $sql .= " AND ed.fk_expedition = e.rowid"; if ($filter) { $sql .= $filter; } $sql .= " ORDER BY obj.fk_product"; dol_syslog("show_list_sending_receive sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { if ($filter) { print_titre($langs->trans("OtherSendingsForSameOrder")); } else { print_titre($langs->trans("SendingsAndReceivingForSameOrder")); } print '<table class="liste" width="100%">'; print '<tr class="liste_titre">'; //print '<td align="left">'.$langs->trans("QtyOrdered").'</td>'; print '<td align="left">' . $langs->trans("SendingSheet") . '</td>'; print '<td align="left">' . $langs->trans("Description") . '</td>'; print '<td align="center">' . $langs->trans("DateCreation") . '</td>'; print '<td align="center">' . $langs->trans("DateDeliveryPlanned") . '</td>'; print '<td align="center">' . $langs->trans("QtyShipped") . '</td>'; if ($conf->livraison_bon->enabled) { print '<td>' . $langs->trans("DeliveryOrder") . '</td>'; //print '<td align="center">'.$langs->trans("QtyReceived").'</td>'; print '<td align="right">' . $langs->trans("DeliveryDate") . '</td>'; } print "</tr>\n"; $var = True; while ($i < $num) { $var = !$var; $objp = $db->fetch_object($resql); print "<tr " . $bc[$var] . ">"; // Sending id print '<td align="left" class="nowrap"><a href="' . DOL_URL_ROOT . '/expedition/fiche.php?id=' . $objp->expedition_id . '">' . img_object($langs->trans("ShowSending"), 'sending') . ' ' . $objp->exp_ref . '<a></td>'; // Description if ($objp->fk_product > 0) { // Define output language if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object = new $origin($db); $object->fetch($origin_id); $object->fetch_thirdparty(); $prod = new Product($db); $prod->id = $objp->fk_product; $prod->getMultiLangs(); $outputlangs = $langs; $newlang = ''; if (empty($newlang) && !empty($_REQUEST['lang_id'])) { $newlang = $_REQUEST['lang_id']; } if (empty($newlang)) { $newlang = $object->client->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $label = !empty($prod->multilangs[$outputlangs->defaultlang]["label"]) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; } else { $label = !empty($objp->label) ? $objp->label : $objp->product_label; } print '<td>'; // Show product and description $product_static->type = $objp->fk_product_type; $product_static->id = $objp->fk_product; $product_static->ref = $objp->ref; $text = $product_static->getNomUrl(1); $text .= ' - ' . $label; $description = !empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description); print $form->textwithtooltip($text, $description, 3, '', '', $i); // Show range print_date_range($objp->date_start, $objp->date_end); // Add description in form if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { print !empty($objp->description) && $objp->description != $objp->product ? '<br>' . dol_htmlentitiesbr($objp->description) : ''; } print '</td>'; } else { print "<td>"; if ($objp->fk_product_type == 1) { $text = img_object($langs->trans('Service'), 'service'); } else { $text = img_object($langs->trans('Product'), 'product'); } if (!empty($objp->label)) { $text .= ' <strong>' . $objp->label . '</strong>'; print $form->textwithtooltip($text, $objp->description, 3, '', '', $i); } else { print $text . ' ' . nl2br($objp->description); } // Show range print_date_range($objp->date_start, $objp->date_end); print "</td>\n"; } //print '<td align="center">'.$objp->qty_asked.'</td>'; // Date creation print '<td align="center" class="nowrap">' . dol_print_date($db->jdate($objp->date_creation), 'day') . '</td>'; // Date shipping creation print '<td align="center" class="nowrap">' . dol_print_date($db->jdate($objp->date_delivery), 'day') . '</td>'; // Qty shipped print '<td align="center">' . $objp->qty_shipped . '</td>'; // Informations on receipt if (!empty($conf->livraison_bon->enabled)) { include_once DOL_DOCUMENT_ROOT . '/livraison/class/livraison.class.php'; $expedition->id = $objp->sendingid; $expedition->fetchObjectLinked($expedition->id, $expedition->element); //var_dump($expedition->linkedObjects); $receiving = !empty($expedition->linkedObjects['delivery'][0]) ? $expedition->linkedObjects['delivery'][0] : ''; if (!empty($receiving)) { // $expedition->fk_origin_line = id of det line of order // $receiving->fk_origin_line = id of det line of order // $receiving->origin may be 'shipping' // $receiving->origin_id may be id of shipping // Ref print '<td>'; print $receiving->getNomUrl($db); //print '<a href="'.DOL_URL_ROOT.'/livraison/fiche.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>'; print '</td>'; // Qty received //print '<td align="center">'; // TODO No solution for the moment to link a line det of receipt with a line det of shipping, // so no way to know the qty received for this line of shipping. //print $langs->trans("FeatureNotYetAvailable"); //print '</td>'; // Date shipping real print '<td align="right">'; print dol_print_date($receiving->date_delivery, 'day'); print '</td>'; } else { //print '<td> </td>'; print '<td> </td>'; print '<td> </td>'; } } print '</tr>'; $i++; } print '</table>'; } $db->free($resql); } else { dol_print_error($db); } return 1; }
<?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);
/** * \file htdocs/expedition/index.php * \ingroup expedition * \brief Home page of shipping area. */ require '../main.inc.php'; require DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; require DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; $langs->load("orders"); $langs->load("sendings"); /* * View */ $orderstatic = new Commande($db); $companystatic = new Societe($db); $shipment = new Expedition($db); $helpurl = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones'; llxHeader('', $langs->trans("Shipment"), $helpurl); print load_fiche_titre($langs->trans("SendingsArea")); print '<div class="fichecenter"><div class="fichethirdleft">'; $var = false; print '<form method="post" action="list.php">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<table class="noborder nohover" width="100%">'; print '<tr class="liste_titre"><td colspan="3">' . $langs->trans("SearchASending") . '</td></tr>'; print '<tr ' . $bc[$var] . '><td>'; print $langs->trans("Ref") . ':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td><td><input type="submit" value="' . $langs->trans("Search") . '" class="button"></td></tr>'; print "</table></form><br>\n"; /* * Shipments to validate */
/** * 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); }
*/ llxHeader('', $langs->trans('Shipment'), 'Expedition'); $form = new Form($db); $formfile = new FormFile($db); $formproduct = new FormProduct($db); $product_static = new Product($db); if ($action == 'create2') { print load_fiche_titre($langs->trans("CreateASending")) . '<br>'; print $langs->trans("ShipmentCreationIsDoneFromOrder"); $action = ''; $id = ''; $ref = ''; } // Mode creation. if ($action == 'create') { $expe = new Expedition($db); print load_fiche_titre($langs->trans("CreateASending")); if (!$origin) { setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors'); } if ($origin) { $classname = ucfirst($origin); $object = new $classname($db); if ($object->fetch($origin_id)) { //var_dump($object); $soc = new Societe($db); $soc->fetch($object->socid); $author = new User($db); $author->fetch($object->user_author_id); if (!empty($conf->stock->enabled)) { $entrepot = new Entrepot($db);
/** * Define array with couple substitution key => substitution value * * @param Expedition $object Main object to use as data source * @param Translate $outputlangs Lang object to use for output * @param array_key $array_key Name of the key for return array * @return array Array of substitution */ function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object') { global $conf; dol_include_once('/core/lib/product.lib.php'); $object->list_delivery_methods($object->shipping_method_id); $calculatedVolume = $object->trueWidth * $object->trueHeight * $object->trueDepth; $array_shipment = array($array_key . '_id' => $object->id, $array_key . '_ref' => $object->ref, $array_key . '_ref_ext' => $object->ref_ext, $array_key . '_ref_customer' => $object->ref_customer, $array_key . '_date_delivery' => dol_print_date($object->date_delivery, 'day'), $array_key . '_hour_delivery' => dol_print_date($object->date_delivery, 'hour'), $array_key . '_date_creation' => dol_print_date($object->date_creation, 'day'), $array_key . '_total_ht' => price($object->total_ht), $array_key . '_total_vat' => price($object->total_tva), $array_key . '_total_ttc' => price($object->total_ttc), $array_key . '_total_discount_ht' => price($object->getTotalDiscount()), $array_key . '_note_private' => $object->note_private, $array_key . '_note' => $object->note_public, $array_key . '_tracking_number' => $object->tracking_number, $array_key . '_tracking_url' => $object->tracking_url, $array_key . '_shipping_method' => $object->listmeths[0]['libelle'], $array_key . '_weight' => $object->trueWeight . ' ' . measuring_units_string($object->weight_units, 'weight'), $array_key . '_width' => $object->trueWidth . ' ' . measuring_units_string($object->width_units, 'size'), $array_key . '_height' => $object->trueHeight . ' ' . measuring_units_string($object->height_units, 'size'), $array_key . '_depth' => $object->trueDepth . ' ' . measuring_units_string($object->depth_units, 'size'), $array_key . '_size' => $calculatedVolume . ' ' . measuring_units_string(0, 'volume')); // Add vat by rates foreach ($object->lines as $line) { if (empty($array_shipment[$array_key . '_total_vat_' . $line->tva_tx])) { $array_shipment[$array_key . '_total_vat_' . $line->tva_tx] = 0; } $array_shipment[$array_key . '_total_vat_' . $line->tva_tx] += $line->total_tva; } // Retrieve extrafields /*if(is_array($object->array_options) && count($object->array_options)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('shipment',true); $object->fetch_optionals($object->id,$extralabels); $array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs); }*/ return $array_shipment; }
if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND e.fk_soc = sc.fk_soc"; $sql .= " AND sc.fk_user = "******" AND e.fk_soc = " . $socid; } if (GETPOST('sf_ref', 'alpha')) { $sql .= " AND e.ref like '%" . $db->escape(GETPOST('sf_ref', 'alpha')) . "%'"; } $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $expedition = new Expedition($db); $param = "&socid={$socid}"; print_barre_liste($langs->trans('ListOfSendings'), $page, "liste.php", $param, $sortfield, $sortorder, '', $num); $i = 0; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print_liste_field_titre($langs->trans("Ref"), "liste.php", "e.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Company"), "liste.php", "s.nom", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("DateDeliveryPlanned"), "liste.php", "e.date_delivery", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("DateReceived"), "liste.php", "e.date_expedition", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Status"), "liste.php", "e.fk_statut", "", $param, 'align="right"', $sortfield, $sortorder); print "</tr>\n"; $var = True; while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); $var = !$var;
public function hookOrderDetailDisplayed($params) { if (Configuration::get('SEUR_Configured') == 1) { $seur_carriers = SeurLib::getSeurCarriers(false); $ids_seur_carriers = array(); foreach ($seur_carriers as $value) { $ids_seur_carriers[] = (int) $value['id']; } $order = new Order((int) $params['order']->id); if (!Validate::isLoadedObject($order)) { return false; } if (in_array((int) $order->id_carrier, $ids_seur_carriers)) { $referencia = sprintf('%06d', (int) $order->id); $datos = array(); $datos['reference_number'] = $referencia; $response = Expedition::getExpeditions($datos); $string_xml = htmlspecialchars_decode($response->out); $xml = simplexml_load_string($string_xml); $seur_order_state = $xml->EXPEDICION->DESCRIPCION_PARA_CLIENTE; $this->context->smarty->assign(array('logo' => $this->_path . 'img/logo.png', 'reference' => $datos['reference_number'], 'delivery' => (string) $xml->EXPEDICION->EXPEDICION_NUM, 'seur_order_state' => !empty($seur_order_state) ? (string) $seur_order_state : $this->l('Sin estado'), 'date' => (string) $xml->EXPEDICION->FECHA_CAPTURA)); return $this->display(__FILE__, 'views/templates/hook/orderDetail.tpl'); } } }
} } 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');
/** * 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); }