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

Conflicts:
	htdocs/compta/bank/bankentries.php
	htdocs/fourn/facture/card.php
This commit is contained in:
Laurent Destailleur 2017-10-17 11:14:58 +02:00
commit d70c215ab8
7 changed files with 41 additions and 24 deletions

View File

@ -100,6 +100,7 @@ $fieldstosearchall = array(
'd.note_public'=>'NotePublic', 'd.note_public'=>'NotePublic',
'd.note_private'=>'NotePrivate', 'd.note_private'=>'NotePrivate',
); );
if($db->type == 'pgsql') unset($fieldstosearchall['d.rowid']);
$arrayfields=array( $arrayfields=array(
'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),

View File

@ -69,7 +69,7 @@ class DolibarrApiAccess implements iAuthenticate
*/ */
public function __isAllowed() public function __isAllowed()
{ {
global $db; global $conf, $db;
$login = ''; $login = '';
$stored_key = ''; $stored_key = '';
@ -100,10 +100,13 @@ class DolibarrApiAccess implements iAuthenticate
if ($api_key) if ($api_key)
{ {
$userentity = 0;
$sql = "SELECT u.login, u.datec, u.api_key, "; $sql = "SELECT u.login, u.datec, u.api_key, ";
$sql.= " u.tms as date_modification, u.entity"; $sql.= " u.tms as date_modification, u.entity";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.api_key = '".$db->escape($api_key)."'"; $sql.= " WHERE u.api_key = '".$db->escape($api_key)."'";
// TODO Check if 2 users has same API key.
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
@ -113,24 +116,31 @@ class DolibarrApiAccess implements iAuthenticate
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$login = $obj->login; $login = $obj->login;
$stored_key = $obj->api_key; $stored_key = $obj->api_key;
$userentity = $obj->entity;
if (! defined("DOLENTITY")) // If API was not forced with HTTP_DOLENTITY, we set entity to entity of user
{
$conf->entity = ($obj->entity?$obj->entity:1);
}
} }
} }
else { else {
throw new RestException(503, 'Error when fetching user api_key :'.$db->error_msg); throw new RestException(503, 'Error when fetching user api_key :'.$db->error_msg);
} }
if ($stored_key != $api_key) { if ($stored_key != $api_key) { // This should not happen since we did a search on api_key
$userClass::setCacheIdentifier($api_key); $userClass::setCacheIdentifier($api_key);
return false; return false;
} }
if (! $login) if (! $login)
{ {
throw new RestException(503, 'Error when searching logn user fro mapi key'); throw new RestException(503, 'Error when searching login user from api key');
} }
$fuser = new User($db); $fuser = new User($db);
if(! $fuser->fetch('',$login)) { $result = $fuser->fetch('', $login, '', 0, (empty($userentity) ? -1 : $conf->entity)); // If user is not entity 0, we search in working entity $conf->entity (that may have been forced to a different value than user entity)
throw new RestException(503, 'Error when fetching user :'.$fuser->error); if ($result <= 0) {
throw new RestException(503, 'Error when fetching user :'.$fuser->error.' (conf->entity='.$conf->entity.')');
} }
$fuser->getrights(); $fuser->getrights();
static::$user = $fuser; static::$user = $fuser;
@ -143,7 +153,7 @@ class DolibarrApiAccess implements iAuthenticate
} }
else else
{ {
throw new RestException(401, "Failed to login to API. No parameter 'DOLAPIKEY' on HTTP header (neither in URL)."); throw new RestException(401, "Failed to login to API. No parameter 'HTTP_DOLAPIKEY' on HTTP header (and no parameter DOLAPIKEY in URL).");
} }
$userClass::setCacheIdentifier(static::$role); $userClass::setCacheIdentifier(static::$role);

View File

@ -1114,7 +1114,7 @@ if ($resql)
$bankstatic->id=$banklinestatic->fk_account; $bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref; $bankstatic->label=$banklinestatic->bank_account_ref;
print ' ('.$langs->trans("TransferFrom").' '; print ' ('.$langs->trans("TransferFrom").' ';
print $bankstatic->getNomUrl(1); print $bankstatic->getNomUrl(1,'transactions');
print ' '.$langs->trans("toward").' '; print ' '.$langs->trans("toward").' ';
$bankstatic->id=$objp->bankid; $bankstatic->id=$objp->bankid;
$bankstatic->label=$objp->bankref; $bankstatic->label=$objp->bankref;
@ -1131,7 +1131,7 @@ if ($resql)
$banklinestatic->fetch($links[$key]['url_id']); $banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id=$banklinestatic->fk_account; $bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref; $bankstatic->label=$banklinestatic->bank_account_ref;
print $bankstatic->getNomUrl(1); print $bankstatic->getNomUrl(1,'transactions');
print ')'; print ')';
} }
//var_dump($links); //var_dump($links);

View File

@ -84,7 +84,7 @@ dol_mkdir($dir);
$stats = new FactureStats($db, $socid, $mode, ($userid>0?$userid:0)); $stats = new FactureStats($db, $socid, $mode, ($userid>0?$userid:0));
if ($mode == 'customer') if ($mode == 'customer')
{ {
if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')'; if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$db->escape($object_status).')';
} }
if ($mode == 'supplier') if ($mode == 'supplier')
{ {
@ -227,12 +227,13 @@ complete_head_from_modules($conf,$langs,null,$head,$h,$type);
dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);
// We use select_thirdparty_list instead of select_company so we can use $filter and share same code for customer and supplier.
$tmp_companies = $form->select_thirdparty_list($socid, 'socid', $filter, 1, 0, 0, array(), '', 1); $tmp_companies = $form->select_thirdparty_list($socid, 'socid', $filter, 1, 0, 0, array(), '', 1);
//Array passed as an argument to Form::selectarray to build a proper select input //Array passed as an argument to Form::selectarray to build a proper select input
$companies = array(); $companies = array();
foreach ($tmp_companies as $value) { foreach ($tmp_companies as $value) {
$companies[$value['value']] = $value['label']; $companies[$value['key']] = $value['label'];
} }
print '<div class="fichecenter"><div class="fichethirdleft">'; print '<div class="fichecenter"><div class="fichethirdleft">';

View File

@ -1439,6 +1439,11 @@ if ($action == 'create')
$dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp);
$datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']);
$datedue=($datetmp==''?-1:$datetmp); $datedue=($datetmp==''?-1:$datetmp);
// Replicate extrafields
$objectsrc->fetch_optionals($originid);
$object->array_options = $objectsrc->array_options;
} }
} }
else else