/**
  *	Function to build pdf onto disk
  *
  *	@param		Object		$object			Object expedition to generate (or id if old method)
  *	@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, $conf, $langs, $hookmanager;
     $object->fetch_thirdparty();
     if (!is_object($outputlangs)) {
         $outputlangs = $langs;
     }
     // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
     if (!empty($conf->global->MAIN_USE_FPDF)) {
         $outputlangs->charset_output = 'ISO-8859-1';
     }
     $outputlangs->load("main");
     $outputlangs->load("dict");
     $outputlangs->load("companies");
     $outputlangs->load("bills");
     $outputlangs->load("products");
     $outputlangs->load("propal");
     $outputlangs->load("deliveries");
     $outputlangs->load("sendings");
     if ($conf->expedition->dir_output) {
         // Definition de $dir et $file
         if ($object->specimen) {
             $dir = $conf->expedition->dir_output . "/sending";
             $file = $dir . "/SPECIMEN.pdf";
         } else {
             $expref = dol_sanitizeFileName($object->ref);
             $dir = $conf->expedition->dir_output . "/sending/" . $expref;
             $file = $dir . "/" . $expref . ".pdf";
         }
         if (!file_exists($dir)) {
             if (dol_mkdir($dir) < 0) {
                 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
                 return 0;
             }
         }
         if (file_exists($dir)) {
             $nblignes = count($object->lines);
             $pdf = pdf_getInstance($this->format);
             $default_font_size = pdf_getPDFFontSize($outputlangs);
             $heightforinfotot = 0;
             // 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);
             if (method_exists($pdf, 'AliasNbPages')) {
                 $pdf->AliasNbPages();
             }
             $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
             $pdf->SetSubject($outputlangs->transnoentities("Shipment"));
             $pdf->SetCreator("Dolibarr " . DOL_VERSION);
             $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
             $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Shipment"));
             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
             // 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;
             if (!empty($object->note_public) || !empty($object->tracking_number) && !empty($object->shipping_method_id)) {
                 $tab_top = 88;
                 $tab_top_alt = $tab_top;
                 // Tracking number
                 if (!empty($object->tracking_number)) {
                     $object->GetUrlTrackingStatus($object->tracking_number);
                     if (!empty($object->tracking_url)) {
                         if ($object->shipping_method_id > 0) {
                             // Get code using getLabelFromKey
                             $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
                             $label = $outputlangs->trans("LinkToTrackYourPackage") . "<br>";
                             $label .= $outputlangs->trans("SendingMethod" . strtoupper($code)) . " :";
                             $pdf->SetFont('', 'B', $default_font_size - 2);
                             $pdf->writeHTMLCell(60, 7, $this->posxdesc - 1, $tab_top - 1, $label . " " . $object->tracking_url, 0, 1, false, true, 'L');
                             $tab_top_alt += 7;
                         }
                     }
                 }
                 // Affiche notes
                 if (!empty($object->note_public)) {
                     $pdf->SetFont('', '', $default_font_size - 1);
                     // Dans boucle pour gerer multi-page
                     $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, 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;
             $num = count($object->lines);
             // Loop on each lines
             for ($i = 0; $i < $num; $i++) {
                 $curY = $nexY;
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // Into loop to work with multipage
                 $pdf->SetTextColor(0, 0, 0);
                 $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();
                 // Description de la ligne produit
                 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxqtyordered - 10, 3, $this->posxdesc, $curY, 0, 1);
                 $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 is moved completely on next page
                 if ($pageposafter > $pageposbefore) {
                     $pdf->setPage($pageposafter);
                     $curY = $tab_top_newpage;
                 }
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // On repositionne la police par defaut
                 $pdf->SetXY($this->posxqtyordered, $curY);
                 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, 3, $object->lines[$i]->qty_asked, '', 'C');
                 $pdf->SetXY($this->posxqtytoship, $curY);
                 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxqtytoship, 3, $object->lines[$i]->qty_shipped, '', 'C');
                 // Add line
                 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < $nblignes - 1) {
                     $pdf->setPage($pageposafter);
                     $pdf->SetLineStyle(array('dash' => '1,1', 'color' => array(210, 210, 210)));
                     //$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);
                     } else {
                         $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
                     }
                     $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 (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);
                     } else {
                         $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
                     }
                     $this->_pagefoot($pdf, $object, $outputlangs, 1);
                     // New page
                     $pdf->AddPage();
                     if (!empty($tplidx)) {
                         $pdf->useTemplate($tplidx);
                     }
                     $pagenb++;
                 }
             }
             // Show square
             if ($pagenb == 1) {
                 $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext - $heightforinfotot, 0, $outputlangs, 0, 0);
                 $bottomlasttab = $this->page_hauteur - $heightforfooter - $heightforfreetext - $heightforinfotot + 1;
             } else {
                 $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext - $heightforinfotot, 0, $outputlangs, 1, 0);
                 $bottomlasttab = $this->page_hauteur - $heightforfooter - $heightforfreetext - $heightforinfotot + 1;
             }
             // Pied de page
             $this->_pagefoot($pdf, $object, $outputlangs);
             if (method_exists($pdf, 'AliasNbPages')) {
                 $pdf->AliasNbPages();
             }
             $pdf->Close();
             $pdf->Output($file, 'F');
             if (!empty($conf->global->MAIN_UMASK)) {
                 @chmod($file, octdec($conf->global->MAIN_UMASK));
             }
             return 1;
         } else {
             $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
             return 0;
         }
     } else {
         $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
         return 0;
     }
     $this->error = $langs->transnoentities("ErrorUnknown");
     return 0;
     // Erreur par defaut
 }
示例#2
0
/**
 * Prepare array with list of tabs
 *
 * @param   Object	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function fichinter_prepare_head($object)
{
    global $langs, $conf, $user;
    $langs->load("fichinter");
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/fichinter/card.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Card");
    $head[$h][2] = 'card';
    $h++;
    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
        $head[$h][0] = DOL_URL_ROOT . '/fichinter/contact.php?id=' . $object->id;
        $head[$h][1] = $langs->trans('InterventionContact');
        $head[$h][2] = 'contact';
        $h++;
    }
    if (!empty($conf->global->MAIN_USE_PREVIEW_TABS)) {
        $head[$h][0] = DOL_URL_ROOT . '/fichinter/apercu.php?id=' . $object->id;
        $head[$h][1] = $langs->trans('Preview');
        $head[$h][2] = 'preview';
        $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, 'intervention');
    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 . '/fichinter/note.php?id=' . $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';
    $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$h][0] = DOL_URL_ROOT . '/fichinter/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Documents");
    if ($nbFiles > 0) {
        $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . '/fichinter/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, 'intervention', 'remove');
    return $head;
}
示例#3
0
/**
 *  Return array head with list of tabs to view object informations
 *
 *  @param	Object	$object         Holiday
 *  @return array           		head
 */
function holiday_prepare_head($object)
{
    global $langs, $conf, $user;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/holiday/card.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Card");
    $head[$h][2] = 'card';
    $h++;
    // Attachments
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    $upload_dir = $conf->holiday->multidir_output[$object->entity] . '/' . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$h][0] = DOL_URL_ROOT . '/holiday/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans('Documents');
    if ($nbFiles > 0) {
        $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$h][2] = 'documents';
    $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, 'holiday');
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'remove');
    return $head;
}
示例#4
0
/**
 *	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;
}
示例#5
0
/**
 * Prepare array with list of tabs
 *
 * @param   ChargeSociales	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function tax_prepare_head(ChargeSociales $object)
{
    global $langs, $conf, $user;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/compta/sociales/charges.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, 'tax');
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    $upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$h][0] = DOL_URL_ROOT . '/compta/sociales/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Documents");
    if ($nbFiles > 0) {
        $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . '/compta/sociales/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, 'tax', 'remove');
    return $head;
}
示例#6
0
/**
 * Prepare array with list of tabs
 *
 * @param   Contact	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function contact_prepare_head(Contact $object)
{
    global $db, $langs, $conf, $user;
    $tab = 0;
    $head = array();
    $head[$tab][0] = DOL_URL_ROOT . '/contact/card.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("Card");
    $head[$tab][2] = 'card';
    $tab++;
    if (!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_CONTACT_ACTIVE)) {
        $langs->load("ldap");
        $head[$tab][0] = DOL_URL_ROOT . '/contact/ldap.php?id=' . $object->id;
        $head[$tab][1] = $langs->trans("LDAPCard");
        $head[$tab][2] = 'ldap';
        $tab++;
    }
    $head[$tab][0] = DOL_URL_ROOT . '/contact/perso.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("PersonalInformations");
    $head[$tab][2] = 'perso';
    $tab++;
    // 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, $tab, 'contact');
    // Notes
    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
        $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1);
        $head[$tab][0] = DOL_URL_ROOT . '/contact/note.php?id=' . $object->id;
        $head[$tab][1] = $langs->trans("Note");
        if ($nbNote > 0) {
            $head[$tab][1] .= ' <span class="badge">' . $nbNote . '</span>';
        }
        $head[$tab][2] = 'note';
        $tab++;
    }
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
    $upload_dir = $conf->societe->dir_output . "/contact/" . 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[$tab][0] = DOL_URL_ROOT . '/contact/document.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("Documents");
    if ($nbFiles + $nbLinks > 0) {
        $head[$tab][1] .= ' <span class="badge">' . ($nbFiles + $nbLinks) . '</span>';
    }
    $head[$tab][2] = 'documents';
    $tab++;
    // Info
    $head[$tab][0] = DOL_URL_ROOT . '/contact/info.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("Info");
    $head[$tab][2] = 'info';
    $tab++;
    complete_head_from_modules($conf, $langs, $object, $head, $tab, 'contact', 'remove');
    return $head;
}
示例#7
0
/**
 * Prepare array with list of tabs
 *
 * @param   Account	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function bank_prepare_head(Account $object)
{
    global $db, $langs, $conf, $user;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/compta/bank/card.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("AccountCard");
    $head[$h][2] = 'bankname';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/account.php?id=" . $object->id;
    $head[$h][1] = $langs->trans("Transactions");
    $head[$h][2] = 'journal';
    $h++;
    //    if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
    //	{
    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/treso.php?account=" . $object->id;
    $head[$h][1] = $langs->trans("PlannedTransactions");
    $head[$h][2] = 'cash';
    $h++;
    //	}
    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/annuel.php?account=" . $object->id;
    $head[$h][1] = $langs->trans("IOMonthlyReporting");
    $head[$h][2] = 'annual';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/graph.php?account=" . $object->id;
    $head[$h][1] = $langs->trans("Graph");
    $head[$h][2] = 'graph';
    $h++;
    if ($object->courant != 2) {
        $head[$h][0] = DOL_URL_ROOT . "/compta/bank/releve.php?account=" . $object->id;
        $head[$h][1] = $langs->trans("AccountStatements");
        $head[$h][2] = 'statement';
        $h++;
    }
    // Attached files
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
    $upload_dir = $conf->bank->dir_output . "/" . 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 . "/compta/bank/document.php?account=" . $object->id;
    $head[$h][1] = $langs->trans("Documents");
    if ($nbFiles + $nbLinks > 0) {
        $head[$h][1] .= ' <span class="badge">' . ($nbFiles + $nbLinks) . '</span>';
    }
    $head[$h][2] = 'document';
    $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, 'bank');
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank', 'remove');
    return $head;
}
示例#8
0
/**
 * Prepare array with list of tabs
 *
 * @param   Contrat	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function contract_prepare_head(Contrat $object)
{
    global $db, $langs, $conf;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/contrat/card.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("ContractCard");
    $head[$h][2] = 'card';
    $h++;
    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
        $head[$h][0] = DOL_URL_ROOT . '/contrat/contact.php?id=' . $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, 'contract');
    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 . '/contrat/note.php?id=' . $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->contrat->dir_output . "/" . 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 . '/contrat/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 . '/contrat/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, 'contract', 'remove');
    return $head;
}
示例#9
0
/**
 * Prepare array with list of tabs
 *
 * @param   Object	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function loan_prepare_head($object)
{
    global $langs, $conf;
    $tab = 0;
    $head = array();
    $head[$tab][0] = DOL_URL_ROOT . '/loan/card.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans('Card');
    $head[$tab][2] = 'card';
    $tab++;
    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
        $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1);
        $head[$tab][0] = DOL_URL_ROOT . "/loan/note.php?id=" . $object->id;
        $head[$tab][1] = $langs->trans("Notes");
        if ($nbNote > 0) {
            $head[$tab][1] .= ' <span class="badge">' . $nbNote . '</span>';
        }
        $head[$tab][2] = 'note';
        $tab++;
    }
    // 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, $tab, 'loan');
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$tab][0] = DOL_URL_ROOT . '/loan/document.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("Documents");
    if ($nbFiles > 0) {
        $head[$tab][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$tab][2] = 'documents';
    $tab++;
    $head[$tab][0] = DOL_URL_ROOT . '/loan/info.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("Info");
    $head[$tab][2] = 'info';
    $tab++;
    complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan', 'remove');
    return $head;
}
示例#10
0
            $var = !$var;
            $obj = $db->fetch_object($resql);
            print "<tr " . $bc[$var] . ">";
            print '<td width="20%" class="nowrap">';
            $commandestatic->id = $obj->rowid;
            $commandestatic->ref = $obj->ref;
            print '<table class="nobordernopadding"><tr class="nocellnopadd">';
            print '<td width="96" class="nobordernopadding nowrap">';
            print $commandestatic->getNomUrl(1);
            print '</td>';
            print '<td width="16" class="nobordernopadding nowrap">';
            print '&nbsp;';
            print '</td>';
            print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
            $filename = dol_sanitizeFileName($obj->ref);
            $filedir = $conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
            $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $obj->rowid;
            print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
            print '</td></tr></table>';
            print '</td>';
            print '<td><a href="' . DOL_URL_ROOT . '/fourn/card.php?socid=' . $obj->socid . '">' . img_object($langs->trans("ShowCompany"), "company") . ' ' . $obj->name . '</a></td>';
            print '<td>' . dol_print_date($db->jdate($obj->tms), 'day') . '</td>';
            print '<td align="right">' . $commandestatic->LibStatut($obj->fk_statut, 5) . '</td>';
            print '</tr>';
            $i++;
        }
    }
    print "</table><br>";
} else {
    dol_print_error($db);
}
 print '<td class="nowrap">';
 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 print '<td width="110" class="nobordernopadding nowrap">';
 $facturestatic->ref = $obj->facnumber;
 $facturestatic->id = $obj->rowid;
 $facturestatic->type = $obj->type;
 print $facturestatic->getNomUrl(1, '');
 print '</td>';
 print '<td width="20" class="nobordernopadding nowrap">';
 if ($db->jdate($obj->datelimite) < $now - $conf->facture->client->warning_delay) {
     print img_warning($langs->trans("Late"));
 }
 print '</td>';
 print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
 $filename = dol_sanitizeFileName($obj->facnumber);
 $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->facnumber);
 $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $obj->rowid;
 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
 print '</td></tr></table>';
 print '</td>';
 print '<td align="left">';
 $societestatic->id = $obj->socid;
 $societestatic->nom = $obj->nom;
 $societestatic->client = 1;
 print $societestatic->getNomUrl(1, 'customer', 44);
 print '</a></td>';
 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
     print '<td align="right">' . price($obj->total) . '</td>';
 }
 print '<td align="right">' . price($obj->total_ttc) . '</td>';
 print '<td align="right">' . price($obj->am) . '</td>';
示例#12
0
 /**	Load an object from its id and create a new one in database
  *
  *	@param	int		$fromid     			Id of object to clone
  *  @param	int		$project_id				Id of project to attach clone task
  *  @param	int		$parent_task_id			Id of task to attach clone task
  *  @param	bool	$clone_change_dt		recalculate date of task regarding new project start date
  *	@param	bool	$clone_affectation		clone affectation of project
  *	@param	bool	$clone_time				clone time of project
  *	@param	bool	$clone_file				clone file of project
  *  @param	bool	$clone_note				clone note of project
  *	@param	bool	$clone_prog				clone progress of project
  * 	@return	int								New id of clone
  */
 function createFromClone($fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false)
 {
     global $user, $langs, $conf;
     $error = 0;
     //Use 00:00 of today if time is use on task.
     $now = dol_mktime(0, 0, 0, dol_print_date(dol_now(), '%m'), dol_print_date(dol_now(), '%d'), dol_print_date(dol_now(), '%Y'));
     $datec = $now;
     $clone_task = new Task($this->db);
     $origin_task = new Task($this->db);
     $clone_task->context['createfromclone'] = 'createfromclone';
     $this->db->begin();
     // Load source object
     $clone_task->fetch($fromid);
     $origin_task->fetch($fromid);
     $defaultref = '';
     $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
     if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . ".php")) {
         require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . '.php';
         $modTask = new $obj();
         $defaultref = $modTask->getNextValue(0, $clone_task);
     }
     $ori_project_id = $clone_task->fk_project;
     $clone_task->id = 0;
     $clone_task->ref = $defaultref;
     $clone_task->fk_project = $project_id;
     $clone_task->fk_task_parent = $parent_task_id;
     $clone_task->date_c = $datec;
     $clone_task->planned_workload = $origin_task->planned_workload;
     $clone_task->rang = $origin_task->rang;
     //Manage Task Date
     if ($clone_change_dt) {
         $projectstatic = new Project($this->db);
         $projectstatic->fetch($ori_project_id);
         //Origin project strat date
         $orign_project_dt_start = $projectstatic->date_start;
         //Calcultate new task start date with difference between origin proj start date and origin task start date
         if (!empty($clone_task->date_start)) {
             $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start;
         }
         //Calcultate new task end date with difference between origin proj end date and origin task end date
         if (!empty($clone_task->date_end)) {
             $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start;
         }
     }
     if (!$clone_prog) {
         $clone_task->progress = 0;
     }
     // Create clone
     $result = $clone_task->create($user);
     // Other options
     if ($result < 0) {
         $this->error = $clone_task->error;
         $error++;
     }
     // End
     if (!$error) {
         $clone_task_id = $clone_task->id;
         $clone_task_ref = $clone_task->ref;
         //Note Update
         if (!$clone_note) {
             $clone_task->note_private = '';
             $clone_task->note_public = '';
         } else {
             $this->db->begin();
             $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_public, ENT_QUOTES), '_public');
             if ($res < 0) {
                 $this->error .= $clone_task->error;
                 $error++;
                 $this->db->rollback();
             } else {
                 $this->db->commit();
             }
             $this->db->begin();
             $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES), '_private');
             if ($res < 0) {
                 $this->error .= $clone_task->error;
                 $error++;
                 $this->db->rollback();
             } else {
                 $this->db->commit();
             }
         }
         //Duplicate file
         if ($clone_file) {
             require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
             //retreive project origin ref to know folder to copy
             $projectstatic = new Project($this->db);
             $projectstatic->fetch($ori_project_id);
             $ori_project_ref = $projectstatic->ref;
             if ($ori_project_id != $project_id) {
                 $projectstatic->fetch($project_id);
                 $clone_project_ref = $projectstatic->ref;
             } else {
                 $clone_project_ref = $ori_project_ref;
             }
             $clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref) . "/" . dol_sanitizeFileName($clone_task_ref);
             $ori_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($ori_project_ref) . "/" . dol_sanitizeFileName($fromid);
             $filearray = dol_dir_list($ori_task_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', '', SORT_ASC, 1);
             foreach ($filearray as $key => $file) {
                 if (!file_exists($clone_task_dir)) {
                     if (dol_mkdir($clone_task_dir) < 0) {
                         $this->error .= $langs->trans('ErrorInternalErrorDetected') . ':dol_mkdir';
                         $error++;
                     }
                 }
                 $rescopy = dol_copy($ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name'], 0, 1);
                 if (is_numeric($rescopy) && $rescopy < 0) {
                     $this->error .= $langs->trans("ErrorFailToCopyFile", $ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name']);
                     $error++;
                 }
             }
         }
         // clone affectation
         if ($clone_affectation) {
             $origin_task = new Task($this->db);
             $origin_task->fetch($fromid);
             foreach (array('internal', 'external') as $source) {
                 $tab = $origin_task->liste_contact(-1, $source);
                 $num = count($tab);
                 $i = 0;
                 while ($i < $num) {
                     $clone_task->add_contact($tab[$i]['id'], $tab[$i]['code'], $tab[$i]['source']);
                     if ($clone_task->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
                         $langs->load("errors");
                         $this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
                         $error++;
                     } else {
                         if ($clone_task->error != '') {
                             $this->error .= $clone_task->error;
                             $error++;
                         }
                     }
                     $i++;
                 }
             }
         }
         if ($clone_time) {
             //TODO clone time of affectation
         }
     }
     unset($clone_task->context['createfromclone']);
     if (!$error) {
         $this->db->commit();
         return $clone_task_id;
     } else {
         $this->db->rollback();
         dol_syslog(get_class($this) . "::createFromClone nbError: " . $error . " error : " . $this->error, LOG_ERR);
         return -1;
     }
 }
示例#13
0
文件: soc.php 项目: nrjacker4/crm-php
        $object->default_lang		= $_POST["default_lang"];

        $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);

        // Gestion du logo de la société
        $dir     = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
        $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
        if ($file_OK)
        {
            if (image_format_supported($_FILES['photo']['name']))
            {
                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);

                    if (! $result > 0)
                    {
                        $errors[] = "ErrorFailedToSaveFile";
                    }
                    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);
示例#14
0
 /**
  *  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("trips");
     $outputlangs->load("project");
     $nblignes = count($object->lines);
     if ($conf->expensereport->dir_output) {
         // Definition of $dir and $file
         if ($object->specimen) {
             $dir = $conf->expensereport->dir_output;
             $file = $dir . "/SPECIMEN.pdf";
         } else {
             $objectref = dol_sanitizeFileName($object->ref);
             $dir = $conf->expensereport->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 (isset($object->lignes) && !isset($object->lines)) {
             $object->lines = $object->lignes;
         }
         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
             // 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_number));
             $pdf->SetSubject($outputlangs->transnoentities("Trips"));
             $pdf->SetCreator("Dolibarr " . DOL_VERSION);
             $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
             $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref) . " " . $outputlangs->transnoentities("Trips"));
             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++;
                 }
             }
             // 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 = 95;
             $tab_top_newpage = empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 95 : 10;
             $tab_height = 110;
             $tab_height_newpage = 110;
             // Show 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 = 95;
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->writeHTMLCell(190, 3, $this->posxpiece - 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++) {
                 $piece_comptable = $i + 1;
                 $curY = $nexY;
                 $pdf->SetFont('', '', $default_font_size - 1);
                 // Into loop to work with multipage
                 $pdf->SetTextColor(0, 0, 0);
                 $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();
                 // Description of product line
                 $curX = $this->posxdesc - 1;
                 $showpricebeforepagebreak = 1;
                 // Accountancy piece
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 1, 3, $this->posxpiece - 1, $curY, $piece_comptable, 0, 1);
                 // Comments
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->SetXY($this->posxcomment, $curY);
                 $pdf->writeHTMLCell($this->posxdate - $this->posxdesc - 1, 3, $this->posxdesc - 1, $curY, $object->lines[$i]->comments, 0, 1);
                 //nexY
                 $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.
                 // Date
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->SetXY($this->posxdate, $curY);
                 $pdf->MultiCell($this->posxtype - $this->posxdate - 1, 3, dol_print_date($object->lines[$i]->date, "day", false, $outpulangs), 0, 'C');
                 // Type
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->SetXY($this->posxtype, $curY);
                 $pdf->MultiCell($this->posxprojet - $this->posxtype - 1, 3, $outputlangs->transnoentities($object->lines[$i]->type_fees_code), 0, 'C');
                 // Project
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->SetXY($this->posxprojet, $curY);
                 $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 3, $object->lines[$i]->projet_ref, 0, 'C');
                 // VAT Rate
                 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
                     $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
                     $pdf->SetFont('', '', $default_font_size - 1);
                     $pdf->SetXY($this->posxtva, $curY);
                     $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R');
                 }
                 // Unit price
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->SetXY($this->posxup, $curY);
                 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 3, price($object->lines[$i]->value_unit), 0, 'R');
                 // Quantity
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->SetXY($this->posxqty, $curY);
                 $pdf->MultiCell($this->postotalttc - $this->posxqty, 3, $object->lines[$i]->qty, 0, 'C');
                 // Total with all taxes
                 $pdf->SetFont('', '', $default_font_size - 1);
                 $pdf->SetXY($this->postotalttc - 1, $curY);
                 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R');
                 $nexY += 5;
                 // Cherche nombre de lignes a venir pour savoir si place suffisante
                 if ($i < $nblignes - 1) {
                     //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;
                 }
                 $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);
                     } else {
                         $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
                     }
                     $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);
                     } else {
                         $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
                     }
                     $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);
                 $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);
                 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
             }
             // Show total area box
             $posy = $bottomlasttab + 5;
             //$nexY+95;
             $pdf->SetXY(100, $posy);
             $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalHT"), 1, 'L');
             $pdf->SetXY(160, $posy);
             $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ht), 1, 'R');
             $pdf->SetFillColor(248, 248, 248);
             if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
                 $posy += 5;
                 $pdf->SetXY(100, $posy);
                 $pdf->SetTextColor(0, 0, 60);
                 $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalVAT"), 1, 'L');
                 $pdf->SetXY(160, $posy);
                 $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_tva), 1, 'R');
             }
             $posy += 5;
             $pdf->SetXY(100, $posy);
             $pdf->SetFont('', 'B', 10);
             $pdf->SetTextColor(0, 0, 60);
             $pdf->MultiCell(60, 5, $outputlangs->transnoentities("TotalTTC"), 1, 'L');
             $pdf->SetXY(160, $posy);
             $pdf->MultiCell($this->page_largeur - $this->marge_gauche - 160, 5, price($object->total_ttc), 1, 'R');
             // 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", "EXPENSEREPORT_OUTPUTDIR");
         return 0;
     }
     $this->error = $langs->trans("ErrorUnknown");
     return 0;
     // Erreur par defaut
 }
</legend>
<label for="filename_template"> <?php 
echo $langs->trans("FileNameToGenerate");
?>
</label>:
 <input type="text" name="filename_template" size="60"
	id="filename_template"
	value="<?php 
$prefix = 'dump';
if ($label == 'MySQL') {
    $prefix = 'mysqldump';
}
if ($label == 'PostgreSQL') {
    $prefix = 'pg_dump';
}
$file = $prefix . '_' . $dolibarr_main_db_name . '_' . dol_sanitizeFileName(DOL_VERSION) . '_' . strftime("%Y%m%d%H%M") . '.sql';
echo $file;
?>
" /> <br>
<br>

<?php 
// Define compressions array
$compression = array('none' => array('function' => '', 'id' => 'radio_compression_none', 'label' => $langs->trans("None")), 'gz' => array('function' => 'gzopen', 'id' => 'radio_compression_gzip', 'label' => $langs->trans("Gzip")));
if ($label == 'MySQL') {
    //	$compression['zip']= array('function' => 'dol_compress', 'id' => 'radio_compression_zip',  'label' => $langs->trans("FormatZip"));		// Not open source format. Must implement dol_compress function
    $compression['bz'] = array('function' => 'bzopen', 'id' => 'radio_compression_bzip', 'label' => $langs->trans("Bzip2"));
}
// Show compression choices
print '<div class="formelementrow">';
print "\n";
 /**
  *  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
 }
示例#17
0
  * Action presend (or prerelance)
  */
 $object->fetch_projet();
 // By default if $action=='presend'
 $titreform = 'SendBillByMail';
 $topicmail = 'SendBillRef';
 $modelmail = 'facture_send';
 if ($action == 'prerelance') {
     $titrefrom = 'SendReminderBillByMail';
     $topicmail = 'SendReminderBillRef';
     $modelmail = 'facture_relance';
     $action = 'relance';
 } else {
     $action = 'send';
 }
 $ref = dol_sanitizeFileName($object->ref);
 include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
 $fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($ref, '/') . '[^\\-]+');
 $file = $fileparams['fullname'];
 // Define output language
 $outputlangs = $langs;
 $newlang = '';
 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) {
     $newlang = $_REQUEST['lang_id'];
 }
 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
     $newlang = $object->thirdparty->default_lang;
 }
 if (!empty($newlang)) {
     $outputlangs = new Translate('', $conf);
     $outputlangs->setDefaultLang($newlang);
 /**
  *  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
 }
示例#19
0
	/**
     *      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
	}
示例#20
0
    /**
     *      Update parameters of third party
     *      @param      id              			id societe
     *      @param      user            			Utilisateur qui demande la mise a jour
     *      @param      call_trigger    			0=non, 1=oui
     *		@param		allowmodcodeclient			Inclut modif code client et code compta
     *		@param		allowmodcodefournisseur		Inclut modif code fournisseur et code compta fournisseur
     *      @return     int             			<0 if KO, >=0 if OK
     */
    function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0)
    {
        require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");

        global $langs,$conf;

        dol_syslog("Societe::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);

        // For triggers
        if ($call_trigger)
        {
        	$objectstatic=new Societe($this->db);
        	$objectstatic->fetch($id);
        	$this->oldobject = $objectstatic;
        }

        $now=dol_now();

        // Clean parameters
        $this->id=$id;
        $this->name=$this->name?trim($this->name):trim($this->nom);
        $this->nom=trim($this->nom);    // TODO obsolete
        $this->address=$this->address?trim($this->address):trim($this->adresse);
        $this->adresse=$this->address;  // TODO obsolete
        $this->zip=$this->zip?trim($this->zip):trim($this->cp);
        $this->cp=$this->zip;           // TODO obsolete
        $this->town=$this->town?trim($this->town):trim($this->ville);
        $this->ville=$this->town;       // TODO obsolete
        $this->departement_id=trim($this->departement_id);
        $this->pays_id=trim($this->pays_id);
        $this->tel=trim($this->tel);
        $this->fax=trim($this->fax);
        $this->tel = preg_replace("/\s/","",$this->tel);
        $this->tel = preg_replace("/\./","",$this->tel);
        $this->fax = preg_replace("/\s/","",$this->fax);
        $this->fax = preg_replace("/\./","",$this->fax);
        $this->email=trim($this->email);
        $this->url=$this->url?clean_url($this->url,0):'';
        $this->siren=trim($this->siren);
        $this->siret=trim($this->siret);
        $this->ape=trim($this->ape);
        $this->idprof4=trim($this->idprof4);
        $this->prefix_comm=trim($this->prefix_comm);

        $this->tva_assuj=trim($this->tva_assuj);
        $this->tva_intra=dol_sanitizeFileName($this->tva_intra,'');
        if (empty($this->status)) $this->status = 0;

        // Local taxes
        $this->localtax1_assuj=trim($this->localtax1_assuj);
        $this->localtax2_assuj=trim($this->localtax2_assuj);

        $this->capital=price2num(trim($this->capital),'MT');
        if (empty($this->capital)) $this->capital = 0;

        $this->effectif_id=trim($this->effectif_id);
        $this->forme_juridique_code=trim($this->forme_juridique_code);

        //Gencod
        $this->gencod=trim($this->gencod);

        // For automatic creation
        if ($this->code_client == -1) $this->get_codeclient($this->prefix_comm,0);
        if ($this->code_fournisseur == -1) $this->get_codefournisseur($this->prefix_comm,1);

        $this->code_compta=trim($this->code_compta);
        $this->code_compta_fournisseur=trim($this->code_compta_fournisseur);

        // Check parameters
        if (! empty($conf->global->SOCIETE_MAIL_REQUIRED) && ! isValidEMail($this->email))
        {
            $langs->load("errors");
            $this->error = $langs->trans("ErrorBadEMail",$this->email);
            return -1;
        }

        $this->db->begin();

        // Check name is required and codes are ok or unique.
        // If error, this->errors[] is filled
        $result = $this->verify();

        if ($result >= 0)
        {
            dol_syslog("Societe::Update verify ok");

            $sql = "UPDATE ".MAIN_DB_PREFIX."societe";
            $sql.= " SET nom = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire
            $sql.= ",datea = '".$this->db->idate($now)."'";
            $sql.= ",address = '" . $this->db->escape($this->address) ."'";

            $sql.= ",cp = ".($this->zip?"'".$this->zip."'":"null");
            $sql.= ",ville = ".($this->town?"'".$this->db->escape($this->town)."'":"null");

            $sql .= ",fk_departement = '" . ($this->departement_id?$this->departement_id:'0') ."'";
            $sql .= ",fk_pays = '" . ($this->pays_id?$this->pays_id:'0') ."'";

            $sql .= ",tel = ".($this->tel?"'".$this->db->escape($this->tel)."'":"null");
            $sql .= ",fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null");
            $sql .= ",email = ".($this->email?"'".$this->db->escape($this->email)."'":"null");
            $sql .= ",url = ".($this->url?"'".$this->db->escape($this->url)."'":"null");

            $sql .= ",siren   = '". $this->db->escape($this->siren)   ."'";
            $sql .= ",siret   = '". $this->db->escape($this->siret)   ."'";
            $sql .= ",ape     = '". $this->db->escape($this->ape)     ."'";
            $sql .= ",idprof4 = '". $this->db->escape($this->idprof4) ."'";

            $sql .= ",tva_assuj = ".($this->tva_assuj!=''?"'".$this->tva_assuj."'":"null");
            $sql .= ",tva_intra = '" . $this->db->escape($this->tva_intra) ."'";
            $sql .= ",status = " .$this->status;

            // Local taxes
            $sql .= ",localtax1_assuj = ".($this->localtax1_assuj!=''?"'".$this->localtax1_assuj."'":"null");
            $sql .= ",localtax2_assuj = ".($this->localtax2_assuj!=''?"'".$this->localtax2_assuj."'":"null");

            $sql .= ",capital = ".$this->capital;

            $sql .= ",prefix_comm = ".($this->prefix_comm?"'".$this->db->escape($this->prefix_comm)."'":"null");

            $sql .= ",fk_effectif = ".($this->effectif_id?"'".$this->effectif_id."'":"null");

            $sql .= ",fk_typent = ".($this->typent_id?"'".$this->typent_id."'":"0");

            $sql .= ",fk_forme_juridique = ".($this->forme_juridique_code?"'".$this->forme_juridique_code."'":"null");

            $sql .= ",client = " . ($this->client?$this->client:0);
            $sql .= ",fournisseur = " . ($this->fournisseur?$this->fournisseur:0);
            $sql .= ",gencod = ".($this->gencod?"'".$this->gencod."'":"null");
            $sql .= ",default_lang = ".($this->default_lang?"'".$this->default_lang."'":"null");
            $sql .= ",logo = ".($this->logo?"'".$this->logo."'":"null");

            if ($allowmodcodeclient)
            {
                //$this->check_codeclient();

                $sql .= ", code_client = ".($this->code_client?"'".$this->db->escape($this->code_client)."'":"null");

                // Attention get_codecompta peut modifier le code suivant le module utilise
                if (empty($this->code_compta)) $this->get_codecompta('customer');

                $sql .= ", code_compta = ".($this->code_compta?"'".$this->db->escape($this->code_compta)."'":"null");
            }

            if ($allowmodcodefournisseur)
            {
                //$this->check_codefournisseur();

                $sql .= ", code_fournisseur = ".($this->code_fournisseur?"'".$this->db->escape($this->code_fournisseur)."'":"null");

                // Attention get_codecompta peut modifier le code suivant le module utilise
                if (empty($this->code_compta_fournisseur)) $this->get_codecompta('supplier');

                $sql .= ", code_compta_fournisseur = ".($this->code_compta_fournisseur?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null");
            }
            $sql .= ", fk_user_modif = ".($user->id > 0 ? "'".$user->id."'":"null");
            $sql .= " WHERE rowid = '" . $id ."'";


            dol_syslog(get_class($this)."::Update sql=".$sql);
            $resql=$this->db->query($sql);
            if ($resql)
            {
                // Si le fournisseur est classe on l'ajoute
                $this->AddFournisseurInCategory($this->fournisseur_categorie);

                $result=$this->insertExtraFields();
                if ($result < 0)
                {
                    $error++;
                }

                if (! $error && $call_trigger)
                {
                    // Appel des triggers
                    include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
                    $interface=new Interfaces($this->db);
                    $result=$interface->run_triggers('COMPANY_MODIFY',$this,$user,$langs,$conf);
                    if ($result < 0) { $error++; $this->errors=$interface->errors; }
                    // Fin appel triggers
                }

                if (! $error)
                {
                    dol_syslog(get_class($this)."::Update success");
                    $this->db->commit();
                    return 1;
                }
                else
                {
                    $this->db->rollback();
                    return -1;
                }
            }
            else
            {
                if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
                {
                    // Doublon
                    $this->error = $langs->trans("ErrorDuplicateField");
                    $result =  -1;
                }
                else
                {

                    $this->error = $langs->trans("Error sql=".$sql);
                    dol_syslog(get_class($this)."::Update fails update sql=".$sql, LOG_ERR);
                    $result =  -2;
                }
                $this->db->rollback();
                return $result;
            }
        }
        else
        {
            $this->db->rollback();
            dol_syslog(get_class($this)."::Update fails verify ".join(',',$this->errors), LOG_WARNING);
            return -3;
        }
    }
示例#21
0
    $sortorder = "ASC";
}
if (!$sortfield) {
    $sortfield = "name";
}
/*
 * Actions
 */
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php';
/*
 * View
 */
llxHeader('', $langs->trans('Project'), 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes');
$form = new Form($db);
if ($object->id > 0) {
    $upload_dir = $conf->projet->dir_output . '/' . dol_sanitizeFileName($object->ref);
    // To verify role of users
    //$userAccess = $object->restrictedProjectArea($user,'read');
    $userWrite = $object->restrictedProjectArea($user, 'write');
    //$userDelete = $object->restrictedProjectArea($user,'delete');
    //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
    $head = project_prepare_head($object);
    dol_fiche_head($head, 'document', $langs->trans("Project"), 0, $object->public ? 'projectpub' : 'project');
    // Files list constructor
    $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', $sortfield, strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC, 1);
    $totalsize = 0;
    foreach ($filearray as $key => $file) {
        $totalsize += $file['size'];
    }
    print '<table class="border" width="100%">';
    $linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php">' . $langs->trans("BackToList") . '</a>';
示例#22
0
         } else {
             print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("NotOwnerOfProject") . '">' . $langs->trans('Delete') . '</a></div>';
         }
     }
 }
 print "</div>";
 print "<br>\n";
 if ($action != 'presend') {
     print '<div class="fichecenter"><div class="fichehalfleft">';
     print '<a name="builddoc"></a>';
     // ancre
     /*
      * Documents generes
      */
     $filename = dol_sanitizeFileName($object->ref);
     $filedir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
     $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
     $genallowed = $user->rights->projet->lire && $userAccess > 0;
     $delallowed = $user->rights->projet->creer && $userWrite > 0;
     $var = true;
     $somethingshown = $formfile->show_documents('project', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf);
     print '</div></div class="fichehalfright">';
     if (!empty($object->id)) {
         // List of actions on element
         include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
         $formactions = new FormActions($db);
         $somethingshown = $formactions->showactions($object, 'project', $socid);
     }
     print '</div>';
 }
 // Hook to add more things on page
示例#23
0
 print $objectstatic->getNomUrl(1);
 print '</td>';
 print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
 if ($objp->fk_statut == 1 && $db->jdate($objp->dfv) < $now - $conf->propal->cloture->warning_delay) {
     print img_warning($langs->trans("Late"));
 }
 if (!empty($objp->note_private)) {
     print ' <span class="note">';
     print '<a href="' . DOL_URL_ROOT . '/comm/propal/note.php?id=' . $objp->propalid . '">' . img_picto($langs->trans("ViewPrivateNote"), 'object_generic') . '</a>';
     print '</span>';
 }
 print '</td>';
 // Ref
 print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">';
 $filename = dol_sanitizeFileName($objp->ref);
 $filedir = $conf->propal->dir_output . '/' . dol_sanitizeFileName($objp->ref);
 $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $objp->propalid;
 print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
 print '</td></tr></table>';
 print "</td>\n";
 // Customer ref
 print '<td class="nocellnopadd nowrap">';
 print $objp->ref_client;
 print '</td>';
 $url = DOL_URL_ROOT . '/comm/card.php?socid=' . $objp->rowid;
 // Company
 $companystatic->id = $objp->rowid;
 $companystatic->name = $objp->name;
 $companystatic->client = $objp->client;
 $companystatic->code_client = $objp->code_client;
 print '<td>';
示例#24
0
 $projectstatic = new Project($db);
 while ($i < min($num, $conf->liste_limit)) {
     $obj = $db->fetch_object($resql);
     $var = !$var;
     $objectstatic->id = $obj->rowid;
     $objectstatic->ref = $obj->ref;
     $objectstatic->ref_supplier = $obj->ref_supplier;
     $objectstatic->total_ht = $obj->total_ht;
     $objectstatic->total_tva = $obj->total_tva;
     $objectstatic->total_ttc = $obj->total_ttc;
     print "<tr " . $bc[$var] . ">";
     // Ref
     print '<td class="nobordernopadding nowrap">';
     print $objectstatic->getNomUrl(1);
     $filename = dol_sanitizeFileName($obj->ref);
     $filedir = $conf->fournisseur->dir_output . '/commande' . '/' . dol_sanitizeFileName($obj->ref);
     print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
     print '</td>' . "\n";
     // Ref Supplier
     if (empty($conf->global->SUPPLIER_ORDER_HIDE_REF_SUPPLIER)) {
         print '<td>' . $obj->ref_supplier . '</td>' . "\n";
     }
     // Thirdparty
     print '<td>';
     $thirdpartytmp->id = $obj->socid;
     $thirdpartytmp->name = $obj->name;
     print $thirdpartytmp->getNomUrl(1, 'supplier');
     print '</td>' . "\n";
     // Project
     if (!empty($conf->global->PROJECT_SHOW_REF_INTO_LISTS)) {
         $projectstatic->id = $obj->project_id;
示例#25
0
/**
 *  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;
}
    } 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&amp;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 . '&amp;action=valide&amp;sortfield=' . $sortfield . '&amp;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 . '&amp;action=delete&amp;sortfield=' . $sortfield . '&amp;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();
示例#27
0
 // Ref
 print '<td class="nowrap" width="140">';
 $supplier_proposalstatic->id = $obj->supplier_proposalid;
 $supplier_proposalstatic->ref = $obj->ref;
 print '<table class="nobordernopadding"><tr class="nocellnopadd">';
 print '<td class="nobordernopadding nowrap">';
 print $supplier_proposalstatic->getNomUrl(1);
 print '</td>';
 print '<td width="18" class="nobordernopadding nowrap">';
 if ($db->jdate($obj->dfv) < $now - $conf->supplier_proposal->cloture->warning_delay) {
     print img_warning($langs->trans("Late"));
 }
 print '</td>';
 print '<td width="16" align="center" class="nobordernopadding">';
 $filename = dol_sanitizeFileName($obj->ref);
 $filedir = $conf->supplier_proposal->dir_output . '/' . dol_sanitizeFileName($obj->ref);
 $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $obj->supplier_proposalid;
 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
 print '</td></tr></table>';
 print "</td>";
 $companystatic->id = $obj->socid;
 $companystatic->name = $obj->socname;
 $companystatic->client = $obj->client;
 $companystatic->canvas = $obj->canvas;
 print '<td align="left">' . $companystatic->getNomUrl(1, 'customer', 44) . '</td>' . "\n";
 print '<td align="right">';
 print dol_print_date($db->jdate($obj->dp), 'day') . '</td>' . "\n";
 print '<td align="right">' . price($obj->total_ttc) . '</td>';
 print '<td align="center" width="14">' . $supplier_proposalstatic->LibStatut($obj->fk_statut, 3) . '</td>' . "\n";
 print '</tr>' . "\n";
 $i++;
    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>&nbsp;</td>';
    print '</tr></table>';
}
llxFooter();
$db->close();
示例#29
0
					{
						print '<a class="butActionDelete" href="fiche.php?id='.$delivery->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
					}
				}

				print '</div>';
			}
			print "\n";

			print '<table width="100%" cellspacing="2"><tr><td width="50%" valign="top">';

			/*
		 	 * Documents generated
			 */

			$deliveryref = dol_sanitizeFileName($delivery->ref);
			$filedir = $conf->expedition->dir_output . "/receipt/" . $deliveryref;
			$urlsource = $_SERVER["PHP_SELF"]."?id=".$delivery->id;

			$genallowed=$user->rights->expedition->livraison->creer;
			$delallowed=$user->rights->expedition->livraison->supprimer;

			$somethingshown=$formfile->show_documents('livraison',$deliveryref,$filedir,$urlsource,$genallowed,$delallowed,$delivery->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
			if ($genallowed && ! $somethingshown) $somethingshown=1;

			print '</td><td valign="top" width="50%">';

			// Rien a droite

			print '</td></tr></table>';
	/**
	 *		\brief      Fonction generant le document sur le disque
	 *		\param	    object			Objet expedition a generer (ou id si ancienne methode)
	 *		\param		outputlangs		Lang output object
	 * 	 	\return	    int     		1=ok, 0=ko
	 */
	function write_file(&$object, $outputlangs)
	{
		global $user,$conf,$langs;
		$default_font_size = pdf_getPDFFontSize($outputlangs);

		$object->fetch_thirdparty();

		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");
		$outputlangs->load("propal");
		$outputlangs->load("deliveries");
        $outputlangs->load("sendings");

		if ($conf->expedition->dir_output)
		{
			// Definition de $dir et $file
			if ($object->specimen)
			{
				$dir = $conf->expedition->dir_output."/sending";
				$file = $dir . "/SPECIMEN.pdf";
			}
			else
			{
				$expref = dol_sanitizeFileName($object->ref);
				$dir = $conf->expedition->dir_output."/sending/" . $expref;
				$file = $dir . "/" . $expref . ".pdf";
			}

			if (! file_exists($dir))
			{
				if (create_exdir($dir) < 0)
				{
					$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir);
					return 0;
				}
			}

			if (file_exists($dir))
			{
                $pdf=pdf_getInstance($this->format);

                if (class_exists('TCPDF'))
                {
                    $pdf->setPrintHeader(false);
                    $pdf->setPrintFooter(false);
                }
                $pdf->SetFont(pdf_getPDFFont($outputlangs));

				$pdf->Open();
				$pagenb=0;
				$pdf->SetDrawColor(128,128,128);

				$pdf->AliasNbPages();

				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
				$pdf->SetSubject($outputlangs->transnoentities("Sending"));
				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
				$pdf->SetKeyWords($outputlangs->convToOutputCharset($fac->ref)." ".$outputlangs->transnoentities("Sending"));
				if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);

				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
				$pdf->SetAutoPageBreak(1,0);

				// New page
				$pdf->AddPage();
				$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_height = 170;
				
				if (! empty($object->note_public) || ! empty($object->tracking_number))
				{
					$tab_top = 88;
					
					// Tracking number
					if (! empty($object->tracking_number))
					{
						$object->GetUrlTrackingStatus($object->tracking_number);
						if (! empty($object->tracking_url))
						{
							if ($object->expedition_method_id > 0)
							{
								// Get code using getLabelFromKey
								$code=$outputlangs->getLabelFromKey($this->db,$object->expedition_method_id,'c_shipment_mode','rowid','code');
								$label=$outputlangs->trans("LinkToTrackYourPackage")."<br>";
								$label.=$outputlangs->trans("SendingMethod".strtoupper($code))." :";
								$pdf->SetFont('','B', $default_font_size - 2);
								$pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $label." ".$object->tracking_url, 0, 1, false, true, 'L');
							}
						}
					}

					// Affiche notes
					if (! empty($object->note_public))
					{
						$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;
				}
				
				$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);

				$nexY = $tab_top + 7;

				for ($i = 0 ; $i < sizeof($object->lines) ; $i++)
				{
					$curY = $nexY;

					$pdf->SetFont('','', $default_font_size - 1);   // Dans boucle pour gerer multi-page

					// Description de la ligne produit
					pdf_writelinedesc($pdf,$object,$i,$outputlangs,150,3,$this->posxdesc,$curY,0,1);

					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
					$nexY = $pdf->GetY();

					$pdf->SetXY ($this->posxqtyordered+5, $curY);
					$pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked,'','C');

					$pdf->SetXY ($this->posxqtytoship+5, $curY);
					$pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped,'','C');

					$nexY+=2;    // Passe espace entre les lignes
				}


				// Pied de page
				$this->_pagefoot($pdf,$object,$outputlangs);
				$pdf->AliasNbPages();

				$pdf->Close();

				$pdf->Output($file,'F');
				if (! empty($conf->global->MAIN_UMASK))
				@chmod($file, octdec($conf->global->MAIN_UMASK));

				return 1;
			}
			else
			{
				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
				return 0;
			}
		}
		else
		{
			$this->error=$langs->transnoentities("ErrorConstantNotDefined","EXP_OUTPUTDIR");
			return 0;
		}
		$this->error=$langs->transnoentities("ErrorUnknown");
		return 0;   // Erreur par defaut
	}