diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 21324613bdf..db3301174c3 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2010-2017 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014-2016 Ferran Marcet @@ -771,6 +771,30 @@ if (empty($reshook)) else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer) { $result = $object->validate($user); + + if ($result > 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } } else if ($action == 'reopen' && $user->rights->contrat->creer) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2df6dfc82b7..18d3f203dac 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1273,14 +1273,15 @@ abstract class CommonObject } /** - * Load object from specific field - * - * @param string $table Table element or element line - * @param string $field Field selected - * @param string $key Import key - * @return int <0 if KO, >0 if OK - */ - function fetchObjectFrom($table,$field,$key) + * Load object from specific field + * + * @param string $table Table element or element line + * @param string $field Field selected + * @param string $key Import key + * @param string $element Element name + * @return int <0 if KO, >0 if OK + */ + function fetchObjectFrom($table, $field, $key, $element = null) { global $conf; @@ -1288,7 +1289,11 @@ abstract class CommonObject $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table; $sql.= " WHERE ".$field." = '".$key."'"; - $sql.= " AND entity = ".$conf->entity; + if (! empty($element)) { + $sql.= " AND entity IN (".getEntity($element).")"; + } else { + $sql.= " AND entity = ".$conf->entity; + } dol_syslog(get_class($this).'::fetchObjectFrom', LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index d40fcadc17c..7554a82a5fd 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -404,13 +404,13 @@ class Notify break; case 'FICHINTER_ADD_CONTACT': $link='/fichinter/card.php?id='.$object->id; - $dir_output = $conf->facture->dir_output; + $dir_output = $conf->ficheinter->dir_output; $object_type = 'ficheinter'; $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact",$object->ref); break; case 'FICHINTER_VALIDATE': $link='/fichinter/card.php?id='.$object->id; - $dir_output = $conf->facture->dir_output; + $dir_output = $conf->ficheinter->dir_output; $object_type = 'ficheinter'; $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$object->ref); break; @@ -664,8 +664,9 @@ class Notify } dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval); $sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto); - $sendto = preg_replace('/^[\s,]+/','',$sendto); // Clean start of string - $sendto = preg_replace('/[\s,]+$/','',$sendto); // Clean end of string + $sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid + $sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string + $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string } if ($sendto) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 17b8aca8474..ce122b045b5 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -157,7 +157,7 @@ class Fichinter extends CommonObject */ function create($user, $notrigger=0) { - global $conf, $user, $langs; + global $conf, $langs; dol_syslog(get_class($this)."::create ref=".$this->ref); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index f2ed3005022..724f90af228 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -101,6 +101,21 @@ if (empty($reshook)) $result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int')); if ($result < 0) dol_print_error($db,$object->error); } + if ($action == 'update_extras') { + $object->fetch($id); + + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + + if ($ret < 0) $error++; + if (! $error) + { + $result = $object->insertExtraFields(); + if ($result < 0) $error++; + } + if ($error) $action = 'edit_extras'; + } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9883db3bec6..44e95f4159b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1153,6 +1153,7 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; + $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; if ($rowid) $sql .= ' AND s.rowid = '.$rowid; if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'";