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 61aba27a6b8b989122aba34bc71c81516fc25db1..64bf03e2f6b7afa5ab357cabab515ae961d68264 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 aaddbc1d7484bee6016ddb2655c140c817f0e3b0..b482d3a0abefe101b3171ce51ea54e6d64d9ca35 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 542f53c24b7958ef1bb13073672474c94e83df4a..33770793c6b18129b47306451476d20ac2d53809 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 6e2601797f86b9ee652fd3a367bc67a09dfddaaf..d42127a23ed7aaedc630ea3ea621cce2e509b543 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 d6773eb2c80aa567462c4159bba6e869e6722e80..d696d95c4d5de9a1db9b3657b80158babfdac6e1 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/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 22bfcb6e6d8709d4e7b3d01c2afb8d0f8be55e49..12b0615701ede9d5f7d4779004f4506b53e0bf4b 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/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 8a274f91ac76f924bf9e01358e40e115b7440b2a..431e88f5e4f03437d9315b0f79fade0f4233361a 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -209,9 +209,15 @@ 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)) { - $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/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index a19e634f6cd5cea053ddfb8aa53141b4b24dc43b..8fdd104c3a569e5a717e8c5de235778c8efebb81 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -273,7 +273,9 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $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/fichinter/card.php b/htdocs/fichinter/card.php index 812d108b2d577623f4b7ca0af33c8b43836608e7..5e86b75c3e073ff3b117da04950e7c09f490999d 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -117,17 +117,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; @@ -143,17 +146,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; 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 2c0a788e4464fa4b0e603603e02bd1c488958e77..068fbc753cbe2f632dd97e07eb66a366496d06a6 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,17 @@ 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, +-- 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; + diff --git a/htdocs/install/mysql/tables/llx_holiday_users.sql b/htdocs/install/mysql/tables/llx_holiday_users.sql index 5aa1c3fc06121a044ee24db85500655e5292be9d..00ac271545857d7b1b11670a6040a6836f8d9e32 100644 --- a/htdocs/install/mysql/tables/llx_holiday_users.sql +++ b/htdocs/install/mysql/tables/llx_holiday_users.sql @@ -21,5 +21,4 @@ CREATE TABLE llx_holiday_users 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 diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 8a4c68990c6820c22be7baae1e4219a09a799efe..44871a70bcda5cdd9758147b9c5a37c260e40e3f 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -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']; } - + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); @@ -216,7 +216,6 @@ if ($object->id) $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; - // Merge propal PDF document PDF files if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { @@ -231,10 +230,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 '<br>'; // Actual file to merge is : diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 935591258746916bd4760e7aee71a19bbd3587ce..2f73685fcb36975220c9198f0abecc8432f32146 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2003 Brian Fraval <brian@fraval.org> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> - * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2005-2016 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net> * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> @@ -1630,10 +1630,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 = sc.fk_user"; + $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) diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php index fcc07837ef25529279e02ed19e314e9b655765c5..9054ff876021ccebc4cfcaf56494572de8046420 100644 --- a/htdocs/societe/commerciaux.php +++ b/htdocs/societe/commerciaux.php @@ -137,12 +137,26 @@ if (! empty($socid)) print '<tr><td>'.$langs->trans("SalesRepresentatives").'</td>'; print '<td colspan="3">'; - $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"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + { + $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; + } $sql .= " WHERE sc.fk_soc =".$object->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) @@ -206,9 +220,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.")"; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index c4fb84fa30fed999d1f21150084055c67f701fee..b492bc3725f9b9917f65d364731614d8d5c80652 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -2303,7 +2303,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 '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendMail').'</a></div>';