Merge remote-tracking branch 'origin/3.8' into 3.9

Conflicts:
	htdocs/core/modules/askpricesupplier/doc/doc_generic_askpricesupplier_odt.modules.php
	htdocs/product/document.php
	htdocs/societe/commerciaux.php
This commit is contained in:
Laurent Destailleur 2016-03-10 15:03:53 +01:00
commit 3b035819a9
15 changed files with 142 additions and 52 deletions

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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
{

View File

@ -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');

View File

@ -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
{

View File

@ -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
{

View File

@ -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;

View File

@ -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;

View File

@ -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;
) ENGINE=innodb;

View File

@ -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 :

View File

@ -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)

View File

@ -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.")";

View File

@ -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.'&amp;action=presend&amp;mode=init">'.$langs->trans('SendMail').'</a></div>';