Browse Source

Merge branch '7.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/compta/bank/card.php
	htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
	htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
	htdocs/core/tpl/admin_extrafields_view.tpl.php
	htdocs/langs/de_DE/admin.lang
Laurent Destailleur 7 years ago
parent
commit
ea2fd67e0d

+ 2 - 1
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) {

+ 2 - 2
htdocs/compta/bank/card.php

@@ -811,11 +811,11 @@ else
 
 		// Ref
 		print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
-		print '<td><input type="text" class="flat maxwidth200" name="ref" value="'.(isset($_POST["ref"])?GETPOST("ref"):$object->ref).'"></td></tr>';
+		print '<td><input type="text" class="flat maxwidth200" name="ref" value="'.dol_escape_htmltag(isset($_POST["ref"])?GETPOST("ref"):$object->ref).'"></td></tr>';
 
 		// Label
 		print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
-		print '<td><input type="text" class="flat minwidth300" name="label" value="'.(isset($_POST["label"])?GETPOST("label"):$object->label).'"></td></tr>';
+		print '<td><input type="text" class="flat minwidth300" name="label" value="'.dol_escape_htmltag(isset($_POST["label"])?GETPOST("label"):$object->label).'"></td></tr>';
 
 		// Type
 		print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';

+ 14 - 4
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');
 		}

+ 1 - 1
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)),

+ 4 - 0
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':

+ 4 - 0
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]);

+ 2 - 1
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;

+ 1 - 1
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;

+ 2 - 1
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';

+ 11 - 2
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;

+ 11 - 2
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;

+ 7 - 1
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];

+ 2 - 0
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
 		{

+ 3 - 0
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')__;

+ 1 - 1
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 <b>%s</b> 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 <a href="https://wiki.dolibarr.org/index.php/Setup_Other#List_of_known_hidden_options" title="External Site - opens in a new window" target="_blank"> hier überprüfen </a>.
+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 <a href="https://wiki.dolibarr.org/index.php/Setup_Other#List_of_known_hidden_options" title="External Site-öffnet sich in einem neuen Fenster" target="_blank"> hier überprüfen </a>.
 MiscellaneousDesc=Alle anderen sicherheitsrelevanten Parameter werden hier eingestellt.
 LimitsSetup=Limits und Genauigkeit Einstellungen
 LimitsDesc=Hier können Sie Grenzwerte, Genauigkeitseinstellungen und das Rundungsverhalten einstellen.

+ 2 - 0
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__';