diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index dfaa4f78571..3be6cadc9ce 100644
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -152,26 +152,29 @@ if (! empty($dolibarr_main_document_root_alt))
// Define DOL_MAIN_URL_ROOT and DOL_URL_ROOT
$tmp='';
$found=0;
-$real_dolibarr_main_document_root=str_replace('\\','/',realpath($dolibarr_main_document_root)); // A) Ex: C:/xxx/dolibarr/htdocs
-$pathroot=$_SERVER["DOCUMENT_ROOT"]; // B) Ex: C:/Program Files/wamp/www/
-$paths=explode('/',str_replace('\\','/',$_SERVER["SCRIPT_NAME"])); // C) Ex: /dolibarr/htdocs/admin/system/phpinfo.php
+$real_dolibarr_main_document_root=str_replace('\\','/',realpath($dolibarr_main_document_root)); // A) Value found into config file, to say where are store htdocs files. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
+$pathroot=$_SERVER["DOCUMENT_ROOT"]; // B) Value reported by web server setup, to say where is root of web server instance. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
+$paths=explode('/',str_replace('\\','/',$_SERVER["SCRIPT_NAME"])); // C) Value reported by web server, to say full path on filesystem of a file. Ex: /dolibarr/htdocs/admin/system/phpinfo.php
+// Try to detect if $_SERVER["DOCUMENT_ROOT"]+start of $_SERVER["SCRIPT_NAME"] is $dolibarr_main_document_root. If yes, relative url to add before dol files is this start part.
$concatpath='';
foreach($paths as $tmppath) // We check to find (B+start of C)=A
{
- if ($tmppath) $concatpath.='/'.$tmppath;
+ if (empty($tmppath)) continue;
+ $concatpath.='/'.$tmppath;
+ //if ($tmppath) $concatpath.='/'.$tmppath;
//print $_SERVER["SCRIPT_NAME"].'-'.$pathroot.'-'.$concatpath.'-'.$real_dolibarr_main_document_root.'-'.realpath($pathroot.$concatpath).'
';
if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) // @ avoid warning when safe_mode is on.
{
- $tmp3=$concatpath;
- //print "Found relative url = ".$tmp3;
+ //print "Found relative url = ".$concatpath;
+ $tmp3=$concatpath;
$found=1;
break;
}
//else print "Not found yet for concatpath=".$concatpath."
\n";
}
-if (! $found) $tmp=$dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT.
+if (! $found) $tmp=$dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT).
else $tmp='http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]!=443))?'':'s').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]==80||$_SERVER["SERVER_PORT"]==443)?'':':'.$_SERVER["SERVER_PORT"]).($tmp3?(preg_match('/^\//',$tmp3)?'':'/').$tmp3:'');
-//print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp;
+//print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp."\n";
if (! empty($dolibarr_main_force_https)) $tmp=preg_replace('/^http:/i','https:',$tmp);
define('DOL_MAIN_URL_ROOT', $tmp); // URL absolute root (https://sss/dolibarr, ...)
$uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 2b23ba4722b..c58c15bed5e 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -123,16 +123,16 @@ if (empty($reshook))
if ($action == 'setaccountancy_code_buy')
{
$result = $object->setValueFrom('accountancy_code_buy', GETPOST('accountancy_code_buy'));
- if ($result < 0)
- setEventMessage(join(',',$object->errors), 'errors');
+ if ($result < 0) setEventMessage(join(',',$object->errors), 'errors');
+ else $object->accountancy_code_buy=GETPOST('accountancy_code_buy');
$action="";
}
if ($action == 'setaccountancy_code_sell')
{
$result = $object->setValueFrom('accountancy_code_sell', GETPOST('accountancy_code_sell'));
- if ($result < 0)
- setEventMessage(join(',',$object->errors), 'errors');
+ if ($result < 0) setEventMessage(join(',',$object->errors), 'errors');
+ else $object->accountancy_code_sell=GETPOST('accountancy_code_sell');
$action="";
}
@@ -369,7 +369,7 @@ if (empty($reshook))
{
$result = $object->delete($object->id);
}
-
+
if ($result > 0)
{
header('Location: '.DOL_URL_ROOT.'/product/liste.php?delprod='.urlencode($object->ref));
diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php
index 17e5975a272..f1e632ac587 100644
--- a/htdocs/projet/fiche.php
+++ b/htdocs/projet/fiche.php
@@ -211,22 +211,42 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ if ($ret < 0)
+ {
+ $error++;
+ }
+ }
- $result=$object->update($user);
+ if (! $error)
+ {
+ $result=$object->update($user);
+ if ($result < 0)
+ {
+ $error++;
+ setEventMessage($object->errors,'errors');
+ }
+ }
- if (GETPOST("reportdate") && ($object->date_start!=$old_start_date))
- {
- $result=$object->shiftTaskDate($old_start_date);
- if (!$result)
- {
- $error++;
- $mesg='