Merge branch 'develop' into prod-attr

# Conflicts:
#	htdocs/compta/facture.php
This commit is contained in:
Marcos García de La Fuente
2017-01-14 23:59:14 +01:00
159 changed files with 4298 additions and 2037 deletions

View File

@@ -110,8 +110,8 @@ class pdf_einstein extends ModelePDFCommandes
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
$this->posxqty=130;
$this->posxunit=147;
}
else
{

View File

@@ -119,8 +119,8 @@ class pdf_crabe extends ModelePDFFactures
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
$this->posxqty=130;
$this->posxunit=147;
}
else
{

View File

@@ -50,8 +50,8 @@ class modAccounting extends DolibarrModules
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Advanced accounting management";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'experimental';
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
$this->special = 0;

View File

@@ -189,7 +189,7 @@ class modAgenda extends DolibarrModules
// $r++;
$this->menu[$r]=array('fk_menu'=>0,
'type'=>'top',
'titre'=>'Agenda',
'titre'=>'TMenuAgenda',
'mainmenu'=>'agenda',
'url'=>'/comm/action/index.php',
'langs'=>'agenda',

View File

@@ -135,10 +135,13 @@ class modDeplacement extends DolibarrModules
$this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement',1).')';
if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR d.fk_soc IS NULL)';
$childids = $user->getAllChildIds();
$childids[]=$user->id;
if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')';
if (! empty($user)) // Not defined during migration process
{
$childids = $user->getAllChildIds();
$childids[]=$user->id;
if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')';
}
}

View File

@@ -62,7 +62,7 @@ class modMultiCurrency extends DolibarrModules
$this->description = "Module to enter elements with a foreign currency";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this->version = 'experimental';
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)

View File

@@ -281,7 +281,14 @@ class modSociete extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id';
$this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe', 1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
if(!$user->rights->societe->client->voir) {
$this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' ';
if ($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS) {
$subordinatesids = $user->getAllChildIds();
$this->export_sql_end[$r] .=count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).')' : '';
}
$this->export_sql_end[$r] .=')';
}
// Export list of contacts and attributes
$r++;
@@ -311,7 +318,14 @@ class modSociete extends DolibarrModules
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
$this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity("societe", 1).')';
if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
if(!$user->rights->societe->client->voir) {
$this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' ';
if ($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS) {
$subordinatesids = $user->getAllChildIds();
$this->export_sql_end[$r] .=count($subronidatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',',$subronidatesids).')' : '';
}
$this->export_sql_end[$r] .=')';
}
// Imports

View File

@@ -0,0 +1,171 @@
<?php
/*
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/modules/oauth/github_oauthcallback.php
* \ingroup oauth
* \brief Page to get oauth callback
*/
require '../../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
use OAuth\Common\Storage\DoliStorage;
use OAuth\Common\Consumer\Credentials;
use OAuth\OAuth2\Service\GitHub;
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$action = GETPOST('action', 'alpha');
$backtourl = GETPOST('backtourl', 'alpha');
/**
* Create a new instance of the URI class with the current URI, stripping the query string
*/
$uriFactory = new \OAuth\Common\Http\Uri\UriFactory();
//$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
//$currentUri->setQuery('');
$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/github_oauthcallback.php');
/**
* Load the credential for the service
*/
/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */
$serviceFactory = new \OAuth\ServiceFactory();
$httpClient = new \OAuth\Common\Http\Client\CurlClient();
// TODO Set options for proxy and timeout
// $params=array('CURLXXX'=>value, ...)
//$httpClient->setCurlParameters($params);
$serviceFactory->setHttpClient($httpClient);
// Dolibarr storage
$storage = new DoliStorage($db, $conf);
// Setup the credentials for the requests
$credentials = new Credentials(
$conf->global->OAUTH_GITHUB_ID,
$conf->global->OAUTH_GITHUB_SECRET,
$currentUri->getAbsoluteUri()
);
$requestedpermissionsarray=array();
if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back
if ($action != 'delete' && empty($requestedpermissionsarray))
{
print 'Error, parameter state is not defined';
exit;
}
//var_dump($requestedpermissionsarray);exit;
// Instantiate the Api service using the credentials, http client and storage mechanism for the token
/** @var $apiService Service */
$apiService = $serviceFactory->createService('GitHub', $credentials, $storage, $requestedpermissionsarray);
// access type needed to have oauth provider refreshing token
//$apiService->setAccessType('offline');
$langs->load("oauth");
/*
* Actions
*/
if ($action == 'delete')
{
$storage->clearToken('GitHub');
setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
header('Location: ' . $backtourl);
exit();
}
if (! empty($_GET['code'])) // We are coming from oauth provider page
{
//llxHeader('',$langs->trans("OAuthSetup"));
//$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
//print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
//dol_fiche_head();
// retrieve the CSRF state parameter
$state = isset($_GET['state']) ? $_GET['state'] : null;
//print '<table>';
// This was a callback request from service, get the token
try {
//var_dump($_GET['code']);
//var_dump($state);
//var_dump($apiService); // OAuth\OAuth2\Service\GitHub
//$token = $apiService->requestAccessToken($_GET['code'], $state);
$token = $apiService->requestAccessToken($_GET['code']);
// Github is a service that does not need state yo be stored.
// Into constructor of GitHub, the call
// parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri)
// has not the ending parameter to true like the Google class constructor.
setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
} catch (Exception $e) {
print $e->getMessage();
}
$backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
unset($_SESSION["backtourlsavedbeforeoauthjump"]);
header('Location: ' . $backtourl);
exit();
}
else // If entry on page with no parameter, we arrive here
{
$_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
// This may create record into oauth_state before the header redirect.
// Creation of record with state in this tables depend on the Provider used (see its constructor).
if (GETPOST('state'))
{
$url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state')));
}
else
{
$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
}
// we go on oauth provider authorization page
header('Location: ' . $url);
exit();
}
/*
* View
*/
// No view at all, just actions
$db->close();

View File

@@ -17,7 +17,7 @@
*/
/**
* \file htdocs/core/modules/oauth/getoauthcallback.php
* \file htdocs/core/modules/oauth/google_oauthcallback.php
* \ingroup oauth
* \brief Page to get oauth callback
*/
@@ -83,7 +83,7 @@ if ($action != 'delete' && empty($requestedpermissionsarray))
/** @var $apiService Service */
$apiService = $serviceFactory->createService('Google', $credentials, $storage, $requestedpermissionsarray);
// access type needed for google refresh token
// access type needed to have oauth provider refreshing token
$apiService->setAccessType('offline');
$langs->load("oauth");
@@ -104,7 +104,7 @@ if ($action == 'delete')
exit();
}
if (! empty($_GET['code'])) // We are coming from Google oauth page
if (! empty($_GET['code'])) // We are coming from oauth provider page
{
//llxHeader('',$langs->trans("OAuthSetup"));
@@ -121,6 +121,7 @@ if (! empty($_GET['code'])) // We are coming from Google oauth page
//var_dump($_GET['code']);
//var_dump($state);
//var_dump($apiService); // OAuth\OAuth2\Service\Google
$token = $apiService->requestAccessToken($_GET['code'], $state);
setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
@@ -138,6 +139,8 @@ else // If entry on page with no parameter, we arrive here
{
$_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
// This may create record into oauth_state before the header redirect.
// Creation of record with state in this tables depend on the Provider used (see its constructor).
if (GETPOST('state'))
{
$url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state')));
@@ -146,7 +149,8 @@ else // If entry on page with no parameter, we arrive here
{
$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
}
// we go on google authorization page
// we go on oauth provider authorization page
header('Location: ' . $url);
exit();
}

View File

@@ -66,6 +66,7 @@ class printing_printgcp extends PrintingDriver
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$this->db = $db;
if (!$conf->oauth->enabled) {
@@ -117,10 +118,28 @@ class printing_printgcp extends PrintingDriver
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info');
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):''));
if ($token_ok) {
$expiredat='';
$refreshtoken = $token->getRefreshToken();
$endoflife=$token->getEndOfLife();
if ($endoflife == $token::EOL_NEVER_EXPIRES)
{
$expiredat = $langs->trans("Never");
}
elseif ($endoflife == $token::EOL_UNKNOWN)
{
$expiredat = $langs->trans("Unknown");
}
else
{
$expiredat=dol_print_date($endoflife, "dayhour");
}
$this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info');
$this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info');
$this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>(dol_print_date($token->getEndOfLife(), "dayhour")), 'type'=>'info');
$this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>($expiredat), 'type'=>'info');
}
/*
if ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)) {

View File

@@ -108,8 +108,8 @@ class pdf_azur extends ModelePDFPropales
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
$this->posxqty=130;
$this->posxunit=147;
}
else
{

View File

@@ -102,8 +102,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
if($conf->global->PRODUCT_USE_UNITS) {
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
$this->posxqty=130;
$this->posxunit=147;
}
//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images

View File

@@ -111,8 +111,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
{
$this->posxtva=99;
$this->posxup=114;
$this->posxqty=133;
$this->posxunit=150;
$this->posxqty=130;
$this->posxunit=147;
} else {
$this->posxtva=112;
$this->posxup=126;