diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 9575bc3c13c..8882396d5fb 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -171,7 +171,8 @@ if ($result) { $line->fetch($obj->fdid); // Situation invoices handling - $prev_progress = $line->get_prev_progress($obj->fdid); + $prev_progress = $line->get_prev_progress($obj->rowid); + if ($obj->type == Facture::TYPE_SITUATION) { // Avoid divide by 0 if ($obj->situation_percent == 0) { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index edbc27f33fb..78c5defed30 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -811,11 +811,11 @@ else // Ref print ''.$langs->trans("Ref").''; - print 'ref).'">'; + print 'ref).'">'; // Label print ''.$langs->trans("Label").''; - print 'label).'">'; + print 'label).'">'; // Type print ''.$langs->trans("AccountType").''; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index b8ede4d7d14..6e1ddf8a796 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -47,8 +47,17 @@ if ($action == 'add' && ! empty($permissiontoadd)) if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields // Set value to insert - if (in_array($object->fields[$key]['type'], array('text', 'html'))) $value = GETPOST($key,'none'); - else $value = GETPOST($key,'alpha'); + if (in_array($object->fields[$key]['type'], array('text', 'html'))) { + $value = GETPOST($key,'none'); + } elseif ($object->fields[$key]['type']=='date') { + $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); + } elseif ($object->fields[$key]['type']=='datetime') { + $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); + } elseif ($object->fields[$key]['type']=='price') { + $value = price2num(GETPOST($key)); + } else { + $value = GETPOST($key,'alpha'); + } if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field @@ -95,11 +104,12 @@ if ($action == 'update' && ! empty($permissiontoadd)) // Set value to update if (in_array($object->fields[$key]['type'], array('text', 'html'))) { $value = GETPOST($key,'none'); - } - elseif ($object->fields[$key]['type']=='date') { + } elseif ($object->fields[$key]['type']=='date') { $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); } elseif ($object->fields[$key]['type']=='datetime') { $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); + } elseif ($object->fields[$key]['type']=='price') { + $value = price2num(GETPOST($key)); } else { $value = GETPOST($key,'alpha'); } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 4d45f5aabbb..d3d77640540 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -376,7 +376,7 @@ abstract class CommonDocGenerator $array_key.'_payment_mode_code'=>$object->mode_reglement_code, $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement), $array_key.'_payment_term_code'=>$object->cond_reglement_code, - $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement), + $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):($object->cond_reglement_doc?$object->cond_reglement_doc:$object->cond_reglement)), $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), $array_key.'_total_vat_locale'=>(! empty($object->total_vat)?price($object->total_vat, 0, $outputlangs):price($object->total_tva, 0, $outputlangs)), diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 319f21c5e9d..fe2db16d973 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4790,6 +4790,10 @@ abstract class CommonObject $new_array_options[$key] = $this->db->idate($this->array_options[$key]); break; case 'datetime': + // If data is a string instead of a timestamp, we convert it + if (! is_int($this->array_options[$key])) { + $this->array_options[$key] = strtotime($this->array_options[$key]); + } $new_array_options[$key] = $this->db->idate($this->array_options[$key]); break; case 'link': diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 0905223c4fe..04d168b288b 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1063,6 +1063,10 @@ class ExtraFields $sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0]; if (!empty($InfoFieldList[4])) { + // can use curent entity filter + if (strpos($InfoFieldList[4], '$ENTITY$')!==false) { + $InfoFieldList[4]=str_replace('$ENTITY$',$conf->entity,$InfoFieldList[4]); + } // can use SELECT request if (strpos($InfoFieldList[4], '$SEL$')!==false) { $InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c7fa142daf1..32de5f2edfd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5335,7 +5335,8 @@ class Form $sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX .$objecttmp->table_element." as t"; if ($objecttmp->ismultientitymanaged == 2) if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE t.entity IN (".getEntity($objecttmp->table_element).")"; + $sql.= " WHERE 1=1"; + if(! empty($objecttmp->ismultientitymanaged)) $sql.= " AND t.entity IN (".getEntity($objecttmp->table_element).")"; if ($objecttmp->ismultientitymanaged == 1 && ! empty($user->societe_id)) { if ($objecttmp->element == 'societe') $sql.= " AND t.rowid = ".$user->societe_id; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d99eed9aa62..8c856b954b4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6241,7 +6241,7 @@ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) $ret=''; // If order not defined, we use the setup - if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)); + if ($nameorder < 0) $nameorder=$conf->global->MAIN_FIRSTNAME_NAME_POSITION; if ($nameorder && ((string) $nameorder != '2')) { $ret.=$firstname; diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 1fec9c1b024..8187c15f684 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -63,7 +63,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors'); return -2; } - if (! preg_match('/^(integer|date|timestamp|varchar|double)/', $addfieldentry['type'])) + if (! preg_match('/^(integer|date|timestamp|varchar|double|html|price)/', $addfieldentry['type'])) { setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors'); return -2; @@ -260,6 +260,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $type = $val['type']; $type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php' if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database + if ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database $texttoinsert.= "\t".$key." ".$type; if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 22b746486c8..dcd1cf15cf8 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -63,7 +63,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices function __construct($db) { global $conf,$langs,$mysoc; - + // Translations $langs->loadLangs(array("main", "bills")); @@ -1086,7 +1086,16 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); + $carac_emetteur=''; + // Add internal contact of proposal if defined + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); + if (count($arrayidcontact) > 0) + { + $object->fetch_user($arrayidcontact[0]); + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + } + + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=42; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 374dde2c64f..c3a8fcaac44 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -1210,8 +1210,17 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($showaddress) { - // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); + // Sender properties + $carac_emetteur=''; + // Add internal contact of proposal if defined + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); + if (count($arrayidcontact) > 0) + { + $object->fetch_user($arrayidcontact[0]); + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + } + + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender $posy=42; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 57b3f9b34c8..d9a79789298 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1690,6 +1690,13 @@ class ExpenseReport extends CommonObject $this->line = new ExpenseReportLine($this->db); + if (preg_match('/\((.*)\)/', $vatrate, $reg)) + { + $vat_src_code = $reg[1]; + $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. + } + $vatrate = preg_replace('/\*/','',$vatrate); + $seller = ''; // seller is unknown $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller); @@ -1924,7 +1931,6 @@ class ExpenseReport extends CommonObject // Clean vat code $vat_src_code=''; - if (preg_match('/\((.*)\)/', $vatrate, $reg)) { $vat_src_code = $reg[1]; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 2966ca37f1a..226ae56125a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -838,6 +838,8 @@ if (empty($reshook)) $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } $action = ''; + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); + exit; } else { diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index c19530acd01..465f408eb1b 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -528,6 +528,9 @@ CREATE TABLE llx_comment ( DELETE FROM llx_const where name = __ENCRYPT('MAIN_SHOW_WORKBOARD')__; +-- Adherent - Update old constants +UPDATE llx_const SET value = REPLACE(value, '%', '__') WHERE name LIKE 'ADHERENT%'; + -- Accountancy - Remove old constants DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_SELL_JOURNAL')__; DELETE FROM llx_const WHERE name = __ENCRYPT('ACCOUNTING_PURCHASE_JOURNAL')__; diff --git a/htdocs/langs/de_DE/admin.lang b/htdocs/langs/de_DE/admin.lang index db23db8f318..2acd876d91c 100644 --- a/htdocs/langs/de_DE/admin.lang +++ b/htdocs/langs/de_DE/admin.lang @@ -1069,7 +1069,7 @@ TriggerAlwaysActive=Trigger in dieser Datei sind unabhängig der Modulkonfigurat TriggerActiveAsModuleActive=Trigger in dieser Datei sind durch das übergeordnete Modul %s aktiviert. GeneratedPasswordDesc=Definieren Sie hier das Schema nach dem automatisch generierte Passwörter erstellt werden sollen. DictionaryDesc=Alle Standardwerte einfügen. Sie können eigene Werte zu den Standartwerten hinzufügen. -ConstDesc=Diese Seite erlaubt es alle anderen Parameter einzustellen, die auf den vorherigen Seiten nicht verfügbar sind. Dies sind meist reservierte Parameter für Entwickler oder für die erweiterte Fehlersuche. Für eine Liste von Optionen hier überprüfen . +ConstDesc=Diese Seite erlaubt es alle anderen Parameter einzustellen, die auf den vorherigen Seiten nicht verfügbar sind. Dies sind meist reservierte Parameter für Entwickler oder für die erweiterte Fehlersuche. Für eine Liste von Optionen hier überprüfen . MiscellaneousDesc=Alle anderen sicherheitsrelevanten Parameter werden hier eingestellt. LimitsSetup=Limits und Genauigkeit Einstellungen LimitsDesc=Hier können Sie Grenzwerte, Genauigkeitseinstellungen und das Rundungsverhalten einstellen. diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index 4c92f507f66..a2f4f64aba5 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -317,6 +317,8 @@ class AdherentTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; + $conf->global->MAIN_FIRSTNAME_NAME_POSITION = 1; // Force setup for firstname then lastname + $template = '__CIVILITY__,__FIRSTNAME__,__LASTNAME__,__FULLNAME__,__COMPANY__,'. '__ADDRESS__,__ZIP__,__TOWN__,__COUNTRY__,__EMAIL__,__BIRTH__,__PHOTO__,__LOGIN__';