From 23e35a6012363953e711b9adb02972f75094d48e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 10 Feb 2016 14:21:57 +0100 Subject: [PATCH 01/15] update size of elementtype column into llx_actioncomm (module_subelement name can be longer than 32) --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 1 + htdocs/install/mysql/tables/llx_actioncomm.sql | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 2c0a788e446..ba5baf8b628 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -797,3 +797,4 @@ ALTER TABLE llx_societe_remise_except MODIFY COLUMN description text NOT NULL; update llx_opensurvey_sondage set format = 'D' where format = 'D+'; update llx_opensurvey_sondage set format = 'A' where format = 'A+'; +ALTER TABLE llx_actioncomm MODIFY COLUMN elementtype varchar(255) DEFAULT NULL; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index 62eaae22e6f..971b1cbd287 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -66,7 +66,7 @@ create table llx_actioncomm recurdateend datetime, fk_element integer DEFAULT NULL, - elementtype varchar(32) DEFAULT NULL + elementtype varchar(255) DEFAULT NULL )ENGINE=innodb; From f9d8aba32568ac52a6478966c372230bcae5c43e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 4 Mar 2016 11:48:46 +0100 Subject: [PATCH 02/15] Fix: wrong modelpdf var name --- htdocs/fichinter/card.php | 42 ++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 4aab3a99573..bada34e924c 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -116,17 +116,20 @@ if (empty($reshook)) if ($result >= 0) { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=fichinter_create($db, $object, (!GETPOST('model','alpha'))?$object->modelpdf:GETPOST('model','alpha'), $outputlangs); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) $result=fichinter_create($db, $object, GETPOST('model','alpha'), $outputlangs); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; @@ -142,17 +145,20 @@ if (empty($reshook)) $result = $object->setDraft($user); if ($result >= 0) { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + $result=fichinter_create($db, $object, (!GETPOST('model','alpha'))?$object->modelpdf:GETPOST('model','alpha'), $outputlangs); } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) $result=fichinter_create($db, $object, (!GETPOST('model','alpha'))?$object->model:GETPOST('model','apha'), $outputlangs); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; From e03f4b4de98e426046f55cd726f7414ab2ba799e Mon Sep 17 00:00:00 2001 From: phf Date: Fri, 4 Mar 2016 12:21:14 +0100 Subject: [PATCH 03/15] Fix can't send mail to thirdparty contact if no mail defined on thirdparty card --- htdocs/societe/soc.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 4bad452110b..76a2c948636 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -2366,7 +2366,18 @@ else $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - if (! empty($object->email)) + $at_least_one_email_contact = false; + $TContact = $object->contact_array_objects(); + foreach ($TContact as &$contact) + { + if (!empty($contact->email)) + { + $at_least_one_email_contact = true; + break; + } + } + + if (! empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); print ''; From 967ae720ef5671db991b0d3f829696d444100dab Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 4 Mar 2016 15:51:34 +0100 Subject: [PATCH 04/15] Fix: compatibility with multicompany transversal mode --- htdocs/societe/class/societe.class.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 72c93fa4b65..d31a240d2e4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Florian Henry @@ -1660,10 +1660,19 @@ class Societe extends CommonObject $reparray=array(); - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.email"; + $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.email"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE u.rowid = sc.fk_user AND sc.fk_soc =".$this->id; - $sql.= " AND entity in (0, ".$conf->entity.")"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + { + $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql.= " WHERE (ug.fk_user = u.rowid"; + $sql.= " AND ug.entity = ".$conf->entity.")"; + $sql.= " OR u.admin = 1"; + } + else + $sql.= " WHERE entity in (0, ".$conf->entity.")"; + + $sql.= " AND u.rowid = sc.fk_user AND sc.fk_soc =".$this->id; $resql = $this->db->query($sql); if ($resql) From bd0320dea08263c5ea5b8ff806e26f892d4891ff Mon Sep 17 00:00:00 2001 From: philippe grand Date: Fri, 4 Mar 2016 16:30:47 +0100 Subject: [PATCH 05/15] fix : missing traduction --- htdocs/langs/fr_FR/products.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 455cb209986..ff46a83bbf2 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -240,8 +240,8 @@ ProductUsedForBuild=Consommé automatiquement par la fabrication ProductBuilded=Fabrication terminée ProductsMultiPrice=Produits multi-prix ProductsOrServiceMultiPrice=Prix clients (des produits ou services, multi-prix) -ProductSellByQuarterHT=Products turnover quarterly before tax -ServiceSellByQuarterHT=Services turnover quarterly before tax +ProductSellByQuarterHT=Chiffre d'affaires trimestriel des produits hors taxes +ServiceSellByQuarterHT=Chiffre d'affaires trimestriel des services hors taxes Quarter1=1er trimestre Quarter2=2eme trimestre Quarter3=3eme trimestre From 735a1c075edfddeb6709c3705a07bc15495cc58b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 4 Mar 2016 16:48:53 +0100 Subject: [PATCH 06/15] Fix: best sql request --- htdocs/societe/class/societe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index d31a240d2e4..864820602c8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1665,9 +1665,9 @@ class Societe extends CommonObject if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) { $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE (ug.fk_user = u.rowid"; + $sql.= " WHERE ((ug.fk_user = sc.fk_user"; $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1"; + $sql.= " OR u.admin = 1)"; } else $sql.= " WHERE entity in (0, ".$conf->entity.")"; From 5292920a84ccb06ad71c8c717bf508cb695e95bd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 4 Mar 2016 17:10:42 +0100 Subject: [PATCH 07/15] Fix: don't see the sales representative of anothers entities --- htdocs/societe/commerciaux.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php index 245626752e4..436dfc5926c 100644 --- a/htdocs/societe/commerciaux.php +++ b/htdocs/societe/commerciaux.php @@ -160,12 +160,24 @@ if (! empty($socid)) print ''.$langs->trans("SalesRepresentatives").''; print ''; - $sql = "SELECT u.rowid, u.lastname, u.firstname"; + $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql .= " WHERE sc.fk_soc =".$soc->id; + if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE sc.fk_soc = ".$soc->id; $sql .= " AND sc.fk_user = u.rowid"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + { + $sql.= " AND ((ug.fk_user = sc.fk_user"; + $sql.= " AND ug.entity = ".$conf->entity.")"; + $sql.= " OR u.admin = 1)"; + } + else + $sql.= " AND u.entity IN (0,".$conf->entity.")"; + $sql .= " ORDER BY u.lastname ASC "; + dol_syslog('societe/commerciaux.php::list salesman sql = '.$sql,LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -227,9 +239,9 @@ if (! empty($socid)) if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) { $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE (ug.fk_user = u.rowid"; + $sql.= " WHERE ((ug.fk_user = u.rowid"; $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1"; + $sql.= " OR u.admin = 1)"; } else $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; From 210d8435daaafa5678f1c2c83abc0345c867912a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Mar 2016 00:39:13 +0100 Subject: [PATCH 08/15] FIX The part added with hidden option MAIN_DOC_USE_TIMING was included with a . instead of -. This make os think it is part of extension instead of file name. --- .../doc/doc_generic_askpricesupplier_odt.modules.php | 4 +++- .../modules/commande/doc/doc_generic_order_odt.modules.php | 4 +++- .../expedition/doc/doc_generic_shipment_odt.modules.php | 4 +++- .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 4 +++- .../modules/project/doc/doc_generic_project_odt.modules.php | 4 +++- .../modules/propale/doc/doc_generic_proposal_odt.modules.php | 4 +++- htdocs/core/modules/societe/doc/doc_generic_odt.modules.php | 4 +++- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php b/htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php index ddc995cc69a..49b0fdb69a3 100644 --- a/htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php +++ b/htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php @@ -273,7 +273,9 @@ class doc_generic_askpricesupplier_odt extends ModelePDFAskPriceSupplier $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; + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; } else { diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 1b7da875073..27a98eff1d8 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -239,7 +239,9 @@ class doc_generic_order_odt extends ModelePDFCommandes $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; + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; } else { 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 index aaddbc1d748..b482d3a0abe 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -239,7 +239,9 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $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; + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; } else { diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 2ca90b13ace..2e45342c244 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -240,7 +240,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures $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; + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; } else { diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 6e2601797f8..d42127a23ed 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -449,7 +449,9 @@ class doc_generic_project_odt extends ModelePDFProjects $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; + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; } else { diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 8f79094befc..44961120bb5 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -273,7 +273,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales $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; + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; } else { diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 90ced6322b7..8d7a2faf261 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -211,7 +211,9 @@ class doc_generic_odt extends ModeleThirdPartyDoc $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; + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; } else { From 896f60a4786a7f1e71253620d35398589011be68 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Mar 2016 00:47:00 +0100 Subject: [PATCH 09/15] hidden solution to solve files overwriting each other --- htdocs/core/modules/societe/doc/doc_generic_odt.modules.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 8d7a2faf261..89ecf7075c5 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -209,6 +209,10 @@ class doc_generic_odt extends ModeleThirdPartyDoc $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); // Get extension (ods or odt) $newfileformat=substr($newfile, strrpos($newfile, '.')+1); + if ( ! empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) + { + $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp; + } if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) { $format=$conf->global->MAIN_DOC_USE_TIMING; From a8e2b49c5ba454f8ae9d6d07abca0febcce9d05e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 8 Mar 2016 10:22:31 +0100 Subject: [PATCH 10/15] FIX : #4768 --- .../modules/propale/doc/pdf_azur.modules.php | 40 +++++++++++++------ htdocs/product/document.php | 15 ++++--- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 7c7fa2273d5..818f6fdb560 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -685,21 +685,39 @@ class pdf_azur extends ModelePDFPropales if (count($filetomerge->lines) > 0) { foreach ( $filetomerge->lines as $linefile ) { if (! empty($linefile->id) && ! empty($linefile->file_name)) { - if (! empty($conf->product->enabled)) - $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . dol_sanitizeFileName($line->product_ref); - elseif (! empty($conf->service->enabled)) - $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . dol_sanitizeFileName($line->product_ref); + + + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + if (! empty($conf->product->enabled)) { + $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos"; + } elseif (! empty($conf->service->enabled)) { + $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos"; + } + } + else + { + if (! empty($conf->product->enabled)) { + $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref); + } elseif (! empty($conf->service->enabled)) { + $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0,0,0,0,$product,'product') . dol_sanitizeFileName($product->ref); + } + } dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG); $infile = $filetomerge_dir . '/' . $linefile->file_name; - if (is_file($infile)) { + if (file_exists($infile) && is_readable($infile)) { $pagecount = $pdf->setSourceFile($infile); 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); + $tplIdx = $pdf->importPage(1); + if ($tplIdx!==false) { + $s = $pdf->getTemplatesize($tplIdx); + $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); + $pdf->useTemplate($tplIdx); + } else { + setEventMessages(null, array($infile.' cannot be added, probably protected PDF'),'warnings'); + } } } } @@ -709,10 +727,6 @@ class pdf_azur extends ModelePDFPropales } } - //exit; - - - $pdf->Close(); $pdf->Output($file,'F'); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index ea16a13582c..eb8530259da 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -72,7 +72,7 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product').dol_sanitizeFileName($object->ref); elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product').dol_sanitizeFileName($object->ref); - + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; @@ -187,13 +187,13 @@ if ($object->id) $filearrayold=dol_dir_list($upload_dirold,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=array_merge($filearray, $filearrayold); } - + $totalsize=0; foreach($filearray as $key => $file) { $totalsize+=$file['size']; } - + print ''; @@ -228,7 +228,6 @@ if ($object->id) $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; - // Merge propal PDF docuemnt PDF files if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { @@ -243,10 +242,16 @@ if ($object->id) $form = new Form($db); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1); + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + { + $filearray = dol_dir_list($upload_dirold, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1); + } + // For each file build select list with PDF extention - if (count($filearray) > 0) + if (count($filearray) > 0) { print '
'; // Actual file to merge is : From 4bf2da4af74ccb99879848bfefeae2deeae3ed5d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 8 Mar 2016 10:24:59 +0100 Subject: [PATCH 11/15] revert SQL changes --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 4 +--- htdocs/install/mysql/tables/llx_actioncomm.sql | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index ba5baf8b628..388afda3e7e 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -795,6 +795,4 @@ ALTER TABLE llx_societe_remise_except MODIFY COLUMN description text NOT NULL; -- Fix bad data update llx_opensurvey_sondage set format = 'D' where format = 'D+'; -update llx_opensurvey_sondage set format = 'A' where format = 'A+'; - -ALTER TABLE llx_actioncomm MODIFY COLUMN elementtype varchar(255) DEFAULT NULL; \ No newline at end of file +update llx_opensurvey_sondage set format = 'A' where format = 'A+'; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index 971b1cbd287..62eaae22e6f 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -66,7 +66,7 @@ create table llx_actioncomm recurdateend datetime, fk_element integer DEFAULT NULL, - elementtype varchar(255) DEFAULT NULL + elementtype varchar(32) DEFAULT NULL )ENGINE=innodb; From b58e155a6f86bcc6bcf6c09842e587c0fb672bf1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 10 Mar 2016 12:22:49 +0100 Subject: [PATCH 12/15] FIX : #4785 --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 14 +++++++++++++- htdocs/install/mysql/tables/llx_holiday_users.sql | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 388afda3e7e..ff1dbb77d4e 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -795,4 +795,16 @@ ALTER TABLE llx_societe_remise_except MODIFY COLUMN description text NOT NULL; -- Fix bad data update llx_opensurvey_sondage set format = 'D' where format = 'D+'; -update llx_opensurvey_sondage set format = 'A' where format = 'A+'; \ No newline at end of file +update llx_opensurvey_sondage set format = 'A' where format = 'A+'; + +--Deal with holidays_user that do not have rowid +CREATE TABLE llx_holiday_users_tmp +( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + fk_user integer NOT NULL, + fk_type integer NOT NULL, + nb_holiday real NOT NULL DEFAULT '0' +) ENGINE=innodb; +INSERT INTO llx_holiday_users_tmp(fk_user,fk_type,nb_holiday) SELECT fk_user,fk_type,nb_holiday FROM llx_holiday_users; +DROP TABLE llx_holiday_users; +ALTER TABLE llx_holiday_users_tmp RENAME TO llx_holiday_users; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_holiday_users.sql b/htdocs/install/mysql/tables/llx_holiday_users.sql index 5aa1c3fc061..a5bc2674392 100644 --- a/htdocs/install/mysql/tables/llx_holiday_users.sql +++ b/htdocs/install/mysql/tables/llx_holiday_users.sql @@ -18,8 +18,8 @@ CREATE TABLE llx_holiday_users ( + rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, fk_user integer NOT NULL, fk_type integer NOT NULL, nb_holiday real NOT NULL DEFAULT '0' -) -ENGINE=innodb; \ No newline at end of file +) ENGINE=innodb; \ No newline at end of file From 80805f78ea409bfa6ee837cc6cbcf49db028a4fa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Mar 2016 13:43:09 +0100 Subject: [PATCH 13/15] Disable too dangerous patch. Fix must be done by doing an insert only without creating/renaming databases. --- .../install/mysql/migration/3.7.0-3.8.0.sql | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index ff1dbb77d4e..f9f15f08c23 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -798,13 +798,14 @@ update llx_opensurvey_sondage set format = 'D' where format = 'D+'; update llx_opensurvey_sondage set format = 'A' where format = 'A+'; --Deal with holidays_user that do not have rowid -CREATE TABLE llx_holiday_users_tmp -( - rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, - fk_user integer NOT NULL, - fk_type integer NOT NULL, - nb_holiday real NOT NULL DEFAULT '0' -) ENGINE=innodb; -INSERT INTO llx_holiday_users_tmp(fk_user,fk_type,nb_holiday) SELECT fk_user,fk_type,nb_holiday FROM llx_holiday_users; -DROP TABLE llx_holiday_users; -ALTER TABLE llx_holiday_users_tmp RENAME TO llx_holiday_users; \ No newline at end of file +--CREATE TABLE llx_holiday_users_tmp +--( +-- rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, +-- fk_user integer NOT NULL, +-- fk_type integer NOT NULL, +-- nb_holiday real NOT NULL DEFAULT '0' +--) ENGINE=innodb; +--INSERT INTO llx_holiday_users_tmp(fk_user,fk_type,nb_holiday) SELECT fk_user,fk_type,nb_holiday FROM llx_holiday_users; +--DROP TABLE llx_holiday_users; +--ALTER TABLE llx_holiday_users_tmp RENAME TO llx_holiday_users; + From f742d4ec663422f9d6e3c9bfddb25e663b6025a9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Mar 2016 13:46:37 +0100 Subject: [PATCH 14/15] Fix code corrupting database --- htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index f9f15f08c23..068fbc753cb 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -797,7 +797,9 @@ ALTER TABLE llx_societe_remise_except MODIFY COLUMN description text NOT NULL; update llx_opensurvey_sondage set format = 'D' where format = 'D+'; update llx_opensurvey_sondage set format = 'A' where format = 'A+'; + --Deal with holidays_user that do not have rowid +-- Disabled: too dangerous patch. rowid is a primary key. How is it possible to have no rowid ? --CREATE TABLE llx_holiday_users_tmp --( -- rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, From d663b28dace1650264848118db4c309f33779da2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Mar 2016 13:49:13 +0100 Subject: [PATCH 15/15] Fix no database structure change is allowed into minor versions --- htdocs/install/mysql/tables/llx_holiday_users.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_holiday_users.sql b/htdocs/install/mysql/tables/llx_holiday_users.sql index a5bc2674392..00ac2715458 100644 --- a/htdocs/install/mysql/tables/llx_holiday_users.sql +++ b/htdocs/install/mysql/tables/llx_holiday_users.sql @@ -18,7 +18,6 @@ CREATE TABLE llx_holiday_users ( - rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, fk_user integer NOT NULL, fk_type integer NOT NULL, nb_holiday real NOT NULL DEFAULT '0'