diff --git a/ChangeLog b/ChangeLog
index 8f2b10398e9..1de4a404620 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,8 @@ For users:
- New: Add new graphical boxes (customer invoices and orders per month).
- New: [ task #286 ] Enhance rounding function of prices to allow round of sum instead of sum of rounding.
- New: Can add an event automatically when a projet is create.
+- New: Add option MAIN_GENERATE_DOCUMENT_WITH_PICTURE.
+- New: Add option excludethirdparties and onlythirdparties into merge pdf scripts.
- Qual: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
For translators:
diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index a5451248078..fd11266b74f 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -105,11 +105,11 @@ else if ($action == 'specimen')
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
{
- $file=dol_buildpath($reldir."core/modules/expedition/doc/pdf_expedition_".$modele.".modules.php",0);
+ $file=dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php",0);
if (file_exists($file))
{
$filefound=1;
- $classname = "pdf_expedition_".$modele;
+ $classname = "pdf_".$modele;
break;
}
}
@@ -175,6 +175,14 @@ else if ($action == 'setmodel')
{
dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
}
+else if ($action=='setModuleOptions') {
+ if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF_ODT_PATH",GETPOST('value1'),'chaine',0,'',$conf->entity))
+ {
+ // La constante qui a ete lue en avant du nouveau set
+ // on passe donc par une variable pour avoir un affichage coherent
+ $conf->global->EXPEDITION_ADDON_PDF_ODT_PATH = GETPOST('value1');
+ }
+}
/*
@@ -370,80 +378,115 @@ clearstatcache();
$var=true;
foreach ($dirmodels as $reldir)
{
- $dir = dol_buildpath($reldir."core/modules/expedition/doc/");
+ foreach (array('','/doc') as $valdir)
+ {
+ $dir = dol_buildpath($reldir."core/modules/expedition".$valdir);
- if (is_dir($dir))
- {
- $handle=opendir($dir);
- if (is_resource($handle))
- {
- while (($file = readdir($handle))!==false)
- {
- if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,15) == 'pdf_expedition_')
- {
- $name = substr($file, 15, dol_strlen($file) - 27);
- $classname = substr($file, 0, dol_strlen($file) - 12);
+ if (is_dir($dir))
+ {
+ $handle=opendir($dir);
+ if (is_resource($handle))
+ {
+ while (($file = readdir($handle))!==false)
+ {
+ $filelist[]=$file;
+ }
+ closedir($handle);
+ arsort($filelist);
- $var=!$var;
- print '
| ';
- print $name;
- print " | \n";
- require_once $dir.$file;
- $module = new $classname();
+ foreach($filelist as $file)
+ {
+ if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
+ {
- print $module->description;
- print ' | ';
+ if (file_exists($dir.'/'.$file))
+ {
+ $name = substr($file, 4, dol_strlen($file) -16);
+ $classname = substr($file, 0, dol_strlen($file) -12);
- // Active
- if (in_array($name, $def))
- {
- print "\n";
- print '';
- print img_picto($langs->trans("Activated"),'switch_on');
- print '';
- print " | ";
- }
- else
- {
- print "\n";
- print ''.img_picto($langs->trans("Disabled"),'switch_off').'';
- print " | ";
- }
+ require_once $dir.'/'.$file;
+ $module = new $classname($db);
- // Default
- print "";
- if ($conf->global->EXPEDITION_ADDON_PDF == $name)
- {
- print img_picto($langs->trans("Default"),'on');
- }
- else
- {
- print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'';
- }
- print ' | ';
+ $modulequalified=1;
+ if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
+ if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
- // Info
- $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
- $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
- $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
- $htmltooltip.='
'.$langs->trans("FeaturesSupported").':';
- $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
- print '';
- print $form->textwithpicto('',$htmltooltip,-1,0);
- print ' | ';
+ if ($modulequalified)
+ {
+ $var = !$var;
+ print '
| ';
+ print (empty($module->name)?$name:$module->name);
+ print " | \n";
+ if (method_exists($module,'info')) print $module->info($langs);
+ else print $module->description;
+ print ' | ';
- // Preview
- $link='scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"),'sending').'';
- print '';
- print $link;
- print ' | ';
+ // Active
+ if (in_array($name, $def))
+ {
+ print ''."\n";
+ print '';
+ print img_picto($langs->trans("Enabled"),'switch_on');
+ print '';
+ print ' | ';
+ }
+ else
+ {
+ print ''."\n";
+ print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'';
+ print " | ";
+ }
- print '
';
- }
- }
- closedir($handle);
- }
- }
+ // Defaut
+ print '';
+ if ($conf->global->EXPEDITION_ADDON_PDF == $name)
+ {
+ print img_picto($langs->trans("Default"),'on');
+ }
+ else
+ {
+ print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'';
+ }
+ print ' | ';
+
+ // Info
+ $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
+ $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+ if ($module->type == 'pdf')
+ {
+ $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+ }
+ $htmltooltip.='
'.$langs->trans("FeaturesSupported").':';
+ $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
+ $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
+ $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
+ $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
+ $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
+
+ print '';
+ print $form->textwithpicto('',$htmltooltip,1,0);
+ print ' | ';
+
+ // Preview
+ print '';
+ if ($module->type == 'pdf')
+ {
+ print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"),'sending').'';
+ }
+ else
+ {
+ print img_object($langs->trans("PreviewNotAvailable"),'generic');
+ }
+ print ' | ';
+
+ print "\n";
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
print '';
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 09afbe57c34..155e2cc0e78 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -408,7 +408,7 @@ else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GET
// prevent browser refresh from reopening proposal several times
if ($object->statut==2 || $object->statut==3)
{
- $object->setStatut(1);
+ $object->reopen($user,1);
}
}
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index f4c87387040..e3160dc61c9 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1587,32 +1587,67 @@ class Propal extends CommonObject
/**
- * Close the commercial proposal
+ * Reopen the commercial proposal
*
* @param User $user Object user that close
* @param int $statut Statut
* @param text $note Comment
+ * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK
*/
- function reopen($user, $statut, $note)
+ function reopen($user, $statut, $note, $notrigger=0)
{
global $langs,$conf;
$this->statut = $statut;
$error=0;
- $now=dol_now();
-
- $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
- $sql.= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($note)."', date_cloture=".$this->db->idate($now).", fk_user_cloture=".$user->id;
+ $sql.= " SET fk_statut = ".$this->statut.",";
+ if (! empty ( $note )) {
+ $sql .= " note_private = '" . $this->db->escape ( $note ) . "',";
+ }
+ $sql.= " date_cloture=NULL, fk_user_cloture=NULL";
$sql.= " WHERE rowid = ".$this->id;
- $resql=$this->db->query($sql);
- if ($resql)
- {
+ $this->db->begin();
- }
+ dol_syslog(get_class($this)."::reopen sql=".$sql, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) {
+ $error++; $this->errors[]="Error ".$this->db->lasterror();
+ }
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Appel des triggers
+ include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers('PROPAL_REOPEN',$this,$user,$langs,$conf);
+ if ($result < 0) {
+ $error++; $this->errors=$interface->errors;
+ }
+ // Fin appel triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
}
diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example
index 589cd212ef5..e0cee5e2719 100644
--- a/htdocs/conf/conf.php.example
+++ b/htdocs/conf/conf.php.example
@@ -37,8 +37,10 @@ $dolibarr_main_document_root='';
// dolibarr_main_url_root_alt
-// This parameter defines the relative sub URLs of alternative Dolibarr root directories.
-// It can be links to some other secondary htdocs directories, separated by a coma.
+// This parameter defines the relative sub URLs to add to $dolibarr_main_url_root to
+// forge alternative root directories (used by modules developers).
+// You can put several values, separated by a coma, but number of entries must match
+// number of entries into $dolibarr_main_document_root_alt.
// Examples:
// $dolibarr_main_url_root_alt='/extensions';
// $dolibarr_main_url_root_alt='/extensions1,/extensions2';
@@ -47,7 +49,10 @@ $dolibarr_main_url_root_alt='';
// dolibarr_main_document_root_alt
-// This parameter contains absolute alternative root file system directories of Dolibarr
+// This parameter contains absolute alternative root file system directories (used by
+// modules developers).
+// You can put several values, separated by a coma, but number of entries must match
+// number of entries into $dolibarr_main_url_root_alt.
// Examples:
// $dolibarr_main_document_root_alt='/var/www/dolibarr/htdocs/extensions';
// $dolibarr_main_document_root_alt='C:/My web sites/dolibarr/htdocs/extensions1,C:/My web sites/dolibarr/htdocs/extensions2';
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 4ce1bbf8c3d..2ed38d94e4a 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -396,6 +396,9 @@ class Conf
if (! isset($this->global->MAIN_MAX_DECIMALS_TOT)) $this->global->MAIN_MAX_DECIMALS_TOT=2;
if (! isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN=8;
+ // Default pdf use dash between lines
+ if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1;
+
// Default max file size for upload
$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024);
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 0767c13c9b1..1be018f61a9 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -1729,7 +1729,7 @@ function img_picto($alt, $picto, $options = '', $pictoisfullpath = false, $srcon
if ($type == 'main') continue;
if (file_exists($dirroot.'/'.$path.'/img/'.$picto))
{
- $url=$conf->file->dol_url_root[$type];
+ $url=DOL_URL_ROOT.$conf->file->dol_url_root[$type];
break;
}
}
diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php
index 52ff16d4964..5eed1e8e2df 100644
--- a/htdocs/core/lib/invoice2.lib.php
+++ b/htdocs/core/lib/invoice2.lib.php
@@ -37,15 +37,16 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
* @param array $filter Array with filters
* @param date $dateafterdate Invoice after date
* @param date $datebeforedate Invoice before date
- * @param date $paymentdateafter Payment after date
- * @param date $paymentdatebefore Payment 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 $option 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
* @return int Error code
*/
-function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate=0, $option='', $paymentbankid='')
+function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate=0, $option='', $paymentbankid='', $thirdpartiesid='')
{
$sql = "SELECT DISTINCT f.rowid, f.facnumber";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
@@ -111,6 +112,18 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
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;
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 61d247ff2c2..f22d35e7de1 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -199,8 +199,8 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
{
$this->SetXY($x,$y);
$val=str_replace('
',"\n",$html);
- $val=dol_string_nohtmltag($val,false,'ISO-8859-1');
- //print 'eee'.$val;exit;
+ //$val=dol_string_nohtmltag($val,false,'ISO-8859-1');
+ $val=dol_string_nohtmltag($val,false,'UTF-8');
$this->MultiCell($w,$h,$val,$border,$align,$fill);
}
}
@@ -1554,25 +1554,29 @@ function pdf_getLinkedObjects($object,$outputlangs)
}
/**
- * Return dimensions to use for images onto PDF
+ * Return dimensions to use for images onto PDF checking that width and height are not higher than
+ * maximum (16x32 by default).
*
* @param string $realpath Full path to photo file to use
- * @return array Height/Width to use to output image (in pixel)
+ * @return array Height and width to use to output image (in pdf user unit, so mm)
*/
-function pdf_getHeightForImage($realpath)
+function pdf_getSizeForImage($realpath)
{
- $maxheight=12; $maxwidth=16;
+ global $conf;
+
+ $maxwidth=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
+ $maxheight=(empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT)?32:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT);
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$tmp=dol_getImageSize($realpath);
if ($tmp['height'])
{
- $width=(int) round($maxheight*$tmp['width']/$tmp['height']);
- if ($width > $maxwidth)
+ $width=(int) round($maxheight*$tmp['width']/$tmp['height']); // I try to use maxheight
+ if ($width > $maxwidth) // Pb with maxheight, so i use maxwidth
{
- $height=(int) round($height*$maxwidth/$width);
$width=$maxwidth;
+ $height=(int) round($maxwidth*$tmp['height']/$tmp['width']);
}
- else
+ else // No pb with maxheight
{
$height=$maxheight;
}
diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
new file mode 100644
index 00000000000..68472f0e747
--- /dev/null
+++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
@@ -0,0 +1,569 @@
+
+ * Copyright (C) 2012 Juanjo Menent
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+* or see http://www.gnu.org/
+*/
+
+/**
+ * \file htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php
+ * \ingroup expedition
+ * \brief File of class to build ODT documents for shipment
+ */
+
+require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
+
+
+/**
+ * Class to build documents using ODF templates generator
+ */
+class doc_generic_shipment_odt extends ModelePdfExpedition
+{
+ var $emetteur; // Objet societe qui emet
+
+ var $phpmin = array(5,2,0); // Minimum version of PHP required by module
+ var $version = 'dolibarr';
+
+
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ function __construct($db)
+ {
+ global $conf,$langs,$mysoc;
+
+ $langs->load("main");
+ $langs->load("companies");
+
+ $this->db = $db;
+ $this->name = "ODT templates";
+ $this->description = $langs->trans("DocumentModelOdt");
+ $this->scandir = 'EXPEDITION_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
+
+ // Dimension page pour format A4
+ $this->type = 'odt';
+ $this->page_largeur = 0;
+ $this->page_hauteur = 0;
+ $this->format = array($this->page_largeur,$this->page_hauteur);
+ $this->marge_gauche=0;
+ $this->marge_droite=0;
+ $this->marge_haute=0;
+ $this->marge_basse=0;
+
+ $this->option_logo = 1; // Affiche logo
+ $this->option_tva = 0; // Gere option tva EXPEDITION_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_escompte = 0; // Affiche si il y a eu escompte
+ $this->option_credit_note = 0; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 0; // Support add of a watermark on drafts
+
+ // Recupere emetteur
+ $this->emetteur=$mysoc;
+ if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
+ }
+
+
+ /**
+ * Define array with couple substitution key => substitution value
+ *
+ * @param Object $object Main object to use as data source
+ * @param Translate $outputlangs Lang object to use for output
+ * @return array Array of substitution
+ */
+ function get_substitutionarray_object($object,$outputlangs)
+ {
+ global $conf;
+
+ $resarray=array(
+ 'object_id'=>$object->id,
+ 'object_ref'=>$object->ref,
+ 'object_ref_ext'=>$object->ref_ext,
+ 'object_ref_customer'=>$object->ref_client,
+ 'object_hour'=>dol_print_date($object->date,'hour'),
+ 'object_date'=>dol_print_date($object->date,'day'),
+ 'object_date_delivery'=>dol_print_date($object->date_livraison,'dayhour'),
+ 'object_date_creation'=>dol_print_date($object->date_creation,'day'),
+ 'object_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''),
+ 'object_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation,'dayhour'):''),
+ 'object_date_delivery_planed'=>(! empty($object->date_livraison)?dol_print_date($object->date_livraison,'day'):''),
+ 'object_date_close'=>dol_print_date($object->date_cloture,'dayhour'),
+ 'object_payment_mode_code'=>$object->mode_reglement_code,
+ 'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
+ 'object_payment_term_code'=>$object->cond_reglement_code,
+ 'object_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
+ 'object_total_ht'=>price($object->total_ht,0,$outputlangs),
+ 'object_total_vat'=>price($object->total_tva,0,$outputlangs),
+ 'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),
+ 'object_total_discount_ht' => price($object->getTotalDiscount(), 0, $outputlangs),
+ 'object_vatrate'=>vatrate($object->tva),
+ 'object_note_private'=>$object->note,
+ 'object_note'=>$object->note_public,
+ );
+
+ // Add vat by rates
+ foreach ($object->lines as $line)
+ {
+ if (empty($resarray['object_total_vat_'.$line->tva_tx])) $resarray['object_total_vat_'.$line->tva_tx]=0;
+ $resarray['object_total_vat_'.$line->tva_tx]+=$line->total_tva;
+ }
+
+ return $resarray;
+ }
+
+ /**
+ * Define array with couple substitution key => substitution value
+ *
+ * @param array $line Array of lines
+ * @param Translate $outputlangs Lang object to use for output
+ * @return array Return a substitution array
+ */
+ function get_substitutionarray_lines($line,$outputlangs)
+ {
+ global $conf;
+
+ return array(
+ 'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
+ 'line_product_ref'=>$line->product_ref,
+ 'line_product_label'=>$line->product_label,
+ 'line_desc'=>$line->desc,
+ 'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
+ 'line_up'=>price($line->subprice, 0, $outputlangs),
+ 'line_qty'=>$line->qty,
+ 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
+ 'line_price_ht'=>price($line->total_ht, 0, $outputlangs),
+ 'line_price_ttc'=>price($line->total_ttc, 0, $outputlangs),
+ 'line_price_vat'=>price($line->total_tva, 0, $outputlangs),
+ 'line_date_start'=>$line->date_start,
+ 'line_date_end'=>$line->date_end
+ );
+ }
+
+ /**
+ * Return description of a module
+ *
+ * @param Translate $langs Lang object to use for output
+ * @return string Description
+ */
+ function info($langs)
+ {
+ global $conf,$langs;
+
+ $langs->load("companies");
+ $langs->load("errors");
+
+ $form = new Form($this->db);
+
+ $texte = $this->description.".
\n";
+ $texte.= '';
+
+ return $texte;
+ }
+
+ /**
+ * Function to build a document on disk using the generic odt module.
+ *
+ * @param Expedition $object Object source to build document
+ * @param Translate $outputlangs Lang output object
+ * @param string $srctemplatepath Full path of source filename for generator using a template file
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return int 1 if OK, <=0 if KO
+ */
+ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
+ {
+ global $user,$langs,$conf,$mysoc,$hookmanager;
+
+ if (empty($srctemplatepath))
+ {
+ dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
+ return -1;
+ }
+
+ // Add odtgeneration hook
+ if (! is_object($hookmanager))
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
+ $hookmanager=new HookManager($this->db);
+ }
+ $hookmanager->initHooks(array('odtgeneration'));
+ global $action;
+
+ if (! is_object($outputlangs)) $outputlangs=$langs;
+ $sav_charset_output=$outputlangs->charset_output;
+ $outputlangs->charset_output='UTF-8';
+
+ $outputlangs->load("main");
+ $outputlangs->load("dict");
+ $outputlangs->load("companies");
+ $outputlangs->load("bills");
+
+ if ($conf->expedition->dir_output."/sending")
+ {
+ // If $object is id instead of object
+ if (! is_object($object))
+ {
+ $id = $object;
+ $object = new Expedition($this->db);
+ $result=$object->fetch($id);
+ if ($result < 0)
+ {
+ dol_print_error($this->db,$object->error);
+ return -1;
+ }
+ }
+
+ $dir = $conf->expedition->dir_output."/sending";
+ $objectref = dol_sanitizeFileName($object->ref);
+ if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
+ $file = $dir . "/" . $objectref . ".odt";
+
+ if (! file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
+ $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
+ return -1;
+ }
+ }
+
+ if (file_exists($dir))
+ {
+ //print "srctemplatepath=".$srctemplatepath; // Src filename
+ $newfile=basename($srctemplatepath);
+ $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
+ $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
+ $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
+ $newfiletmp=$objectref.'_'.$newfiletmp;
+ //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
+ // Get extension (ods or odt)
+ $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
+ if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
+ {
+ $filename=$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.'.$newfileformat;
+ }
+ else
+ {
+ $filename=$newfiletmp.'.'.$newfileformat;
+ }
+ $file=$dir.'/'.$filename;
+ //print "newdir=".$dir;
+ //print "newfile=".$newfile;
+ //print "file=".$file;
+ //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
+
+ dol_mkdir($conf->expedition->dir_temp);
+
+
+ // If BILLING contact defined on invoice, we use it
+ $usecontact=false;
+ $arrayidcontact=$object->getIdContact('external','BILLING');
+ if (count($arrayidcontact) > 0)
+ {
+ $usecontact=true;
+ $result=$object->fetch_contact($arrayidcontact[0]);
+ }
+
+ // Recipient name
+ if (! empty($usecontact))
+ {
+ // On peut utiliser le nom de la societe du contact
+ if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
+ else $socobject = $object->client;
+ }
+ else
+ {
+ $socobject=$object->client;
+ }
+
+ // Make substitution
+ $substitutionarray=array(
+ '__FROM_NAME__' => $this->emetteur->nom,
+ '__FROM_EMAIL__' => $this->emetteur->email,
+ '__TOTAL_TTC__' => $object->total_ttc,
+ '__TOTAL_HT__' => $object->total_ht,
+ '__TOTAL_VAT__' => $object->total_vat
+ );
+ complete_substitutions_array($substitutionarray, $langs, $object);
+ // Call the ODTSubstitution hook
+ $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
+ $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+
+ // Line of free text
+ $newfreetext='';
+ $paramfreetext='EXPEDITION_FREE_TEXT';
+ if (! empty($conf->global->$paramfreetext))
+ {
+ $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
+ }
+
+ // Open and load template
+ require_once ODTPHP_PATH.'odf.php';
+ $odfHandler = new odf(
+ $srctemplatepath,
+ array(
+ 'PATH_TO_TMP' => $conf->expedition->dir_temp,
+ 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
+ 'DELIMITER_LEFT' => '{',
+ 'DELIMITER_RIGHT' => '}'
+ )
+ );
+ // After construction $odfHandler->contentXml contains content and
+ // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
+ // [!-- BEGIN lines --]*[!-- END lines --]
+ //print html_entity_decode($odfHandler->__toString());
+ //print exit;
+
+
+ // Make substitutions into odt of freetext
+ try {
+ $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
+ }
+ catch(OdfException $e)
+ {
+ }
+
+ // Make substitutions into odt of user info
+ $tmparray=$this->get_substitutionarray_user($user,$outputlangs);
+ //var_dump($tmparray); exit;
+ foreach($tmparray as $key=>$value)
+ {
+ try {
+ if (preg_match('/logo$/',$key)) // Image
+ {
+ //var_dump($value);exit;
+ if (file_exists($value)) $odfHandler->setImage($key, $value);
+ else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
+ }
+ else // Text
+ {
+ $odfHandler->setVars($key, $value, true, 'UTF-8');
+ }
+ }
+ catch(OdfException $e)
+ {
+ }
+ }
+ // Make substitutions into odt of mysoc
+ $tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
+ //var_dump($tmparray); exit;
+ foreach($tmparray as $key=>$value)
+ {
+ try {
+ if (preg_match('/logo$/',$key)) // Image
+ {
+ //var_dump($value);exit;
+ if (file_exists($value)) $odfHandler->setImage($key, $value);
+ else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
+ }
+ else // Text
+ {
+ $odfHandler->setVars($key, $value, true, 'UTF-8');
+ }
+ }
+ catch(OdfException $e)
+ {
+ }
+ }
+ // Make substitutions into odt of thirdparty
+ $tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
+ foreach($tmparray as $key=>$value)
+ {
+ try {
+ if (preg_match('/logo$/',$key)) // Image
+ {
+ if (file_exists($value)) $odfHandler->setImage($key, $value);
+ else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
+ }
+ else // Text
+ {
+ $odfHandler->setVars($key, $value, true, 'UTF-8');
+ }
+ }
+ catch(OdfException $e)
+ {
+ }
+ }
+ // Replace tags of object + external modules
+ $tmparray=$this->get_substitutionarray_object($object,$outputlangs);
+ complete_substitutions_array($tmparray, $outputlangs, $object);
+ // Call the ODTSubstitution hook
+ $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
+ $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ foreach($tmparray as $key=>$value)
+ {
+ try {
+ if (preg_match('/logo$/',$key)) // Image
+ {
+ if (file_exists($value)) $odfHandler->setImage($key, $value);
+ else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
+ }
+ else // Text
+ {
+ $odfHandler->setVars($key, $value, true, 'UTF-8');
+ }
+ }
+ catch(OdfException $e)
+ {
+ }
+ }
+ // Replace tags of lines
+ try
+ {
+ $listlines = $odfHandler->setSegment('lines');
+ foreach ($object->lines as $line)
+ {
+ $tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
+ complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
+ // Call the ODTSubstitutionLine hook
+ $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
+ $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ foreach($tmparray as $key => $val)
+ {
+ try
+ {
+ $listlines->setVars($key, $val, true, 'UTF-8');
+ }
+ catch(OdfException $e)
+ {
+ }
+ catch(SegmentException $e)
+ {
+ }
+ }
+ $listlines->merge();
+ }
+ $odfHandler->mergeSegment($listlines);
+ }
+ catch(OdfException $e)
+ {
+ $this->error=$e->getMessage();
+ dol_syslog($this->error, LOG_WARNING);
+ return -1;
+ }
+
+ // Call the beforeODTSave hook
+ $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+
+ // Write new file
+ if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
+ try {
+ $odfHandler->exportAsAttachedPDF($file);
+ }catch (Exception $e){
+ $this->error=$e->getMessage();
+ return -1;
+ }
+ }
+ else {
+ try {
+ $odfHandler->saveToDisk($file);
+ }catch (Exception $e){
+ $this->error=$e->getMessage();
+ return -1;
+ }
+ }
+
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
+
+ $odfHandler=null; // Destroy object
+
+ return 1; // Success
+ }
+ else
+ {
+ $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
+ return -1;
+ }
+ }
+
+ return -1;
+ }
+
+}
+
+?>
diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
similarity index 99%
rename from htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php
rename to htdocs/core/modules/expedition/doc/pdf_merou.modules.php
index 4ffd39d0031..492c01be2da 100644
--- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
@@ -20,7 +20,7 @@
*/
/**
- * \file htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php
+ * \file htdocs/core/modules/expedition/doc/pdf_merou.modules.php
* \ingroup expedition
* \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Merou
*/
@@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
/**
* Classe permettant de generer les borderaux envoi au modele Merou
*/
-class pdf_expedition_merou extends ModelePdfExpedition
+class pdf_merou extends ModelePdfExpedition
{
var $emetteur; // Objet societe qui emet
diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
similarity index 99%
rename from htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php
rename to htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index 15a94b8aaed..2f7a70b0e3f 100644
--- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -19,7 +19,7 @@
*/
/**
- * \file htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php
+ * \file htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
* \ingroup expedition
* \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Rouget
*/
@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
/**
* Classe permettant de generer les borderaux envoi au modele Rouget
*/
-class pdf_expedition_rouget extends ModelePdfExpedition
+class pdf_rouget extends ModelePdfExpedition
{
var $emetteur; // Objet societe qui emet
diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php
index bf74e1adcd1..d205f662974 100644
--- a/htdocs/core/modules/expedition/modules_expedition.php
+++ b/htdocs/core/modules/expedition/modules_expedition.php
@@ -188,14 +188,14 @@ function expedition_pdf_create($db, $object, $modele, $outputlangs)
{
foreach(array('doc','pdf') as $prefix)
{
- $file = $prefix."_expedition_".$modele.".modules.php";
+ $file = $prefix."_".$modele.".modules.php";
// We check the model location
$file=dol_buildpath($reldir."core/modules/expedition/doc/".$file,0);
if (file_exists($file))
{
$filefound=1;
- $classname=$prefix.'_expedition_'.$modele;
+ $classname=$prefix.'_'.$modele;
break;
}
}
diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php
index 5704f96d0cc..40515f68fed 100644
--- a/htdocs/core/modules/modExpedition.class.php
+++ b/htdocs/core/modules/modExpedition.class.php
@@ -94,6 +94,13 @@ class modExpedition extends DolibarrModules
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des expeditions';
$this->const[$r][4] = 0;
$r++;
+
+ $r++;
+ $this->const[$r][0] = "EXPEDITION_ADDON_PDF_ODT_PATH";
+ $this->const[$r][1] = "chaine";
+ $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/shipment";
+ $this->const[$r][3] = "";
+ $this->const[$r][4] = 0;
$this->const[$r][0] = "LIVRAISON_ADDON_PDF";
$this->const[$r][1] = "chaine";
@@ -108,6 +115,13 @@ class modExpedition extends DolibarrModules
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des bons de reception';
$this->const[$r][4] = 0;
$r++;
+
+ $r++;
+ $this->const[$r][0] = "EXPEDITION_ADDON_PDF_ODT_PATH";
+ $this->const[$r][1] = "chaine";
+ $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/delivery";
+ $this->const[$r][3] = "";
+ $this->const[$r][4] = 0;
// Boxes
$this->boxes = array();
@@ -229,6 +243,24 @@ class modExpedition extends DolibarrModules
// Permissions
$this->remove($options);
+
+ //ODT template
+ $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt';
+ $dirodt=DOL_DATA_ROOT.'/doctemplates/shipment';
+ $dest=$dirodt.'/template_shipment.odt';
+
+ if (file_exists($src) && ! file_exists($dest))
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ dol_mkdir($dirodt);
+ $result=dol_copy($src,$dest,0,0);
+ if ($result < 0)
+ {
+ $langs->load("errors");
+ $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
+ return 0;
+ }
+ }
$sql = array();
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index caeb4c3be1d..ed501026c8a 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -272,15 +272,62 @@ class pdf_azur extends ModelePDFPropales
$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(); $realpath='';
+ if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
+ {
+ if ($object->lines[$i]->fk_product)
+ {
+ $objphoto = new Product($this->db);
+ $objphoto->fetch($object->lines[$i]->fk_product);
+
+ $pdir = get_exdir($object->lines[$i]->fk_product,2) . $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 (!empty($realpath)) $imglinesize=pdf_getSizeForImage($realpath);
+ }
+ }
+
$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 (($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo to high, we moved completely on new page
+ {
+ $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($pagenb+1);
+
+ $curY = $tab_top_newpage;
+ $showpricebeforepagebreak=0;
+ }
+
+ if (isset($imglinesize['width']) && isset($imglinesize['height']))
+ {
+ $curX = $this->posxpicture-1;
+ $pdf->Image($realpath, $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;
- $showpricebeforepagebreak=1;
-
$pdf->startTransaction();
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
{
@@ -329,6 +376,7 @@ class pdf_azur extends ModelePDFPropales
{
$pdf->commitTransaction();
}
+ $posYAfterDescription=$pdf->GetY();
$nexY = $pdf->GetY();
$pageposafter=$pdf->getPage();
@@ -336,67 +384,13 @@ class pdf_azur extends ModelePDFPropales
$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
+ // 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
- // Photo
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITH_PICTURE))
- {
- $curX = $this->posxpicture-1;
- if ($object->lines[$i]->fk_product)
- {
- $objphoto = new Product($this->db);
- $objphoto->fetch($object->lines[$i]->fk_product);
-
- $pdir = get_exdir($object->lines[$i]->fk_product,2) . $object->lines[$i]->fk_product ."/photos/";
- $dir = $conf->product->dir_output.'/'.$pdir;
-
- $realpath='';
- if ($object->ref == 'SPECIMEN')
- {
- $realpath = DOL_DOCUMENT_ROOT.'/theme/common/nophoto.jpg';
- }
- else
- {
- foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
- {
- if ($obj['photo_vignette'])
- {
- $filename='thumbs/'.$obj['photo_vignette'];
- }
- else
- {
- $filename=$obj['photo'];
- }
-
- $realpath = $dir.$filename;
- break;
- }
- }
-
- if (!empty($realpath))
- {
- //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
- $tmp=pdf_getHeightForImage($realpath);
- //var_dump(constant('PDF_IMAGE_SCALE_RATIO'));var_dump($pdf->getImageScale());var_dump($tmp['width']);var_dump($pdf->pixelsToUnits($tmp['width']));exit;
- // measures 1/72 of an inch, i.e. approximately 0.0139 inch or 25.4/72 = 0.3528 mm
- var_dump($this->page_largeur);exit;
- //var_dump(tmp['height']);exit;
- $pdf->Line($this->posxtva,10,$this->posxtva+0.5,10);
- $pdf->Image($realpath, $this->posxtva, 10, $tmp['width'], $tmp['height'],'','','',2,0); // Use 300 dpi
- $pdf->Line($this->posxtva+$pdf->pixelsToUnits($tmp['width']),10,$this->posxtva+$pdf->pixelsToUnits($tmp['width'])+0.5,10);
- $pdf->Image($realpath, $curX + ($this->posxtva-$this->posxpicture-($pdf->pixelsToUnits($tmp['width'])))/2, $curY-1, $tmp['width'], $tmp['height'],'','','',2, 300); // Use 300 dpi
- //$nexY += 7; // +7 for height = 12
- $nexY += round($pdf->pixelsToUnits($tmp['height']));
- //var_dump($nexY);exit;
- }
- }
- }
-
// VAT Rate
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
@@ -459,6 +453,8 @@ class pdf_azur extends ModelePDFPropales
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
$this->tva[$vatrate] += $tvaligne;
+ if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
+
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
{
@@ -1063,7 +1059,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
- if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 6, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
}
$pdf->SetDrawColor(128,128,128);
@@ -1074,7 +1070,7 @@ class pdf_azur extends ModelePDFPropales
if (empty($hidetop))
{
- $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
+ $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); // line prend une position y en 2eme param et 4eme param
$pdf->SetXY($this->posxdesc-1, $tab_top+1);
$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
@@ -1085,8 +1081,8 @@ class pdf_azur extends ModelePDFPropales
$pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
if (empty($hidetop))
{
- $pdf->SetXY($this->posxpicture-1, $tab_top+1);
- $pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
+ //$pdf->SetXY($this->posxpicture-1, $tab_top+1);
+ //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C');
}
}
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 996e41a649a..56be5f04b54 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -74,6 +74,12 @@ $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($co
$object = new Expedition($db);
+// Load object
+if ($id > 0 || ! empty($ref))
+{
+ $ret=$object->fetch($id, $ref);
+}
+
/*
* Actions
*/
@@ -297,14 +303,9 @@ else if ($action == 'settrackingnumber' || $action == 'settrackingurl'
// Build document
else if ($action == 'builddoc') // En get ou en post
{
- // Sauvegarde le dernier modele choisi pour generer un document
- $shipment = new Expedition($db);
- $shipment->fetch($id);
- $shipment->fetch_thirdparty();
-
if (GETPOST('model','alpha'))
{
- $shipment->setDocModel($user, GETPOST('model','alpha'));
+ $object->setDocModel($user, GETPOST('model','alpha'));
}
// Define output language
@@ -317,7 +318,7 @@ else if ($action == 'builddoc') // En get ou en post
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
- $result=expedition_pdf_create($db,$shipment,GETPOST('model','alpha'),$outputlangs);
+ $result=expedition_pdf_create($db,$object,$object->modelpdf,$outputlangs);
if ($result <= 0)
{
dol_print_error($db,$result);
diff --git a/htdocs/install/doctemplates/shipment/template_shipment.odt b/htdocs/install/doctemplates/shipment/template_shipment.odt
new file mode 100644
index 00000000000..100afe5dac4
Binary files /dev/null and b/htdocs/install/doctemplates/shipment/template_shipment.odt differ
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index b39d5216218..161cb4aa30e 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -78,7 +78,7 @@ if (! empty($dolibarr_main_document_root_alt))
{
if (preg_match('/^http(s)?:/',$value))
{
- print 'Error: values for $dolibarr_main_url_root_alt into conf.php file must contains relative path to alternative URLs.
'."\n";
+ print 'Error: values for $dolibarr_main_url_root_alt into conf.php file must contains relative path added to $dolibarr_main_url_root to get alternative URLs.
'."\n";
print "Found: \"".$value."\"
\n";
print "Should found something like following examples:
\n";
print "\"/extensions\"
\n";
diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php
index 2bba8666e0c..9646e808c37 100755
--- a/scripts/invoices/rebuild_merge_pdf.php
+++ b/scripts/invoices/rebuild_merge_pdf.php
@@ -112,7 +112,7 @@ foreach ($argv as $key => $value)
$dateafterdate=dol_stringtotime($argv[$key+1]);
$datebeforedate=dol_stringtotime($argv[$key+2]);
- print 'Rebuild PDF for invoices validated between '.dol_print_date($dateafterdate,'day')." and ".dol_print_date($datebeforedate,'day').".\n";
+ print 'Rebuild PDF for invoices validated between '.dol_print_date($dateafterdate,'day','gmt')." and ".dol_print_date($datebeforedate,'day','gmt').".\n";
}
if ($value == 'filter=payments')
@@ -121,14 +121,14 @@ foreach ($argv as $key => $value)
$option.=(empty($option)?'':'_').'payments_'.$argv[$key+1].'_'.$argv[$key+2];
$filter[]='payments';
- $paymentdateafter=dol_stringtotime($argv[$key+1]);
- $paymentdatebefore=dol_stringtotime($argv[$key+2]);
+ $paymentdateafter=dol_stringtotime($argv[$key+1].'000000');
+ $paymentdatebefore=dol_stringtotime($argv[$key+2].'235959');
if (empty($paymentdateafter) || empty($paymentdatebefore))
{
print 'Error: Bad date format or value'."\n";
exit(-1);
}
- print 'Rebuild PDF for invoices with at least one payment between '.dol_print_date($paymentdateafter,'day')." and ".dol_print_date($paymentdatebefore,'day').".\n";
+ print 'Rebuild PDF for invoices with at least one payment between '.dol_print_date($paymentdateafter,'day','gmt')." and ".dol_print_date($paymentdatebefore,'day','gmt').".\n";
}
if ($value == 'filter=nopayment')
@@ -183,6 +183,27 @@ foreach ($argv as $key => $value)
print 'Exclude credit note invoices'."\n";
}
+ if ($value == 'filter=excludethirdparties')
+ {
+ $found=true;
+ $filter[]='excludethirdparties';
+
+ $thirdpartiesid=explode(',',$argv[$key+1]);
+ print 'Exclude thirdparties with id in list ('.join(',',$thirdpartiesid).").\n";
+
+ $option.=(empty($option)?'':'_').'excludethirdparties'.join('-',$thirdpartiesid);
+ }
+ if ($value == 'filter=onlythirdparties')
+ {
+ $found=true;
+ $filter[]='onlythirdparties';
+
+ $thirdpartiesid=explode(',',$argv[$key+1]);
+ print 'Only thirdparties with id in list ('.join(',',$thirdpartiesid).").\n";
+
+ $option.=(empty($option)?'':'_').'onlythirdparty'.join('-',$thirdpartiesid);
+ }
+
if (! $found && preg_match('/filter=/i',$value))
{
usage();
@@ -211,7 +232,7 @@ if (in_array('bank',$filter) && in_array('nopayment',$filter))
// Define SQL and SQL request to select invoices
// Use $filter, $dateafterdate, datebeforedate, $paymentdateafter, $paymentdatebefore
-$result=rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, 1, $regenerate, $option, $paymentonbankid);
+$result=rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, 1, $regenerate, $option, $paymentonbankid, $thirdpartiesid);
@@ -258,6 +279,8 @@ function usage()
print "To exclude credit notes, use filter=nocreditnote\n";
print "To exclude replacement invoices, use filter=noreplacement\n";
print "To exclude deposit invoices, use filter=nodeposit\n";
+ print "To exclude some thirdparties, use filter=excludethirdparties id1,id2...\n";
+ print "To limit to some thirdparties, use filter=onlythirdparties id1,id2...\n";
print "To regenerate existing PDF, use regenerate=crabe\n";
print "To generate invoices in a language, use lang=xx_XX\n";
print "\n";