/**
  * \brief		Constructor
  * \param		db		Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("immobilier@immobilier");
     $this->db = $db;
     $this->name = 'quitance';
     $this->description = $langs->trans('Quittance');
     // Dimension page pour format A4 en portrait
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 15;
     $this->marge_droite = 15;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     $this->unit = 'mm';
     $this->oriantation = 'P';
     $this->espaceH_dispo = $this->page_largeur - ($this->marge_gauche + $this->marge_droite);
     $this->milieu = $this->espaceH_dispo / 2;
     $this->espaceV_dispo = $this->page_hauteur - ($this->marge_haute + $this->marge_basse);
     // Get source company
     $this->emetteur = $mysoc;
     if (!$this->emetteur->country_code) {
         $this->emetteur->country_code = substr($langs->defaultlang, -2);
     }
     // By default, if was not defined
 }
 /**
  *	Constructor
  *
  *	@param	DoliDB	$db		Database handler
  */
 function __construct($db = 0)
 {
     global $conf, $langs, $mysoc;
     $this->db = $db;
     $this->name = "rouget";
     $this->description = $langs->trans("DocumentModelSimple");
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 10;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     $this->option_logo = 1;
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->pays_code) {
         $this->emetteur->pays_code = substr($langs->defaultlang, -2);
     }
     // By default if not defined
     // Defini position des colonnes
     $this->posxdesc = $this->marge_gauche + 1;
     $this->posxqtyordered = 120;
     $this->posxqtytoship = 160;
 }
Exemplo n.º 3
0
 /**
  *	Constructor
  *
  *	@param	DoliDB	$db		Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("bills");
     $this->db = $db;
     $this->name = "blochet";
     $this->tab_top = 60;
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->country_code) {
         $this->emetteur->country_code = substr($langs->defaultlang, -2);
     }
     // By default if not defined
     // Defini position des colonnes
     $this->line_height = 5;
     $this->line_per_page = 40;
     $this->tab_height = 200;
     //$this->line_height * $this->line_per_page;
 }
Exemplo n.º 4
0
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("bills");
     $langs->load("sendings");
     $langs->load("companies");
     $this->db = $db;
     $this->name = "sirocco";
     $this->description = $langs->trans("DocumentModelSirocco");
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 10;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->pays_code) {
         $this->emetteur->pays_code = substr($langs->defaultlang, -2);
     }
     // Par defaut, si n'�tait pas d�fini
     $this->tva = array();
 }
Exemplo n.º 5
0
 /**
  *	Constructor
  *
  *	@param	DoliDB	$db		Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("bills");
     $this->db = $db;
     $this->name = "blochet";
     $this->tab_top = 60;
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 20;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->pays_code) {
         $this->emetteur->pays_code = substr($langs->defaultlang, -2);
     }
     // Par defaut, si n'�tait pas d�fini
     // Defini position des colonnes
     $this->line_height = 5;
     $this->line_per_page = 40;
     $this->tab_height = 200;
     //$this->line_height * $this->line_per_page;
 }
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db = 0)
 {
     global $conf, $langs, $mysoc;
     $this->db = $db;
     $this->name = "merou";
     //$this->description = "Modele Merou A5";
     $this->description = $langs->trans("DocumentModelMerou");
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = round($formatarray['height'] / 2);
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 10;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     $this->option_logo = 1;
     // Affiche logo
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->pays_code) {
         $this->emetteur->pays_code = substr($langs->defaultlang, -2);
     }
     // By default if not defined
 }
 /**
  *	Constructor
  *
  *	@param	DoliDB	$db		Database handler
  */
 function __construct($db = 0)
 {
     global $conf, $langs, $mysoc;
     $this->db = $db;
     $this->name = "rouget";
     $this->description = $langs->trans("DocumentModelSimple");
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->option_logo = 1;
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->country_code) {
         $this->emetteur->country_code = substr($langs->defaultlang, -2);
     }
     // By default if not defined
     // Defini position des colonnes
     $this->posxdesc = $this->marge_gauche + 1;
     $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 70;
     $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 35;
 }
 /**
  *	Constructor
  *
  *	@param	DoliDB	$db		Database handler
  */
 function __construct($db = 0)
 {
     global $conf, $langs, $mysoc;
     $this->db = $db;
     $this->name = "BerryPro-A4-SinVal";
     $this->description = "BerryPro A4 Sin Valorar";
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->option_logo = 1;
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->pays_code) {
         $this->emetteur->pays_code = substr($langs->defaultlang, -2);
     }
     // By default if not defined
     // Defini position des colonnes
     $this->posxdesc = $this->marge_gauche + 1;
     $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 77;
     $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 63;
     $this->posxup = $this->page_largeur - $this->marge_droite - 49;
     $this->posxtotalht = $this->page_largeur - $this->marge_droite - 29;
 }
 /**
  *  Constructor
  *
  *  @param      DoliDb		$db      Database handler
  */
 function __construct($db)
 {
     global $langs, $conf;
     $langs->load("bills");
     $langs->load("compta");
     $this->db = $db;
     $this->description = $langs->transnoentities("ListOfCustomerPayments");
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->tab_top = 30;
     $this->line_height = 5;
     $this->line_per_page = 25;
     $this->tab_height = 230;
     //$this->line_height * $this->line_per_page;
     $this->posxdate = $this->marge_gauche + 2;
     $this->posxpaymenttype = 42;
     $this->posxinvoice = 82;
     $this->posxinvoiceamount = 122;
     $this->posxpaymentamount = 162;
     if ($this->page_largeur < 210) {
         $this->posxpaymenttype -= 10;
         $this->posxinvoice -= 0;
         $this->posxinvoiceamount -= 10;
         $this->posxpaymentamount -= 20;
     }
 }
Exemplo n.º 10
0
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("bills");
     $this->db = $db;
     $this->name = "azur";
     $this->description = $langs->trans('DocModelAzurDescription');
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 10;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     $this->option_logo = 1;
     // Affiche logo
     $this->option_tva = 1;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_modereg = 1;
     // Affiche mode reglement
     $this->option_condreg = 1;
     // Affiche conditions reglement
     $this->option_codeproduitservice = 1;
     // Affiche code produit-service
     $this->option_multilang = 1;
     // Dispo en plusieurs langues
     $this->option_escompte = 1;
     // Affiche si il y a eu escompte
     $this->option_credit_note = 1;
     // Gere les avoirs
     $this->option_freetext = 1;
     // Support add of a personalised text
     $this->option_draft_watermark = 1;
     //Support add of a watermark on drafts
     $this->franchise = !$mysoc->tva_assuj;
     // Recupere emetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->pays_code) {
         $this->emetteur->pays_code = substr($langs->defaultlang, -2);
     }
     // Par defaut, si n'etait pas defini
     // Defini position des colonnes
     $this->posxdesc = $this->marge_gauche + 1;
     $this->posxtva = 111;
     $this->posxup = 126;
     $this->posxqty = 145;
     $this->posxdiscount = 162;
     $this->postotalht = 174;
     $this->tva = array();
     $this->localtax1 = array();
     $this->localtax2 = array();
     $this->atleastoneratenotnull = 0;
     $this->atleastonediscount = 0;
 }
Exemplo n.º 11
0
 /**
  *	Constructor
  *
  *  @param	DoliDB		$db     	Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("bills");
     $this->db = $db;
     $this->name = "canelle";
     $this->description = $langs->trans('SuppliersInvoiceModel');
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->option_logo = 1;
     // Affiche logo
     $this->option_tva = 1;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_modereg = 1;
     // Affiche mode reglement
     $this->option_condreg = 1;
     // Affiche conditions reglement
     $this->option_codeproduitservice = 1;
     // Affiche code produit-service
     $this->option_multilang = 1;
     // Dispo en plusieurs langues
     $this->franchise = !$mysoc->tva_assuj;
     // Defini position des colonnes
     $this->posxdesc = $this->marge_gauche + 1;
     $this->posxtva = 112;
     $this->posxup = 126;
     $this->posxqty = 145;
     $this->posxdiscount = 162;
     $this->postotalht = 174;
     //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
     $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
     // width of images
     if ($this->page_largeur < 210) {
         $this->posxpicture -= 20;
         $this->posxtva -= 20;
         $this->posxup -= 20;
         $this->posxqty -= 20;
         $this->posxdiscount -= 20;
         $this->postotalht -= 20;
     }
     $this->tva = array();
     $this->localtax1 = array();
     $this->localtax2 = array();
     $this->atleastoneratenotnull = 0;
     $this->atleastonediscount = 0;
 }
Exemplo n.º 12
0
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("bills");
     $langs->load("sendings");
     $langs->load("companies");
     $this->db = $db;
     $this->name = "typhon";
     $this->description = $langs->trans("DocumentModelTyphon");
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->option_logo = 1;
     // Affiche logo FAC_PDF_LOGO
     $this->option_tva = 1;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_codeproduitservice = 1;
     // Affiche code produit-service
     $this->franchise = !$mysoc->tva_assuj;
     // Get source company
     $this->emetteur = $mysoc;
     if (empty($this->emetteur->country_code)) {
         $this->emetteur->country_code = substr($langs->defaultlang, -2);
     }
     // By default, if was not defined
     // Define position of columns
     $this->posxdesc = $this->marge_gauche + 1;
     $this->posxcomm = 112;
     //$this->posxtva=112;
     //$this->posxup=126;
     $this->posxqty = 165;
     $this->posxremainingqty = 185;
     //$this->posxdiscount=162;
     //$this->postotalht=174;
     if ($this->page_largeur < 210) {
         $this->posxcomm -= 20;
         //$this->posxtva-=20;
         //$this->posxup-=20;
         $this->posxqty -= 20;
         //$this->posxdiscount-=20;
         //$this->postotalht-=20;
     }
     $this->tva = array();
     $this->atleastoneratenotnull = 0;
     $this->atleastonediscount = 0;
 }
Exemplo n.º 13
0
 /**
  *	Constructor
  *
  *  @param	DoliDB		$db     	Database handler
  *  @param	Societe		$object		Supplier invoice
  */
 function __construct($db, $object)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("bills");
     $this->db = $db;
     $this->name = "canelle";
     $this->description = $langs->trans('SuppliersInvoiceModel');
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 10;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     $this->option_logo = 1;
     // Affiche logo
     $this->option_tva = 1;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_modereg = 1;
     // Affiche mode reglement
     $this->option_condreg = 1;
     // Affiche conditions reglement
     $this->option_codeproduitservice = 1;
     // Affiche code produit-service
     $this->option_multilang = 1;
     // Dispo en plusieurs langues
     $this->franchise = !$mysoc->tva_assuj;
     // Get source company
     if (!is_object($object->thirdparty)) {
         $object->fetch_thirdparty();
     }
     $this->emetteur = $object->thirdparty;
     if (!$this->emetteur->country_code) {
         $this->emetteur->country_code = substr($langs->defaultlang, -2);
     }
     // By default, if was not defined
     // Defini position des colonnes
     $this->posxdesc = $this->marge_gauche + 1;
     $this->posxtva = 111;
     $this->posxup = 126;
     $this->posxqty = 145;
     $this->posxdiscount = 162;
     $this->postotalht = 174;
     $this->tva = array();
     $this->localtax1 = array();
     $this->localtax2 = array();
     $this->atleastoneratenotnull = 0;
     $this->atleastonediscount = 0;
 }
Exemplo n.º 14
0
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("bills");
     $langs->load("sendings");
     $langs->load("companies");
     $this->db = $db;
     $this->name = "typhon";
     $this->description = $langs->trans("DocumentModelTyphon");
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 10;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     $this->option_logo = 1;
     // Affiche logo FAC_PDF_LOGO
     $this->option_tva = 1;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_codeproduitservice = 1;
     // Affiche code produit-service
     $this->franchise = !$mysoc->tva_assuj;
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->pays_code) {
         $this->emetteur->pays_code = substr($langs->defaultlang, -2);
     }
     // Par defaut, si n'�tait pas d�fini
     // Defini position des colonnes
     $this->posxdesc = $this->marge_gauche + 1;
     $this->posxcomm = 120;
     //$this->posxtva=111;
     $this->posxup = 132;
     $this->posxqty = 168;
     $this->posxdiscount = 162;
     $this->postotalht = 177;
     $this->tva = array();
     $this->atleastoneratenotnull = 0;
     $this->atleastonediscount = 0;
 }
Exemplo n.º 15
0
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $this->db = $db;
     $this->name = 'soleil';
     $this->description = $langs->trans("DocumentModelStandard");
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->option_logo = 1;
     // Affiche logo
     $this->option_tva = 0;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_modereg = 0;
     // Affiche mode reglement
     $this->option_condreg = 0;
     // Affiche conditions reglement
     $this->option_codeproduitservice = 0;
     // Affiche code produit-service
     $this->option_multilang = 1;
     // Dispo en plusieurs langues
     $this->option_draft_watermark = 1;
     //Support add of a watermark on drafts
     // Get source company
     $this->emetteur = $mysoc;
     if (empty($this->emetteur->country_code)) {
         $this->emetteur->country_code = substr($langs->defaultlang, -2);
     }
     // By default, if not defined
     // Define position of columns
     $this->posxdesc = $this->marge_gauche + 1;
 }
 /**
  * Constructor
  *
  * @param 	DoliDB	$db		Database handler
  * @param	int		$month	Month
  * @param	int		$year	Year
  */
 function __construct($db, $month, $year)
 {
     global $conf, $langs;
     $langs->load("commercial");
     $this->db = $db;
     $this->description = "";
     $this->date_edition = time();
     $this->month = $month;
     $this->year = $year;
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->title = $langs->transnoentitiesnoconv("ActionsReport") . ' ' . $this->year . "-" . $this->month;
     $this->subject = $langs->transnoentitiesnoconv("ActionsReport") . ' ' . $this->year . "-" . $this->month;
 }
Exemplo n.º 17
0
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("projects");
     $langs->load("companies");
     $this->db = $db;
     $this->name = "baleine";
     $this->description = $langs->trans("DocumentModelBaleine");
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->option_logo = 1;
     // Affiche logo FAC_PDF_LOGO
     $this->option_tva = 1;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_codeproduitservice = 1;
     // Affiche code produit-service
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->country_code) {
         $this->emetteur->country_code = substr($langs->defaultlang, -2);
     }
     // By default if not defined
     // Defini position des colonnes
     $this->posxref = $this->marge_gauche + 1;
     $this->posxlabel = $this->marge_gauche + 25;
     $this->posxworkload = $this->marge_gauche + 100;
     $this->posxprogress = $this->marge_gauche + 130;
     $this->posxdatestart = $this->marge_gauche + 150;
     $this->posxdateend = $this->marge_gauche + 170;
 }
Exemplo n.º 18
0
 /**
  * 	Constructor
  *
  *	@param		DoliDb	$db		Database access handler
  */
 function __construct($db = 0)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("bills");
     $this->db = $db;
     $this->name = "edison";
     $this->description = $langs->trans('PDFEdisonDescription');
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 10;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     $this->option_multilang = 0;
     // Dispo en plusieurs langues
     $this->option_draft_watermark = 1;
     //Support add of a watermark on drafts
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->pays_code) {
         $this->emetteur->pays_code = substr($langs->defaultlang, -2);
     }
     // By default, if was not defined
     // Defini position des colonnes
     $this->posxdesc = $this->marge_gauche + 1;
     $this->posxtva = 111;
     $this->posxup = 126;
     $this->posxqty = 145;
     $this->posxdiscount = 162;
     $this->postotalht = 174;
     $this->tva = array();
     $this->atleastoneratenotnull = 0;
     $this->atleastonediscount = 0;
 }
Exemplo n.º 19
0
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $this->db = $db;
     $this->name = 'soleil';
     $this->description = $langs->trans("DocumentModelStandard");
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 10;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     $this->option_logo = 1;
     // Affiche logo
     $this->option_tva = 0;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_modereg = 0;
     // Affiche mode reglement
     $this->option_condreg = 0;
     // Affiche conditions reglement
     $this->option_codeproduitservice = 0;
     // Affiche code produit-service
     $this->option_multilang = 0;
     // Dispo en plusieurs langues
     $this->option_draft_watermark = 1;
     //Support add of a watermark on drafts
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->code_pays) {
         $this->emetteur->code_pays = substr($langs->defaultlang, -2);
     }
     // By default, if not defined
     // Defini position des colonnes
     $this->posxdesc = $this->marge_gauche + 1;
 }
Exemplo n.º 20
0
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("projects");
     $langs->load("companies");
     $this->db = $db;
     $this->name = "baleine";
     $this->description = $langs->trans("DocumentModelBaleine");
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 10;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     $this->option_logo = 1;
     // Affiche logo FAC_PDF_LOGO
     $this->option_tva = 1;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_codeproduitservice = 1;
     // Affiche code produit-service
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->pays_code) {
         $this->emetteur->pays_code = substr($langs->defaultlang, -2);
     }
     // Par defaut, si n'�tait pas d�fini
     // Defini position des colonnes
     $this->posxref = $this->marge_gauche + 1;
     $this->posxlabel = $this->marge_gauche + 25;
     $this->posxprogress = $this->marge_gauche + 140;
     $this->posxdatestart = $this->marge_gauche + 150;
     $this->posxdateend = $this->marge_gauche + 170;
 }
Exemplo n.º 21
0
 /**
  *  Constructor
  *
  *  @param      DoliDb		$db      Database handler
  */
 function __construct($db)
 {
     global $langs;
     $langs->load("bills");
     $langs->load("compta");
     $this->db = $db;
     $this->description = $langs->transnoentities("ListOfCustomerPayments");
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = 10;
     $this->marge_droite = 10;
     $this->marge_haute = 10;
     $this->marge_basse = 10;
     $this->tab_top = 30;
     $this->line_height = 5;
     $this->line_per_page = 25;
     $this->tab_height = 230;
     //$this->line_height * $this->line_per_page;
 }
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db = 0)
 {
     global $conf, $langs, $mysoc;
     $this->db = $db;
     $this->name = "pruebaA5";
     $this->description = "Documento de prueba";
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = round($formatarray['height'] / 2);
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->option_logo = 1;
     // Recupere emmetteur
     $this->emetteur = $mysoc;
     if (!$this->emetteur->country_code) {
         $this->emetteur->country_code = substr($langs->defaultlang, -2);
     }
     // By default if not defined
 }
Exemplo n.º 23
0
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("bills");
     $this->db = $db;
     $this->name = "crabe";
     $this->description = $langs->trans('PDFCrabeDescription');
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->option_logo = 1;
     // Affiche logo
     $this->option_tva = 1;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_modereg = 1;
     // Affiche mode reglement
     $this->option_condreg = 1;
     // Affiche conditions reglement
     $this->option_codeproduitservice = 1;
     // Affiche code produit-service
     $this->option_multilang = 1;
     // Dispo en plusieurs langues
     $this->option_escompte = 1;
     // Affiche si il y a eu escompte
     $this->option_credit_note = 1;
     // Support credit notes
     $this->option_freetext = 1;
     // Support add of a personalised text
     $this->option_draft_watermark = 1;
     // Support add of a watermark on drafts
     $this->franchise = !$mysoc->tva_assuj;
     // Get source company
     $this->emetteur = $mysoc;
     if (empty($this->emetteur->country_code)) {
         $this->emetteur->country_code = substr($langs->defaultlang, -2);
     }
     // By default, if was not defined
     // Define position of columns
     $this->posxdesc = $this->marge_gauche + 1;
     if ($conf->global->PRODUCT_USE_UNITS) {
         $this->posxtva = 99;
         $this->posxup = 114;
         $this->posxqty = 133;
         $this->posxunit = 150;
     } else {
         $this->posxtva = 112;
         $this->posxup = 126;
         $this->posxqty = 145;
     }
     $this->posxdiscount = 162;
     $this->posxprogress = 174;
     // Only displayed for situation invoices
     $this->postotalht = 174;
     if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
         $this->posxtva = $this->posxup;
     }
     $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
     // width of images
     if ($this->page_largeur < 210) {
         $this->posxpicture -= 20;
         $this->posxtva -= 20;
         $this->posxup -= 20;
         $this->posxqty -= 20;
         $this->posxdiscount -= 20;
         $this->postotalht -= 20;
     }
     $this->tva = array();
     $this->localtax1 = array();
     $this->localtax2 = array();
     $this->atleastoneratenotnull = 0;
     $this->atleastonediscount = 0;
     $this->situationinvoice = False;
 }
Exemplo n.º 24
0
 /**
  *	Constructor
  *
  *  @param		DoliDB		$db      Database handler
  */
 function __construct($db)
 {
     global $conf, $langs, $mysoc;
     $langs->load("main");
     $langs->load("trips");
     $langs->load("project");
     $langs->load("trips");
     $this->db = $db;
     $this->name = "";
     $this->description = $langs->trans('PDFStandardExpenseReports');
     // Dimension page pour format A4
     $this->type = 'pdf';
     $formatarray = pdf_getFormat();
     $this->page_largeur = $formatarray['width'];
     $this->page_hauteur = $formatarray['height'];
     $this->format = array($this->page_largeur, $this->page_hauteur);
     $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
     $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
     $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
     $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
     $this->option_logo = 1;
     // Affiche logo
     $this->option_tva = 1;
     // Gere option tva FACTURE_TVAOPTION
     $this->option_modereg = 1;
     // Affiche mode reglement
     $this->option_condreg = 1;
     // Affiche conditions reglement
     $this->option_codeproduitservice = 1;
     // Affiche code produit-service
     $this->option_multilang = 1;
     // Dispo en plusieurs langues
     $this->option_escompte = 1;
     // Affiche si il y a eu escompte
     $this->option_credit_note = 1;
     // Support credit notes
     $this->option_freetext = 1;
     // Support add of a personalised text
     $this->option_draft_watermark = 1;
     // Support add of a watermark on drafts
     $this->franchise = !$mysoc->tva_assuj;
     // Get source company
     $this->emetteur = $mysoc;
     if (empty($this->emetteur->country_code)) {
         $this->emetteur->country_code = substr($langs->defaultlang, -2);
     }
     // By default, if was not defined
     // Define position of columns
     $this->posxpiece = $this->marge_gauche + 1;
     $this->posxdesc = 20;
     $this->posxdate = 85;
     $this->posxtype = 105;
     $this->posxprojet = 125;
     $this->posxtva = 145;
     $this->posxup = 162;
     $this->posxqty = 176;
     $this->postotalttc = 186;
     if ($this->page_largeur < 210) {
         $this->posxdate -= 20;
         $this->posxtype -= 20;
         $this->posxprojet -= 20;
         $this->posxtva -= 20;
         $this->posxup -= 20;
         $this->posxqty -= 20;
         $this->postotalttc -= 20;
     }
     $this->tva = array();
     $this->localtax1 = array();
     $this->localtax2 = array();
     $this->atleastoneratenotnull = 0;
     $this->atleastonediscount = 0;
 }
Exemplo n.º 25
0
/**
 * Function to build a compiled PDF
 *
 * @param	DoliDB		$db						Database handler
 * @param	Translate	$langs					Object langs
 * @param	Conf		$conf					Object conf
 * @param	string		$diroutputpdf			Dir to output file
 * @param	string		$newlangid				Lang id
 * @param 	array		$filter					Array with filters
 * @param 	date		$dateafterdate			Invoice after date
 * @param 	date 		$datebeforedate			Invoice before date
 * @param 	date		$paymentdateafter		Payment after date (must includes hour)
 * @param 	date		$paymentdatebefore		Payment before date (must includes hour)
 * @param	int			$usestdout				Add information onto standard output
 * @param	int			$regenerate				''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template
 * @param	string		$filesuffix				Suffix to add into file name of generated PDF
 * @param	string		$paymentbankid			Only if payment on this bank account id
 * @param	array		$thirdpartiesid			List of thirdparties id when using filter excludethirdpartiesid	or onlythirdpartiesid
 * @param	string		$fileprefix				Prefix to add into filename of generated PDF
 * @return	int									Error code
 */
function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate = 0, $filesuffix = '', $paymentbankid = '', $thirdpartiesid = '', $fileprefix = 'mergedpdf')
{
    $sql = "SELECT DISTINCT f.rowid, f.facnumber";
    $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";
    $sqlwhere = '';
    $sqlorder = '';
    if (in_array('all', $filter)) {
        $sqlorder = " ORDER BY f.facnumber ASC";
    }
    if (in_array('date', $filter)) {
        if (empty($sqlwhere)) {
            $sqlwhere = ' WHERE ';
        } else {
            $sqlwhere .= " AND";
        }
        $sqlwhere .= " f.fk_statut > 0";
        $sqlwhere .= " AND f.datef >= '" . $db->idate($dateafterdate) . "'";
        $sqlwhere .= " AND f.datef <= '" . $db->idate($datebeforedate) . "'";
        $sqlorder = " ORDER BY f.datef ASC";
    }
    if (in_array('nopayment', $filter)) {
        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "paiement_facture as pf ON f.rowid = pf.fk_facture";
        if (empty($sqlwhere)) {
            $sqlwhere = ' WHERE ';
        } else {
            $sqlwhere .= " AND";
        }
        $sqlwhere .= " f.fk_statut > 0";
        $sqlwhere .= " AND pf.fk_paiement IS NULL";
    }
    if (in_array('payments', $filter) || in_array('bank', $filter)) {
        $sql .= ", " . MAIN_DB_PREFIX . "paiement_facture as pf, " . MAIN_DB_PREFIX . "paiement as p";
        if (in_array('bank', $filter)) {
            $sql .= ", " . MAIN_DB_PREFIX . "bank as b";
        }
        if (empty($sqlwhere)) {
            $sqlwhere = ' WHERE ';
        } else {
            $sqlwhere .= " AND";
        }
        $sqlwhere .= " f.fk_statut > 0";
        $sqlwhere .= " AND f.rowid = pf.fk_facture";
        $sqlwhere .= " AND pf.fk_paiement = p.rowid";
        if (in_array('payments', $filter)) {
            $sqlwhere .= " AND p.datep >= '" . $db->idate($paymentdateafter) . "'";
            $sqlwhere .= " AND p.datep <= '" . $db->idate($paymentdatebefore) . "'";
        }
        if (in_array('bank', $filter)) {
            $sqlwhere .= " AND p.fk_bank = b.rowid";
            $sqlwhere .= " AND b.fk_account = " . $paymentbankid;
        }
        $sqlorder = " ORDER BY p.datep ASC";
    }
    if (in_array('nodeposit', $filter)) {
        if (empty($sqlwhere)) {
            $sqlwhere = ' WHERE ';
        } else {
            $sqlwhere .= " AND";
        }
        $sqlwhere .= ' type <> 3';
    }
    if (in_array('noreplacement', $filter)) {
        if (empty($sqlwhere)) {
            $sqlwhere = ' WHERE ';
        } else {
            $sqlwhere .= " AND";
        }
        $sqlwhere .= ' type <> 1';
    }
    if (in_array('nocreditnote', $filter)) {
        if (empty($sqlwhere)) {
            $sqlwhere = ' WHERE ';
        } else {
            $sqlwhere .= " AND";
        }
        $sqlwhere .= ' type <> 2';
    }
    if (in_array('excludethirdparties', $filter) && is_array($thirdpartiesid)) {
        if (empty($sqlwhere)) {
            $sqlwhere = ' WHERE ';
        } else {
            $sqlwhere .= " AND";
        }
        $sqlwhere .= ' f.fk_soc NOT IN (' . join(',', $thirdpartiesid) . ')';
    }
    if (in_array('onlythirdparties', $filter) && is_array($thirdpartiesid)) {
        if (empty($sqlwhere)) {
            $sqlwhere = ' WHERE ';
        } else {
            $sqlwhere .= " AND";
        }
        $sqlwhere .= ' f.fk_soc IN (' . join(',', $thirdpartiesid) . ')';
    }
    if ($sqlwhere) {
        $sql .= $sqlwhere;
    }
    if ($sqlorder) {
        $sql .= $sqlorder;
    }
    //print $sql; exit;
    dol_syslog("scripts/invoices/rebuild_merge.php:", LOG_DEBUG);
    if ($usestdout) {
        print '--- start' . "\n";
    }
    // Start of transaction
    //$db->begin();
    $error = 0;
    $result = 0;
    $files = array();
    // liste les fichiers
    dol_syslog("scripts/invoices/rebuild_merge.php", LOG_DEBUG);
    if ($resql = $db->query($sql)) {
        $num = $db->num_rows($resql);
        $cpt = 0;
        $oldemail = '';
        $message = '';
        $total = '';
        if ($num) {
            // First loop on each resultset to build PDF
            // -----------------------------------------
            while ($cpt < $num) {
                $obj = $db->fetch_object($resql);
                $fac = new Facture($db);
                $result = $fac->fetch($obj->rowid);
                if ($result > 0) {
                    $outputlangs = $langs;
                    if (!empty($newlangid)) {
                        if ($outputlangs->defaultlang != $newlangid) {
                            $outputlangs = new Translate("", $conf);
                            $outputlangs->setDefaultLang($newlangid);
                        }
                    }
                    $filename = $conf->facture->dir_output . '/' . $fac->ref . '/' . $fac->ref . '.pdf';
                    if ($regenerate || !dol_is_file($filename)) {
                        if ($usestdout) {
                            print "Build PDF for invoice " . $obj->facnumber . " - Lang = " . $outputlangs->defaultlang . "\n";
                        }
                        $result = $fac->generateDocument($regenerate ? $regenerate : $fac->modelpdf, $outputlangs);
                    } else {
                        if ($usestdout) {
                            print "PDF for invoice " . $obj->facnumber . " already exists\n";
                        }
                    }
                    // Add file into files array
                    $files[] = $filename;
                }
                if ($result <= 0) {
                    $error++;
                    if ($usestdout) {
                        print "Error: Failed to build PDF for invoice " . ($fac->ref ? $fac->ref : ' id ' . $obj->rowid) . "\n";
                    } else {
                        dol_syslog("Failed to build PDF for invoice " . ($fac->ref ? $fac->ref : ' id ' . $obj->rowid), LOG_ERR);
                    }
                }
                $cpt++;
            }
            // Define format of output PDF
            $formatarray = pdf_getFormat($langs);
            $page_largeur = $formatarray['width'];
            $page_hauteur = $formatarray['height'];
            $format = array($page_largeur, $page_hauteur);
            if ($usestdout) {
                print "Using output PDF format " . join('x', $format) . "\n";
            } else {
                dol_syslog("Using output PDF format " . join('x', $format), LOG_ERR);
            }
            // Now, build a merged files with all files in $files array
            //---------------------------------------------------------
            // Create empty PDF
            $pdf = pdf_getInstance($format);
            if (class_exists('TCPDF')) {
                $pdf->setPrintHeader(false);
                $pdf->setPrintFooter(false);
            }
            $pdf->SetFont(pdf_getPDFFont($langs));
            if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) {
                $pdf->SetCompression(false);
            }
            //$pdf->SetCompression(false);
            // Add all others
            foreach ($files as $file) {
                if ($usestdout) {
                    print "Merge PDF file for invoice " . $file . "\n";
                } else {
                    dol_syslog("Merge PDF file for invoice " . $file);
                }
                // Charge un document PDF depuis un fichier.
                $pagecount = $pdf->setSourceFile($file);
                for ($i = 1; $i <= $pagecount; $i++) {
                    $tplidx = $pdf->importPage($i);
                    $s = $pdf->getTemplatesize($tplidx);
                    $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
                    $pdf->useTemplate($tplidx);
                }
            }
            // Create output dir if not exists
            dol_mkdir($diroutputpdf);
            // Save merged file
            $filename = $fileprefix;
            if (empty($filename)) {
                $filename = 'mergedpdf';
            }
            if (!empty($filesuffix)) {
                $filename .= '_' . $filesuffix;
            }
            $file = $diroutputpdf . '/' . $filename . '.pdf';
            if (!$error && $pagecount) {
                $pdf->Output($file, 'F');
                if (!empty($conf->global->MAIN_UMASK)) {
                    @chmod($file, octdec($conf->global->MAIN_UMASK));
                }
            }
            if ($usestdout) {
                if (!$error) {
                    print "Merged PDF has been built in " . $file . "\n";
                } else {
                    print "Can't build PDF " . $file . "\n";
                }
            }
            $result = 1;
        } else {
            if ($usestdout) {
                print "No invoices found for criteria.\n";
            } else {
                dol_syslog("No invoices found for criteria");
            }
            $result = 0;
        }
    } else {
        dol_print_error($db);
        dol_syslog("scripts/invoices/rebuild_merge.php: Error");
        $error++;
    }
    if ($error) {
        return -1;
    } else {
        return $result;
    }
}