/** * Prepare array with list of tabs * * @param Donation $object Donation * @return array Array of tabs to show */ function donation_prepare_head($object) { global $db, $langs, $conf; $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT . '/don/card.php?id=' . $object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation'); require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $upload_dir = $conf->don->dir_output . '/' . get_exdir($filename, 2, 0, 1, $object, 'donation') . '/' . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT . '/don/document.php?id=' . $object->id; $head[$h][1] = $langs->trans('Documents'); if ($nbFiles + $nbLinks > 0) { $head[$h][1] .= ' <span class="badge">' . ($nbFiles + $nbLinks) . '</span>'; } $head[$h][2] = 'documents'; $h++; $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove'); return $head; }
/** * Prepare array with list of tabs * * @param Object $object Object related to tabs * @return array Array of tabs to show */ function facturefourn_prepare_head($object) { global $db, $langs, $conf; $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT . '/fourn/facture/card.php?facid=' . $object->id; $head[$h][1] = $langs->trans('CardBill'); $head[$h][2] = 'card'; $h++; if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $head[$h][0] = DOL_URL_ROOT . '/fourn/facture/contact.php?facid=' . $object->id; $head[$h][1] = $langs->trans('ContactsAddresses'); $head[$h][2] = 'contact'; $h++; } // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_invoice'); if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { $nbNote = 0; if (!empty($object->note_private)) { $nbNote++; } if (!empty($object->note_public)) { $nbNote++; } $head[$h][0] = DOL_URL_ROOT . '/fourn/facture/note.php?facid=' . $object->id; $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) { $head[$h][1] .= ' <span class="badge">' . $nbNote . '</span>'; } $head[$h][2] = 'note'; $h++; } require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $upload_dir = $conf->fournisseur->facture->dir_output . '/' . get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier') . $object->ref; $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT . '/fourn/facture/document.php?facid=' . $object->id; $head[$h][1] = $langs->trans('Documents'); if ($nbFiles + $nbLinks > 0) { $head[$h][1] .= ' <span class="badge">' . ($nbFiles + $nbLinks) . '</span>'; } $head[$h][2] = 'documents'; $h++; $head[$h][0] = DOL_URL_ROOT . '/fourn/facture/info.php?facid=' . $object->id; $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++; complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_invoice', 'remove'); return $head; }
/** * Function to build pdf onto disk * * @param Object $object Object to generate * @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=OK, 0=KO */ function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $user, $langs, $conf, $mysoc, $db, $hookmanager; 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"); $nblignes = count($object->lines); // Loop on each lines to detect if there is at least one image to show $realpatharray = array(); if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE)) { for ($i = 0; $i < $nblignes; $i++) { if (empty($object->lines[$i]->fk_product)) { continue; } $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product . "/photos/"; $dir = $conf->product->dir_output . '/' . $pdir; $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { $filename = $obj['photo']; //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette']; $realpath = $dir . $filename; break; } if ($realpath) { $realpatharray[$i] = $realpath; } } } if (count($realpatharray) == 0) { $this->posxpicture = $this->posxtva; } if ($conf->facture->dir_output) { $object->fetch_thirdparty(); $deja_regle = $object->getSommePaiement(); $amount_credit_notes_included = $object->getSumCreditNotesUsed(); $amount_deposits_included = $object->getSumDepositsUsed(); // Definition of $dir and $file if ($object->specimen) { $dir = $conf->facture->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->facture->dir_output . "/" . $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)) { // Add pdfgeneration hook if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); // Create pdf instance $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5; // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1, 0); 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); } $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Invoice")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Invoice")); if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { $pdf->SetCompression(false); } $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // Positionne $this->atleastonediscount si on a au moins une remise for ($i = 0; $i < $nblignes; $i++) { if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } } if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS)) { $this->posxpicture += $this->postotalht - $this->posxdiscount; $this->posxtva += $this->postotalht - $this->posxdiscount; $this->posxup += $this->postotalht - $this->posxdiscount; $this->posxqty += $this->postotalht - $this->posxdiscount; $this->posxdiscount += $this->postotalht - $this->posxdiscount; //$this->postotalht; } // Situation invoice handling if ($object->situation_cycle_ref) { $this->situationinvoice = True; $progress_width = 14; $this->posxtva -= $progress_width; $this->posxup -= $progress_width; $this->posxqty -= $progress_width; $this->posxdiscount -= $progress_width; $this->posxprogress -= $progress_width; } // 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 = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10; $tab_height = 130; $tab_height_newpage = 150; // Incoterm $height_incoterms = 0; if ($conf->incoterm->enabled) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms = $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_incoterms + 1); $tab_top = $nexY + 6; $height_incoterms += 4; } } // Affiche notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep if (is_object($object->thirdparty)) { $salereparray = $object->thirdparty->getSalesRepresentatives($user); $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); if (!empty($salerepobj->signature)) { $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } } if ($notetoshow) { $tab_top = 88 + $height_incoterms; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 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; // Loop on each lines for ($i = 0; $i < $nblignes; $i++) { $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it $imglinesize = array(); if (!empty($realpatharray[$i])) { $imglinesize = pdf_getSizeForImage($realpatharray[$i]); } $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore = $pdf->getPage(); $showpricebeforepagebreak = 1; $posYAfterImage = 0; $posYAfterDescription = 0; // We start with Photo of product line if (isset($imglinesize['width']) && isset($imglinesize['height']) && $curY + $imglinesize['height'] > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) { $pdf->AddPage('', '', true); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; $showpricebeforepagebreak = 0; } if (isset($imglinesize['width']) && isset($imglinesize['height'])) { $curX = $this->posxpicture - 1; $pdf->Image($realpatharray[$i], $curX + ($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2, $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually $posYAfterImage = $curY + $imglinesize['height']; } // Description of product line $curX = $this->posxdesc - 1; $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) { $pdf->rollbackTransaction(true); $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; if ($posyafter > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)) { if ($i == $nblignes - 1) { $pdf->AddPage('', '', true); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } $pdf->setPage($pageposafter + 1); } } else { // We found a page break $showpricebeforepagebreak = 0; } } else { $pdf->commitTransaction(); } $posYAfterDescription = $pdf->GetY(); $nexY = $pdf->GetY(); $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut // VAT Rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 3, $vat_rate, 0, 'R'); } // Unit price before discount $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0); // Quantity $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); // Enough for 6 chars if ($conf->global->PRODUCT_USE_UNITS) { $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); } else { $pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R'); } // Unit if ($conf->global->PRODUCT_USE_UNITS) { $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $pdf->SetXY($this->posxunit, $curY); $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L'); } // Discount on line if ($object->lines[$i]->remise_percent) { $pdf->SetXY($this->posxdiscount - 2, $curY); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R'); } if ($this->situationinvoice) { // Situation progress $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxprogress, $curY); $pdf->MultiCell($this->postotalht - $this->posxprogress, 3, $progress, 0, 'R'); } // Total HT line $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $prev_progress = $object->lines[$i]->get_prev_progress(); if ($prev_progress > 0) { if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { $tvaligne = $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; } else { $tvaligne = $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; } } else { if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { $tvaligne = $object->lines[$i]->multicurrency_total_tva; } else { $tvaligne = $object->lines[$i]->total_tva; } } $localtax1ligne = $object->lines[$i]->total_localtax1; $localtax2ligne = $object->lines[$i]->total_localtax2; $localtax1_rate = $object->lines[$i]->localtax1_tx; $localtax2_rate = $object->lines[$i]->localtax2_tx; $localtax1_type = $object->lines[$i]->localtax1_type; $localtax2_type = $object->lines[$i]->localtax2_type; if ($object->remise_percent) { $tvaligne -= $tvaligne * $object->remise_percent / 100; } if ($object->remise_percent) { $localtax1ligne -= $localtax1ligne * $object->remise_percent / 100; } if ($object->remise_percent) { $localtax2ligne -= $localtax2ligne * $object->remise_percent / 100; } $vatrate = (string) $object->lines[$i]->tva_tx; // Retrieve type from database for backward compatibility with old records if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') && (!empty($localtax1_rate) || !empty($localtax2_rate))) { $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc); $localtax1_type = $localtaxtmp_array[0]; $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) { $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne; } if ($localtax2_type && $localtax2ligne != 0) { $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne; } if (($object->lines[$i]->info_bits & 0x1) == 0x1) { $vatrate .= '*'; } if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = ''; } $this->tva[$vatrate] += $tvaligne; if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; } // Add line if ($conf->global->MAIN_PDF_DASH_BETWEEN_LINES && $i < $nblignes - 1) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); $pdf->SetLineStyle(array('dash' => 0)); } $nexY += 2; // Passe espace entre les lignes // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); } $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone infos $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); } $pdf->Close(); $pdf->Output($file, 'F'); // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } return 1; // Pas d'erreur } else { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { $this->error = $langs->trans("ErrorConstantNotDefined", "FAC_OUTPUTDIR"); return 0; } $this->error = $langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }
/** * Get list of products for a category * * @param array $authentication Array of authentication information * @param array $id Category id * @param $lang $lang Force lang * @return array Array result */ function getProductsForCategory($authentication, $id, $lang = '') { global $db, $conf, $langs; $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT); $langs->setDefaultLang($langcode); dol_syslog("Function: getProductsForCategory login="******" id=" . $id); if ($authentication['entity']) { $conf->entity = $authentication['entity']; } $objectresp = array(); $errorcode = ''; $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); if (!$error && !$id) { $error++; $errorcode = 'BAD_PARAMETERS'; $errorlabel = "Parameter id must be provided."; } if (!$error) { $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT); $langs->setDefaultLang($langcode); $fuser->getrights(); if ($fuser->rights->produit->lire) { $categorie = new Categorie($db); $result = $categorie->fetch($id); if ($result > 0) { $table = "product"; $field = "product"; $sql = "SELECT fk_" . $field . " FROM " . MAIN_DB_PREFIX . "categorie_" . $table; $sql .= " WHERE fk_categorie = " . $id; $sql .= " ORDER BY fk_" . $field . " ASC"; dol_syslog("getProductsForCategory get id of product into category", LOG_DEBUG); $res = $db->query($sql); if ($res) { while ($rec = $db->fetch_array($res)) { $obj = new Product($db); $obj->fetch($rec['fk_' . $field]); $iProduct = 0; if ($obj->status > 0) { $dir = !empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output; $pdir = get_exdir($obj->id, 2) . $obj->id . "/photos/"; $dir = $dir . '/' . $pdir; $products[] = array('id' => $obj->id, 'ref' => $obj->ref, 'ref_ext' => $obj->ref_ext, 'label' => !empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label, 'description' => !empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description, 'date_creation' => dol_print_date($obj->date_creation, 'dayhourrfc'), 'date_modification' => dol_print_date($obj->date_modification, 'dayhourrfc'), 'note' => !empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note, 'status_tosell' => $obj->status, 'status_tobuy' => $obj->status_buy, 'type' => $obj->type, 'barcode' => $obj->barcode, 'barcode_type' => $obj->barcode_type, 'country_id' => $obj->country_id > 0 ? $obj->country_id : '', 'country_code' => $obj->country_code, 'custom_code' => $obj->customcode, 'price_net' => $obj->price, 'price' => $obj->price_ttc, 'vat_rate' => $obj->tva_tx, 'price_base_type' => $obj->price_base_type, 'stock_real' => $obj->stock_reel, 'stock_alert' => $obj->seuil_stock_alerte, 'pmp' => $obj->pmp, 'import_key' => $obj->import_key, 'dir' => $pdir, 'images' => $obj->liste_photos($dir, $nbmax = 10)); //Retreive all extrafield for thirdsparty // fetch optionals attributes and labels $extrafields = new ExtraFields($db); $extralabels = $extrafields->fetch_name_optionals_label('product', true); //Get extrafield values $product->fetch_optionals($obj->id, $extralabels); foreach ($extrafields->attribute_label as $key => $label) { $products[$iProduct] = array_merge($products[$iProduct], array('options_' . $key => $product->array_options['options_' . $key])); } $iProduct++; } } // Retour $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'products' => $products); } else { $errorcode = 'NORECORDS_FOR_ASSOCIATION'; $errorlabel = 'No products associated' . $sql; $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); dol_syslog("getProductsForCategory:: " . $c->error, LOG_DEBUG); } } else { $error++; $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id=' . $id; } } else { $error++; $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } } if ($error) { $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel)); } return $objectresp; }
/** * Write the object to document file to disk * * @param Don $don Donation object * @param Translate $outputlangs Lang object for output language * @return int >0 if OK, <0 if KO */ function write_file($don, $outputlangs) { global $user, $conf, $langs, $mysoc; $now = dol_now(); $id = !is_object($don) ? $don : ''; if (!is_object($outputlangs)) { $outputlangs = $langs; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); $outputlangs->load("donations"); if (!empty($conf->don->dir_output)) { // Definition de l'objet $don (pour compatibilite ascendante) if (!is_object($don)) { $don = new Don($this->db); $ret = $don->fetch($id); $id = $don->id; } // Definition de $dir et $file if (!empty($don->specimen)) { $dir = $conf->don->dir_output; $file = $dir . "/SPECIMEN.html"; } else { $donref = dol_sanitizeFileName($don->ref); $dir = $conf->don->dir_output . "/" . get_exdir($donref, 2); $file = $dir . "/" . $donref . ".html"; } if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return -1; } } if (file_exists($dir)) { $formclass = new Form($this->db); //This is not the proper way to do it but $formclass->form_modes_reglement //prints the translation instead of returning it if ($don->modepaiementid) { $formclass->load_cache_types_paiements(); $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label']; } else { $paymentmode = ''; } // Defini contenu $donmodel = DOL_DOCUMENT_ROOT . "/core/modules/dons/html_cerfafr.html"; $form = implode('', file($donmodel)); $form = str_replace('__REF__', $don->id, $form); $form = str_replace('__DATE__', dol_print_date($don->date, 'day', false, $outputlangs), $form); //$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist $form = str_replace('__AMOUNT__', $don->amount, $form); $form = str_replace('__CURRENCY__', $outputlangs->transnoentitiesnoconv("Currency" . $conf->currency), $form); $form = str_replace('__CURRENCYCODE__', $conf->currency, $form); $form = str_replace('__MAIN_INFO_SOCIETE_NOM__', $mysoc->name, $form); $form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__', $mysoc->address, $form); $form = str_replace('__MAIN_INFO_SOCIETE_ZIP__', $mysoc->zip, $form); $form = str_replace('__MAIN_INFO_SOCIETE_TOWN__', $mysoc->town, $form); $form = str_replace('__DONATOR_FIRSTNAME__', $don->firstname, $form); $form = str_replace('__DONATOR_LASTNAME__', $don->lastname, $form); $form = str_replace('__DONATOR_ADDRESS__', $don->address, $form); $form = str_replace('__DONATOR_ZIP__', $don->zip, $form); $form = str_replace('__DONATOR_TOWN__', $don->town, $form); $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode, $form); $form = str_replace('__NOW__', dol_print_date($now, '', false, $outputlangs), $form); $form = str_replace('__DonationRef__', $outputlangs->trans("DonationRef"), $form); $form = str_replace('__DonationReceipt__', $outputlangs->trans("DonationReceipt"), $form); $form = str_replace('__DonationRecipient__', $outputlangs->trans("DonationRecipient"), $form); $form = str_replace('__DatePayment__', $outputlangs->trans("DatePayment"), $form); $form = str_replace('__PaymentMode__', $outputlangs->trans("PaymentMode"), $form); $form = str_replace('__Name__', $outputlangs->trans("Name"), $form); $form = str_replace('__Address__', $outputlangs->trans("Address"), $form); $form = str_replace('__Zip__', $outputlangs->trans("Zip"), $form); $form = str_replace('__Town__', $outputlangs->trans("Town"), $form); $form = str_replace('__Donor__', $outputlangs->trans("Donor"), $form); $form = str_replace('__Date__', $outputlangs->trans("Date"), $form); $form = str_replace('__Signature__', $outputlangs->trans("Signature"), $form); $form = str_replace('__ThankYou__', $outputlangs->trans("ThankYou"), $form); $form = str_replace('__IConfirmDonationReception__', $outputlangs->trans("IConfirmDonationReception"), $form); $frencharticle = ''; if (preg_match('/fr/i', $outputlangs->defaultlang)) { $frencharticle = '<font size="+1"><b>(Article 200-5 du Code Général des Impôts)</b></font><br>+ article 238 bis'; } $form = str_replace('__FrenchArticle__', $frencharticle, $form); // Sauve fichier sur disque dol_syslog("html_cerfafr::write_file {$file}"); $handle = fopen($file, "w"); fwrite($handle, $form); fclose($handle); if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } return 1; } else { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { $this->error = $langs->trans("ErrorConstantNotDefined", "DON_OUTPUTDIR"); return 0; } $this->error = $langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }
/** * Show list of documents in a directory * * @param array $filearray Array of files loaded by dol_dir_list('files') function before calling this * @param Object $object Object on which document is linked to * @param string $modulepart Value for modulepart used by download or viewimage wrapper * @param string $param Parameters on sort links (param must start with &, example &aaa=bbb&ccc=ddd) * @param int $forcedownload Force to open dialog box "Save As" when clicking on file * @param string $relativepath Relative path of docs (autodefined if not provided) * @param int $permtodelete Permission to delete * @param int $useinecm Change output for use in ecm module * @param string $textifempty Text to show if filearray is empty ('NoFileFound' if not defined) * @param int $maxlength Maximum length of file name shown * @param string $title Title before list * @param string $url Full url to use for click links ('' = autodetect) * @param int $showrelpart 0=Show only filename (default), 1=Show first level 1 dir * @return int <0 if KO, nb of files shown if OK */ function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permtodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0) { global $user, $conf, $langs, $hookmanager; global $bc; global $sortfield, $sortorder, $maxheightmini; $hookmanager->initHooks(array('formfile')); $parameters = array('filearray' => $filearray, 'modulepart' => $modulepart, 'param' => $param, 'forcedownload' => $forcedownload, 'relativepath' => $relativepath, 'permtodelete' => $permtodelete, 'useinecm' => $useinecm, 'textifempty' => $textifempty, 'maxlength' => $maxlength, 'title' => $title, 'url' => $url); $reshook = $hookmanager->executeHooks('showFilesList', $parameters, $object); if (isset($reshook) && $reshook != '') { return $reshook; } else { $param = (isset($object->id) ? '&id=' . $object->id : '') . $param; // Show list of existing files if (empty($useinecm)) { print load_fiche_titre($title ? $title : $langs->trans("AttachedFiles")); } if (empty($url)) { $url = $_SERVER["PHP_SELF"]; } print '<table width="100%" class="' . ($useinecm ? 'nobordernopadding' : 'liste') . '">'; print '<tr class="liste_titre">'; print_liste_field_titre($langs->trans("Documents2"), $url, "name", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Size"), $url, "size", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Date"), $url, "date", "", $param, 'align="center"', $sortfield, $sortorder); if (empty($useinecm)) { print_liste_field_titre('', $url, "", "", $param, 'align="center"'); } print_liste_field_titre(''); print "</tr>\n"; $nboffiles = count($filearray); if ($nboffiles > 0) { include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; } $var = true; foreach ($filearray as $key => $file) { if ($file['name'] != '.' && $file['name'] != '..' && !preg_match('/\\.meta$/i', $file['name'])) { // Define relative path used to store the file if (empty($relativepath)) { $relativepath = (!empty($object->ref) ? dol_sanitizeFileName($object->ref) : '') . '/'; if ($object->element == 'invoice_supplier') { $relativepath = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier') . $relativepath; } // TODO Call using a defined value for $relativepath if ($object->element == 'member') { $relativepath = get_exdir($object->id, 2, 0, 0, $object, 'member') . $relativepath; } // TODO Call using a defined value for $relativepath if ($object->element == 'project_task') { $relativepath = 'Call_not_supported_._Call_function_using_a_defined_relative_path_.'; } } // For backward compatiblity, we detect file is stored into an old path if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $file['level1name'] == 'photos') { $relativepath = preg_replace('/^.*\\/produit\\//', '', $file['path']) . '/'; } $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>'; //print "XX".$file['name']; //$file['name'] must be utf8 print '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart; if ($forcedownload) { print '&attachment=1'; } if (!empty($object->entity)) { print '&entity=' . $object->entity; } $filepath = $relativepath . $file['name']; /* Restore old code: When file is at level 2+, full relative path (and not only level1) must be into url if ($file['level1name'] <> $object->id) $filepath=$object->id.'/'.$file['level1name'].'/'.$file['name']; else $filepath=$object->id.'/'.$file['name']; */ print '&file=' . urlencode($filepath); print '">'; print img_mime($file['name'], $file['name'] . ' (' . dol_print_size($file['size'], 0, 0) . ')') . ' '; if ($showrelpart == 1) { print $relativepath; } print dol_trunc($file['name'], $maxlength, 'middle'); print '</a>'; print "</td>\n"; print '<td align="right">' . dol_print_size($file['size'], 1, 1) . '</td>'; print '<td align="center">' . dol_print_date($file['date'], "dayhour", "tzuser") . '</td>'; // Preview if (empty($useinecm)) { $fileinfo = pathinfo($file['name']); print '<td align="center">'; $minifile = $fileinfo['filename'] . '_mini.' . strtolower($fileinfo['extension']); // Thumbs are created with filename in lower case if (image_format_supported($file['name']) > 0) { print '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath . $fileinfo['filename'] . '.' . strtolower($fileinfo['extension'])) . '" class="aphoto" target="_blank">'; print '<img border="0" height="' . $maxheightmini . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath . 'thumbs/' . $minifile) . '" title="">'; print '</a>'; } else { print ' '; } print '</td>'; } // Delete or view link // ($param must start with &) print '<td align="right">'; if ($useinecm) { print '<a href="' . DOL_URL_ROOT . '/ecm/docfile.php?urlfile=' . urlencode($file['name']) . $param . '" class="editfilelink" rel="' . urlencode($file['name']) . '">' . img_view() . '</a> '; } else { if (image_format_supported($file['name']) > 0) { $permtoedit = 0; $newmodulepart = $modulepart; if ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service') { if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) { $permtoedit = 1; } if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) { $permtoedit = 1; } $newmodulepart = 'produit|service'; } /* TODO Not yet working if ($modulepart == 'holiday') { if ($user->rights->holiday->write_all) $permtoedit=1; } */ if (empty($conf->global->MAIN_UPLOAD_DOC)) { $permtoedit = 0; } if ($permtoedit) { // Link to resize print '<a href="' . DOL_URL_ROOT . '/core/photos_resize.php?modulepart=' . urlencode($newmodulepart) . '&id=' . $object->id . '&file=' . urlencode($relativepath . $fileinfo['filename'] . '.' . strtolower($fileinfo['extension'])) . '" title="' . dol_escape_htmltag($langs->trans("Resize")) . '">' . img_picto($langs->trans("Resize"), DOL_URL_ROOT . '/theme/common/transform-crop-and-resize', '', 1) . '</a> '; } } } if ($permtodelete) { /* if ($file['level1name'] <> $object->id) $filepath=$file['level1name'].'/'.$file['name']; else $filepath=$file['name']; */ $useajax = 1; if (!empty($conf->dol_use_jmobile)) { $useajax = 0; } if (empty($conf->use_javascript_ajax)) { $useajax = 0; } if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) { $useajax = 0; } print '<a href="' . ($useinecm && $useajax ? '#' : $url . '?action=delete&urlfile=' . urlencode($filepath) . $param) . '" class="deletefilelink" rel="' . $filepath . '">' . img_delete() . '</a>'; } else { print ' '; } print "</td>"; print "</tr>\n"; } } if ($nboffiles == 0) { print '<tr ' . $bc[false] . '><td colspan="' . (empty($useinecm) ? '5' : '4') . '">'; if (empty($textifempty)) { print $langs->trans("NoFileFound"); } else { print $textifempty; } print '</td></tr>'; } print "</table>"; return $nboffiles; } }
/** * Migrate file from old path to new one for product $product * * @param Product $product Object product * @return void */ function migrate_product_photospath($product) { global $conf; $dir = $conf->product->multidir_output[$product->entity]; $origin = $dir . '/' . get_exdir($product->id, 2) . $product->id . "/photos"; $destin = $dir . '/' . dol_sanitizeFileName($product->ref); $error = 0; $origin_osencoded = dol_osencode($origin); $destin_osencoded = dol_osencode($destin); dol_mkdir($destin); if (dol_is_dir($origin)) { $handle = opendir($origin_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) != false) { if ($file != '.' && $file != '..' && is_dir($origin_osencoded . '/' . $file)) { $thumbs = opendir($origin_osencoded . '/' . $file); if (is_resource($thumbs)) { dol_mkdir($destin . '/' . $file); while (($thumb = readdir($thumbs)) != false) { dol_move($origin . '/' . $file . '/' . $thumb, $destin . '/' . $file . '/' . $thumb); } // dol_delete_dir($origin.'/'.$file); } } else { if (dol_is_file($origin . '/' . $file)) { dol_move($origin . '/' . $file, $destin . '/' . $file); } } } } } }
function Add_PDF_card(&$pdf,$textleft,$header='',$footer='',$outputlangs,$textright='',$idmember,$photomember) { global $mysoc,$conf,$langs; // We are in a new page, then we must add a page if (($this->_COUNTX ==0) and ($this->_COUNTY==0) and (!$this->_First==1)) { $pdf->AddPage(); } $this->_First=0; $_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space)); $_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space)); // Define logo $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; if (! is_readable($logo)) { $logo=''; if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { $logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; } elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; } } // Define photo $dir=$conf->adherent->dir_output; $file=get_exdir($idmember,2).'photos/'.$photomember; $photo=$dir.'/'.$file; if (empty($photomember) || ! is_readable($photo)) $photo=''; // Define background image $backgroundimage=''; if(! empty($conf->global->ADHERENT_CARD_BACKGROUND) && file_exists($conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND)) { $backgroundimage=$conf->adherent->dir_output.'/'.$conf->global->ADHERENT_CARD_BACKGROUND; } // Print lines if ($this->code == "CARD") { $this->Tformat=$this->_Avery_Labels["CARD"]; //$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25); $this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10); } // Background if ($backgroundimage) { $pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height); } // Top if ($header!='') { if ($this->code == "CARD") { $pdf->SetDrawColor(128,128,128); $pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); $pdf->SetDrawColor(0,0,0); } $pdf->SetXY($_PosX, $_PosY+1); $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C'); } // Center if ($textright=='') // Only a left part { if ($textleft == '%LOGO%' && $logo) $this->Image($logo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); else if ($textleft == '%PHOTO%' && $photo) $this->Image($photo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); else { $pdf->SetXY($_PosX+3, $_PosY+3+$this->_Line_Height); $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); } } else if ($textleft!='' && $textright!='') // { if ($textleft == '%LOGO%' || $textleft == '%PHOTO%') { if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+2,$_PosY+3+$this->_Line_Height,20); $pdf->SetXY($_PosX+21, $_PosY+3+$this->_Line_Height); $pdf->MultiCell($this->_Width-22, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); } else if ($textright == '%LOGO%' || $textright == '%PHOTO%') { if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-21,$_PosY+3+$this->_Line_Height,20); else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-21,$_PosY+3+$this->_Line_Height,20); $pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); $pdf->MultiCell($this->_Width-22, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); } else { $pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); $pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft), 0, 'L'); $pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+3+$this->_Line_Height); $pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); } } else // Only a right part { if ($textright == '%LOGO%' && $logo) $this->Image($logo,$_PosX+$this->_Width-21,$_PosY+1,20); else if ($textright == '%PHOTO%' && $photo) $this->Image($photo,$_PosX+$this->_Width-21,$_PosY+1,20); else { $pdf->SetXY($_PosX+2, $_PosY+3+$this->_Line_Height); $pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R'); } } // Bottom if ($footer!='') { if ($this->code == "CARD") { $pdf->SetDrawColor(128,128,128); $pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2); $pdf->SetDrawColor(0,0,0); } $pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1); $pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C'); } //print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n"; $this->_COUNTY++; if ($this->_COUNTY == $this->_Y_Number) { // Si on est en bas de page, on remonte le 'curseur' de position $this->_COUNTX++; $this->_COUNTY=0; } if ($this->_COUNTX == $this->_X_Number) { // Si on est en bout de page, alors on repart sur une nouvelle page $this->_COUNTX=0; $this->_COUNTY=0; } }
if (!$resql) { $error ++; setEventMessages($db->lasterror(), null, 'errors'); } } if (!$error && !count($object->errors)) { if (GETPOST('deletephoto') && $object->photo) { $fileimg = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/'.$object->photo; $dirthumbs = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { $dir = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user'); dol_mkdir($dir); if (@is_dir($dir)) { $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']); if (!$result > 0) { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } else { // Create small thumbs for company (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); // Create mini thumbs for company (Ratio is near 16/9)
/** * Constructor * * @param array $options Options array * @param int $fk_element fk_element * @param string $element element */ function __construct($options = null, $fk_element = null, $element = null) { global $db, $conf; global $object; $this->fk_element = $fk_element; $this->element = $element; $pathname = $filename = $element; if (preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) { $pathname = $regs[1]; $filename = $regs[2]; } $parentForeignKey = ''; // For compatibility if ($element == 'propal') { $pathname = 'comm/propal'; $dir_output = $conf->{$element}->dir_output; } elseif ($element == 'facture') { $pathname = 'compta/facture'; $dir_output = $conf->{$element}->dir_output; } elseif ($element == 'project') { $element = $pathname = 'projet'; $dir_output = $conf->{$element}->dir_output; } elseif ($element == 'project_task') { $pathname = 'projet'; $filename = 'task'; $dir_output = $conf->projet->dir_output; $parentForeignKey = 'fk_project'; $parentClass = 'Project'; $parentElement = 'projet'; $parentObject = 'project'; } elseif ($element == 'fichinter') { $element = 'ficheinter'; $dir_output = $conf->{$element}->dir_output; } elseif ($element == 'order_supplier') { $pathname = 'fourn'; $filename = 'fournisseur.commande'; $dir_output = $conf->fournisseur->commande->dir_output; } elseif ($element == 'invoice_supplier') { $pathname = 'fourn'; $filename = 'fournisseur.facture'; $dir_output = $conf->fournisseur->facture->dir_output; } elseif ($element == 'product') { $dir_output = $conf->product->multidir_output[$conf->entity]; } elseif ($element == 'action') { $pathname = 'comm/action'; $filename = 'actioncomm'; $dir_output = $conf->agenda->dir_output; } elseif ($element == 'chargesociales') { $pathname = 'compta/sociales'; $filename = 'chargesociales'; $dir_output = $conf->tax->dir_output; } else { $dir_output = $conf->{$element}->dir_output; } dol_include_once('/' . $pathname . '/class/' . $filename . '.class.php'); $classname = ucfirst($filename); if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } elseif ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } $object = new $classname($db); $object->fetch($fk_element); if (!empty($parentForeignKey)) { dol_include_once('/' . $parentElement . '/class/' . $parentObject . '.class.php'); $parent = new $parentClass($db); $parent->fetch($object->{$parentForeignKey}); if (!empty($parent->socid)) { $parent->fetch_thirdparty(); } $object->{$parentObject} = dol_clone($parent); } else { $object->fetch_thirdparty(); } $object_ref = dol_sanitizeFileName($object->ref); if ($element == 'invoice_supplier') { $object_ref = get_exdir($object->id, 2) . $object_ref; } else { if ($element == 'project_task') { $object_ref = $object->project->ref . '/' . $object_ref; } } $this->options = array('script_url' => $_SERVER['PHP_SELF'], 'upload_dir' => $dir_output . '/' . $object_ref . '/', 'upload_url' => DOL_URL_ROOT . '/document.php?modulepart=' . $element . '&attachment=1&file=/' . $object_ref . '/', 'param_name' => 'files', 'delete_type' => 'DELETE', 'max_file_size' => null, 'min_file_size' => 1, 'accept_file_types' => '/.+$/i', 'max_number_of_files' => null, 'max_width' => null, 'max_height' => null, 'min_width' => 1, 'min_height' => 1, 'discard_aborted_uploads' => true, 'image_versions' => array('thumbnail' => array('upload_dir' => $dir_output . '/' . $object_ref . '/thumbs/', 'upload_url' => DOL_URL_ROOT . '/document.php?modulepart=' . $element . '&attachment=1&file=/' . $object_ref . '/thumbs/', 'max_width' => 80, 'max_height' => 80))); if ($options) { $this->options = array_replace_recursive($this->options, $options); } }
if ($user->rights->don->lire || preg_match('/^specimen/i',$original_file)) { $accessallowed=1; } $original_file=$conf->don->dir_output.'/'.$original_file; } // Wrapping pour les remises de cheques else if ($modulepart == 'remisecheque') { if ($user->rights->banque->lire || preg_match('/^specimen/i',$original_file)) { $accessallowed=1; } $original_file=$conf->banque->dir_output.'/bordereau/'.get_exdir(basename($original_file,".pdf"),2,1).$original_file; } // Wrapping for export module else if ($modulepart == 'export') { // Aucun test necessaire car on force le rep de download sur // le rep export qui est propre a l'utilisateur $accessallowed=1; $original_file=$conf->export->dir_temp.'/'.$user->id.'/'.$original_file; } // Wrapping for import module else if ($modulepart == 'import') { // Aucun test necessaire car on force le rep de download sur
/** * Build document onto disk * * @param Object $object Object invoice to build (or id if old method) * @param Translate $outputlangs Lang object for output language * @return int 1=OK, 0=KO */ function write_file($object, $outputlangs = '') { global $user, $langs, $conf, $mysoc; 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"); $default_font_size = pdf_getPDFFontSize($outputlangs); if ($conf->fournisseur->dir_output . '/facture') { $object->fetch_thirdparty(); $deja_regle = $object->getSommePaiement(); //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); //$amount_deposits_included = $object->getSumDepositsUsed(); // Definition de $dir et $file if ($object->specimen) { $dir = $conf->fournisseur->facture->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->fournisseur->facture->dir_output . '/' . get_exdir($object->id, 2) . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } if (file_exists($dir)) { $nblignes = count($object->lines); $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); } $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Invoice")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Order")); 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 < $nblignes; $i++) { $curY = $nexY; $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page // Description of product line $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $curX = $this->posxdesc - 1; pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, 0, 0, 1); $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $nexY = $pdf->GetY(); // VAT rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs); $pdf->SetXY($this->posxtva, $curY); $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R'); } // Unit price before discount $pdf->SetXY($this->posxup, $curY); $pdf->MultiCell($this->posxqty - $this->posxup - 1, 3, price($object->lines[$i]->pu_ht), 0, 'R', 0); // Quantity $pdf->SetXY($this->posxqty, $curY); $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 3, $object->lines[$i]->qty, 0, 'R'); // Discount on line $pdf->SetXY($this->posxdiscount, $curY); if ($object->lines[$i]->remise_percent) { $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $object->lines[$i]->remise_percent . "%", 0, 'R'); } // Total HT line $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs); $pdf->SetXY($this->postotalht, $curY); $pdf->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $tvaligne = $object->lines[$i]->total_tva; $localtax1ligne = $object->lines[$i]->total_localtax1; $localtax2ligne = $object->lines[$i]->total_localtax2; if ($object->remise_percent) { $tvaligne -= $tvaligne * $object->remise_percent / 100; } $vatrate = (string) $object->lines[$i]->tva_tx; $localtax1rate = (string) $object->lines[$i]->localtax1_tx; $localtax2rate = (string) $object->lines[$i]->localtax2_tx; if (($object->lines[$i]->info_bits & 0x1) == 0x1) { $vatrate .= '*'; } $this->tva[$vatrate] += $tvaligne; $this->localtax1[$localtax1rate] += $localtax1ligne; $this->localtax2[$localtax2rate] += $localtax2ligne; $nexY += 2; // Passe espace entre les lignes // Cherche nombre de lignes a venir pour savoir si place suffisante if ($i < $nblignes - 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; // Et si on affiche dates de validite, on ajoute encore une ligne if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { $nblineFollowDesc += 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 < $nblignes - 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(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } $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; } // Affiche zone totaux $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); $amount_credit_notes_included = 0; $amount_deposits_included = 0; if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($file, 'F'); // Actions on extra fields (by external module or standard code) if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } return 1; // Pas d'erreur } else { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); return 0; } $this->error = $langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }
/** * Write the object to document file to disk * * @param Don $don Donation object * @param Translate $outputlangs Lang object for output language * @return int >0 if OK, <0 if KO */ function write_file($don, $outputlangs) { global $user, $conf, $langs, $mysoc; $now = dol_now(); $id = !is_object($don) ? $don : ''; if (!is_object($outputlangs)) { $outputlangs = $langs; } $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); $outputlangs->load("donations"); if (!empty($conf->don->dir_output)) { // Definition of the object don (for upward compatibility) if (!is_object($don)) { $don = new Don($this->db); $ret = $don->fetch($id); $id = $don->id; } // Definition of $dir and $file if (!empty($don->specimen)) { $dir = $conf->don->dir_output; $file = $dir . "/SPECIMEN.html"; } else { $donref = dol_sanitizeFileName($don->ref); $dir = $conf->don->dir_output . "/" . get_exdir($donref, 2); $file = $dir . "/" . $donref . ".html"; } if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return -1; } } if (file_exists($dir)) { $formclass = new Form($this->db); // This is not the proper way to do it but $formclass->form_modes_reglement // prints the translation instead of returning it if ($don->modepaiementid) { $formclass->load_cache_types_paiements(); $paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label']; } else { $paymentmode = ''; } // Define contents $donmodel = DOL_DOCUMENT_ROOT . "/core/modules/dons/html_cerfafr.html"; $form = implode('', file($donmodel)); $form = str_replace('__REF__', $don->id, $form); $form = str_replace('__DATE__', dol_print_date($don->date, 'day', false, $outputlangs), $form); //$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist $form = str_replace('__AMOUNT__', $don->amount, $form); $form = str_replace('__CURRENCY__', $outputlangs->transnoentitiesnoconv("Currency" . $conf->currency), $form); $form = str_replace('__CURRENCYCODE__', $conf->currency, $form); $form = str_replace('__MAIN_INFO_SOCIETE_NOM__', $mysoc->name, $form); $form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__', $mysoc->address, $form); $form = str_replace('__MAIN_INFO_SOCIETE_ZIP__', $mysoc->zip, $form); $form = str_replace('__MAIN_INFO_SOCIETE_TOWN__', $mysoc->town, $form); $form = str_replace('__DONATOR_FIRSTNAME__', $don->firstname, $form); $form = str_replace('__DONATOR_LASTNAME__', $don->lastname, $form); $form = str_replace('__DONATOR_ADDRESS__', $don->address, $form); $form = str_replace('__DONATOR_ZIP__', $don->zip, $form); $form = str_replace('__DONATOR_TOWN__', $don->town, $form); $form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode, $form); $form = str_replace('__NOW__', dol_print_date($now, 'day', false, $outputlangs), $form); $form = str_replace('__DonationRef__', $outputlangs->trans("DonationRef"), $form); $form = str_replace('__DonationTitle__', $outputlangs->trans("DonationTitle"), $form); $form = str_replace('__DonationReceipt__', $outputlangs->trans("DonationReceipt"), $form); $form = str_replace('__DonationRecipient__', $outputlangs->trans("DonationRecipient"), $form); $form = str_replace('__DonationDatePayment__', $outputlangs->trans("DonationDatePayment"), $form); $form = str_replace('__PaymentMode__', $outputlangs->trans("PaymentMode"), $form); $form = str_replace('__Name__', $outputlangs->trans("Name"), $form); $form = str_replace('__Address__', $outputlangs->trans("Address"), $form); $form = str_replace('__Zip__', $outputlangs->trans("Zip"), $form); $form = str_replace('__Town__', $outputlangs->trans("Town"), $form); $form = str_replace('__Object__', $outputlangs->trans("Object"), $form); $form = str_replace('__Donor__', $outputlangs->trans("Donor"), $form); $form = str_replace('__Date__', $outputlangs->trans("Date"), $form); $form = str_replace('__Signature__', $outputlangs->trans("Signature"), $form); $form = str_replace('__Message__', $outputlangs->trans("Message"), $form); $form = str_replace('__IConfirmDonationReception__', $outputlangs->trans("IConfirmDonationReception"), $form); $form = str_replace('__DonationMessage__', $conf->global->DONATION_MESSAGE, $form); $frencharticle = ''; if (preg_match('/fr/i', $outputlangs->defaultlang)) { $frencharticle = '<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>'; } $form = str_replace('__FrenchArticle__', $frencharticle, $form); $frencheligibility = ''; if (preg_match('/fr/i', $outputlangs->defaultlang)) { $frencheligibility = 'Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :'; } $form = str_replace('__FrenchEligibility__', $frencheligibility, $form); $art200 = ''; if (preg_match('/fr/i', $outputlangs->defaultlang)) { if ($conf->global->DONATION_ART200 >= 1) { $art200 = '<input type="checkbox" checked="checked">200 du CGI'; } else { $art200 = '<input type="checkbox">200 du CGI'; } } $form = str_replace('__ARTICLE200__', $art200, $form); $art238 = ''; if (preg_match('/fr/i', $outputlangs->defaultlang)) { if ($conf->global->DONATION_ART238 >= 1) { $art238 = '<input type="checkbox" checked="checked">238 bis du CGI'; } else { $art238 = '<input type="checkbox">238 bis du CGI'; } } $form = str_replace('__ARTICLE238__', $art238, $form); $art885 = ''; if (preg_match('/fr/i', $outputlangs->defaultlang)) { if ($conf->global->DONATION_ART885 >= 1) { $art885 = '<input type="checkbox" checked="checked">885-0 V bis du CGI'; } else { $art885 = '<input type="checkbox">885-0 V bis du CGI'; } } $form = str_replace('__ARTICLE885__', $art885, $form); // Save file on disk dol_syslog("html_cerfafr::write_file {$file}"); $handle = fopen($file, "w"); fwrite($handle, $form); fclose($handle); if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } return 1; } else { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } } else { $this->error = $langs->trans("ErrorConstantNotDefined", "DON_OUTPUTDIR"); return 0; } $this->error = $langs->trans("ErrorUnknown"); return 0; // Error by default }
/** * Deplace fichier uploade sous le nom $files dans le repertoire sdir * * @param string $sdir Repertoire destination finale * @param string $file Nom du fichier uploade * @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut) * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut) * @return void */ function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120) { require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; $dir = $sdir . '/' . get_exdir($this->id, 2) . $this->id . "/"; $dir .= "photos/"; if (!file_exists($dir)) { dol_mkdir($dir); } if (file_exists($dir)) { $originImage = $dir . $file['name']; // Cree fichier en taille origine $result = dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0); if (file_exists($originImage)) { // Cree fichier en taille vignette $this->add_thumb($originImage, $maxWidth, $maxHeight); } } }
/** * Fonction to generate document on disk * * @param RemiseCheque $object Object RemiseCheque * @param string $_dir Directory * @param string $number Number * @param Translate $outputlangs Lang output object * @return int 1=ok, 0=ko */ function write_file($object, $_dir, $number, $outputlangs) { global $user, $conf, $langs, $hookmanager; 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 $sav_charset_output = $outputlangs->charset_output; if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); $outputlangs->load("compta"); $dir = $_dir . "/" . get_exdir($number, 0, 1, 0, $object, 'cheque') . $number; if (!is_dir($dir)) { $result = dol_mkdir($dir); if ($result < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } $file = $dir . "/bordereau-" . $number . ".pdf"; // Add pdfgeneration hook if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Create PDF instance $pdf = pdf_getInstance($this->format); $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfreetext = isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5; // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->transnoentities("CheckReceipt") . " " . $number); $pdf->SetSubject($outputlangs->transnoentities("CheckReceipt")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->transnoentities("CheckReceipt") . " " . $number); if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { $pdf->SetCompression(false); } $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $nboflines = count($this->lines); // Define nb of page $pages = intval($nboflines / $this->line_per_page); if ($nboflines % $this->line_per_page > 0) { $pages++; } if ($pages == 0) { // force to build at least one page if report has no lines $pages = 1; } $pdf->AddPage(); $pagenb++; $this->Header($pdf, $pagenb, $pages, $outputlangs); $this->Body($pdf, $pagenb, $pages, $outputlangs); // Pied de page $this->_pagefoot($pdf, '', $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); } $pdf->Close(); $pdf->Output($file, 'F'); // Add pdfgeneration hook if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs); global $action; $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } $outputlangs->charset_output = $sav_charset_output; return 1; // Pas d'erreur }
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $message .= '<div class="error">' . $langs->trans("ErrorLoginAlreadyExists", $edituser->login) . '</div>'; } else { $message .= '<div class="error">' . $edituser->error . '</div>'; } } if ($ret >= 0 && !count($edituser->errors)) { if (GETPOST('deletephoto') && $edituser->photo) { $fileimg = $conf->user->dir_output . '/' . get_exdir($edituser->id, 2, 0, 1) . '/logos/' . $edituser->photo; $dirthumbs = $conf->user->dir_output . '/' . get_exdir($edituser->id, 2, 0, 1) . '/logos/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { $dir = $conf->user->dir_output . '/' . get_exdir($edituser->id, 2, 0, 1); create_exdir($dir); if (@is_dir($dir)) { $newfile = $dir . '/' . dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']); if (!$result > 0) { $message .= '<div class="error">' . $langs->trans("ErrorFailedToSaveFile") . '</div>'; } else { // Create small thumbs for company (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); // Create mini thumbs for company (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); } }
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $object->client->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('bills'); } // Build document if it not exists if (!$file || !is_readable($file)) { $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result <= 0) { dol_print_error($db, $object->error, $object->errors); exit; } $fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output . '/' . get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier') . $ref, preg_quote($ref, '/') . '([^\\-])+'); $file = $fileparams['fullname']; } print '<div class="clearboth"></div>'; print '<br>'; print load_fiche_titre($langs->trans('SendBillByMail')); dol_fiche_head(''); // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->param['langsmodels'] = empty($newlang) ? $langs->defaultlang : $newlang; $formmail->fromtype = 'user'; $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs); $formmail->frommail = $user->email; if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && $conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1) {
/** * Show photos of a product (nbmax maximum), into several columns * TODO Move this into html.formproduct.class.php * * @param string $sdir Directory to scan * @param int $size 0=original size, 1 use thumbnail if possible * @param int $nbmax Nombre maximum de photos (0=pas de max) * @param int $nbbyrow Nombre vignettes par ligne (si mode vignette) * @param int $showfilename 1=Show filename * @param int $showaction 1=Show icon with action links (resize, delete) * @param int $maxHeight Max height of image when size=1 * @param int $maxWidth Max width of image when size=1 * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160) { global $conf,$user,$langs; include_once(DOL_DOCUMENT_ROOT ."/core/lib/files.lib.php"); include_once(DOL_DOCUMENT_ROOT ."/core/lib/images.lib.php"); $pdir = get_exdir($this->id,2) . $this->id ."/photos/"; $dir = $sdir . '/'. $pdir; $dirthumb = $dir.'thumbs/'; $pdirthumb = $pdir.'thumbs/'; $return ='<!-- Photo -->'."\n"; /*$return.="<script type=\"text/javascript\"> jQuery(function() { jQuery('a.lightbox').lightBox({ overlayBgColor: '#888', overlayOpacity: 0.6, imageLoading: '".DOL_URL_ROOT."/theme/eldy/img/working.gif', imageBtnClose: '".DOL_URL_ROOT."/theme/eldy/img/previous.png', imageBtnPrev: '".DOL_URL_ROOT."/theme/eldy/img/1leftarrow.png', imageBtnNext: '".DOL_URL_ROOT."/theme/eldy/img/1rightarrow.png', containerResizeSpeed: 350, txtImage: '".$langs->trans("Image")."', txtOf: '".$langs->trans("on")."', fixedNavigation:false }); }); </script>\n"; */ $nbphoto=0; $dir_osencoded=dol_osencode($dir); if (file_exists($dir_osencoded)) { $handle=opendir($dir_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) != false) { $photo=''; if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory if (dol_is_file($dir.$file) && preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) { $nbphoto++; $photo = $file; $viewfilename = $file; if ($size == 1) { // Format vignette // On determine nom du fichier vignette $photo_vignette=''; if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) { $photo_vignette=preg_replace('/'.$regs[0].'/i', '', $photo)."_small".$regs[0]; if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; } // Get filesize of original file $imgarray=dol_getImageSize($dir.$photo); if ($nbbyrow && $nbphoto == 1) $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) $return.= '<tr align=center valign=middle border=1>'; if ($nbbyrow) $return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; $return.= "\n"; $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="lightbox" target="_blank">'; // Show image (width height=$maxHeight) // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine $alt=$langs->transnoentitiesnoconv('File').': '.$pdir.$photo; $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; if ($photo_vignette && $imgarray['height'] > $maxHeight) { $return.= '<!-- Show thumb -->'; $return.= '<img class="photo" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; } else { $return.= '<!-- Show original file -->'; $return.= '<img class="photo" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; } $return.= '</a>'."\n"; if ($showfilename) $return.= '<br>'.$viewfilename; if ($showaction) { $return.= '<br>'; // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites if ($photo_vignette && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight)) { $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').' </a>'; } if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize $return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$_GET["id"].'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> '; // Link to delete $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; $return.= img_delete().'</a>'; } } $return.= "\n"; if ($nbbyrow) $return.= '</td>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) $return.= '</tr>'; } if ($size == 0) { // Format origine $return.= '<img class="photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">'; if ($showfilename) $return.= '<br>'.$viewfilename; if ($showaction) { if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize $return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$_GET["id"].'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> '; // Link to delete $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; $return.= img_delete().'</a>'; } } } // On continue ou on arrete de boucler ? if ($nbmax && $nbphoto >= $nbmax) break; } } } if ($nbbyrow && $size==1) { // Ferme tableau while ($nbphoto % $nbbyrow) { $return.= '<td width="'.ceil(100/$nbbyrow).'%"> </td>'; $nbphoto++; } if ($nbphoto) $return.= '</table>'; } closedir($handle); } $this->nbphoto = $nbphoto; return $return; }
/** * Fonction generant le rapport sur le disque * * @param string $_dir Directory * @param string $number Number * @param Translate $outputlangs Lang output object * @return int 1=ok, 0=ko */ function write_file($_dir, $number, $outputlangs) { global $user, $conf, $langs; 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 $sav_charset_output = $outputlangs->charset_output; if (!empty($conf->global->MAIN_USE_FPDF)) { $outputlangs->charset_output = 'ISO-8859-1'; } $outputlangs->load("main"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); $outputlangs->load("compta"); $dir = $_dir . "/" . get_exdir($number, 2, 1) . $number; if (!is_dir($dir)) { $result = dol_mkdir($dir); if ($result < 0) { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } $month = sprintf("%02d", $month); $year = sprintf("%04d", $year); $_file = $dir . "/bordereau-" . $number . ".pdf"; // Create PDF instance $pdf = pdf_getInstance($this->format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->Open(); $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); $pdf->SetTitle($outputlangs->transnoentities("CheckReceipt") . " " . $number); $pdf->SetSubject($outputlangs->transnoentities("CheckReceipt")); $pdf->SetCreator("Dolibarr " . DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->transnoentities("CheckReceipt") . " " . $number); 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); $nboflines = count($this->lines); // Define nb of page $pages = intval($nboflines / $this->line_per_page); if ($nboflines % $this->line_per_page > 0) { $pages++; } if ($pages == 0) { // force to build at least one page if report has no lines $pages = 1; } $pdf->AddPage(); $pagenb++; $this->Header($pdf, $pagenb, $pages, $outputlangs); $this->Body($pdf, $pagenb, $pages, $outputlangs); // Pied de page $this->_pagefoot($pdf, '', $outputlangs); $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($_file, 'F'); if (!empty($conf->global->MAIN_UMASK)) { @chmod($_file, octdec($conf->global->MAIN_UMASK)); } $outputlangs->charset_output = $sav_charset_output; return 1; // Pas d'erreur }
/** * Show photos of a product (nbmax maximum), into several columns * TODO Move this into html.formproduct.class.php * * @param string $sdir Directory to scan * @param int $size 0=original size, 1 use thumbnail if possible * @param int $nbmax Nombre maximum de photos (0=pas de max) * @param int $nbbyrow Number of image per line or -1 to use div. Used only if size=1. * @param int $showfilename 1=Show filename * @param int $showaction 1=Show icon with action links (resize, delete) * @param int $maxHeight Max height of image when size=1 * @param int $maxWidth Max width of image when size=1 * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ function show_photos($sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160) { global $conf, $user, $langs; include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; $dir = $sdir . '/'; $pdir = '/'; if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { $dir .= get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id . "/photos/"; $pdir .= get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id . "/photos/"; } else { $dir .= $this->ref . '/'; $pdir .= $this->ref . '/'; } $dirthumb = $dir . 'thumbs/'; $pdirthumb = $pdir . 'thumbs/'; $return = '<!-- Photo -->' . "\n"; $nbphoto = 0; $dir_osencoded = dol_osencode($dir); if (file_exists($dir_osencoded)) { $handle = opendir($dir_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) != false) { $photo = ''; if (!utf8_check($file)) { $file = utf8_encode($file); } // To be sure file is stored in UTF8 in memory if (dol_is_file($dir . $file) && preg_match('/(' . $this->regeximgext . ')$/i', $dir . $file)) { $nbphoto++; $photo = $file; $viewfilename = $file; if ($size == 1) { // Format vignette // On determine nom du fichier vignette $photo_vignette = ''; if (preg_match('/(\\.jpg|\\.bmp|\\.gif|\\.png|\\.tiff)$/i', $photo, $regs)) { $photo_vignette = preg_replace('/' . $regs[0] . '/i', '', $photo) . "_small" . $regs[0]; if (!dol_is_file($dirthumb . $photo_vignette)) { $photo_vignette = ''; } } // Get filesize of original file $imgarray = dol_getImageSize($dir . $photo); if ($nbbyrow > 0) { if ($nbphoto == 1) { $return .= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; } if ($nbphoto % $nbbyrow == 1) { $return .= '<tr align=center valign=middle border=1>'; } $return .= '<td width="' . ceil(100 / $nbbyrow) . '%" class="photo">'; } else { if ($nbbyrow < 0) { $return .= '<div class="inline-block">'; } } $return .= "\n"; $return .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=product&entity=' . $this->entity . '&file=' . urlencode($pdir . $photo) . '" class="aphoto" target="_blank">'; // Show image (width height=$maxHeight) // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine $alt = $langs->transnoentitiesnoconv('File') . ': ' . $pdir . $photo; $alt .= ' - ' . $langs->transnoentitiesnoconv('Size') . ': ' . $imgarray['width'] . 'x' . $imgarray['height']; if ($photo_vignette && $imgarray['height'] > $maxHeight) { $return .= '<!-- Show thumb -->'; $return .= '<img class="photo photowithmargin" border="0" ' . ($conf->dol_use_jmobile ? 'max-height' : 'height') . '="' . $maxHeight . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=product&entity=' . $this->entity . '&file=' . urlencode($pdirthumb . $photo_vignette) . '" title="' . dol_escape_htmltag($alt) . '">'; } else { $return .= '<!-- Show original file -->'; $return .= '<img class="photo photowithmargin" border="0" ' . ($conf->dol_use_jmobile ? 'max-height' : 'height') . '="' . $maxHeight . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=product&entity=' . $this->entity . '&file=' . urlencode($pdir . $photo) . '" title="' . dol_escape_htmltag($alt) . '">'; } $return .= '</a>' . "\n"; if ($showfilename) { $return .= '<br>' . $viewfilename; } if ($showaction) { $return .= '<br>'; // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites if ($photo_vignette && preg_match('/(' . $this->regeximgext . ')$/i', $photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight)) { $return .= '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=addthumb&file=' . urlencode($pdir . $viewfilename) . '">' . img_picto($langs->trans('GenerateThumb'), 'refresh') . ' </a>'; } if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize $return .= '<a href="' . DOL_URL_ROOT . '/core/photos_resize.php?modulepart=' . urlencode('produit|service') . '&id=' . $this->id . '&file=' . urlencode($pdir . $viewfilename) . '" title="' . dol_escape_htmltag($langs->trans("Resize")) . '">' . img_picto($langs->trans("Resize"), DOL_URL_ROOT . '/theme/common/transform-crop-and-resize', '', 1) . '</a> '; // Link to delete $return .= '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=delete&file=' . urlencode($pdir . $viewfilename) . '">'; $return .= img_delete() . '</a>'; } } $return .= "\n"; if ($nbbyrow > 0) { $return .= '</td>'; if ($nbphoto % $nbbyrow == 0) { $return .= '</tr>'; } } else { if ($nbbyrow < 0) { $return .= '</div>'; } } } if ($size == 0) { // Format origine $return .= '<img class="photo photowithmargin" border="0" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=product&entity=' . $this->entity . '&file=' . urlencode($pdir . $photo) . '">'; if ($showfilename) { $return .= '<br>' . $viewfilename; } if ($showaction) { if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize $return .= '<a href="' . DOL_URL_ROOT . '/core/photos_resize.php?modulepart=' . urlencode('produit|service') . '&id=' . $this->id . '&file=' . urlencode($pdir . $viewfilename) . '" title="' . dol_escape_htmltag($langs->trans("Resize")) . '">' . img_picto($langs->trans("Resize"), DOL_URL_ROOT . '/theme/common/transform-crop-and-resize', '', 1) . '</a> '; // Link to delete $return .= '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=delete&file=' . urlencode($pdir . $viewfilename) . '">'; $return .= img_delete() . '</a>'; } } } // On continue ou on arrete de boucler ? if ($nbmax && $nbphoto >= $nbmax) { break; } } } } if ($size == 1) { if ($nbbyrow > 0) { // Ferme tableau while ($nbphoto % $nbbyrow) { $return .= '<td width="' . ceil(100 / $nbbyrow) . '%"> </td>'; $nbphoto++; } if ($nbphoto) { $return .= '</table>'; } } } closedir($handle); } $this->nbphoto = $nbphoto; return $return; }
$i++; } print "</table>"; } else { dol_print_error($db); } dol_fiche_end(); } /* * Boutons Actions */ print '<div class="tabsAction">'; if ($user->societe_id == 0 && sizeof($accounts) == 1 && $action == 'new' && $user->rights->banque->cheque) { print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=create&accountid=' . $account_id . '">' . $langs->trans('NewCheckReceipt') . '</a>'; } if ($user->societe_id == 0 && $remisecheque->statut == 0 && $remisecheque->id && $user->rights->banque->cheque) { print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $remisecheque->id . '&action=valide">' . $langs->trans('Valid') . '</a>'; } if ($user->societe_id == 0 && $remisecheque->id && $user->rights->banque->cheque) { print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $remisecheque->id . '&action=delete">' . $langs->trans('Delete') . '</a>'; } print '</div>'; if ($action != 'new') { if ($remisecheque->statut == 1) { $dirchequereceipts = $dir . get_exdir($remisecheque->number, 2, 1) . $remisecheque->ref; $formfile->show_documents("remisecheque", $remisecheque->ref, $dirchequereceipts, $_SERVER["PHP_SELF"] . '?id=' . $remisecheque->id, 1, 1); print '<br>'; } } $db->close(); llxFooter('$Date: 2011/08/03 00:46:28 $ - $Revision: 1.78 $');
foreach ($object->substitutionarray as $key => $val) { print $key . ' = ' . $langs->trans($val) . '<br>'; } print '</i></td>'; print '<td>'; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $doleditor = new DolEditor('body', $_POST['body'], '', 320, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, 70); $doleditor->Create(); print '</td></tr>'; print '</table>'; print '<br><center><input type="submit" class="button" value="' . $langs->trans("CreateMailing") . '"></center>'; print '</form>'; } else { if ($object->id > 0) { $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id, 2, 0, 1); $head = emailing_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("Mailing"), 0, 'email'); // Confirmation de la validation du mailing if ($action == 'valid') { print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $object->id, $langs->trans("ValidMailing"), $langs->trans("ConfirmValidMailing"), "confirm_valid", '', '', 1); } else { if ($action == 'reset') { print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $object->id, $langs->trans("ResetMailing"), $langs->trans("ConfirmResetMailing", $object->ref), "confirm_reset", '', '', 2); } else { if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $object->id . (!empty($urlfrom) ? '&urlfrom=' . urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); } } } if ($action != 'edit') {
} else { dol_print_error($db); } dol_fiche_end(); } /* * Boutons Actions */ print '<div class="tabsAction">'; /*if ($user->societe_id == 0 && count($accounts) == 1 && $action == 'new' && $user->rights->banque->cheque) { print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create&accountid='.$account_id.'">'.$langs->trans('NewCheckReceipt').'</a>'; }*/ if ($user->societe_id == 0 && !empty($object->id) && $object->statut == 0 && $user->rights->banque->cheque) { print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=valide&sortfield=' . $sortfield . '&sortorder=' . $sortorder . '">' . $langs->trans('Valid') . '</a>'; } if ($user->societe_id == 0 && !empty($object->id) && $user->rights->banque->cheque) { print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=delete&sortfield=' . $sortfield . '&sortorder=' . $sortorder . '">' . $langs->trans('Delete') . '</a>'; } print '</div>'; if ($action != 'new') { if ($object->statut == 1) { $filename = dol_sanitizeFileName($object->ref); $filedir = $dir . get_exdir($object->number, 2, 1) . dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $formfile->show_documents('remisecheque', $filename, $filedir, $urlsource, 1, 1); print '<br>'; } } $db->close(); llxFooter();
print '</div>' . "\n"; /* * Ajouter une photo */ if ($action == 'ajout_photo' && $user->rights->categorie->creer && !empty($conf->global->MAIN_UPLOAD_DOC)) { // Affiche formulaire upload $formfile = new FormFile($db); $formfile->form_attach_new_file($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&type=' . $type, $langs->trans("AddPhoto"), 1, '', $user->rights->categorie->creer, 50, $object, '', false, '', 0); } // Affiche photos if ($action != 'ajout_photo') { $nbphoto = 0; $nbbyrow = 5; $maxWidth = 160; $maxHeight = 120; $pdir = get_exdir($object->id, 2) . $object->id . "/photos/"; $dir = $upload_dir . '/' . $pdir; print '<br>'; print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; foreach ($object->liste_photos($dir) as $key => $obj) { $nbphoto++; if ($nbbyrow && $nbphoto % $nbbyrow == 1) { print '<tr align=center valign=middle border=1>'; } if ($nbbyrow) { print '<td width="' . ceil(100 / $nbbyrow) . '%" class="photo">'; } print '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=category&entity=' . $object->entity . '&file=' . urlencode($pdir . $obj['photo']) . '" alt="Taille origine" target="_blank">'; // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine if ($obj['photo_vignette']) { $filename = 'thumbs/' . $obj['photo_vignette'];
if ($don->statut == 1 && $resteapayer > 0) { print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?rowid=' . $don->id . '&action=create">' . $langs->trans("DoPayment") . "</a></div>"; } if ($don->statut == 1 && $resteapayer == 0 && $don->paye == 0) { print '<div class="inline-block divButAction"><a class="butAction" href="fiche.php?rowid=' . $don->id . '&action=set_paid">' . $langs->trans("ClassifyPaid") . "</a></div>"; } if ($user->rights->don->supprimer) { print '<div class="inline-block divButAction"><a class="butActionDelete" href="fiche.php?rowid=' . $don->id . '&action=delete">' . $langs->trans("Delete") . "</a></div>"; } else { print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">' . $langs->trans("Delete") . "</a></div>"; } print "</div>"; print '<table width="100%"><tr><td width="50%" valign="top">'; /* * Documents generes */ $filename = dol_sanitizeFileName($don->id); $filedir = $conf->don->dir_output . '/' . get_exdir($filename, 2); $urlsource = $_SERVER['PHP_SELF'] . '?rowid=' . $don->id; // $genallowed=($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer); // $delallowed=$user->rights->facture->supprimer; $genallowed = 1; $delallowed = 0; $var = true; print '<br>'; $formfile->show_documents('donation', $filename, $filedir, $urlsource, $genallowed, $delallowed); print '</td><td> </td>'; print '</tr></table>'; } llxFooter(); $db->close();
$sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) { $sortorder = "ASC"; } if (!$sortfield) { $sortfield = "name"; } $upload_dir = $conf->adherent->dir_output . "/" . get_exdir($id, 2, 0, 1) . '/' . $id; $form = new Form($db); $object = new Adherent($db); $membert = new AdherentType($db); $result = $object->fetch($id); if ($result < 0) { dol_print_error($db); exit; } /* * Actions */ include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; /* * View */
/** * Return array head with list of tabs to view object informations * * @param Adherent $object Member * @return array head */ function member_prepare_head(Adherent $object) { global $db, $langs, $conf, $user; $h = 0; $head = array(); $head[$h][0] = DOL_URL_ROOT . '/adherents/card.php?rowid=' . $object->id; $head[$h][1] = $langs->trans("MemberCard"); $head[$h][2] = 'general'; $h++; if (!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE)) { $langs->load("ldap"); $head[$h][0] = DOL_URL_ROOT . '/adherents/ldap.php?id=' . $object->id; $head[$h][1] = $langs->trans("LDAPCard"); $head[$h][2] = 'ldap'; $h++; } if (!empty($user->rights->adherent->cotisation->lire)) { $head[$h][0] = DOL_URL_ROOT . '/adherents/card_subscriptions.php?rowid=' . $object->id; $head[$h][1] = $langs->trans("Subscriptions"); $head[$h][2] = 'subscription'; $h++; } // Show agenda tab if (!empty($conf->agenda->enabled)) { $head[$h][0] = DOL_URL_ROOT . "/adherents/agenda.php?id=" . $object->id; $head[$h][1] = $langs->trans('Agenda'); $head[$h][2] = 'agenda'; $h++; } // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'member'); $nbNote = 0; if (!empty($object->note)) { $nbNote++; } if (!empty($object->note_private)) { $nbNote++; } if (!empty($object->note_public)) { $nbNote++; } $head[$h][0] = DOL_URL_ROOT . '/adherents/note.php?id=' . $object->id; $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; if ($nbNote > 0) { $head[$h][1] .= ' <span class="badge">' . $nbNote . '</span>'; } $h++; // Attachments require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $upload_dir = $conf->adherent->multidir_output[$object->entity] . '/' . get_exdir($object->id, 2, 0, 1, $object, 'member') . '/' . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT . '/adherents/document.php?id=' . $object->id; $head[$h][1] = $langs->trans('Documents'); if ($nbFiles + $nbLinks > 0) { $head[$h][1] .= ' <span class="badge">' . ($nbFiles + $nbLinks) . '</span>'; } $head[$h][2] = 'documents'; $h++; $head[$h][0] = DOL_URL_ROOT . '/adherents/info.php?id=' . $object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove'); return $head; }
/** * * Return POS Config * * @return array Array with config */ public static function getConfig() { global $db, $conf, $langs; $cash = new Cash($db); $terminal = $_SESSION['TERMINAL_ID']; $cash->fetch($terminal); $userstatic = new User($db); $userstatic->fetch($_SESSION['uid']); $soc = new Societe($db, $cash->fk_soc); $soc->fetch($cash->fk_soc); $name = $soc->name ? $soc->name : $soc->nom; $ret['error']['value'] = 0; $ret['error']['desc'] = ''; $ret['data']['terminal']['id'] = $cash->id; $ret['data']['terminal']['name'] = $cash->name; $ret['data']['terminal']['tactil'] = $cash->tactil; $ret['data']['terminal']['warehouse'] = $cash->fk_warehouse; $ret['data']['terminal']['barcode'] = $cash->barcode; $ret['data']['terminal']['mode_info'] = 0; $ret['data']['terminal']['faclimit'] = $conf->global->POS_MAX_TTC; $ret['data']['module']['places'] = $conf->global->POS_PLACES; $ret['data']['module']['print'] = $conf->global->POS_PRINT; $ret['data']['module']['mail'] = $conf->global->POS_MAIL; $ret['data']['module']['points'] = $conf->global->REWARDS_DISCOUNT; $ret['data']['module']['ticket'] = $conf->global->POS_TICKET; $ret['data']['module']['facture'] = $conf->global->POS_FACTURE; $ret['data']['module']['print_mode'] = $conf->global->POS_PRINT_MODE; $ret['data']['user']['id'] = $userstatic->id; $ret['data']['user']['name'] = $userstatic->getFullName($langs); $dir = $conf->user->dir_output; if ($userstatic->photo) { $file = get_exdir($userstatic->id, 2) . $userstatic->photo; } if ($file && file_exists($dir . "/" . $file)) { $ret['data']['user']['photo'] = DOL_URL_ROOT . '/viewimage.php?modulepart=userphoto&entity=' . $userstatic->entity . '&file=' . urlencode($file); } else { $ret['data']['user']['photo'] = DOL_URL_ROOT . '/theme/common/nophoto.jpg'; } $ret['data']['customer']['id'] = $soc->id; $ret['data']['customer']['name'] = $name; $ret['data']['customer']['remise'] = $soc->remise_percent; $ret['data']['customer']['coupon'] = $soc->getAvailableDiscounts(); $ret['data']['customer']['points'] = null; if ($conf->global->REWARDS_POS && !empty($conf->rewards->enabled)) { $rew = new Rewards($db); $res = $rew->getCustomerReward($soc->id); if ($res) { $ret['data']['customer']['points'] = $rew->getCustomerPoints($soc->id); } } $ret['data']['decrange']['unit'] = $conf->global->MAIN_MAX_DECIMALS_UNIT; $ret['data']['decrange']['tot'] = $conf->global->MAIN_MAX_DECIMALS_TOT; $ret['data']['decrange']['maxshow'] = $conf->global->MAIN_MAX_DECIMALS_SHOWN; return $ret; }
/** * Write the invoice as a document onto disk * @param object Object invoice to build (or id if old method) * @param outputlangs Lang object for output language * @return int 1=OK, 0=KO */ function write_file($object,$outputlangs='') { global $user,$langs,$conf,$mysoc; if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!class_exists('TCPDF')) $outputlangs->charset_output='ISO-8859-1'; $outputlangs->load("main"); $outputlangs->load("dict"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); $default_font_size = pdf_getPDFFontSize($outputlangs); if ($conf->fournisseur->dir_output.'/facture') { $object->fetch_thirdparty(); $deja_regle = $object->getSommePaiement(); //$amount_credit_notes_included = $object->getSumCreditNotesUsed(); //$amount_deposits_included = $object->getSumDepositsUsed(); // Definition de $dir et $file if ($object->specimen) { $dir = $conf->fournisseur->facture->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$objectref; $file = $dir . "/" . $objectref . ".pdf"; } if (! file_exists($dir)) { if (create_exdir($dir) < 0) { $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); return 0; } } if (file_exists($dir)) { $nblignes = sizeof($object->lines); $pdf=pdf_getInstance($this->format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->Open(); $pagenb=0; $pdf->SetDrawColor(128,128,128); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Invoice")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")); 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(); $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->SetXY ($this->posxdesc-1, $tab_top); $pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'L'); $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 < $nblignes ; $i++) { $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page // Description of product line $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $curX = $this->posxdesc-1; pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1); $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $nexY = $pdf->GetY(); // VAT rate if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs); $pdf->SetXY ($this->posxtva, $curY); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); } // Unit price before discount $pdf->SetXY ($this->posxup, $curY); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, price($object->lines[$i]->pu_ht), 0, 'R', 0); // Quantity $pdf->SetXY ($this->posxqty, $curY); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $object->lines[$i]->qty, 0, 'R'); // Discount on line $pdf->SetXY ($this->posxdiscount, $curY); if ($object->lines[$i]->remise_percent) { $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $object->lines[$i]->remise_percent."%", 0, 'R'); } // Total HT line $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs); $pdf->SetXY ($this->postotalht, $curY); $pdf->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $tvaligne=$object->lines[$i]->total_tva; $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; $vatrate=(string) $object->lines[$i]->tva_tx; $localtax1rate=(string) $object->lines[$i]->localtax1_tx; $localtax2rate=(string) $object->lines[$i]->localtax2_tx; if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; $this->tva[$vatrate] += $tvaligne; $this->localtax1[$localtax1rate]+=$localtax1ligne; $this->localtax2[$localtax2rate]+=$localtax2ligne; $nexY+=2; // Passe espace entre les lignes // 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 < ($nblignes - 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; } // Affiche zone totaux $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // 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; // Pas d'erreur } else { $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); return 0; } } else { $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); return 0; } $this->error=$langs->trans("ErrorUnknown"); return 0; // Erreur par defaut }
/** * Get object and lines from database * * @param int $id Id of object to load * @param string $ref Ref of object * @param string $ref_ext External reference of object * @param string $ref_int Internal reference of other object * @return int >0 if OK, 0 if not found, <0 if KO */ function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') { global $conf; // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) { return -1; } $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut"; $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql .= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery"; $sql .= ", e.fk_shipping_method, e.tracking_number"; $sql .= ", el.fk_source as origin_id, el.sourcetype as origin"; $sql .= ", e.note_private, e.note_public"; $sql .= ', e.fk_incoterms, e.location_incoterms'; $sql .= ', i.libelle as libelle_incoterms'; $sql .= " FROM " . MAIN_DB_PREFIX . "expedition as e"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "element_element as el ON el.fk_target = e.rowid AND el.targettype = '" . $this->element . "'"; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_incoterms as i ON e.fk_incoterms = i.rowid'; $sql .= " WHERE e.entity IN (" . getEntity('expedition', 1) . ")"; if ($id) { $sql .= " AND e.rowid=" . $id; } if ($ref) { $sql .= " AND e.ref='" . $this->db->escape($ref) . "'"; } if ($ref_ext) { $sql .= " AND e.ref_ext='" . $this->db->escape($ref_ext) . "'"; } if ($ref_int) { $sql .= " AND e.ref_int='" . $this->db->escape($ref_int) . "'"; } dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; $this->ref = $obj->ref; $this->socid = $obj->socid; $this->ref_customer = $obj->ref_customer; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date = $this->db->jdate($obj->date_expedition); // TODO deprecated $this->date_expedition = $this->db->jdate($obj->date_expedition); // TODO deprecated $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_address; $this->modelpdf = $obj->model_pdf; $this->shipping_method_id = $obj->fk_shipping_method; $this->tracking_number = $obj->tracking_number; $this->origin = $obj->origin ? $obj->origin : 'commande'; // For compatibility $this->origin_id = $obj->origin_id; $this->billed = $obj->fk_statut == 2 ? 1 : 0; $this->trueWeight = $obj->weight; $this->weight_units = $obj->weight_units; $this->trueWidth = $obj->width; $this->width_units = $obj->size_units; $this->trueHeight = $obj->height; $this->height_units = $obj->size_units; $this->trueDepth = $obj->size; $this->depth_units = $obj->size_units; $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; // A denormalized value $this->trueSize = $obj->size . "x" . $obj->width . "x" . $obj->height; $this->size_units = $obj->size_units; //Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; $this->db->free($result); if ($this->statut == 0) { $this->brouillon = 1; } $file = $conf->expedition->dir_output . "/" . get_exdir($this->id, 2, 0, 0, $this, 'shipment') . "/" . $this->id . ".pdf"; $this->pdf_filename = $file; // Tracking url $this->GetUrlTrackingStatus($obj->tracking_number); /* * Thirparty */ $result = $this->fetch_thirdparty(); // Retrieve all extrafields for expedition // fetch optionals attributes and labels require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($this->table_element, true); $this->fetch_optionals($this->id, $extralabels); /* * Lines */ $result = $this->fetch_lines(); if ($result < 0) { return -3; } return 1; } else { dol_syslog(get_class($this) . '::Fetch no expedition found', LOG_ERR); $this->error = 'Delivery with id ' . $id . ' not found'; return 0; } } else { $this->error = $this->db->error(); return -1; } }