From bd0c7c433f6d7d6b38355a95947106d94610ba78 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Thu, 5 Nov 2015 23:21:16 +0100 Subject: [PATCH 01/60] composer --- composer.lock | 67 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/composer.lock b/composer.lock index f178ec4f419..4f7f131603d 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "f441e6348ae7862942693cab10810418", + "hash": "d88b5c84a9ea1af354d867ba2e2ab251", "packages": [ { "name": "ccampbell/chromephp", @@ -126,6 +126,64 @@ "homepage": "https://github.com/firephp/firephp-core", "time": "2013-04-23 15:28:20" }, + { + "name": "mike42/escpos-php", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/mike42/escpos-php.git", + "reference": "0564ff94de45564221eca99c4cd5ab24492894c2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mike42/escpos-php/zipball/0564ff94de45564221eca99c4cd5ab24492894c2", + "reference": "0564ff94de45564221eca99c4cd5ab24492894c2", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "4.5.*" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roni Saha", + "email": "roni.cse@gmail.com" + }, + { + "name": "Michael Billington", + "email": "michael.billington@gmail.com" + }, + { + "name": "Gergely Radics", + "email": "gerifield@ustream.tv" + }, + { + "name": "Warren Doyle", + "email": "w.doyle@fuelled.co" + }, + { + "name": "vharo", + "email": "vharo@geepok.com" + } + ], + "description": "Thermal receipt printer library, for use with ESC/POS compatible printers", + "homepage": "https://github.com/mike42/escpos-php", + "keywords": [ + "ESC-POS", + "driver", + "escpos", + "print", + "receipt" + ], + "time": "2015-11-02 10:50:46" + }, { "name": "mobiledetect/mobiledetectlib", "version": "2.8.3", @@ -424,13 +482,16 @@ "pdf417", "qrcode" ], + "abandoned": "tecnickcom/tcpdf", "time": "2015-01-28 18:51:40" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "mike42/escpos-php": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { From 729f1c9d3ab63ee4303fa16ebfd6ae3e980ad295 Mon Sep 17 00:00:00 2001 From: frederic34 Date: Thu, 5 Nov 2015 23:50:13 +0100 Subject: [PATCH 02/60] composer --- composer.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 4f7f131603d..47122ebe431 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,11 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], "hash": "d88b5c84a9ea1af354d867ba2e2ab251", + "content-hash": "85e60ec7f8ab593387c7bd10d8db860d", "packages": [ { "name": "ccampbell/chromephp", From 2dc644da30a4671936bf04a6ddd90c6bbfd99fe4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Nov 2015 01:33:49 +0100 Subject: [PATCH 03/60] Debug Direct print module using the OAuth setup. --- htdocs/admin/oauth.php | 21 ++- htdocs/core/lib/geturl.lib.php | 2 +- htdocs/core/modules/modOauth.class.php | 2 +- .../modules/oauth/getgoogleoauthcallback.php | 124 ++++++++++-------- .../modules/printing/printgcp.modules.php | 8 +- .../OAuth/Common/Storage/DoliStorage.php | 22 +++- htdocs/langs/en_US/oauth.lang | 4 + htdocs/langs/en_US/printing.lang | 8 +- htdocs/printing/admin/printing.php | 7 +- 9 files changed, 122 insertions(+), 76 deletions(-) diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index aab05bd4c56..66878753b46 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -27,6 +27,13 @@ require '../main.inc.php'; // required Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +// 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 + + $langs->load("admin"); $langs->load("oauth"); @@ -36,6 +43,8 @@ if (!$user->admin) $action = GETPOST('action', 'alpha'); +// Supported OAUTH +$supportedoauth2array=array('OAUTH_GOOGLE_NAME'); // API access parameters OAUTH $list = array ( array( @@ -297,11 +306,7 @@ print ''; dol_fiche_head(array(), '', '', 0, 'technic'); -// 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 - +print $langs->trans("ListOfSupportedOauthProviders").'

'; print ''; @@ -309,12 +314,16 @@ $var = true; foreach ($list as $key) { + $supported=0; + if (in_array($key[0], $supportedoauth2array)) $supported=1; + if (! $supported) continue; // show only supported + print ''; // Api Name $label = $langs->trans($key[0]); print ''; - if (in_array($key[0], array('OAUTH_GOOGLE_NAME'))) + if ($supported) { $redirect_uri=$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php'; $var = !$var; diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 682ddb1b1d1..83c67509dcc 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -101,7 +101,7 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea curl_setopt($ch, CURLOPT_POST, 0); // GET } - //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled. + //if USE_PROXY constant set at begin of this method. if ($USE_PROXY) { dol_syslog("getURLContent set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS); diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index c77ab6de68e..35be63a5c59 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -51,7 +51,7 @@ class modOauth extends DolibarrModules $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "Enable OAuth authentication"; - $this->version = 'development'; // 'development' or 'experimental' or 'dolibarr' or version + $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version $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) $this->special = 1; diff --git a/htdocs/core/modules/oauth/getgoogleoauthcallback.php b/htdocs/core/modules/oauth/getgoogleoauthcallback.php index f1e0ddd03f3..e159198314c 100644 --- a/htdocs/core/modules/oauth/getgoogleoauthcallback.php +++ b/htdocs/core/modules/oauth/getgoogleoauthcallback.php @@ -30,14 +30,25 @@ use OAuth\Common\Consumer\Credentials; use OAuth\Common\Token\TokenInterface; use OAuth\OAuth2\Service\Google; +// 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->createFromSuperGlobalArray($_SERVER); +//$currentUri->setQuery(''); +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php'); + /** * Load the credential for the service @@ -45,8 +56,15 @@ $currentUri->setQuery(''); /** @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_GOOGLE_ID, @@ -54,6 +72,7 @@ $credentials = new Credentials( $currentUri->getAbsoluteUri() ); + // Instantiate the Api service using the credentials, http client and storage mechanism for the token /** @var $apiService Service */ // TODO remove hardcoded array @@ -61,80 +80,71 @@ $apiService = $serviceFactory->createService('Google', $credentials, $storage, a // access type needed for google refresh token $apiService->setAccessType('offline'); -if ($action == 'delete') { - // delete token - llxHeader('',$langs->trans("OAuthSetup")); - $linkback=''.$langs->trans("BackToModuleList").''; - print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup'); - dol_fiche_head(); +$langs->load("oauth"); + + +/* + * Actions + */ + + +if ($action == 'delete') +{ $storage->clearToken('Google'); - dol_fiche_end(); + + setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs'); + + header('Location: ' . $backtourl); + exit(); +} +if (! empty($_GET['code'])) // We are coming from Google oauth page +{ + //llxHeader('',$langs->trans("OAuthSetup")); -} elseif (! empty($_GET['code'])) { - llxHeader('',$langs->trans("OAuthSetup")); + //$linkback=''.$langs->trans("BackToModuleList").''; + //print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup'); - $linkback=''.$langs->trans("BackToModuleList").''; - print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup'); - - dol_fiche_head(); + //dol_fiche_head(); // retrieve the CSRF state parameter $state = isset($_GET['state']) ? $_GET['state'] : null; - print '
'.$label.'
'; - // looking for a token already stored in db - //try { - // $token = $storage->retrieveAccessToken('Google'); - // $old_token=1; - //} catch (Exception $e) { - // $old_token=0; - //} - //if ($old_token==1) { - // print ''; - // print ''; - //} - //$refreshtoken = $token->getRefreshToken(); + //print '
'.$langs->trans('OldTokenStored').'
'.print_r($token,true).'
'; // This was a callback request from service, get the token try { - $apiService->requestAccessToken($_GET['code'], $state); + //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'); } catch (Exception $e) { print $e->getMessage(); } - //print '
'.print_r($apiService,true).'
'; - // retrieve new token in db - try { - $token = $storage->retrieveAccessToken('Google'); - $new_token=1; - } catch (Exception $e) { - $new_token=0; - } - $newrefreshtoken = $token->getRefreshToken(); - if (empty($newrefreshtoken) && ! empty($refreshtoken)) { - $token->setRefreshToken($refreshtoken); - $storage->storeAccessToken('Google', $token); - } - if ($new_token==1) { - print ''; - print ''; - } - //print ''; - //$apiService->refreshAccessToken($token); - //print '
'.print_r($apiService,true).'
'; - //$token = $storage->retrieveAccessToken('Google'); - //print ''; - print ''; - print '
'.$langs->trans('NewTokenStored').'
'.print_r($token,true).'
'.print_r($token,true).'
'.print_r($token,true).'
Applications associées à votre compte
'; - - dol_fiche_end(); -} else { + $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; + unset($_SESSION["backtourlsavedbeforeoauthjump"]); + + header('Location: ' . $backtourl); + exit(); +} +else +{ + $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; + $url = $apiService->getAuthorizationUri(); // we go on google authorization page header('Location: ' . $url); exit(); } -llxFooter(); + +/* + * View + */ + +// No view at all, just actions $db->close(); + diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 7010ec7de78..aab1ae13bb6 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -87,6 +87,8 @@ class printing_printgcp extends PrintingDriver $this->errors[] = $e->getMessage(); $token_ok = false; } + //var_dump($this->errors);exit; + $expire = false; // Is token expired or will token expire in the next 30 seconds if ($token_ok) { @@ -116,12 +118,12 @@ class printing_printgcp extends PrintingDriver $refreshtoken = $token->getRefreshToken(); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info'); - $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRE_AT', 'info'=>(date("Y-m-d H:i:s", $token->getEndOfLife())), 'type'=>'info'); + $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRE_AT', 'info'=>(dol_print_date($token->getEndOfLife(), "dayhour")), 'type'=>'info'); } if (!$storage->hasAccessToken('Google')) { - $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php', 'type'=>'authlink'); + $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); } else { - $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete', 'type'=>'delete'); + $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete'); } } else { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info'); diff --git a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php index 2e4b9c195a2..0ce3abf39c1 100644 --- a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php +++ b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php @@ -86,6 +86,10 @@ class DoliStorage implements TokenStorageInterface */ public function storeAccessToken($service, TokenInterface $token) { + //var_dump("storeAccessToken"); + //var_dump($token); + dol_syslog("storeAccessToken"); + $serializedToken = serialize($token); $this->tokens[$service] = $token; @@ -95,6 +99,10 @@ class DoliStorage implements TokenStorageInterface $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_token"; $sql.= " WHERE service='".$service."' AND entity=1"; $resql = $this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + } $obj = $this->db->fetch_array($resql); if ($obj) { // update @@ -108,7 +116,8 @@ class DoliStorage implements TokenStorageInterface $sql.= " VALUES ('".$service."', '".$this->db->escape($serializedToken)."', 1)"; $resql = $this->db->query($sql); } - + //print $sql; + // allow chaining return $this; } @@ -122,8 +131,13 @@ class DoliStorage implements TokenStorageInterface $sql = "SELECT token FROM ".MAIN_DB_PREFIX."oauth_token"; $sql.= " WHERE service='".$service."'"; $resql = $this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + } $result = $this->db->fetch_array($resql); - $token = unserialize($result[token]); + $token = unserialize($result['token']); + $this->tokens[$service] = $token; return is_array($this->tokens) @@ -194,6 +208,10 @@ class DoliStorage implements TokenStorageInterface $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_state"; $sql.= " WHERE service='".$service."' AND entity=1"; $resql = $this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + } $obj = $this->db->fetch_array($resql); if ($obj) { // update diff --git a/htdocs/langs/en_US/oauth.lang b/htdocs/langs/en_US/oauth.lang index ef58d605c49..4567af2a0b6 100644 --- a/htdocs/langs/en_US/oauth.lang +++ b/htdocs/langs/en_US/oauth.lang @@ -1,7 +1,11 @@ # Dolibarr language file - Source file is en_US - oauth ConfigOAuth=Oauth Configuration NoAccessToken=No token access saved. +HasAccessToken=A token was generated and saved into database +NewTokenStored=Token received ans saved +TokenDeleted=Token deleted UseTheFollowingUrlAsRedirectURI=Use the following URL as the Redirect URI when creating your credential on your OAuth provider: +ListOfSupportedOauthProviders=Enter here credential provided by your OAuth2 provider. Only supported OAuth2 providers are visible here. This setup may be used by other modules than need OAuth2 authentication. OAUTH_AMAZON_NAME=Api Amazon OAUTH_AMAZON_ID=Api Amazon Id OAUTH_AMAZON_SECRET=Api Amazon Secret diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang index a4f9fe09e04..fa154976603 100644 --- a/htdocs/langs/en_US/printing.lang +++ b/htdocs/langs/en_US/printing.lang @@ -20,11 +20,13 @@ UserConf=Setup per user PRINTGCP=Google Cloud Print PRINTGCP_INFO=Google Api State PRINTGCP_AUTHLINK=Authentication -PRINTGCP_TOKEN_ACCESS=Google Cloud Print Token +PRINTGCP_TOKEN_ACCESS=Google Cloud Print OAuth Token PRINTGCP_TOKEN_REFRESH=Token Refresh Present PRINTGCP_TOKEN_EXPIRED=Token Expired PRINTGCP_TOKEN_EXPIRE_AT=Token expire at -RequestAccess=Request Access +PRINTGCP_DELETE_TOKEN=Delete saved token +RequestAccess=Click here to request access and receive a token to save +DeleteAccess=Click here to delete token PrintGCPDesc=This driver allow to send documents directly to a printer with Google Cloud Print. PrintingDriverDescprintgcp=Configuration variables for printing driver Google Cloud Print. PrintTestDescprintgcp=List of Printers for Google Cloud Print. @@ -83,4 +85,4 @@ MEDIA_IPP_thermal=Thermal IPP_COLOR_print-black=BW Printer DirectPrintingJobsDesc=This page lists printing jobs found for available printers. GoogleAuthNotConfigured=Google OAuth setup not done. Enable module OAuth and set a Google ID/Secret. -GoogleAuthConfigured=Google OAuth credentials found. \ No newline at end of file +GoogleAuthConfigured=Google OAuth credentials found into setup of module OAuth. \ No newline at end of file diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index ac6f030ae16..ce87a5c7178 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -137,7 +137,8 @@ if ($mode == 'setup' && $user->admin) $classname = 'printing_'.$driver; $langs->load($driver); $printer = new $classname($db); - //print '
'.print_r($printer, true).'
'; + //var_dump($printer); + $i=0; $submit_enabled=0; foreach ($printer->conf as $key) @@ -157,14 +158,14 @@ if ($mode == 'setup' && $user->admin) case "authlink": print ''; print ''.$langs->trans($key['varname']).''; - print ''.$langs->trans('RequestAccess').''; + print ''.$langs->trans('RequestAccess').''; print ' '; print ''."\n"; break; case "delete": print ''; print ''.$langs->trans($key['varname']).''; - print ''.$langs->trans('DeleteAccess').''; + print ''.$langs->trans('DeleteAccess').''; print ' '; print ''."\n"; break; From de8e7107ee42659c0f46fba61048058c5e36e89e Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Fri, 6 Nov 2015 01:53:20 +0100 Subject: [PATCH 04/60] Maintain origin_id and origin for copy document Fix any errors. --- htdocs/comm/propal/class/propal.class.php | 21 ++++++++++++++----- htdocs/commande/class/commande.class.php | 8 +++++-- htdocs/compta/facture/class/facture.class.php | 8 ++++--- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 390e05363bb..f7a55bf6e02 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -375,13 +375,15 @@ class Propal extends CommonObject * @param int $date_end End date of the line * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param string $origin 'order', ... + * @param int $origin_id Id of origin object * @return int >0 if OK, <0 if KO * * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin, $origin_id) { - global $mysoc; + global $mysoc, $conf, $langs; dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -499,6 +501,9 @@ class Propal extends CommonObject $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; + $this->line->origin_id = $origin_id; + $this->line->origin = $origin; + // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; @@ -570,7 +575,8 @@ class Propal extends CommonObject { global $mysoc; - dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$a_ht, type=$type, date_start=$date_start, date_end=$date_end"); + dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, + txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, type=$type, date_start=$date_start, date_end=$date_end"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters @@ -894,7 +900,9 @@ class Propal extends CommonObject $this->lines[$i]->date_start, $this->lines[$i]->date_end, $this->lines[$i]->array_options, - $this->lines[$i]->fk_unit + $this->lines[$i]->fk_unit, + $this->element, + $this->lines[$i]->id ); if ($result < 0) @@ -1384,7 +1392,10 @@ class Propal extends CommonObject */ function update_extrafields($user) { + global $conf, $hookmanager; + $action='update'; + $error = 0; // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! @@ -2717,7 +2728,7 @@ class Propal extends CommonObject */ function getNomUrl($withpicto=0,$option='', $get_params='') { - global $langs; + global $langs, $conf; $result=''; $label = '' . $langs->trans("ShowPropal") . ''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 29be83ea3e2..1de3b25e5d2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -777,7 +777,9 @@ class Commande extends CommonOrder $this->lines[$i]->pa_ht, $this->lines[$i]->label, $this->lines[$i]->array_options, - $this->lines[$i]->fk_unit + $this->lines[$i]->fk_unit, + $this->element, + $this->lines[$i]->id ); if ($result < 0) { @@ -2321,6 +2323,7 @@ class Commande extends CommonOrder function classifyBilled() { global $conf, $user, $langs; + $error = 0; $this->db->begin(); @@ -2635,6 +2638,7 @@ class Commande extends CommonOrder global $hookmanager, $conf; $action='create'; + $error = 0; // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! @@ -2871,7 +2875,7 @@ class Commande extends CommonOrder */ function LibStatut($statut,$billed,$mode) { - global $langs; + global $langs, $conf; //print 'x'.$statut.'-'.$billed; if ($mode == 0) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1462bf43a9b..8f8c9ae5d47 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -385,6 +385,8 @@ class Facture extends CommonInvoice { $newinvoiceline=$this->lines[$i]; $newinvoiceline->fk_facture=$this->id; + $newinvoiceline->origin = $this->element; + $newinvoiceline->origin_id = $this->lines[$i]->id; if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 { // Reset fk_parent_line for no child products and special product @@ -441,8 +443,8 @@ class Facture extends CommonInvoice $this->lines[$i]->product_type, $this->lines[$i]->rang, $this->lines[$i]->special_code, - '', - 0, + $this->element, + $this->lines[$i]->id, $fk_parent_line, $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, @@ -873,7 +875,7 @@ class Facture extends CommonInvoice */ function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='') { - global $langs; + global $langs, $conf; $result=''; From 0f358eea49456451b9fb63206a5bef26d6560715 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Nov 2015 01:56:56 +0100 Subject: [PATCH 05/60] Fix path definition of thumbs with the new function --- htdocs/core/lib/functions.lib.php | 10 +++++----- htdocs/core/lib/images.lib.php | 4 +++- htdocs/product/document.php | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 727dd9d8a9e..be0523958bd 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5225,17 +5225,17 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) /** * Return the filename of file to get the thumbs * - * @param string $file Original filename + * @param string $file Original filename (full or relative path) * @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini') - * @param string $extImgTarget Force image format for thumbs. Use '' to keep same extension than original image. - * @return string New file name + * @param string $extImgTarget Force image extension for thumbs. Use '' to keep same extension than original image. + * @return string New file name (full or relative path, including the thumbs/) */ function getImageFileNameForSize($file, $extName, $extImgTarget='') { $dirName = dirname($file); if ($dirName == '.') $dirName=''; - $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // We remove extension, whatever is its case $fileName = basename($fileName); if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':''); @@ -5249,5 +5249,5 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='') $subdir=''; if ($extName) $subdir = 'thumbs/'; - return $dirName.$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb + return ($dirName?$dirName.'/':'').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb } diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index e61dc22eeb0..20a58d7021c 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -512,7 +512,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse $fileName = basename($fileName); - $imgThumbName = $dirthumb.'/'.getImageFileNameForSize($file, $extName, $extImgTarget); // Chemin complet du fichier de la vignette + //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file + $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file + // Check if permission are ok //$fp = fopen($imgThumbName, "w"); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 3d5f40b768c..baf736b47e5 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -70,8 +70,8 @@ if ($id > 0 || ! empty($ref)) { $result = $object->fetch($id, $ref); - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product').dol_sanitizeFileName($object->ref); - elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product').dol_sanitizeFileName($object->ref); + if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { From f9d0c887ae4735b825533e286e60bb6d7a551948 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Nov 2015 02:20:42 +0100 Subject: [PATCH 06/60] NEW Add a refresh button on page list of direct print jobs. --- htdocs/langs/en_US/printing.lang | 2 +- htdocs/printing/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang index fa154976603..ab70ca671d7 100644 --- a/htdocs/langs/en_US/printing.lang +++ b/htdocs/langs/en_US/printing.lang @@ -3,7 +3,7 @@ Module64000Name=Direct Printing Module64000Desc=Enable Direct Printing System PrintingSetup=Setup of Direct Printing System PrintingDesc=This module adds a Print button to send documents directly to a printer (without opening document into an application) with various module. -MenuDirectPrinting=Direct Printing +MenuDirectPrinting=Direct Printing jobs DirectPrint=Direct print ModuleDriverSetup=Setup Module Driver PrintingDriverDesc=Configuration variables for printing driver. diff --git a/htdocs/printing/index.php b/htdocs/printing/index.php index d263c60db8d..13e3883702d 100644 --- a/htdocs/printing/index.php +++ b/htdocs/printing/index.php @@ -27,7 +27,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; llxHeader("",$langs->trans("Printing")); -print load_fiche_titre($langs->trans("Printing")); +print_barre_liste($langs->trans("Printing"), 0, $_SERVER["PHP_SELF"], '', '', '', ''.$langs->trans("Refresh").'', 0); print $langs->trans("DirectPrintingJobsDesc").'

'; From 6bf8b7f328f7c9fb8cecb32b38708d40f3764a96 Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Fri, 6 Nov 2015 02:25:51 +0100 Subject: [PATCH 07/60] Default value origin_id and origin --- htdocs/comm/propal/class/propal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f7a55bf6e02..fcac4ba9de1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -381,7 +381,7 @@ class Propal extends CommonObject * * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin, $origin_id) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0) { global $mysoc, $conf, $langs; From 67c9db6a5147181f73142ba08a0ec152c46d1ede Mon Sep 17 00:00:00 2001 From: philippe grand Date: Fri, 6 Nov 2015 09:36:16 +0100 Subject: [PATCH 08/60] [Qual] Uniformize code --- htdocs/categories/edit.php | 4 +-- htdocs/categories/traduction.php | 4 +-- htdocs/categories/viewcat.php | 6 ++-- htdocs/comm/action/rapport/index.php | 2 +- htdocs/comm/mailing/card.php | 48 ++++++++++++++-------------- htdocs/comm/mailing/cibles.php | 8 ++--- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 0a13c3e7fab..9ffd7ac6401 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -101,12 +101,12 @@ if ($action == 'update' && $user->rights->categorie->creer) } else { - setEventMessage($categorie->error, 'errors'); + setEventMessages($categorie->error, $categorie->errors, 'errors'); } } else { - setEventMessage($categorie->error, 'errors'); + setEventMessages($categorie->error, $categorie->errors, 'errors'); } } diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 94570d48f3e..98f02c7a742 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -95,7 +95,7 @@ $cancel != $langs->trans("Cancel") && else { $action = 'add'; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -128,7 +128,7 @@ $cancel != $langs->trans("Cancel") && else { $action = 'edit'; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index bf86c1d496c..39f8d62fb7b 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -122,7 +122,7 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -137,13 +137,13 @@ if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' $result=$object->add_type($newobject,$elementtype); if ($result >= 0) { - setEventMessage($langs->trans("WasAddedSuccessfully",$newobject->ref)); + setEventMessages($langs->trans("WasAddedSuccessfully",$newobject->ref), null, 'mesgs'); } else { if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - setEventMessage($langs->trans("ObjectAlreadyLinkedToCategory"),'warnings'); + setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings'); } else { diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 24eb117684f..066df5fb39e 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -62,7 +62,7 @@ if ($action == 'builddoc') $result=$cat->write_file(GETPOST('id','int')); if ($result < 0) { - setEventMessage($cat->error, 'errors'); + setEventMessages($cat->error, $cat->errors, 'errors'); } } diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 2ff7796bfae..2a892033865 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -117,7 +117,7 @@ if (empty($reshook)) { if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { @@ -129,7 +129,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } $action=''; @@ -141,14 +141,14 @@ if (empty($reshook)) if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) { // As security measure, we don't allow send from the GUI - setEventMessage($langs->trans("MailingNeedCommand"), 'warnings'); - setEventMessage('', 'warnings'); - setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); + setEventMessages('', null, 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); $action=''; } else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { - setEventMessage($langs->trans("NotEnoughPermissions"), 'warnings'); + setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings'); $action=''; } else @@ -351,27 +351,27 @@ if (empty($reshook)) } else { - setEventMessage($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo")); + setEventMessages($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"), null, 'mesgs'); } // Loop finished, set global statut of mail if ($nbko > 0) { $statut=2; // Status 'sent partially' (because at least one error) - if ($nbok > 0) setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); - else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); + else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); } else { if ($nbok >= $num) { $statut=3; // Send to everybody - setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); } else { $statut=2; // Status 'sent partially' (because not send to everybody) - setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); } } @@ -443,11 +443,11 @@ if (empty($reshook)) $result=$mailfile->sendfile(); if ($result) { - setEventMessage($langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2))); + setEventMessages($langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)), null, 'mesgs'); } else { - setEventMessage($langs->trans("ResultKo").'
'.$mailfile->error.' '.$result, 'errors'); + setEventMessages($langs->trans("ResultKo").'
'.$mailfile->error.' '.$result, null, 'errors'); } $action=''; @@ -488,7 +488,7 @@ if (empty($reshook)) $mesgs[] = $object->error; } - setEventMessage($mesgs, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); $action="create"; } @@ -518,7 +518,7 @@ if (empty($reshook)) $mesg = $object->error; } - setEventMessage($mesg, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); $action=""; } @@ -582,7 +582,7 @@ if (empty($reshook)) $mesgs[] =$object->error; } - setEventMessage($mesgs, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); $action="edit"; } else @@ -597,7 +597,7 @@ if (empty($reshook)) if ($object->id > 0) { $object->valid($user); - setEventMessage($langs->trans("MailingSuccessfullyValidated")); + setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -628,7 +628,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } } @@ -764,18 +764,18 @@ else // You ensure that every user is using its own SMTP server. $linktoadminemailbefore=''; $linktoadminemailend=''; - setEventMessage($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), 'warnings'); - setEventMessage($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), 'warnings'); - if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessage($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), 'warnings'); + setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, 'warnings'); + setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings'); + if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings'); $_GET["action"]=''; } else if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) { // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, // on affiche donc juste un message - setEventMessage($langs->trans("MailingNeedCommand"), 'warnings'); - setEventMessage('', 'warnings'); - setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); + setEventMessages('', null, 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); $_GET["action"]=''; } else diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index cd3ff7b00ee..92b9f5446ca 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -100,24 +100,24 @@ if ($action == 'add') } if ($result > 0) { - setEventMessage($langs->trans("XTargetsAdded",$result),'mesgs'); + setEventMessages($langs->trans("XTargetsAdded",$result), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } if ($result == 0) { - setEventMessage($langs->trans("WarningNoEMailsAdded"),'warnings'); + setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings'); } if ($result < 0) { - setEventMessage($langs->trans("Error").($obj->error?' '.$obj->error:''),'errors'); + setEventMessages($langs->trans("Error").($obj->error?' '.$obj->error:''), null, 'errors'); } } if (GETPOST('clearlist')) { - // Chargement de la classe + // Loading Class $obj = new MailingTargets($db); $obj->clear_target($id); From 5f74a0f1c0e0ef0e7a8fe364db46fca97282e46e Mon Sep 17 00:00:00 2001 From: philippe grand Date: Fri, 6 Nov 2015 09:46:18 +0100 Subject: [PATCH 09/60] Traduction --- htdocs/admin/barcode.php | 2 +- htdocs/admin/facture.php | 2 +- htdocs/admin/payment.php | 2 +- htdocs/admin/security.php | 2 +- htdocs/comm/mailing/cibles.php | 4 ++-- htdocs/comm/mailing/index.php | 2 +- htdocs/core/modules/export/modules_export.php | 2 +- htdocs/core/modules/import/modules_import.php | 2 +- htdocs/exports/class/export.class.php | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 0a57508c271..fbaf68a96d9 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -162,7 +162,7 @@ foreach($dirbarcode as $reldir) { $filebis=$reg[1]; - // Chargement de la classe de codage + // Loading encoding class require_once $newdir.$file; $classname = "mod".ucfirst($filebis); $module = new $classname($db); diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 46ca2b9fd87..b3f1d7a5d51 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -344,7 +344,7 @@ foreach ($dirmodels as $reldir) $classname = preg_replace('/\-.*$/','',$classname); if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') { - // Chargement de la classe de numerotation + // Charging the numbering class require_once $dir.$filebis; $module = new $classname($db); diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index c9bf610bd1b..07113231bcc 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -130,7 +130,7 @@ foreach ($dirmodels as $reldir) $classname = preg_replace('/\-.*$/','',$classname); if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') { - // Chargement de la classe de numerotation + // Charging the numbering class require_once $dir.$filebis; $module = new $classname($db); diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index a409d0c8b3f..ea81e63305e 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -221,7 +221,7 @@ if (is_resource($handle)) { if (preg_match('/(modGeneratePass[a-z]+)\.class\.php/i',$file,$reg)) { - // Chargement de la classe de numerotation + // Charging the numbering class $classname = $reg[1]; require_once $dir.'/'.$file; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 92b9f5446ca..ad4e3210619 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -80,7 +80,7 @@ if ($action == 'add') //print $dir."\n
"; dol_syslog("Scan directory ".$dir." for modules"); - // Chargement de la classe + // Loading Class $file = $dir."/".$module.".modules.php"; $classname = "mailing_".$module; @@ -267,7 +267,7 @@ if ($object->fetch($id) >= 0) // Loop on each submodule foreach($modulenames as $modulename) { - // Chargement de la classe + // Loading Class $file = $dir.$modulename.".modules.php"; $classname = "mailing_".$modulename; require_once $file; diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 59753ee1904..5904bec0009 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -83,7 +83,7 @@ if (is_resource($handle)) $modulename=$reg[1]; if ($modulename == 'example') continue; - // Chargement de la classe + // Loading Class $file = $dir."/".$modulename.".modules.php"; $classname = "mailing_".$modulename; require_once $file; diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 113f35299ca..ee1c3b8e96c 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -64,7 +64,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac { $moduleid=$reg[1]; - // Chargement de la classe + // Loading Class $file = $dir."/export_".$moduleid.".modules.php"; $classname = "Export".ucfirst($moduleid); diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index 4fa5052a90a..a27b0fd9426 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -84,7 +84,7 @@ class ModeleImports { $moduleid=$reg[1]; - // Chargement de la classe + // Loading Class $file = $dir."/import_".$moduleid.".modules.php"; $classname = "Import".ucfirst($moduleid); diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 88e4ecc8596..3a3436c71a9 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -107,7 +107,7 @@ class Export if ($enabled) { - // Chargement de la classe + // Loading Class $file = $dir.$modulename.".class.php"; $classname = $modulename; require_once $file; From f62d6d1950e8de706f7c27d0c67e8e119d35b224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 6 Nov 2015 11:08:41 +0100 Subject: [PATCH 10/60] FIX Product::updatePrice() now sets new prices to Product::multiprices_* arrays --- htdocs/product/class/product.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4c1fbc6c929..cd00f843f61 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1443,6 +1443,14 @@ class Product extends CommonObject $resql=$this->db->query($sql); if ($resql) { + $this->multiprices[$level] = $price; + $this->multiprices_ttc[$level] = $price_ttc; + $this->multiprices_min[$level]= $price_min; + $this->multiprices_min_ttc[$level]= $price_min_ttc; + $this->multiprices_base_type[$level]= $newpricebase; + $this->multiprices_tva_tx[$level]= $newvat; + $this->multiprices_recuperableonly[$level]= $newnpr; + $this->price = $price; $this->price_ttc = $price_ttc; $this->price_min = $price_min; From dac0a7bc501fe07380ff78be00d074c0ba2634bf Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 6 Nov 2015 11:09:54 +0100 Subject: [PATCH 11/60] Fix : finally, autofocus on product search field is a bad idea --- htdocs/core/class/html.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 10f5fc25695..575f11b90af 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1546,7 +1546,7 @@ class Form print img_picto($langs->trans("Search"), 'search'); } } - print ''; + print ''; if ($hidelabel == 3) { print img_picto($langs->trans("Search"), 'search'); } @@ -1663,7 +1663,7 @@ class Form require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; $num = $this->db->num_rows($result); - $out.=''; $out.=''; $i = 0; From d3d62f7db521a1bbf2c805db1b6c53e12473d410 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 6 Nov 2015 11:11:23 +0100 Subject: [PATCH 12/60] FIX: #3913 --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 19ee13533b0..a7d8573f6de 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -51,16 +51,16 @@ create table llx_overwrite_trans transvalue text )ENGINE=innodb; -ALTER TABLE llx_payment_salary ADD COLUMN datec datetime after tms; +ALTER TABLE llx_payment_salary ADD COLUMN datec datetime AFTER tms; ALTER TABLE llx_payment_salary CHANGE COLUMN fk_user_creat fk_user_author integer; -ALTER TABLE llx_adherent ADD COLUMN pass_crypted varchar(128) after pass; +ALTER TABLE llx_adherent ADD COLUMN pass_crypted varchar(128) AFTER pass; -ALTER TABLE llx_paiement ADD COLUMN ref varchar(30) NOT NULL AFTER rowid; +ALTER TABLE llx_paiement ADD COLUMN ref varchar(30) NOT NULL DEFAULT '' AFTER rowid; ALTER TABLE llx_socpeople ADD COLUMN photo varchar(255) AFTER skype; -ALTER TABLE llx_user_param MODIFY COLUMN value text NOT NULL; +ALTER TABLE llx_user_param MODIFY COLUMN value text NOT NULL DEFAULT ''; ALTER TABLE llx_expedition ADD COLUMN import_key varchar(14); ALTER TABLE llx_expedition ADD COLUMN extraparams varchar(255); @@ -71,7 +71,7 @@ ALTER TABLE llx_prelevement_lignes MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30); -ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL after fk_shipping_method; +ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL AFTER fk_shipping_method; ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750); ALTER TABLE llx_ecm_directories DROP INDEX idx_ecm_directories; @@ -102,7 +102,7 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (label, entity); --ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); -ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 after tobuy; +ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 AFTER tobuy; ALTER TABLE llx_user ADD COLUMN employee tinyint DEFAULT 1; From 11f0cad2ab09e23588a5a4f0318e24cca8a1a723 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Nov 2015 11:22:50 +0100 Subject: [PATCH 13/60] FIX #3912 --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 19ee13533b0..ab833203759 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -18,6 +18,11 @@ -- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); + +-- Was done into a 3.8 fix, so we must do it also in 3.9 +ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL DEFAULT 0 after country; + + -- Fix bad data update llx_opensurvey_sondage set format = 'D' where format = 'D+'; update llx_opensurvey_sondage set format = 'A' where format = 'A+'; From 28b229c83a84c77fd296fdcd7642a31d5b3392a7 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 6 Nov 2015 11:24:52 +0100 Subject: [PATCH 14/60] FIX: #3916 --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index a7d8573f6de..06aa013cea0 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -102,20 +102,20 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (label, entity); --ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); -ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 AFTER tobuy; +ALTER TABLE llx_product ADD COLUMN onportal smallint DEFAULT 0 AFTER tobuy; -ALTER TABLE llx_user ADD COLUMN employee tinyint DEFAULT 1; +ALTER TABLE llx_user ADD COLUMN employee smallint DEFAULT 1; CREATE TABLE IF NOT EXISTS llx_c_hrm_function ( rowid integer PRIMARY KEY, - pos tinyint DEFAULT 0 NOT NULL, + pos smallint DEFAULT 0 NOT NULL, code varchar(16) NOT NULL, label varchar(50), - c_level tinyint DEFAULT 0 NOT NULL, - active tinyint DEFAULT 1 NOT NULL + c_level smallint DEFAULT 0 NOT NULL, + active smallint DEFAULT 1 NOT NULL )ENGINE=innodb; INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5, 'EXECBOARD', 'Executive board', 0, 1); @@ -131,10 +131,10 @@ INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES CREATE TABLE IF NOT EXISTS llx_c_hrm_department ( rowid integer PRIMARY KEY, - pos tinyint DEFAULT 0 NOT NULL, + pos smallint DEFAULT 0 NOT NULL, code varchar(16) NOT NULL, label varchar(50), - active tinyint DEFAULT 1 NOT NULL + active smallint DEFAULT 1 NOT NULL )ENGINE=innodb; INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(1, 5,'MANAGEMENT', 'Management', 1); @@ -173,7 +173,7 @@ CREATE TABLE IF NOT EXISTS llx_establishment ( fk_user_mod integer NOT NULL, datec datetime NOT NULL, tms timestamp NOT NULL, - status tinyint DEFAULT 1 + status smallint DEFAULT 1 ) ENGINE=InnoDB; @@ -255,7 +255,7 @@ CREATE TABLE llx_product_pricerules var_percent FLOAT NOT NULL, -- Price variation over based price var_min_percent FLOAT NOT NULL -- Min price discount over general price ); -ALTER TABLE llx_product ADD COLUMN price_autogen TINYINT(1) DEFAULT 0; +ALTER TABLE llx_product ADD COLUMN price_autogen smallint DEFAULT 0; ALTER TABLE llx_product_pricerules ADD CONSTRAINT unique_level UNIQUE (level); From 610ef2359dc3f422491fa9e421c01b2b14b7b428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 6 Nov 2015 11:24:48 +0100 Subject: [PATCH 15/60] FIX #3914 Properties Product::multiprices_min and Product::multiprices_min_ttc, Product::url dynamically declared Close #3914 --- htdocs/product/class/product.class.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4c1fbc6c929..e7d43a180e0 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -84,11 +84,13 @@ class Product extends CommonObject //! Base price ('TTC' for price including tax or 'HT' for net price) var $price_base_type; //! Arrays for multiprices - var $multiprices=array(); - var $multiprices_ttc=array(); - var $multiprices_base_type=array(); - var $multiprices_tva_tx=array(); - var $multiprices_recuperableonly=array(); + public $multiprices=array(); + public $multiprices_ttc=array(); + public $multiprices_base_type=array(); + public $multiprices_min=array(); + public $multiprices_min_ttc=array(); + public $multiprices_tva_tx=array(); + public $multiprices_recuperableonly=array(); //! Price by quantity arrays var $price_by_qty; var $prices_by_qty=array(); @@ -125,6 +127,12 @@ class Product extends CommonObject var $customcode; // Customs code + /** + * Product URL + * @var string + */ + public $url; + //! Unites de mesure var $weight; var $weight_units; From 996917926785f867ef013a56a685de1a333ca0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 6 Nov 2015 11:35:39 +0100 Subject: [PATCH 16/60] NEW Deprecated Product::setPriceExpression. Use Product::update instead --- htdocs/product/class/product.class.php | 27 +++++--------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index cd00f843f61..d7e50da4e06 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -717,6 +717,7 @@ class Product extends CommonObject $sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); + $sql.= ", fk_price_expression = ".($this->fk_price_expression != 0 ? $this->fk_price_expression : 'NULL'); $sql.= " WHERE rowid = " . $id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -1495,33 +1496,15 @@ class Product extends CommonObject * * @param int $expression_id Expression * @return int <0 if KO, >0 if OK + * @deprecated Use Product::update instead */ function setPriceExpression($expression_id) { - global $conf; + global $user; - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; + $this->fk_price_expression = $expression_id; - $sql = "UPDATE ".MAIN_DB_PREFIX."product"; - $sql.= " SET fk_price_expression = ".$expression_id; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::setPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } + return $this->update($this->id, $user); } /** From ac8bee28ef2b96165946d315e0a472b7d08b4bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 6 Nov 2015 11:40:22 +0100 Subject: [PATCH 17/60] NEW #3898 Remove deprecated Product::hidden property Close #3898 --- htdocs/product/canvas/product/tpl/card_create.tpl.php | 3 --- htdocs/product/canvas/service/tpl/card_create.tpl.php | 3 --- htdocs/product/card.php | 2 -- 3 files changed, 8 deletions(-) diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index 81ddb147fe3..c5f968dee4f 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -90,9 +90,6 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe volume_units; ?> -trans("Hidden"); ?> -hidden; ?> - trans("NoteNotVisibleOnBill"); ?> textarea_note; ?> diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index 9d526383a67..39c91695f8f 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -63,9 +63,6 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe duration_unit; ?> -trans("Hidden"); ?> -hidden; ?> - trans("NoteNotVisibleOnBill"); ?> textarea_note; ?> diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 9fadd0f3e5a..3388c7e4c15 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -249,7 +249,6 @@ if (empty($reshook)) $object->volume = GETPOST('volume'); $object->volume_units = GETPOST('volume_units'); $object->finished = GETPOST('finished'); - $object->hidden = GETPOST('hidden')=='yes'?1:0; $object->fk_unit = GETPOST('units'); $object->accountancy_code_sell = GETPOST('accountancy_code_sell'); $object->accountancy_code_buy = GETPOST('accountancy_code_buy'); @@ -335,7 +334,6 @@ if (empty($reshook)) $object->volume = GETPOST('volume'); $object->volume_units = GETPOST('volume_units'); $object->finished = GETPOST('finished'); - $object->hidden = GETPOST('hidden')=='yes'?1:0; $units = GETPOST('units', 'int'); From ef3c7f927ea3226b028733736b8a78ab9d6af684 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Fri, 6 Nov 2015 16:38:26 +0100 Subject: [PATCH 18/60] FIX : wrong coma in llx_opensurvey_sondage.sql creation script --- htdocs/install/mysql/tables/llx_opensurvey_sondage.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql index 16e8a624e72..b728702db79 100644 --- a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql +++ b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql @@ -29,5 +29,5 @@ CREATE TABLE llx_opensurvey_sondage ( allow_comments tinyint NOT NULL DEFAULT 1, allow_spy tinyint NOT NULL DEFAULT 1, tms TIMESTAMP, - sujet TEXT, -- Not filled if format = 'F'. Question are into table llx_opensurvey_formquestions + sujet TEXT -- Not filled if format = 'F'. Question are into table llx_opensurvey_formquestions ) ENGINE=InnoDB; From d0e6db7f89c36e051f9c05c4f2c632b8d36b20f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Nov 2015 18:57:35 +0100 Subject: [PATCH 19/60] Use the new banner for first tab of products. --- htdocs/core/class/html.form.class.php | 6 +- htdocs/core/lib/functions.lib.php | 61 +++++++++++--- htdocs/product/card.php | 111 +++++++++++-------------- htdocs/product/class/product.class.php | 8 +- 4 files changed, 106 insertions(+), 80 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 10f5fc25695..bb7e399f28a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5157,7 +5157,7 @@ class Form * To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria. * * @param object $object Object to show - * @param string $paramid Name of parameter to use to name the id into the URL link + * @param string $paramid Name of parameter to use to name the id into the URL next/previous link * @param string $morehtml More html content to output just before the nav bar * @param int $shownav Show Condition (navigation is shown if value is 1) * @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field) @@ -5192,7 +5192,7 @@ class Form $ret.='
'; - // For thirdparty and contact, the ref is he id, so we show something else + // For thirdparty and contact, the ref is the id, so we show something else if ($object->element == 'societe') { $ret.=dol_htmlentities($object->name); @@ -5360,7 +5360,7 @@ class Form else { $nophoto='/public/theme/common/nophoto.png'; - if (in_array($modulepart,array('userphoto','contact'))) // For module thar are "physical" users + if (in_array($modulepart,array('userphoto','contact'))) // For module that are "physical" users { $nophoto='/public/theme/common/user_anonymous.png'; if ($object->gender == 'man') $nophoto='/public/theme/common/user_man.png'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index be0523958bd..db59c8d966d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -854,7 +854,7 @@ function dol_get_fiche_end($notab=0) * Show tab footer of a card * * @param object $object Object to show - * @param string $paramid Name of parameter to use to name the id into the URL link + * @param string $paramid Name of parameter to use to name the id into the URL next/previous link * @param string $morehtml More html content to output just before the nav bar * @param int $shownav Show Condition (navigation is shown if value is 1) * @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field) @@ -870,28 +870,67 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r { global $conf, $form, $user, $langs; - //$showlogo=$object->logo; - $showlogo=1; + $maxvisiblephotos=1; + $showimage=1; $showbarcode=empty($conf->barcode->enabled)?0:($object->barcode?1:0); if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; - $modulepart='societe'; + $modulepart='unknown'; + if ($object->element == 'societe') $modulepart='societe'; if ($object->element == 'contact') $modulepart='contact'; if ($object->element == 'member') $modulepart='memberphoto'; if ($object->element == 'user') $modulepart='userphoto'; + if ($object->element == 'product') $modulepart='product'; print '
'; - if ($showlogo) $morehtmlleft.='
'.$form->showphoto($modulepart,$object,0,0,0,'photoref').'
'; + if ($object->element == 'product') + { + $width=80; $cssclass='photoref'; + $showimage=$object->is_photo_available($conf->product->multidir_output[$object->entity]); + $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); + if ($conf->browser->phone) $maxvisiblephotos=1; + if ($showimage) $morehtmlleft.='
'.$object->show_photos($conf->product->multidir_output[$object->entity],1,-$maxvisiblephotos,0,0,0,$width,0).'
'; + else + { + $nophoto='/public/theme/common/nophoto.png'; + $morehtmlleft.='
No photo
'; + } + } + else + { + if ($showimage) $morehtmlleft.='
'.$form->showphoto($modulepart,$object,0,0,0,'photoref','',1,0,$maxvisiblephotos).'
'; + } if ($showbarcode) $morehtmlleft.='
'.$form->showbarcode($object).'
'; if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { $morehtmlright.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased'); - } else { + } + elseif ($object->element == 'product') + { + //$morehtmlright.=$langs->trans("Status").' ('.$langs->trans("Sell").') '; + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + $morehtmlright.=ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); + } else { + $morehtmlright.=$object->getLibStatut(2,0); + } + $morehtmlright.='   '; + //$morehtmlright.=$langs->trans("Status").' ('.$langs->trans("Buy").') '; + if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + $morehtmlright.=ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); + } else { + $morehtmlright.=$object->getLibStatut(2,1); + } + } + else { $morehtmlright.=$object->getLibStatut(2); } - if (! empty($object->name_alias)) $morehtmlref.='
'.$object->name_alias.'
'; - $morehtmlref.='
'; - $morehtmlref.=$object->getBannerAddress('refaddress',$object); - $morehtmlref.='
'; - if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member'))) + if (! empty($object->name_alias)) $morehtmlref.='
'.$object->name_alias.'
'; // For thirdparty + if (! empty($object->label)) $morehtmlref.='
'.$object->label.'
'; // For product + if ($object->element != 'product') + { + $morehtmlref.='
'; + $morehtmlref.=$object->getBannerAddress('refaddress',$object); + $morehtmlref.='
'; + } + if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) { $morehtmlref.='
'; $morehtmlref.=$langs->trans("TechnicalID").': '.$object->id; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 9fadd0f3e5a..dcc303a2e0b 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1239,16 +1239,9 @@ else print $object->showOptionals($extrafields,'edit'); } - // Note - print ''.$langs->trans("NoteNotVisibleOnBill").''; - - $doleditor = new DolEditor('note', $object->note, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); - $doleditor->Create(); - - print ""; - - if($conf->categorie->enabled) { - // Categories + // Tags-Categories + if ($conf->categorie->enabled) + { print ''.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -1260,6 +1253,14 @@ else print ""; } + // Note + print ''.$langs->trans("NoteNotVisibleOnBill").''; + + $doleditor = new DolEditor('note', $object->note, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); + $doleditor->Create(); + + print ""; + print ''; print '
'; @@ -1298,58 +1299,29 @@ else // Fiche en mode visu else { - $head=product_prepare_head($object); + $showbarcode=empty($conf->barcode->enabled)?0:1; + if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; + + $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'card', $titre, 0, $picto); - $showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]); - $showbarcode=empty($conf->barcode->enabled)?0:1; - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; - - // En mode visu - print ''; - - // Ref - print ''; - - print ''; - - // Label - print ''; - - $nblignes=7; - if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) $nblignes++; - if ($showbarcode) $nblignes+=2; - if ($object->type!= Product::TYPE_SERVICE) $nblignes++; - if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) $nblignes+=2; - if ($object->isservice()) $nblignes++; - else $nblignes+=4; - - // Photo - if ($showphoto || $showbarcode) - { - print ''; - } - - print ''; - + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + + print '
'; + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->label.''; - print '
'; - $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); - if ($conf->browser->phone) $maxvisiblephotos=1; - if ($showphoto) print $object->show_photos($conf->product->multidir_output[$object->entity],1,$maxvisiblephotos,0,0,0,80); - if ($showphoto && $showbarcode) print '

'; - if ($showbarcode) print $form->showbarcode($object); - print '
'; - print '
'; + // Type if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) { // TODO change for compatibility with edit in place $typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); - print ''; } @@ -1412,6 +1384,7 @@ else print ''; // Status (to sell) + /* print ''; - + */ + // Batch number management (to batch) if (! empty($conf->productbatch->enabled)) { print ''; + print '
'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).''; + print '
'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).''; print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat); print '
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); @@ -1428,7 +1401,8 @@ else print $object->getLibStatut(2,1); } print '
'.$langs->trans("ManageLotSerial").''; @@ -1448,10 +1422,17 @@ else print dol_print_url($object->url); print '
'; + print '
'; + print '
'; + + print '
'; + print ''; + // Nature if($object->type!= Product::TYPE_SERVICE) { - print ''; } @@ -1459,7 +1440,7 @@ else if ($object->isservice()) { // Duration - print ''."\n"; - print ' '."\n"; - // Categories if($conf->categorie->enabled) { print '"; } - print "
'.$langs->trans("Nature").''; + print '
'.$langs->trans("Nature").''; print $object->getLibFinished(); print '
'.$langs->trans("Duration").''.$object->duration_value.' '; + print '
'.$langs->trans("Duration").''.$object->duration_value.' '; if ($object->duration_value > 1) { $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); @@ -1475,7 +1456,7 @@ else else { // Weight - print '
'.$langs->trans("Weight").''; + print '
'.$langs->trans("Weight").''; if ($object->weight != '') { print $object->weight." ".measuring_units_string($object->weight_units,"weight"); @@ -1549,11 +1530,6 @@ else print $object->showOptionals($extrafields); } - // Note - print ' '."\n"; - print '
'.$langs->trans("Note").''.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'
'.$langs->trans("Categories").''; @@ -1561,8 +1537,17 @@ else print "
\n"; + // Note + print ' '."\n"; + print ''.$langs->trans("Note").''.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).''."\n"; + print ' '."\n"; + print "\n"; + print '
'; + + print '
'; + print '
'; + dol_fiche_end(); } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4c1fbc6c929..aea4a3c1433 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3485,9 +3485,10 @@ class Product extends CommonObject * @param int $showaction 1=Show icon with action links (resize, delete) * @param int $maxHeight Max height of image when size=1 * @param int $maxWidth Max width of image when size=1 + * @param int $nolink Do not add a href link to view enlarged imaged into a new tab * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ - function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160) + function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160,$nolink=0) { global $conf,$user,$langs; @@ -3552,7 +3553,7 @@ class Product extends CommonObject else if ($nbbyrow < 0) $return .= '
'; $return.= "\n"; - $return.= ''; + if (empty($nolink)) $return.= ''; // Show image (width height=$maxHeight) // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine @@ -3568,7 +3569,8 @@ class Product extends CommonObject $return.= 'dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; } - $return.= ''."\n"; + if (empty($nolink)) $return.= ''; + $return.="\n"; if ($showfilename) $return.= '
'.$viewfilename; if ($showaction) From e7554d377fdb6c2d4dc16f784ff3e9717b68bef0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Nov 2015 19:07:05 +0100 Subject: [PATCH 20/60] Fix better error message --- htdocs/admin/dict.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 6fe2e8efb38..7022c5877eb 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -510,7 +510,7 @@ if ($id == 10) } -// Actions ajout ou modification d'une entree dans un dictionnaire de donnee +// Actions add or modify an entry into a dictionary if (GETPOST('actionadd') || GETPOST('actionmodify')) { $listfield=explode(',',$tabfield[$id]); @@ -581,7 +581,12 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")), null, 'errors'); } } - + if ($id == 3 && ! is_numeric($_POST["code"])) + { + $ok=0; + setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors'); + } + // Clean some parameters if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 From 09fb87e47da412f13871c7b1f1da1ea2b999ae91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Nov 2015 11:40:31 +0100 Subject: [PATCH 21/60] Prepare tables for categories/tags on projects. Looking for a dev to implement categories/tags on projects ! --- .../install/mysql/migration/3.8.0-3.9.0.sql | 22 +++++++++++++++- .../install/mysql/tables/llx_budget_lines.sql | 18 ++++++------- .../tables/llx_categorie_project.key.sql | 24 ++++++++++++++++++ .../mysql/tables/llx_categorie_project.sql | 25 +++++++++++++++++++ 4 files changed, 79 insertions(+), 10 deletions(-) create mode 100644 htdocs/install/mysql/tables/llx_categorie_project.key.sql create mode 100644 htdocs/install/mysql/tables/llx_categorie_project.sql diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 1f34377e6ec..0705512893e 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -226,7 +226,7 @@ create table llx_budget_lines ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_budget integer NOT NULL, - fk_project integer NOT NULL, + fk_project_ids varchar(255) NOT NULL, -- List of project ids related to this budget. If budget is dedicated to projects not yet started, we recommand to create a project "Projects to come". amount double(24,8) NOT NULL, datec datetime, tms timestamp, @@ -287,3 +287,23 @@ CREATE TABLE llx_opensurvey_user_formanswers ( ) ENGINE=InnoDB; + + +create table llx_categorie_project +( + fk_categorie integer NOT NULL, + fk_project integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +ALTER TABLE llx_categorie_project ADD PRIMARY KEY pk_categorie_project (fk_categorie, fk_project); +ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_project (fk_project); + +ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_fk_project FOREIGN KEY (fk_project) REFERENCES llx_project (rowid); + + + + + diff --git a/htdocs/install/mysql/tables/llx_budget_lines.sql b/htdocs/install/mysql/tables/llx_budget_lines.sql index c5d3d3a4bf2..11b68f68fc4 100644 --- a/htdocs/install/mysql/tables/llx_budget_lines.sql +++ b/htdocs/install/mysql/tables/llx_budget_lines.sql @@ -18,13 +18,13 @@ create table llx_budget_lines ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_budget integer NOT NULL, - fk_project integer NOT NULL, - amount double(24,8) NOT NULL, - datec datetime, - tms timestamp, - fk_user_creat integer, - fk_user_modif integer, - import_key integer + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_budget integer NOT NULL, + fk_project_ids varchar(255) NOT NULL, -- 'IDS:x,y' = List of project ids related to this budget. If budget is dedicated to projects not yet started, we recommand to create a project "Projects to come". 'FILTER:x=y' = Can also be a dynamic rule to select projects. + amount double(24,8) NOT NULL, + datec datetime, + tms timestamp, + fk_user_creat integer, + fk_user_modif integer, + import_key integer )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_categorie_project.key.sql b/htdocs/install/mysql/tables/llx_categorie_project.key.sql new file mode 100644 index 00000000000..12532b6eb09 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_categorie_project.key.sql @@ -0,0 +1,24 @@ +-- ============================================================================ +-- Copyright (C) 2007 Patrick Raguin +-- +-- 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 . +-- +-- ============================================================================ + +ALTER TABLE llx_categorie_project ADD PRIMARY KEY pk_categorie_project (fk_categorie, fk_project); +ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_project (fk_project); + +ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_fk_project FOREIGN KEY (fk_project) REFERENCES llx_project (rowid); diff --git a/htdocs/install/mysql/tables/llx_categorie_project.sql b/htdocs/install/mysql/tables/llx_categorie_project.sql new file mode 100644 index 00000000000..ca536822ac2 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_categorie_project.sql @@ -0,0 +1,25 @@ +-- ============================================================================ +-- Copyright (C) 2007 Patrick Raguin +-- Copyright (C) 2012 Juanjo Menent +-- +-- 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 . +-- +-- ============================================================================ + +create table llx_categorie_project +( + fk_categorie integer NOT NULL, + fk_project integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; From 99f52110703a22810f854c60645050c414dbffbe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Nov 2015 11:48:35 +0100 Subject: [PATCH 22/60] NEW Can use the * as a joker characters into search boxes of lists --- htdocs/core/lib/functions.lib.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index db59c8d966d..013217a9f57 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5193,6 +5193,10 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0) { global $db,$langs; + if ($mode == 0) + { + $value=preg_replace('/\*/','%',$value); // Replace * with % + } if ($mode == 1) { $value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do From 6611cc70189688ff7e058fc91e34aa99784f93a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 7 Nov 2015 12:19:48 +0100 Subject: [PATCH 23/60] NEW #3767 Allow changing multiple prices of a product at once --- htdocs/product/class/product.class.php | 11 ++ htdocs/product/price.php | 228 ++++++++++++++----------- 2 files changed, 137 insertions(+), 102 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ba4dc432d36..1ebd94b383f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4073,4 +4073,15 @@ class Product extends CommonObject return 1; } + + public function getRights() + { + global $user; + + if ($this->isproduct()) { + return $user->rights->produit; + } else { + return $user->rights->service; + } + } } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 69802f51d57..1e03780995f 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -113,86 +113,108 @@ if (empty($reshook)) $action=''; } - if (($action == 'update_price') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) + if (($action == 'update_price') && !$cancel && $object->getRights()->creer) { - $newprice = ''; - $newprice_min = ''; - $newpricebase = ''; - $newvat = ''; - + $error = 0; + $pricestoupdate = array(); + + $psq = GETPOST('psqflag'); + $psq = empty($newpsq) ? 0 : $newpsq; $maxpricesupplier = $object->min_recommended_price(); - $object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression - // MultiPrix - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - - //Shall we generate prices using price rules? - $object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false; - $object->update($object->id, $user); - - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { - if (isset($_POST ["price_".$i])) { - $level = $i; - $newprice = price2num($_POST ["price_".$i], 'MU'); - $newprice_min = price2num($_POST ["price_min_".$i], 'MU'); - $newpricebase = $_POST ["multiprices_base_type_".$i]; - $newnpr = (preg_match('/\*/', $_POST ["tva_tx_".$i]) ? 1 : 0); - $newvat = str_replace('*', '', $_POST ["tva_tx_".$i]); - $newpsq = GETPOST('psqflag'); - $newpsq = empty($newpsq) ? 0 : $newpsq; - break; // We found submited price - } - } - } else { - $level = 0; - $newprice = price2num($_POST ["price"], 'MU'); - $newprice_min = price2num($_POST ["price_min"], 'MU'); - $newpricebase = $_POST ["price_base_type"]; - $newnpr = (preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0); - $newvat = str_replace('*', '', $_POST ["tva_tx"]); - $newpsq = GETPOST('psqflag'); - $newpsq = empty($newpsq) ? 0 : $newpsq; - } - - if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) { - setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors'); - $error ++; - $action = 'edit_price'; - } - - if ($newprice < $newprice_min && !empty($object->fk_price_expression)) { - $newprice = $newprice_min; //Set price same as min, the user will not see the - } - - $res = $object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq); - - if ($res) { + if (!empty($conf->dynamicprices->enabled)) { + $object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression if ($object->fk_price_expression != 0) { //Check the expression validity by parsing it $priceparser = new PriceParser($db); - $price_result = $priceparser->parseProduct($object); - if ($price_result < 0) { //Expression is not valid + + if ($priceparser->parseProduct($object) < 0) { $error ++; - $action = 'edit_price'; setEventMessage($priceparser->translatedError(), 'errors'); } } - if (empty($error) && !empty($conf->dynamicprices->enabled)) { - $ret = $object->setPriceExpression($object->fk_price_expression); - if ($ret < 0) { - $error ++; - $action = 'edit_price'; - setEventMessage($object->error, 'errors'); + } + + // Multiprices + if (!$error && !empty($conf->global->PRODUIT_MULTIPRICES)) { + + $newprice = GETPOST('price', 'array'); + $newprice_min = GETPOST('price_min', 'array'); + $newpricebase = GETPOST('multiprices_base_type', 'array'); + $newvattx = GETPOST('tva_tx', 'array'); + + //Shall we generate prices using price rules? + $object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false; + + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { + + if (!isset($newprice[$i])) { + continue; } - } - if (empty($error)) { - $action = ''; - setEventMessage($langs->trans("RecordSaved")); + + $newnpr = (preg_match('/\*/', $newvattx[$i] ? 1 : 0)); + $newvat = str_replace('*', '', $newvattx[$i]); + + $pricestoupdate[$i] = array( + 'price' => $newprice[$i], + 'price_min' => $newprice_min[$i], + 'price_base_type' => $newpricebase[$i], + 'vat_tx' => $newvat, + 'npr' => $newnpr + ); } } else { - $action = 'edit_price'; + $pricestoupdate[0] = array( + 'price' => $_POST ["price"], + 'price_min' => $_POST ["price_min"], + 'price_base_type' => $_POST ["price_base_type"], + 'vat_tx' => str_replace('*', '', $_POST ["tva_tx"]), + 'npr' => preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0 + ); + } + + if (!$error && $object->update($object->id, $user) < 1) { + $error++; setEventMessage($object->error, 'errors'); + $action = 'edit_price'; + } + + if (!$error) { + foreach ($pricestoupdate as $key => $val) { + + $newprice = $val['price']; + + if ($val['price'] < $val['price_min'] && !empty($object->fk_price_expression)) { + $newprice = $val['price_min']; //Set price same as min, the user will not see the + } + + $newprice = price2num($newprice, 'MU'); + $newprice_min = price2num($val['price_min'], 'MU'); + + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) { + setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors'); + $error ++; + break; + } + + $res = $object->updatePrice($newprice, $val['price_base_type'], $user, $val['vat_tx'], $newprice_min, $key, $val['npr'], $psq); + + if ($res < 0) { + $error ++; + setEventMessage($object->error, 'errors'); + break; + } + } + } + + if (empty($error)) { + $action = ''; + setEventMessage($langs->trans("RecordSaved")); + $db->commit(); + } else { + $action = 'edit_price'; + $db->rollback(); } } @@ -444,13 +466,13 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) // Selling price print '' . $langs->trans("SellingPrice") . ''; print ''; - if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') { - print price($object->multiprices_ttc["$soc->price_level"]); + if ($object->multiprices_base_type[$soc->price_level] == 'TTC') { + print price($object->multiprices_ttc[$soc->price_level]); } else { - print price($object->multiprices["$soc->price_level"]); + print price($object->multiprices[$soc->price_level]); } - if ($object->multiprices_base_type["$soc->price_level"]) { - print ' ' . $langs->trans($object->multiprices_base_type["$soc->price_level"]); + if ($object->multiprices_base_type[$soc->price_level]) { + print ' ' . $langs->trans($object->multiprices_base_type[$soc->price_level]); } else { print ' ' . $langs->trans($object->price_base_type); } @@ -458,18 +480,18 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) // Price min print '' . $langs->trans("MinPrice") . ''; - if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') + if ($object->multiprices_base_type[$soc->price_level] == 'TTC') { - print price($object->multiprices_min_ttc["$soc->price_level"]) . ' ' . $langs->trans($object->multiprices_base_type["$soc->price_level"]); + print price($object->multiprices_min_ttc[$soc->price_level]) . ' ' . $langs->trans($object->multiprices_base_type[$soc->price_level]); } else { - print price($object->multiprices_min["$soc->price_level"]) . ' ' . $langs->trans(empty($object->multiprices_base_type["$soc->price_level"])?'HT':$object->multiprices_base_type["$soc->price_level"]); + print price($object->multiprices_min[$soc->price_level]) . ' ' . $langs->trans(empty($object->multiprices_base_type[$soc->price_level])?'HT':$object->multiprices_base_type[$soc->price_level]); } print ''; if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // TVA - print '' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx["$soc->price_level"], true) . ''; + print '' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx[$soc->price_level], true) . ''; } else { @@ -503,28 +525,28 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); print ''; - if ($object->multiprices_base_type ["$i"] == 'TTC') { - print '' . price($object->multiprices_ttc["$i"]); + if ($object->multiprices_base_type [$i] == 'TTC') { + print '' . price($object->multiprices_ttc[$i]); } else { - print '' . price($object->multiprices["$i"]); + print '' . price($object->multiprices[$i]); } - if ($object->multiprices_base_type["$i"]) { - print ' '.$langs->trans($object->multiprices_base_type ["$i"]).'';; + if ($object->multiprices_base_type[$i]) { + print ' '.$langs->trans($object->multiprices_base_type [$i]).''; } else { - print ' '.$langs->trans($object->price_base_type).'';; + print ' '.$langs->trans($object->price_base_type).''; } // Prix min print ''; - if (empty($object->multiprices_base_type["$i"])) $object->multiprices_base_type["$i"]="HT"; - if ($object->multiprices_base_type["$i"] == 'TTC') + if (empty($object->multiprices_base_type[$i])) $object->multiprices_base_type[$i]="HT"; + if ($object->multiprices_base_type[$i] == 'TTC') { - print price($object->multiprices_min_ttc["$i"]) . ' ' . $langs->trans($object->multiprices_base_type["$i"]); + print price($object->multiprices_min_ttc[$i]) . ' ' . $langs->trans($object->multiprices_base_type[$i]); } else { - print price($object->multiprices_min["$i"]) . ' ' . $langs->trans($object->multiprices_base_type["$i"]); + print price($object->multiprices_min[$i]) . ' ' . $langs->trans($object->multiprices_base_type[$i]); } print ''; @@ -914,11 +936,12 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> id . '" method="POST">'; + for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { - - print '
'; - if ($i > 1) print '
'; + + if ($i > 1) print '
'; elseif (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { print $langs->trans('UseMultipriceRules'). ' price_autogen ? 'checked' : '').'>

'; } @@ -927,7 +950,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> print ''; if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { - print ''; + print ''; } print ''; @@ -936,7 +959,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // This option is kept for backward compatibility but has no sense { print ''; } @@ -945,22 +968,22 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> $text = $langs->trans('SellingPrice') . ' ' . $i; print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; // Min price print ''; - print ''; - print '
' . $langs->trans("VATRate") . ''; - print $form->load_tva("tva_tx_" . $i, $object->multiprices_tva_tx["$i"], $mysoc, '', $object->id); + print $form->load_tva("tva_tx[" . $i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id); print '
'; - if ($object->multiprices_base_type ["$i"] == 'TTC') { - print ''; + if ($object->multiprices_base_type [$i] == 'TTC') { + print ''; } else { - print ''; + print ''; } - print $form->selectPriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i); + print $form->selectPriceBaseType($object->multiprices_base_type [$i], "multiprices_base_type[" . $i."]"); print '
'; $text = $langs->trans('MinPrice') . ' ' . $i; print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); - if ($object->multiprices_base_type ["$i"] == 'TTC') { - print ''; + if ($object->multiprices_base_type [$i] == 'TTC') { + print ''; } else { - print ''; + print ''; } if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { @@ -968,15 +991,16 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> } print '
'; - print '   '; - print '
'; - print '
'; } - + + print '
'; + print ''; + print '   '; + print '
'; + print ''; + dol_fiche_end(); } } From 45b4122a95bd91d7b197fc8dec6880db77ee72f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 7 Nov 2015 12:19:48 +0100 Subject: [PATCH 24/60] NEW #3767 Allow changing multiple prices of a product at once --- htdocs/product/class/product.class.php | 11 ++ htdocs/product/price.php | 235 ++++++++++++++----------- 2 files changed, 144 insertions(+), 102 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ba4dc432d36..1ebd94b383f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4073,4 +4073,15 @@ class Product extends CommonObject return 1; } + + public function getRights() + { + global $user; + + if ($this->isproduct()) { + return $user->rights->produit; + } else { + return $user->rights->service; + } + } } diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 69802f51d57..056455a3fff 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -113,86 +113,115 @@ if (empty($reshook)) $action=''; } - if (($action == 'update_price') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) + if (($action == 'update_price') && !$cancel && $object->getRights()->creer) { - $newprice = ''; - $newprice_min = ''; - $newpricebase = ''; - $newvat = ''; - + $error = 0; + $pricestoupdate = array(); + + $psq = GETPOST('psqflag'); + $psq = empty($newpsq) ? 0 : $newpsq; $maxpricesupplier = $object->min_recommended_price(); - $object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression - // MultiPrix - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - - //Shall we generate prices using price rules? - $object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false; - $object->update($object->id, $user); - - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { - if (isset($_POST ["price_".$i])) { - $level = $i; - $newprice = price2num($_POST ["price_".$i], 'MU'); - $newprice_min = price2num($_POST ["price_min_".$i], 'MU'); - $newpricebase = $_POST ["multiprices_base_type_".$i]; - $newnpr = (preg_match('/\*/', $_POST ["tva_tx_".$i]) ? 1 : 0); - $newvat = str_replace('*', '', $_POST ["tva_tx_".$i]); - $newpsq = GETPOST('psqflag'); - $newpsq = empty($newpsq) ? 0 : $newpsq; - break; // We found submited price - } - } - } else { - $level = 0; - $newprice = price2num($_POST ["price"], 'MU'); - $newprice_min = price2num($_POST ["price_min"], 'MU'); - $newpricebase = $_POST ["price_base_type"]; - $newnpr = (preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0); - $newvat = str_replace('*', '', $_POST ["tva_tx"]); - $newpsq = GETPOST('psqflag'); - $newpsq = empty($newpsq) ? 0 : $newpsq; - } - - if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) { - setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors'); - $error ++; - $action = 'edit_price'; - } - - if ($newprice < $newprice_min && !empty($object->fk_price_expression)) { - $newprice = $newprice_min; //Set price same as min, the user will not see the - } - - $res = $object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq); - - if ($res) { + if (!empty($conf->dynamicprices->enabled)) { + $object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression if ($object->fk_price_expression != 0) { //Check the expression validity by parsing it $priceparser = new PriceParser($db); - $price_result = $priceparser->parseProduct($object); - if ($price_result < 0) { //Expression is not valid + + if ($priceparser->parseProduct($object) < 0) { $error ++; - $action = 'edit_price'; setEventMessage($priceparser->translatedError(), 'errors'); } } - if (empty($error) && !empty($conf->dynamicprices->enabled)) { - $ret = $object->setPriceExpression($object->fk_price_expression); - if ($ret < 0) { - $error ++; - $action = 'edit_price'; - setEventMessage($object->error, 'errors'); + } + + // Multiprices + if (!$error && !empty($conf->global->PRODUIT_MULTIPRICES)) { + + $newprice = GETPOST('price', 'array'); + $newprice_min = GETPOST('price_min', 'array'); + $newpricebase = GETPOST('multiprices_base_type', 'array'); + $newvattx = GETPOST('tva_tx', 'array'); + + //Shall we generate prices using price rules? + $object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false; + + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { + + if (!isset($newprice[$i])) { + continue; + } + + $newnpr = (preg_match('/\*/', $newvattx[$i] ? 1 : 0)); + $newvat = str_replace('*', '', $newvattx[$i]); + + $pricestoupdate[$i] = array( + 'price' => $newprice[$i], + 'price_min' => $newprice_min[$i], + 'price_base_type' => $newpricebase[$i], + 'vat_tx' => $newvat, + 'npr' => $newnpr + ); + + //If autogeneration is enabled, then we only set the first level + if ($object->price_autogen) { + break; } } - if (empty($error)) { - $action = ''; - setEventMessage($langs->trans("RecordSaved")); + } else { + $pricestoupdate[0] = array( + 'price' => $_POST ["price"], + 'price_min' => $_POST ["price_min"], + 'price_base_type' => $_POST ["price_base_type"], + 'vat_tx' => str_replace('*', '', $_POST ["tva_tx"]), + 'npr' => preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0 + ); + } + + if (!$error && $object->update($object->id, $user) < 1) { + $error++; + setEventMessage($object->error, 'errors'); + $action = 'edit_price'; + } + + if (!$error) { + $db->begin(); + + foreach ($pricestoupdate as $key => $val) { + + $newprice = $val['price']; + + if ($val['price'] < $val['price_min'] && !empty($object->fk_price_expression)) { + $newprice = $val['price_min']; //Set price same as min, the user will not see the + } + + $newprice = price2num($newprice, 'MU'); + $newprice_min = price2num($val['price_min'], 'MU'); + + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) { + setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors'); + $error ++; + break; + } + + $res = $object->updatePrice($newprice, $val['price_base_type'], $user, $val['vat_tx'], $newprice_min, $key, $val['npr'], $psq); + + if ($res < 0) { + $error ++; + setEventMessage($object->error, 'errors'); + break; + } } + } + + if (empty($error)) { + $action = ''; + setEventMessage($langs->trans("RecordSaved")); + $db->commit(); } else { $action = 'edit_price'; - setEventMessage($object->error, 'errors'); + $db->rollback(); } } @@ -444,13 +473,13 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) // Selling price print '' . $langs->trans("SellingPrice") . ''; print ''; - if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') { - print price($object->multiprices_ttc["$soc->price_level"]); + if ($object->multiprices_base_type[$soc->price_level] == 'TTC') { + print price($object->multiprices_ttc[$soc->price_level]); } else { - print price($object->multiprices["$soc->price_level"]); + print price($object->multiprices[$soc->price_level]); } - if ($object->multiprices_base_type["$soc->price_level"]) { - print ' ' . $langs->trans($object->multiprices_base_type["$soc->price_level"]); + if ($object->multiprices_base_type[$soc->price_level]) { + print ' ' . $langs->trans($object->multiprices_base_type[$soc->price_level]); } else { print ' ' . $langs->trans($object->price_base_type); } @@ -458,18 +487,18 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) // Price min print '' . $langs->trans("MinPrice") . ''; - if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') + if ($object->multiprices_base_type[$soc->price_level] == 'TTC') { - print price($object->multiprices_min_ttc["$soc->price_level"]) . ' ' . $langs->trans($object->multiprices_base_type["$soc->price_level"]); + print price($object->multiprices_min_ttc[$soc->price_level]) . ' ' . $langs->trans($object->multiprices_base_type[$soc->price_level]); } else { - print price($object->multiprices_min["$soc->price_level"]) . ' ' . $langs->trans(empty($object->multiprices_base_type["$soc->price_level"])?'HT':$object->multiprices_base_type["$soc->price_level"]); + print price($object->multiprices_min[$soc->price_level]) . ' ' . $langs->trans(empty($object->multiprices_base_type[$soc->price_level])?'HT':$object->multiprices_base_type[$soc->price_level]); } print ''; if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // TVA - print '' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx["$soc->price_level"], true) . ''; + print '' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx[$soc->price_level], true) . ''; } else { @@ -503,28 +532,28 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); print ''; - if ($object->multiprices_base_type ["$i"] == 'TTC') { - print '' . price($object->multiprices_ttc["$i"]); + if ($object->multiprices_base_type [$i] == 'TTC') { + print '' . price($object->multiprices_ttc[$i]); } else { - print '' . price($object->multiprices["$i"]); + print '' . price($object->multiprices[$i]); } - if ($object->multiprices_base_type["$i"]) { - print ' '.$langs->trans($object->multiprices_base_type ["$i"]).'';; + if ($object->multiprices_base_type[$i]) { + print ' '.$langs->trans($object->multiprices_base_type [$i]).''; } else { - print ' '.$langs->trans($object->price_base_type).'';; + print ' '.$langs->trans($object->price_base_type).''; } // Prix min print ''; - if (empty($object->multiprices_base_type["$i"])) $object->multiprices_base_type["$i"]="HT"; - if ($object->multiprices_base_type["$i"] == 'TTC') + if (empty($object->multiprices_base_type[$i])) $object->multiprices_base_type[$i]="HT"; + if ($object->multiprices_base_type[$i] == 'TTC') { - print price($object->multiprices_min_ttc["$i"]) . ' ' . $langs->trans($object->multiprices_base_type["$i"]); + print price($object->multiprices_min_ttc[$i]) . ' ' . $langs->trans($object->multiprices_base_type[$i]); } else { - print price($object->multiprices_min["$i"]) . ' ' . $langs->trans($object->multiprices_base_type["$i"]); + print price($object->multiprices_min[$i]) . ' ' . $langs->trans($object->multiprices_base_type[$i]); } print ''; @@ -894,7 +923,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> id . '" method="POST">'; + for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { - - print '
'; - if ($i > 1) print '
'; + + if ($i > 1) print '
'; elseif (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { print $langs->trans('UseMultipriceRules'). ' price_autogen ? 'checked' : '').'>

'; } @@ -927,7 +957,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> print ''; if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { - print ''; + print ''; } print ''; @@ -936,7 +966,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // This option is kept for backward compatibility but has no sense { print ''; } @@ -945,22 +975,22 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> $text = $langs->trans('SellingPrice') . ' ' . $i; print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; // Min price print ''; - print ''; - print '
' . $langs->trans("VATRate") . ''; - print $form->load_tva("tva_tx_" . $i, $object->multiprices_tva_tx["$i"], $mysoc, '', $object->id); + print $form->load_tva("tva_tx[" . $i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id); print '
'; - if ($object->multiprices_base_type ["$i"] == 'TTC') { - print ''; + if ($object->multiprices_base_type [$i] == 'TTC') { + print ''; } else { - print ''; + print ''; } - print $form->selectPriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i); + print ' '.$form->selectPriceBaseType($object->multiprices_base_type [$i], "multiprices_base_type[" . $i."]"); print '
'; $text = $langs->trans('MinPrice') . ' ' . $i; print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); - if ($object->multiprices_base_type ["$i"] == 'TTC') { - print ''; + if ($object->multiprices_base_type [$i] == 'TTC') { + print ''; } else { - print ''; + print ''; } if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { @@ -968,15 +998,16 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> } print '
'; - print '   '; - print '
'; - print '
'; } - + + print '
'; + print ''; + print '   '; + print '
'; + print ''; + dol_fiche_end(); } } From 350ef610e99d931cbe1d2b3a27a4fbf36efa2b1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Nov 2015 12:36:34 +0100 Subject: [PATCH 25/60] Fix beluga pdf for projects. Add missing expense reports. --- .../project/doc/pdf_beluga.modules.php | 57 +++++++++++++------ htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/admin/project.php | 2 +- htdocs/projet/card.php | 14 +++-- htdocs/projet/class/project.class.php | 5 +- 5 files changed, 56 insertions(+), 23 deletions(-) diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 4a8839ef865..11b1d378981 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -94,8 +94,8 @@ class pdf_beluga extends ModelePDFProjects $this->posxref=$this->marge_gauche+1; $this->posxdate=$this->marge_gauche+25; $this->posxsociety=$this->marge_gauche+45; - $this->posxamountht=$this->marge_gauche+115; - $this->posxamountttc=$this->marge_gauche+140; + $this->posxamountht=$this->marge_gauche+110; + $this->posxamountttc=$this->marge_gauche+135; $this->posxstatut=$this->marge_gauche+165; } @@ -231,14 +231,16 @@ class pdf_beluga extends ModelePDFProjects 'class'=>'Propal', 'table'=>'propal', 'datefieldname'=>'datep', - 'test'=>$conf->propal->enabled && $user->rights->propale->lire), + 'test'=>$conf->propal->enabled && $user->rights->propale->lire, + 'lang'=>'propal'), 'order'=>array( 'name'=>"CustomersOrders", 'title'=>"ListOrdersAssociatedProject", 'class'=>'Commande', 'table'=>'commande', 'datefieldname'=>'date_commande', - 'test'=>$conf->commande->enabled && $user->rights->commande->lire), + 'test'=>$conf->commande->enabled && $user->rights->commande->lire, + 'lang'=>'order'), 'invoice'=>array( 'name'=>"CustomersInvoices", 'title'=>"ListInvoicesAssociatedProject", @@ -246,21 +248,24 @@ class pdf_beluga extends ModelePDFProjects 'margin'=>'add', 'table'=>'facture', 'datefieldname'=>'datef', - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), + 'test'=>$conf->facture->enabled && $user->rights->facture->lire, + 'lang'=>'bills'), 'invoice_predefined'=>array( 'name'=>"PredefinedInvoices", 'title'=>"ListPredefinedInvoicesAssociatedProject", 'class'=>'FactureRec', 'table'=>'facture_rec', 'datefieldname'=>'datec', - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), + 'test'=>$conf->facture->enabled && $user->rights->facture->lire, + 'lang'=>'bills'), 'order_supplier'=>array( 'name'=>"SuppliersOrders", 'title'=>"ListSupplierOrdersAssociatedProject", 'class'=>'CommandeFournisseur', 'table'=>'commande_fournisseur', 'datefieldname'=>'date_commande', - 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire, + 'lang'=>'orders'), 'invoice_supplier'=>array( 'name'=>"BillsSuppliers", 'title'=>"ListSupplierInvoicesAssociatedProject", @@ -268,14 +273,16 @@ class pdf_beluga extends ModelePDFProjects 'margin'=>'minus', 'table'=>'facture_fourn', 'datefieldname'=>'datef', - 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire, + 'lang'=>'bills'), 'contract'=>array( 'name'=>"Contracts", 'title'=>"ListContractAssociatedProject", 'class'=>'Contrat', 'table'=>'contrat', 'datefieldname'=>'date_contrat', - 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), + 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire, + 'lang'=>'contract'), 'intervention'=>array( 'name'=>"Interventions", 'title'=>"ListFichinterAssociatedProject", @@ -283,7 +290,8 @@ class pdf_beluga extends ModelePDFProjects 'table'=>'fichinter', 'datefieldname'=>'date_valid', 'disableamount'=>1, - 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), + 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire, + 'lang'=>'interventions'), 'trip'=>array( 'name'=>"TripsAndExpenses", 'title'=>"ListTripAssociatedProject", @@ -292,7 +300,18 @@ class pdf_beluga extends ModelePDFProjects 'datefieldname'=>'dated', 'margin'=>'minus', 'disableamount'=>1, - 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), + 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire, + 'lang'=>'trip'), + 'expensereport'=>array( + 'name'=>"ExpensesReports", + 'title'=>"ListTripAssociatedProject", + 'class'=>'ExpenseReport', + 'table'=>'expensereport', + 'datefieldname'=>'dated', + 'margin'=>'minus', + 'disableamount'=>1, + 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire, + 'lang'=>'trip'), 'agenda'=>array( 'name'=>"Agenda", 'title'=>"ListActionsAssociatedProject", @@ -300,7 +319,8 @@ class pdf_beluga extends ModelePDFProjects 'table'=>'actioncomm', 'datefieldname'=>'datep', 'disableamount'=>1, - 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) + 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read, + 'lang'=>'agenda') ); @@ -311,12 +331,17 @@ class pdf_beluga extends ModelePDFProjects $tablename=$value['table']; $datefieldname=$value['datefieldname']; $qualified=$value['test']; + $langstoload=$value['lang']; + $langs->load($langstoload); if ($qualified) { + //var_dump("$key, $tablename, $datefieldname, $dates, $datee"); $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee); + //var_dump($elementarray); + $num = count($elementarray); - if ($num > 0) + if ($num >= 0) { $nexY = $pdf->GetY() + 5; $curY = $nexY; @@ -334,9 +359,9 @@ class pdf_beluga extends ModelePDFProjects $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $outputlangs->transnoentities("ThirdParty"), 1, 'L'); if (empty($value['disableamount'])) { $pdf->SetXY($this->posxamountht, $curY); - $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHT"), 1, 'R'); + $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R'); $pdf->SetXY($this->posxamountttc, $curY); - $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTC"), 1, 'R'); + $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTCShort"), 1, 'R'); } else { $pdf->SetXY($this->posxamountht, $curY); $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); @@ -434,8 +459,6 @@ class pdf_beluga extends ModelePDFProjects } } - - /* * Pied de page */ diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 4ed6ccfc2f5..505f6bce8e5 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -176,6 +176,7 @@ ProjectOpenedProjectByOppStatus=Opened project/lead by opportunity status ProjectsStatistics=Statistics on projects/leads TaskAssignedToEnterTime=Task assigned. Entering time on this task should be possible. IdTaskTime=Id task time +YouCanCompleteRef=If you want to complete the ref with some information (to use it as search filters), it is recommanded to add a - character to separate it, so the automatic numbering will still work correctly for next projects. For example %s-ABC. You may also prefer to add search keys into label. OpenedProjectsByThirdparties=Opened projects by thirdparties OpportunityTotalAmount=Opportunities total amount OpportunityPonderatedAmount=Opportunities weighted amount diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 686e764978a..f42fc7c4720 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -104,7 +104,7 @@ else if ($action == 'specimen') $project = new Project($db); $project->initAsSpecimen(); - + // Search template files $file=''; $classname=''; $filefound=0; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 748f91dbefe..c05cb6948a5 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -450,10 +450,13 @@ if ($action == 'create' && $user->rights->projet->creer) if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; // Ref - print ''.$langs->trans("Ref").''; + $suggestedref=($_POST["ref"]?$_POST["ref"]:$defaultref); + print ''.$langs->trans("Ref").''; + print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref)); + print ''; // Label - print ''.$langs->trans("Label").''; + print ''.$langs->trans("Label").''; // Thirdparty print ''.$langs->trans("ThirdParty").''; @@ -617,12 +620,15 @@ else print ''; // Ref + $suggestedref=$object->ref; print ''; - print ''; + print ''; // Label print ''; - print ''; + print ''; // Thirdparty print '
'.$langs->trans("Ref").'
'; + print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref)); + print '
'.$langs->trans("Label").'
'.$langs->trans("ThirdParty").''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7ac7fa66cea..aca5fe67d0d 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -453,7 +453,9 @@ class Project extends CommonObject function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='') { $elements = array(); - + + if ($this->id <= 0) return $elements; + if ($type == 'agenda') { $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; @@ -929,6 +931,7 @@ class Project extends CommonObject $this->date_c = $now; $this->date_m = $now; $this->date_start = $now; + $this->date_end = $now + (3600 * 24 * 365); $this->note_public = 'SPECIMEN'; $this->fk_ele = 20000; $this->opp_amount = 20000; From 439e4a483df61da1801eb857d5e27124ba4b1b0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Nov 2015 12:37:05 +0100 Subject: [PATCH 26/60] Doc comment --- htdocs/install/mysql/tables/llx_budget.sql | 2 +- htdocs/install/mysql/tables/llx_budget_lines.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_budget.sql b/htdocs/install/mysql/tables/llx_budget.sql index aeb60cd1ce5..908bfc1337c 100644 --- a/htdocs/install/mysql/tables/llx_budget.sql +++ b/htdocs/install/mysql/tables/llx_budget.sql @@ -20,7 +20,7 @@ create table llx_budget ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer NOT NULL DEFAULT 1, - label varchar(255) NOT NULL, + label varchar(255) NOT NULL, -- For example 'Global budget for year' or 'Budget for each project' status integer, note text, date_start date, diff --git a/htdocs/install/mysql/tables/llx_budget_lines.sql b/htdocs/install/mysql/tables/llx_budget_lines.sql index 11b68f68fc4..aba5c7f53ee 100644 --- a/htdocs/install/mysql/tables/llx_budget_lines.sql +++ b/htdocs/install/mysql/tables/llx_budget_lines.sql @@ -20,7 +20,7 @@ create table llx_budget_lines ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_budget integer NOT NULL, - fk_project_ids varchar(255) NOT NULL, -- 'IDS:x,y' = List of project ids related to this budget. If budget is dedicated to projects not yet started, we recommand to create a project "Projects to come". 'FILTER:x=y' = Can also be a dynamic rule to select projects. + fk_project_ids varchar(255) NOT NULL, -- 'IDS:x,y' = List of project ids related to this budget. If budget is dedicated to projects not yet started, we recommand to create a project "Projects to come". 'FILTER:ref=*ABC' = Can also be a dynamic rule to select projects. amount double(24,8) NOT NULL, datec datetime, tms timestamp, From c0872d690e7dc56b4c6b077bf766c38395df3b1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Nov 2015 13:32:14 +0100 Subject: [PATCH 27/60] Use new banner for other tabs of product --- htdocs/margin/tabs/productMargins.php | 35 +-- htdocs/margin/tabs/thirdpartyMargins.php | 32 +-- htdocs/product/document.php | 30 +-- htdocs/product/fournisseurs.php | 31 +-- htdocs/product/price.php | 41 +--- htdocs/product/stock/product.php | 213 ++++++++---------- .../product/stock/tpl/stockcorrection.tpl.php | 4 +- .../product/stock/tpl/stocktransfer.tpl.php | 6 +- htdocs/product/traduction.php | 128 +++++------ 9 files changed, 231 insertions(+), 289 deletions(-) diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 934be1f5a41..3b952b099ef 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -82,28 +82,13 @@ if ($id > 0 || ! empty($ref)) $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'margin', $titre, 0, $picto); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $object->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2,1); - print '
'; // Total Margin print '
'.$langs->trans("TotalMargin").''; @@ -125,7 +110,11 @@ if ($id > 0 || ! empty($ref)) } print "
"; - print ''; + + print ''; + print '
'; + + dol_fiche_end(); if ($user->rights->facture->lire) { diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index bd2730edda0..9f2f745ad0c 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -73,21 +73,21 @@ if ($socid > 0) dol_fiche_head($head, 'margin', $langs->trans("ThirdParty"),0,'company'); - print ''; - - print ''; - print ''; - - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } + dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + + print '
'; + + print '
'; + print '
'.$langs->trans('ThirdPartyName').''; - print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); - print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; + + // Alias names (commercial, trademark or alias names) + print '"; if ($object->client) { - print ''; @@ -123,7 +123,11 @@ if ($socid > 0) } print "
'.$langs->trans('AliasNames').''; + print $object->name_alias; + print "
'; + print '
'; print $langs->trans('CustomerCode').''; print $object->code_client; if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; @@ -96,7 +96,7 @@ if ($socid > 0) if ($object->fournisseur) { - print '
'; + print '
'; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; @@ -104,7 +104,7 @@ if ($socid > 0) } // Total Margin - print '
'.$langs->trans("TotalMargin").''; + print '
'.$langs->trans("TotalMargin").''; print ''; // set by jquery (see below) print '
"; + + dol_fiche_end(); + print ''; + print '
'; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index baf736b47e5..93a5c21862d 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -195,33 +195,21 @@ if ($object->id) } - print ''; - - // Ref - print ''; - print ''; - print ''; - - // Label - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $object->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2,1); - print '
'; print ''; print ''; print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; print ''; + print '
'; + + dol_fiche_end(); $modulepart = 'produit'; $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 526b67b123c..dfbd5679ac4 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -264,21 +264,15 @@ if ($id > 0 || $ref) $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'suppliers', $titre, 0, $picto); - - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Label - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->label.'
'; // Minimum Price - print ''; + print ''; print ''; - // Status (to buy) - print ''; - print '
'.$langs->trans("BuyingPriceMin").'
'.$langs->trans("BuyingPriceMin").''; $product_fourn = new ProductFournisseur($db); if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) @@ -288,14 +282,13 @@ if ($id > 0 || $ref) } print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2,1); - print '
'; - print "\n"; + print ''; + print '
'; + + dol_fiche_end(); + // Form to add or update a price if (($action == 'add_price' || $action == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer)) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 69802f51d57..e1e1eeab0fe 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -402,34 +402,13 @@ $titre = $langs->trans("CardProduct" . $object->type); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'price', $titre, 0, $picto); -print ''; +dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); -// Ref -print ''; -print ''; -print ''; -// Label -print ''; +print '
'; -$isphoto = $object->is_photo_available($conf->product->multidir_output [$object->entity]); - -$nblignes = 5; -if ($isphoto) { - // Photo - print '
'; -} - -print ''; - -// Status (to sell) -print ''; +print '
'; +print '
' . $langs->trans("Ref") . ''; -print $form->showrefnav($object, 'ref', '', 1, 'ref'); -print '
' . $langs->trans("Label") . '' . $object->label . ''; - print $object->show_photos($conf->product->multidir_output [$object->entity], 1, 1, 0, 0, 0, 80); - print '
' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')'; -print $object->getLibStatut(2, 0); -print '
'; // MultiPrix if (! empty($conf->global->PRODUIT_MULTIPRICES)) @@ -442,7 +421,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) $soc->fetch($socid); // Selling price - print '' . $langs->trans("SellingPrice") . ''; + print ''; print ''; + print ''; } else { // TVA - print ''; + print ''; } print ''; @@ -605,7 +584,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) else { // TVA - print ''; + print ''; // Price print '
' . $langs->trans("SellingPrice") . ''; if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') { print price($object->multiprices_ttc["$soc->price_level"]); @@ -483,12 +462,12 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // We show only vat for level 1 - print '
' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx [1], true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx [1], true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
'.$langs->trans("PriceLevel").''.$langs->trans("SellingPrice").''.$langs->trans("MinPrice").'
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
' . $langs->trans("SellingPrice") . ''; @@ -703,6 +682,10 @@ else print "
\n"; +print ''; +print '
'; + + dol_fiche_end(); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index dfa0cf0c55c..c37424e548b 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -72,24 +72,24 @@ if ($cancel) $action=''; // Set stock limit if ($action == 'setstocklimit') { - $product = new Product($db); - $result=$product->fetch($id); - $product->seuil_stock_alerte=$stocklimit; - $result=$product->update($product->id,$user,0,'update'); + $object = new Product($db); + $result=$object->fetch($id); + $object->seuil_stock_alerte=$stocklimit; + $result=$object->update($object->id,$user,0,'update'); if ($result < 0) - setEventMessage($product->error, 'errors'); + setEventMessage($object->error, 'errors'); $action=''; } // Set desired stock if ($action == 'setdesiredstock') { - $product = new Product($db); - $result=$product->fetch($id); - $product->desiredstock=$desiredstock; - $result=$product->update($product->id,$user,0,'update'); + $object = new Product($db); + $result=$object->fetch($id); + $object->desiredstock=$desiredstock; + $result=$object->update($object->id,$user,0,'update'); if ($result < 0) - setEventMessage($product->error, 'errors'); + setEventMessage($object->error, 'errors'); $action=''; } @@ -112,10 +112,10 @@ if ($action == "correct_stock" && ! $cancel) if (! empty($conf->productbatch->enabled)) { - $product = new Product($db); - $result=$product->fetch($id); + $object = new Product($db); + $result=$object->fetch($id); - if ($product->hasbatch() && (! GETPOST("sellby")) && (! GETPOST("eatby")) && (! GETPOST("batch_number"))) { + if ($object->hasbatch() && (! GETPOST("sellby")) && (! GETPOST("eatby")) && (! GETPOST("batch_number"))) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); $error++; $action='correction'; @@ -127,13 +127,13 @@ if ($action == "correct_stock" && ! $cancel) $priceunit=price2num(GETPOST("unitprice")); if (is_numeric(GETPOST("nbpiece")) && $id) { - if (empty($product)) { - $product = new Product($db); - $result=$product->fetch($id); + if (empty($object)) { + $object = new Product($db); + $result=$object->fetch($id); } - if ($product->hasbatch()) + if ($object->hasbatch()) { - $result=$product->correct_stock_batch( + $result=$object->correct_stock_batch( $user, GETPOST("id_entrepot"), GETPOST("nbpiece"), @@ -148,7 +148,7 @@ if ($action == "correct_stock" && ! $cancel) } else { - $result=$product->correct_stock( + $result=$object->correct_stock( $user, GETPOST("id_entrepot"), GETPOST("nbpiece"), @@ -168,13 +168,13 @@ if ($action == "correct_stock" && ! $cancel) } else { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } } else { - setEventMessage($product->error,'errors'); + setEventMessage($object->error,'errors'); $action='correction'; } } @@ -207,20 +207,20 @@ if ($action == "transfert_stock" && ! $cancel) { if ($id) { - $product = new Product($db); - $result=$product->fetch($id); + $object = new Product($db); + $result=$object->fetch($id); $db->begin(); - $product->load_stock(); // Load array product->stock_warehouse + $object->load_stock(); // Load array product->stock_warehouse // Define value of products moved $pricesrc=0; - //if (isset($product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp; - if (isset($product->pmp)) $pricesrc=$product->pmp; + //if (isset($object->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$object->stock_warehouse[GETPOST("id_entrepot_source")]->pmp; + if (isset($object->pmp)) $pricesrc=$object->pmp; $pricedest=$pricesrc; - if ($product->hasbatch()) + if ($object->hasbatch()) { $pdluo = new Productbatch($db); @@ -251,7 +251,7 @@ if ($action == "transfert_stock" && ! $cancel) if (! $error) { // Remove stock - $result1=$product->correct_stock_batch( + $result1=$object->correct_stock_batch( $user, $srcwarehouseid, GETPOST("nbpiece",'int'), @@ -262,7 +262,7 @@ if ($action == "transfert_stock" && ! $cancel) GETPOST('inventorycode') ); // Add stock - $result2=$product->correct_stock_batch( + $result2=$object->correct_stock_batch( $user, GETPOST("id_entrepot_destination",'int'), GETPOST("nbpiece",'int'), @@ -277,7 +277,7 @@ if ($action == "transfert_stock" && ! $cancel) else { // Remove stock - $result1=$product->correct_stock( + $result1=$object->correct_stock( $user, GETPOST("id_entrepot_source"), GETPOST("nbpiece"), @@ -288,7 +288,7 @@ if ($action == "transfert_stock" && ! $cancel) ); // Add stock - $result2=$product->correct_stock( + $result2=$object->correct_stock( $user, GETPOST("id_entrepot_destination"), GETPOST("nbpiece"), @@ -309,13 +309,13 @@ if ($action == "transfert_stock" && ! $cancel) } else { - header("Location: product.php?id=".$product->id); + header("Location: product.php?id=".$object->id); exit; } } else { - setEventMessages($product->error, $product->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); $action='transfert'; } @@ -370,70 +370,45 @@ if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) * View */ +$form = new Form($db); $formproduct=new FormProduct($db); if ($id > 0 || $ref) { - $product = new Product($db); - $result = $product->fetch($id,$ref); - $product->load_stock(); + $object = new Product($db); + $result = $object->fetch($id,$ref); + $object->load_stock(); $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; - llxHeader("",$langs->trans("CardProduct".$product->type),$help_url); + llxHeader("",$langs->trans("CardProduct".$object->type),$help_url); if ($result > 0) { - $head=product_prepare_head($product); - $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); + $head=product_prepare_head($object); + $titre=$langs->trans("CardProduct".$object->type); + $picto=($object->type==Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'stock', $titre, 0, $picto); dol_htmloutput_events(); - $form = new Form($db); - - print ''; - - // Ref - print ''; - print ''; - print ''; - - // Label - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; - + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); - } else { - print $product->getLibStatut(2,0); - } - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); - } else { - print $product->getLibStatut(2,1); - } - print '
'; + if ($conf->productbatch->enabled) { print ''; } // PMP print ''; print ''; print ''; @@ -441,14 +416,13 @@ if ($id > 0 || $ref) print ''; print ''; - $object = $product; if (empty($conf->global->PRODUIT_MULTIPRICES)) { // Price @@ -483,17 +457,17 @@ if ($id > 0 || $ref) } // Stock alert threshold - print ''; // Desired stock - print ''; // Real stock - $product->load_stock(); + $object->load_stock(); $text_stock_options = ''; $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)?$langs->trans("DeStockOnShipment").'
':''); $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'
':''); @@ -504,15 +478,15 @@ if ($id > 0 || $ref) print ''; - print ''; print ''; // Calculating a theorical value print ''; - print "'; @@ -528,36 +502,36 @@ if ($id > 0 || $ref) if (! empty($conf->commande->enabled)) { if ($found) print '
'; else $found=1; - print $langs->trans("ProductQtyInCustomersOrdersRunning").': '.$product->stats_commande['qty']; - $result=$product->load_stats_commande(0,'0'); - if ($result < 0) dol_print_error($db,$product->error); - print ' ('.$langs->trans("ProductQtyInDraft").': '.$product->stats_commande['qty'].')'; + print $langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty']; + $result=$object->load_stats_commande(0,'0'); + if ($result < 0) dol_print_error($db,$object->error); + print ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; } // Number of product from customer order already sent (partial shipping) if (! empty($conf->expedition->enabled)) { if ($found) print '
'; else $found=1; - $result=$product->load_stats_sending(0,'2'); - print $langs->trans("ProductQtyInShipmentAlreadySent").': '.$product->stats_expedition['qty']; + $result=$object->load_stats_sending(0,'2'); + print $langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; } // Number of supplier order running if (! empty($conf->fournisseur->enabled)) { if ($found) print '
'; else $found=1; - $result=$product->load_stats_commande_fournisseur(0,'3,4'); - print $langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$product->stats_commande_fournisseur['qty']; - $result=$product->load_stats_commande_fournisseur(0,'0,1,2'); - if ($result < 0) dol_print_error($db,$product->error); - print ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$product->stats_commande_fournisseur['qty'].')'; + $result=$object->load_stats_commande_fournisseur(0,'3,4'); + print $langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty']; + $result=$object->load_stats_commande_fournisseur(0,'0,1,2'); + if ($result < 0) dol_print_error($db,$object->error); + print ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; } // Number of product from supplier order already received (partial receipt) if (! empty($conf->fournisseur->enabled)) { if ($found) print '
'; else $found=1; - print $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$product->stats_reception['qty']; + print $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; } print ''; @@ -565,7 +539,7 @@ if ($id > 0 || $ref) // Last movement $sql = "SELECT max(m.datem) as datem"; $sql.= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; - $sql.= " WHERE m.fk_product = '".$product->id."'"; + $sql.= " WHERE m.fk_product = '".$object->id."'"; $resqlbis = $db->query($sql); if ($resqlbis) { @@ -580,18 +554,21 @@ if ($id > 0 || $ref) if ($lastmovementdate) { print dol_print_date($lastmovementdate,'dayhour').' '; - print '('.$langs->trans("FullList").')'; + print '('.$langs->trans("FullList").')'; } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ""; print "
'.$langs->trans("ManageLotSerial").''; - print $product->getLibStatut(0,2); + print $object->getLibStatut(0,2); print '
'.$langs->trans("AverageUnitPricePMP").''; - if ($product->pmp > 0) print price($product->pmp).' '.$langs->trans("HT"); + if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT"); print '
'.$langs->trans("BuyingPriceMin").''; $product_fourn = new ProductFournisseur($db); - if ($product_fourn->find_min_price_product_fournisseur($product->id) > 0) + if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) { if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur(); else print $langs->trans("NotDefined"); } print '
'.$form->editfieldkey("StockLimit",'stocklimit',$product->seuil_stock_alerte,$product,$user->rights->produit->creer).''; - print $form->editfieldval("StockLimit",'stocklimit',$product->seuil_stock_alerte,$product,$user->rights->produit->creer); + print '
'.$form->editfieldkey("StockLimit",'stocklimit',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).''; + print $form->editfieldval("StockLimit",'stocklimit',$object->seuil_stock_alerte,$object,$user->rights->produit->creer); print '
'.$form->editfieldkey("DesiredStock",'desiredstock',$product->desiredstock,$product,$user->rights->produit->creer).''; - print $form->editfieldval("DesiredStock",'desiredstock',$product->desiredstock,$product,$user->rights->produit->creer); + print '
'.$form->editfieldkey("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer).''; + print $form->editfieldval("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer); print '
'; print $form->textwithtooltip($langs->trans("PhysicalStock"), $text_stock_options, 2, 1, img_picto('', 'info'), '', 2); print ''.$product->stock_reel; - if ($product->seuil_stock_alerte && ($product->stock_reel < $product->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit")); + print ''.$object->stock_reel; + if ($object->seuil_stock_alerte && ($object->stock_reel < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit")); print '
'.$langs->trans("VirtualStock").'".(empty($product->stock_theorique)?0:$product->stock_theorique); - if ($product->stock_theorique < $product->seuil_stock_alerte) { + print "".(empty($object->stock_theorique)?0:$object->stock_theorique); + if ($object->stock_theorique < $object->seuil_stock_alerte) { print ' '.img_warning($langs->trans("StockLowerThanLimit")); } print '
"; + print ''; + print '
'; + + dol_fiche_end(); } - print ''; /* * Correct stock @@ -618,7 +595,7 @@ if ($id > 0 || $ref) if ($_GET["action"] == "definir") { print load_fiche_titre($langs->trans("SetStock")); - print "
id\" method=\"post\">\n"; + print "id\" method=\"post\">\n"; print ''; print ''; print ''; @@ -645,19 +622,19 @@ else /* ************************************************************************** */ -if (empty($action) && $product->id) +if (empty($action) && $object->id) { print "
\n"; if ($user->rights->stock->mouvement->creer) { - print ''.$langs->trans("StockCorrection").''; + print ''.$langs->trans("StockCorrection").''; } - //if (($user->rights->stock->mouvement->creer) && ! $product->hasbatch()) + //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) if ($user->rights->stock->mouvement->creer) { - print ''.$langs->trans("StockMovement").''; + print ''.$langs->trans("StockMovement").''; } print '
'; @@ -678,7 +655,7 @@ print ''; print ''; print ''; print ''; -if ((! empty($conf->productbatch->enabled)) && $product->hasbatch()) +if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) { print ''; print ''; @@ -695,7 +672,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql.= " WHERE ps.reel != 0"; $sql.= " AND ps.fk_entrepot = e.rowid"; $sql.= " AND e.entity IN (".getEntity('stock', 1).")"; -$sql.= " AND ps.fk_product = ".$product->id; +$sql.= " AND ps.fk_product = ".$object->id; $sql.= " ORDER BY e.label"; $entrepotstatic=new Entrepot($db); @@ -718,25 +695,25 @@ if ($resql) print ''; print ''; // PMP - print ''; + print ''; // Value purchase - print ''; + print ''; // Sell price print ''; // Value sell print ''; + if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).''; else print $langs->trans("Variable"); print ''; ; $total += $obj->reel; - if (price2num($product->pmp)) $totalwithpmp += $obj->reel; - $totalvalue = $totalvalue + ($product->pmp*$obj->reel); - $totalvaluesell = $totalvaluesell + ($product->price*$obj->reel); + if (price2num($object->pmp)) $totalwithpmp += $obj->reel; + $totalvalue = $totalvalue + ($object->pmp*$obj->reel); + $totalvaluesell = $totalvaluesell + ($object->price*$obj->reel); //Batch Detail - if ((! empty($conf->productbatch->enabled)) && $product->hasbatch()) + if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) { $details=Productbatch::findAll($db,$obj->product_stock_id); if ($details<0) dol_print_error($db); @@ -762,7 +739,7 @@ if ($resql) { print "\n".'
'.$langs->trans("EstimatedStockValueShort").''.$langs->trans("SellPriceMin").''.$langs->trans("EstimatedStockValueSellShort").'
'.$langs->trans("batch_number").''.$entrepotstatic->getNomUrl(1).''.$obj->reel.($obj->reel<0?' '.img_warning():'').''.(price2num($product->pmp)?price2num($product->pmp,'MU'):'').''.(price2num($object->pmp)?price2num($object->pmp,'MU'):'').''.(price2num($product->pmp)?price(price2num($product->pmp*$obj->reel,'MT')):'').''.(price2num($object->pmp)?price(price2num($object->pmp*$obj->reel,'MT')):'').''; - if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price,'MU'),1); + if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price,'MU'),1); else print $langs->trans("Variable"); print ''; - if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price*$obj->reel,'MT'),1).'
'; print img_picto($langs->trans("Tranfer"),'uparrow','class="hideonsmartphone"').' '; - print 'id.'">'.$langs->trans("StockMovement").''; + print 'id.'">'.$langs->trans("StockMovement").''; // Disabled, because edition of stock content must use the "Correct stock menu". // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... //print 'id.'#'.$pdluo->id.'">'; diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index dc102d8eb05..b1121731293 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -21,7 +21,9 @@ load("productbatch"); + if (! is_object($product)) $product=$object; + + $langs->load("productbatch"); if (empty($id)) $id = $object->id; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index de947a75014..93c3135e5f1 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -21,7 +21,11 @@ load("productbatch"); + + $pdluoid=GETPOST('pdluoid','int'); $pdluo = new Productbatch($db); diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 413cb589dff..96187fad8dd 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -58,9 +58,9 @@ if ($cancel == $langs->trans("Cancel")) if ($action == 'delete' && GETPOST('langtodelete','alpha')) { - $product = new Product($db); - $product->fetch($id); - $product->delMultiLangs(GETPOST('langtodelete','alpha')); + $object = new Product($db); + $object->fetch($id); + $object->delMultiLangs(GETPOST('langtodelete','alpha')); } // Add translation @@ -68,33 +68,33 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { - $product = new Product($db); - $product->fetch($id); + $object = new Product($db); + $object->fetch($id); $current_lang = $langs->getDefaultLang(); // update de l'objet if ( $_POST["forcelangprod"] == $current_lang ) { - $product->label = $_POST["libelle"]; - $product->description = dol_htmlcleanlastbr($_POST["desc"]); - $product->note = dol_htmlcleanlastbr($_POST["note"]); + $object->label = $_POST["libelle"]; + $object->description = dol_htmlcleanlastbr($_POST["desc"]); + $object->note = dol_htmlcleanlastbr($_POST["note"]); } else { - $product->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; - $product->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); - $product->multilangs[$_POST["forcelangprod"]]["note"] = dol_htmlcleanlastbr($_POST["note"]); + $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; + $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); + $object->multilangs[$_POST["forcelangprod"]]["note"] = dol_htmlcleanlastbr($_POST["note"]); } // sauvegarde en base - if ( $product->setMultiLangs() > 0 ) + if ( $object->setMultiLangs() > 0 ) { $action = ''; } else { $action = 'add'; - setEventMessage($product->error,'errors'); + setEventMessage($object->error,'errors'); } } @@ -103,34 +103,34 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { - $product = new Product($db); - $product->fetch($id); + $object = new Product($db); + $object->fetch($id); $current_lang = $langs->getDefaultLang(); - foreach ( $product->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet + foreach ( $object->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet { if ( $key == $current_lang ) { - $product->label = $_POST["libelle-".$key]; - $product->description = dol_htmlcleanlastbr($_POST["desc-".$key]); - $product->note = dol_htmlcleanlastbr($_POST["note-".$key]); + $object->label = $_POST["libelle-".$key]; + $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->note = dol_htmlcleanlastbr($_POST["note-".$key]); } else { - $product->multilangs[$key]["label"] = $_POST["libelle-".$key]; - $product->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); - $product->multilangs[$key]["note"] = dol_htmlcleanlastbr($_POST["note-".$key]); + $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->multilangs[$key]["note"] = dol_htmlcleanlastbr($_POST["note-".$key]); } } - if ( $product->setMultiLangs() > 0 ) + if ( $object->setMultiLangs() > 0 ) { $action = ''; } else { $action = 'edit'; - setEventMessage($product->error,'errors'); + setEventMessage($object->error,'errors'); } } @@ -139,24 +139,24 @@ if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { - $product = new Product($db); - $product->fetch($id); + $object = new Product($db); + $object->fetch($id); $langtodelete=GETPOST('langdel','alpha'); - if ( $product->delMultiLangs($langtodelete) > 0 ) + if ( $object->delMultiLangs($langtodelete) > 0 ) { $action = ''; } else { $action = 'edit'; - setEventMessage($product->error,'errors'); + setEventMessage($object->error,'errors'); } } -$product = new Product($db); -$result = $product->fetch($id,$ref); +$object = new Product($db); +$result = $object->fetch($id,$ref); /* @@ -168,20 +168,10 @@ llxHeader("","",$langs->trans("Translation")); $form = new Form($db); $formadmin=new FormAdmin($db); -$head=product_prepare_head($product); -$titre=$langs->trans("CardProduct".$product->type); -$picto=($product->type==Product::TYPE_SERVICE?'service':'product'); -dol_fiche_head($head, 'translation', $titre, 0, $picto); +$head=product_prepare_head($object); +$titre=$langs->trans("CardProduct".$object->type); +$picto=($object->type==Product::TYPE_SERVICE?'service':'product'); -print ''; - -// Reference -print ''; -print ''; -print ''; -print '
'.$langs->trans("Ref").''; -print $form->showrefnav($product,'ref','',1,'ref'); -print '
'; if ($action == 'edit') { @@ -191,33 +181,40 @@ if ($action == 'edit') print ''; print ''; print ''; - print ''; + print ''; - if (! empty($product->multilangs)) + dol_fiche_head($head, 'translation', $titre, 0, $picto); + + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + if (! empty($object->multilangs)) { - foreach ($product->multilangs as $key => $value) + foreach ($object->multilangs as $key => $value) { - print "
".$langs->trans('Language_'.$key)." :
"; + $s=picto_from_langcode($key); + print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".'
'.img_delete('', '')."
"; + print ''; - print ''; + print ''; print ''; print ''; - print ''; print '
'.$langs->trans('Label').'
'.$langs->trans('Label').'
'.$langs->trans('Description').''; - $doleditor = new DolEditor("desc-$key", $product->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); + $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print '
'.$langs->trans('Note').''; - $doleditor = new DolEditor("note-$key", $product->multilangs[$key]["note"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); + $doleditor = new DolEditor("note-$key", $object->multilangs[$key]["note"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print '
'.$langs->trans("Delete").'
'; } } - print '
'; + dol_fiche_end(); + + print '
'; print ''; print '     '; print ''; @@ -228,25 +225,30 @@ if ($action == 'edit') } else { - $cnt_trans = 0; - if (! empty($product->multilangs)) + dol_fiche_head($head, 'translation', $titre, 0, $picto); + + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + $cnt_trans = 0; + if (! empty($object->multilangs)) { - foreach ($product->multilangs as $key => $value) + foreach ($object->multilangs as $key => $value) { $cnt_trans++; $s=picto_from_langcode($key); - print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '')."
"; + print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '')."
"; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print '
'.$langs->trans('Label').''.$product->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$product->multilangs[$key]["description"].'
'.$langs->trans('Note').''.$product->multilangs[$key]["note"].'
'.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
'.$langs->trans('Note').''.$object->multilangs[$key]["note"].'
'; } } if (! $cnt_trans) print '
'. $langs->trans('NoTranslation'); + + dol_fiche_end(); } -print "
\n"; /* ************************************************************************** */ @@ -260,8 +262,8 @@ print "\n
\n"; if ($action == '') if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''.$langs->trans("Add").''; - print ''.$langs->trans("Update").''; + print ''.$langs->trans("Add").''; + print ''.$langs->trans("Update").''; } print "\n
\n"; @@ -284,7 +286,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print ''; print ''; print ''; print '
'.$langs->trans('Language').''; - print $formadmin->select_language('','forcelangprod',0,$product->multilangs,1); + print $formadmin->select_language('','forcelangprod',0,$object->multilangs,1); print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; From 8ccb8c92e000b8f39811858eb16d7b28287b8d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 7 Nov 2015 14:29:38 +0100 Subject: [PATCH 28/60] FIX #3897 Incorrect colspan in tr#tablelines > tr#trlinefordates Close #3897 --- htdocs/core/tpl/objectline_create.tpl.php | 36 +++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index edb065c9d9b..ee70101318b 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -5,6 +5,7 @@ * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Raphaël Doursenaud + * Copyright (C) 2015 Marcos García * * 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 @@ -315,14 +316,39 @@ else { service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { - if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; - else $colspan = 9; - if($this->situation_cycle_ref) $colspan++; - if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc - if (in_array($object->element,array('propal','askpricesupplier','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button + $colspan = 6; + + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $colspan++; + } + if ($this->situation_cycle_ref) { + $colspan++; + } + // We add 1 if col total ttc + if (!empty($inputalsopricewithtax)) { + $colspan++; + } if ($conf->global->PRODUCT_USE_UNITS) { $colspan++; } + if (count($object->lines)) { + //There will be an edit and a delete button + $colspan += 2; + + // With this, there is a column move button ONLY if lines > 1 + if (in_array($object->element, array( + 'propal', + 'askpricesupplier', + 'facture', + 'invoice', + 'commande', + 'order', + 'order_supplier', + 'invoice_supplier' + ))) { + $colspan++; + } + } if (! empty($usemargins)) { From 0451cc1e734ce3244b505edd0d7a2a6f25d14e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 7 Nov 2015 14:31:12 +0100 Subject: [PATCH 29/60] FIX #3931 [Insight] Logical operators should be avoided - in htdocs/core/class/extrafields.class.php, line 261 Close #3931 --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c53d1b793f3..645b50cb8bc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -258,7 +258,7 @@ class ExtraFields if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname)) { - if(is_array($param) and count($param) > 0) + if(is_array($param) && count($param) > 0) { $params = $this->db->escape(serialize($param)); } From ba42a7779fb7a27a2de5b6fc9019d31bf6278f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 7 Nov 2015 14:34:26 +0100 Subject: [PATCH 30/60] FIX #3877 HTML encoded strings when searching for a supplier invoice Close #3877 --- htdocs/fourn/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 4252e4a9ef6..a46c5e6ca38 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -273,7 +273,7 @@ if ($resql) if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); + print $langs->transnoentities("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); } print ''; From 75b4cb472785aea6152cbee70837b4d365e0a9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 7 Nov 2015 14:37:47 +0100 Subject: [PATCH 31/60] NEW #3876 Renamed Product::isservice and Product::isproduct to match PSR-2 --- htdocs/core/lib/doc.lib.php | 2 +- htdocs/core/lib/pdf.lib.php | 2 +- htdocs/core/lib/product.lib.php | 2 +- htdocs/product/card.php | 8 ++++---- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/composition/card.php | 4 ++-- htdocs/product/fournisseurs.php | 2 +- htdocs/public/paybox/newpayment.php | 2 +- htdocs/public/paypal/newpayment.php | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/core/lib/doc.lib.php b/htdocs/core/lib/doc.lib.php index 330d3d2ba39..76337ec2763 100644 --- a/htdocs/core/lib/doc.lib.php +++ b/htdocs/core/lib/doc.lib.php @@ -106,7 +106,7 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli $ref_prodserv = ""; if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this { - if ($prodser->isservice()) + if ($prodser->isService()) { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 8e0eef6d53b..881415555bc 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1166,7 +1166,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl $ref_prodserv = ""; if (! empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) // In standard mode, we do not show this { - if ($prodser->isservice()) + if ($prodser->isService()) { $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service")." "; } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 69eb63717b2..d0bc74e77c3 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -98,7 +98,7 @@ function product_prepare_head($object) $head[$h][2] = 'referers'; $h++; - if ($object->isproduct() || ($object->isservice() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option) + if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option) { if (! empty($conf->stock->enabled) && $user->rights->stock->lire) { diff --git a/htdocs/product/card.php b/htdocs/product/card.php index a7291cc1895..4c30691318f 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1038,7 +1038,7 @@ else require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $type = $langs->trans('Product'); - if ($object->isservice()) $type = $langs->trans('Service'); + if ($object->isService()) $type = $langs->trans('Service'); //print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), ""); // Main official, simple, and not duplicated code @@ -1144,7 +1144,7 @@ else // Stock /* - if ($object->isproduct() && ! empty($conf->stock->enabled)) + if ($object->isProduct() && ! empty($conf->stock->enabled)) { print "".''; } - if ($object->isservice()) + if ($object->isService()) { // Duration print ''; } - if ($object->isservice()) + if ($object->isService()) { // Duration print '"; $nblignes=6; - if ($object->isproduct() && ! empty($conf->stock->enabled)) $nblignes++; - if ($object->isservice()) $nblignes++; + if ($object->isProduct() && ! empty($conf->stock->enabled)) $nblignes++; + if ($object->isService()) $nblignes++; // Reference print ''; - else print ''; + else print ''; } else { print ''; } - print ''; + print ''; print ''; print '
'.$langs->trans("StockLimit").''; print ''; @@ -1169,7 +1169,7 @@ else print '
'.$langs->trans("Duration").''; @@ -1435,7 +1435,7 @@ else print '
'.$langs->trans("Duration").''.$object->duration_value.' '; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ba4dc432d36..0311d7cf281 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3789,7 +3789,7 @@ class Product extends CommonObject * * @return boolean True if it's a product */ - function isproduct() + function isProduct() { return ($this->type == Product::TYPE_PRODUCT ? true : false); } @@ -3799,7 +3799,7 @@ class Product extends CommonObject * * @return boolean True if it's a service */ - function isservice() + function isService() { return ($this->type == Product::TYPE_SERVICE ? true : false); } diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 276356d8bca..86dfb8a8fd4 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -193,8 +193,8 @@ if ($id > 0 || ! empty($ref)) print "
'.$langs->trans("Ref").''; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index dfbd5679ac4..96aa9aa6311 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -521,7 +521,7 @@ if ($id > 0 || $ref) { // Suppliers list title print ''; - if ($object->isproduct()) $nblignefour=4; + if ($object->isProduct()) $nblignefour=4; else $nblignefour=4; $param="&id=".$object->id; diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index 42ea013eade..481fd17f049 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -583,7 +583,7 @@ if (GETPOST("source") == 'contractline' && $valid) $duration=''; if ($contractline->fk_product) { - if ($product->isservice() && $product->duration_value > 0) + if ($product->isService() && $product->duration_value > 0) { $label=$langs->trans("Duration"); diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index 23f81c4295b..dcb43c07170 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -720,7 +720,7 @@ if (GETPOST("source") == 'contractline' && $valid) $duration=''; if ($contractline->fk_product) { - if ($product->isservice() && $product->duration_value > 0) + if ($product->isService() && $product->duration_value > 0) { $label=$langs->trans("Duration"); From 57e162d7f87a250014c7ec6ae6e4a9094a3b6ee6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Nov 2015 15:13:51 +0100 Subject: [PATCH 32/60] The component selectAjaxArray can return javascript part into a global "delayed" variable so caller can output it at end of page. This reduce the Flash Over Unstyle Content effect. --- htdocs/core/class/html.form.class.php | 32 ++++++---- htdocs/main.inc.php | 31 +++++---- htdocs/margin/tabs/productMargins.php | 2 +- htdocs/product/class/product.class.php | 10 +-- htdocs/product/document.php | 2 +- htdocs/product/stats/card.php | 63 ++++++++----------- htdocs/product/stats/commande.php | 36 ++++------- htdocs/product/stats/commande_fournisseur.php | 43 +++++-------- htdocs/product/stats/contrat.php | 38 +++++------ htdocs/product/stats/facture.php | 37 ++++------- htdocs/product/stats/facture_fournisseur.php | 36 ++++------- htdocs/product/stats/propal.php | 36 ++++------- htdocs/product/stock/product.php | 7 ++- htdocs/public/test/test_forms.php | 1 - 14 files changed, 158 insertions(+), 216 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 822c43f3370..6c586ffe9b7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4513,22 +4513,25 @@ class Form * @param string $morecss Add more class to css styles * @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected. * @param string $placeholder String to use as placeholder - * @return string HTML select string. + * @param string $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) + * @return string HTML select string */ - static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='') + static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0) { global $langs; + global $delayedhtmlcontent; - $out = ''; - $tmpplugin='select2'; - $out.=' + + $out=''; + + $outdelayed=' '; + }); + '; - - $out.=''; - + if ($acceptdelayedhtml) + { + $delayedhtmlcontent.=$outdelayed; + } + else + { + $out.=$outdelayed; + } return $out; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8943ca95821..354ecb7b611 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -931,7 +931,7 @@ if (! function_exists("llxHeader")) } if (empty($conf->dol_hide_leftmenu)) { - left_menu('', $help_url, '', '', 1, $title); + left_menu('', $help_url, '', '', 1, $title, 1); } // main area @@ -1401,13 +1401,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a ' . "\n"; } - // Wrapper to show tooltips - print '' . "\n"; - // Raven.js for client-side Sentry logging support if (array_key_exists('mod_syslog_sentry', $conf->loghandlers) && ! empty($conf->global->SYSLOG_SENTRY_DSN)) { @@ -1539,9 +1532,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a * @param array $menu_array_after Table of menu entries to show after entries of menu handler * @param int $leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules. * @param string $title Title of web page + * @param string $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return void */ -function left_menu($menu_array_before, $helppagename='', $notused='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='') +function left_menu($menu_array_before, $helppagename='', $notused='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='', $acceptdelayedhtml=0) { global $user, $conf, $langs, $db, $form; global $hookmanager, $menumanager; @@ -1563,7 +1557,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra { if (! is_object($form)) $form=new Form($db); $selected=-1; - $searchform.=$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, $langs->trans("Search")); + $searchform.=$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1); } else { @@ -1770,7 +1764,6 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra print "\n"; print ''."\n"; - if (empty($leftmenuwithoutmainarea)) main_area($title); } @@ -1892,6 +1885,7 @@ if (! function_exists("llxFooter")) /** * Show HTML footer * Close div /DIV data-role=page + /DIV class=fiche + /DIV /DIV main layout + /BODY + /HTML. + * If global var $delayedhtmlcontent was filled, we output it just before closing the body. * * @param string $comment A text to add as HTML comment into HTML generated page * @param string $zone 'private' (for private pages) or 'public' (for public pages) @@ -1900,7 +1894,8 @@ if (! function_exists("llxFooter")) function llxFooter($comment='',$zone='private') { global $conf, $langs; - + global $delayedhtmlcontent; + // Global html output events ($mesgs, $errors, $warnings) dol_htmloutput_events(); @@ -1937,6 +1932,18 @@ if (! function_exists("llxFooter")) //var_dump($langs); // Uncommment to see the property _tab_loaded to see which language file were loaded if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print ' '."\n"; // End div container + + if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent; + + // Wrapper to show tooltips + print "\n\n"; + print '' . "\n"; + + print "\n"; print "\n"; } diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 3b952b099ef..b409d0c752f 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -91,7 +91,7 @@ if ($id > 0 || ! empty($ref)) print '
'; // Total Margin - print ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ba4dc432d36..3b653f9d919 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2207,7 +2207,7 @@ class Product extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.rowid = d.fk_facture"; - $sql.= " AND d.fk_product =".$this->id; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.entity IN (".getEntity('facture', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2236,7 +2236,7 @@ class Product extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.rowid = d.fk_facture_fourn"; - $sql.= " AND d.fk_product =".$this->id; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.entity IN (".getEntity('facture_fourn', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2265,7 +2265,7 @@ class Product extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.rowid = d.fk_propal"; - $sql.= " AND d.fk_product =".$this->id; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2292,7 +2292,7 @@ class Product extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = d.fk_commande"; - $sql.= " AND d.fk_product =".$this->id; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2319,7 +2319,7 @@ class Product extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = d.fk_commande"; - $sql.= " AND d.fk_product =".$this->id; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.entity IN (".getEntity('commande_fournisseur', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 93a5c21862d..ecb3d12bb52 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -202,7 +202,7 @@ if ($object->id) print '
'; print '
'.$langs->trans("TotalMargin").''; + print '
'.$langs->trans("TotalMargin").''; print ''; // set by jquery (see below) print '
'; - print ''; + print ''; print ''; print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 5fe6d5a4be3..4203705cfee 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -38,7 +38,7 @@ $langs->load("products"); $langs->load("bills"); $langs->load("other"); -$id = GETPOST('id','int'); +$id = GETPOST('id','int'); // For this page, id can also be 'all' $ref = GETPOST('ref'); $mode = (GETPOST('mode') ? GETPOST('mode') : 'byunit'); $error = 0; @@ -56,16 +56,24 @@ $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','', /* * View */ + $form = new Form($db); -if (! empty($id) || ! empty($ref)) +if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') { $object = new Product($db); - $result = $object->fetch($id,$ref); - - llxHeader("","",$langs->trans("CardProduct".$object->type)); - - if ($result) + if (! empty($id) || ! empty($ref)) + { + $result = $object->fetch($id,$ref); + llxHeader("",$langs->trans("CardProduct".$object->type)); + } + else + { + llxHeader("",$langs->trans("ProductStatistics")); + } + + + if ($result && (! empty($id) || ! empty($ref))) { $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); @@ -73,37 +81,18 @@ if (! empty($id) || ! empty($ref)) dol_fiche_head($head, 'stats', $titre, 0, $picto); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Label - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; - - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $object->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2,1); - print '
'; - + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + dol_fiche_end(); - - + } + + + if ($result) + { // Choice of stats if (! empty($conf->dol_use_jmobile)) print "\n".'
'."\n"; - if ($mode == 'bynumber') print ''; + if ($mode == 'bynumber') print 'id).'&mode=byunit">'; else print img_picto('','tick').' '; print $langs->trans("StatsByNumberOfUnits"); if ($mode == 'bynumber') print ''; @@ -111,7 +100,7 @@ if (! empty($id) || ! empty($ref)) if (! empty($conf->dol_use_jmobile)) print '
'."\n".'
'."\n"; else print '   /   '; - if ($mode == 'byunit') print ''; + if ($mode == 'byunit') print 'id).'&mode=bynumber">'; else print img_picto('','tick').' '; print $langs->trans("StatsByNumberOfEntities"); if ($mode == 'byunit') print ''; @@ -237,13 +226,13 @@ if (! empty($id) || ! empty($ref)) if ($graphfiles[$key]['output'] && ! $px->isGraphKo()) { if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) print '
'.$langs->trans("GeneratedOn",dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']),"dayhour")).''.$langs->trans("GeneratedOn",dol_print_date(dol_now()),"dayhour").''.$langs->trans("GeneratedOn",dol_print_date(dol_now(),"dayhour")).''.($mesg?''.$mesg.'':$langs->trans("ChartNotGenerated")).''.img_picto($langs->trans("ReCalculate"),'refresh').'id).'&action=recalcul&mode='.$mode.'">'.img_picto($langs->trans("ReCalculate"),'refresh').'
'; diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index cdf571d7c75..69334976141 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -81,6 +81,8 @@ if ($id > 0 || ! empty($ref)) $product = new Product($db); $result = $product->fetch($id, $ref); + $object = $product; + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -97,34 +99,22 @@ if ($id > 0 || ! empty($ref)) $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $product->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $product->getLibStatut(2,1); - print '
'; show_stats_for_company($product,$socid); print "
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); + if ($user->rights->commande->lire) { diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index ef5352892c6..83f0912b3ee 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -86,16 +86,17 @@ if ($id > 0 || ! empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); - $parameters = array ( - 'id' => $id - ); + $object = $product; + + $parameters = array ('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); llxHeader("", "", $langs->trans("CardProduct" . $product->type)); - if ($result > 0) { + if ($result > 0) + { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct" . $product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -105,34 +106,22 @@ if ($id > 0 || ! empty($ref)) { if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
' . $langs->trans("Ref") . ''; - print $form->showrefnav($product, 'ref', '', 1, 'ref'); - print '
' . $langs->trans("Label") . '' . $product->label . '
' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')'; - print $product->getLibStatut(2, 0); - print '
' . $langs->trans("Status") . ' (' . $langs->trans("Buy") . ')'; - print $product->getLibStatut(2, 1); - print '
'; show_stats_for_company($product, $socid); print "
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); + if ($user->rights->fournisseur->commande->lire) { diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index 9d4d7d53abc..c2e6b25f7ab 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -71,6 +71,8 @@ if ($id > 0 || ! empty($ref)) $product = new Product($db); $result = $product->fetch($id, $ref); + $object = $product; + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -87,34 +89,22 @@ if ($id > 0 || ! empty($ref)) $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'; - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; - - show_stats_for_company($product,$socid); + show_stats_for_company($product,$socid); print "
'.$langs->trans("Ref").''; - print $form->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $product->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $product->getLibStatut(2,1); - print '
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); + $now=dol_now(); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index da39d5d67c1..590830702bb 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -81,7 +81,9 @@ if ($id > 0 || ! empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); - + + $object = $product; + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -98,34 +100,21 @@ if ($id > 0 || ! empty($ref)) $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $product->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $product->getLibStatut(2,1); - print '
'; show_stats_for_company($product,$socid); print "
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); if ($user->rights->facture->lire) diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 3d5cbcbe455..27e5495a771 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -83,6 +83,8 @@ if ($id > 0 || ! empty($ref)) $product = new Product($db); $result = $product->fetch($id, $ref); + $object = $product; + $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -99,34 +101,22 @@ if ($id > 0 || ! empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
' . $langs->trans("Ref") . ''; - print $form->showrefnav($product, 'ref', '', 1, 'ref'); - print '
' . $langs->trans("Label") . '' . $product->label . '
' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')'; - print $product->getLibStatut(2, 0); - print '
' . $langs->trans("Status") . ' (' . $langs->trans("Buy") . ')'; - print $product->getLibStatut(2, 1); - print '
'; show_stats_for_company($product, $socid); print "
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); + if ($user->rights->fournisseur->facture->lire) { diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 44101d72e52..2fa69740e8b 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -81,6 +81,8 @@ if ($id > 0 || ! empty($ref)) $product = new Product($db); $result = $product->fetch($id, $ref); + $object = $product; + $parameters = array ('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -97,34 +99,22 @@ if ($id > 0 || ! empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
' . $langs->trans("Ref") . ''; - print $form->showrefnav($product, 'ref', '', 1, 'ref'); - print '
' . $langs->trans("Label") . '' . $product->label . '
' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')'; - print $product->getLibStatut(2, 0); - print '
' . $langs->trans("Status") . ' (' . $langs->trans("Buy") . ')'; - print $product->getLibStatut(2, 1); - print '
'; show_stats_for_company($product, $socid); print "
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); + if ($user->rights->propale->lire) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index c37424e548b..093a364752c 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -399,14 +399,15 @@ if ($id > 0 || $ref) print '
'; print ''; - if ($conf->productbatch->enabled) { - print ''; } // PMP - print ''; + print ''; print ''; diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index f1c00f94acf..7fec8e895b6 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -68,7 +68,6 @@ print "Test 4d: a select with ajax refresh and with onchange call of url
\n"; $selected=-1; print $form->selectArrayAjax('testselectc', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, 'style="min-width: 250px;"', '', 0, 1, '', 1); - print '

'."\n"; // Test5a: form->select_thirdparty From 4e64230ac975ee04cef10080b38652923acee35f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Nov 2015 16:25:14 +0100 Subject: [PATCH 33/60] NEW Add chart of product statistics --- htdocs/core/menus/standard/eldy.lib.php | 4 +- htdocs/product/popuprop.php | 58 +++++++------ htdocs/product/stats/card.php | 107 +++++++++++++++++++++--- 3 files changed, 130 insertions(+), 39 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 099d65f7f95..6d31fbc52f6 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1088,7 +1088,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } if (! empty($conf->propal->enabled)) { - $newmenu->add("/product/popuprop.php?leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire); + $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire); } } @@ -1100,7 +1100,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire); if (! empty($conf->propal->enabled)) { - $newmenu->add("/product/popuprop.php?leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire); + $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire); } } diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index c8da665dd98..aad606627cb 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -38,18 +38,16 @@ $type=GETPOST("type","int"); if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service'); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page < 0) $page = 0; +if ($page == -1) { $page = 0; } if (! $sortfield) $sortfield="c"; if (! $sortorder) $sortorder="DESC"; - -$conf->liste_limit = 3; - -if ($page == -1) $page = 0; -$limit = $conf->liste_limit; $offset = $limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; $staticproduct=new Product($db); @@ -69,7 +67,13 @@ if ($type == '0') else if ($type == '1') { $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - $title=$langs->trans("StatisticsOfServices"); + //$title=$langs->trans("StatisticsOfServices"); + $title=$langs->trans("Statistics"); +} +else +{ + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfProductsOrServices"); $title=$langs->trans("Statistics"); } @@ -80,24 +84,30 @@ print load_fiche_titre($title, $mesg,'title_products.png'); $param = ''; $title = $langs->trans("ListProductServiceByPopularity"); -if ($type != '') { - $param = '&type='.$type; - - if ($type == 1) { - $title = $langs->trans("ListServiceByPopularity"); - } else { - $title = $langs->trans("ListProductByPopularity"); - } +if ((string) $type == '1') { + $title = $langs->trans("ListServiceByPopularity"); } +if ((string) $type == '0') { + $title = $langs->trans("ListProductByPopularity"); +} + +if ($type != '') $param .= '&type='.$type; + $h=0; $head = array(); -$head[$h][0] = $_SERVER['PHP_SELF']; -$head[$h][1] = $title; -$head[$h][2] = 'product'; + +$head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php?id=all'; +$head[$h][1] = $langs->trans("Chart"); +$head[$h][2] = 'chart'; $h++; -dol_fiche_head($head,'product',$langs->trans("Statistics")); +$head[$h][0] = $_SERVER['PHP_SELF']; +$head[$h][1] = $title; +$head[$h][2] = 'popularityprop'; +$h++; + +dol_fiche_head($head,'popularityprop',$langs->trans("Statistics")); @@ -127,15 +137,15 @@ if ($result) $num = $db->num_rows($result); $i = 0; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num, $totalnboflines, ''); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $totalnboflines, ''); print '
'.$langs->trans("ManageLotSerial").''; + if ($conf->productbatch->enabled) + { + print '
'.$langs->trans("ManageLotSerial").''; print $object->getLibStatut(0,2); print '
'.$langs->trans("AverageUnitPricePMP").'
'.$langs->trans("AverageUnitPricePMP").''; if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT"); print '
'; print ""; - print_liste_field_titre($langs->trans('Ref'), $_SERVER["PHP_SELF"], 'p.ref', '', '', '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans('Type'), $_SERVER["PHP_SELF"], 'p.type', '', '', '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans('Label'), $_SERVER["PHP_SELF"], 'p.label', '', '', '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans('NbOfProposals'), $_SERVER["PHP_SELF"], 'c', '', '', 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans('Ref'), $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans('Type'), $_SERVER["PHP_SELF"], 'p.fk_product_type', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans('Label'), $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans('NbOfProposals'), $_SERVER["PHP_SELF"], 'c', '', $param, 'align="right"', $sortfield, $sortorder); print "\n"; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 4203705cfee..33390e51a70 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -62,14 +62,38 @@ $form = new Form($db); if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') { $object = new Product($db); - if (! empty($id) || ! empty($ref)) + if (GETPOST('id') == 'all') { - $result = $object->fetch($id,$ref); - llxHeader("",$langs->trans("CardProduct".$object->type)); + llxHeader("",$langs->trans("ProductStatistics")); + + $type = GETPOST('type'); + + $helpurl=''; + if ($type == '0') + { + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + //$title=$langs->trans("StatisticsOfProducts"); + $title=$langs->trans("Statistics"); + } + else if ($type == '1') + { + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfServices"); + $title=$langs->trans("Statistics"); + } + else + { + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfProductsOrServices"); + $title=$langs->trans("Statistics"); + } + + print load_fiche_titre($title, $mesg,'title_products.png'); } else { - llxHeader("",$langs->trans("ProductStatistics")); + $result = $object->fetch($id,$ref); + llxHeader("",$langs->trans("CardProduct".$object->type)); } @@ -85,14 +109,70 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') dol_fiche_end(); } - - - if ($result) + if (GETPOST('id') == 'all') { + $h=0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php?id=all'; + $head[$h][1] = $langs->trans("Chart"); + $head[$h][2] = 'chart'; + $h++; + + $title = $langs->trans("ListProductServiceByPopularity"); + if ((string) $type == '1') { + $title = $langs->trans("ListServiceByPopularity"); + } + if ((string) $type == '0') { + $title = $langs->trans("ListProductByPopularity"); + } + + $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != ''?'?type='.$type:''); + $head[$h][1] = $title; + $head[$h][2] = 'popularityprop'; + $h++; + + dol_fiche_head($head,'chart',$langs->trans("Statistics")); + } + + + if ($result || GETPOST('id') == 'all') + { + if (GETPOST('id') == 'all') + { + // Choice of type of product + if (! empty($conf->dol_use_jmobile)) print "\n".'
'."\n"; + + if ((string) $type != '0') print 'id).'&type=0">'; + else print img_picto('','tick').' '; + print $langs->trans("Products"); + if ((string) $type != '0') print ''; + + if (! empty($conf->dol_use_jmobile)) print '
'."\n".'
'."\n"; + else print '   /   '; + + if ((string) $type != '1') print 'id).'&type=1">'; + else print img_picto('','tick').' '; + print $langs->trans("Services"); + if ((string) $type != '1') print ''; + + if (! empty($conf->dol_use_jmobile)) print '
'."\n".'
'."\n"; + else print '   /   '; + + if ((string) $type == '0' || (string) $type == '1') print 'id).'">'; + else print img_picto('','tick').' '; + print $langs->trans("ProductsAndServices"); + if ((string) $type == '0' || (string) $type == '1') print ''; + + if (! empty($conf->dol_use_jmobile)) print '
'; + else print '
'; + print '
'; + } + // Choice of stats if (! empty($conf->dol_use_jmobile)) print "\n".'
'."\n"; - if ($mode == 'bynumber') print 'id).'&mode=byunit">'; + if ($mode == 'bynumber') print 'id).($type != '' ? '&type='.$type:'').'&mode=byunit">'; else print img_picto('','tick').' '; print $langs->trans("StatsByNumberOfUnits"); if ($mode == 'bynumber') print ''; @@ -100,7 +180,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') if (! empty($conf->dol_use_jmobile)) print '
'."\n".'
'."\n"; else print '   /   '; - if ($mode == 'byunit') print 'id).'&mode=bynumber">'; + if ($mode == 'byunit') print 'id).($type != '' ? '&type='.$type:'').'&mode=bynumber">'; else print img_picto('','tick').' '; print $langs->trans("StatsByNumberOfEntities"); if ($mode == 'byunit') print ''; @@ -255,10 +335,11 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') print "\n".'
'; print '

'."\n"; } - - print '
'; - print '
'; - + } + + if (GETPOST('id') == 'all') + { + dol_fiche_end(); } } else From 198f8102fadbd61c3fe890860d08755506c3b542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 7 Nov 2015 16:46:15 +0100 Subject: [PATCH 34/60] FIX #3941 Error installing Dolibarr develop --- htdocs/install/mysql/tables/llx_opensurvey_sondage.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql index 16e8a624e72..b728702db79 100644 --- a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql +++ b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql @@ -29,5 +29,5 @@ CREATE TABLE llx_opensurvey_sondage ( allow_comments tinyint NOT NULL DEFAULT 1, allow_spy tinyint NOT NULL DEFAULT 1, tms TIMESTAMP, - sujet TEXT, -- Not filled if format = 'F'. Question are into table llx_opensurvey_formquestions + sujet TEXT -- Not filled if format = 'F'. Question are into table llx_opensurvey_formquestions ) ENGINE=InnoDB; From b34edeb751fe43e5bf3a9ba045e3e605436c8efb Mon Sep 17 00:00:00 2001 From: philippe grand Date: Sat, 7 Nov 2015 21:56:21 +0100 Subject: [PATCH 35/60] [Qual] Uniformize code --- htdocs/comm/address.php | 4 ++-- htdocs/comm/card.php | 10 +++++----- htdocs/comm/mailing/card.php | 2 +- htdocs/comm/propal.php | 36 +++++++++++++++++----------------- htdocs/comm/propal/contact.php | 16 +++++++-------- htdocs/comm/remx.php | 16 +++++++-------- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/htdocs/comm/address.php b/htdocs/comm/address.php index eb3c51b1760..edb5042e358 100644 --- a/htdocs/comm/address.php +++ b/htdocs/comm/address.php @@ -106,7 +106,7 @@ if ($action == 'add' || $action == 'update') } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action='create'; } } @@ -147,7 +147,7 @@ if ($action == 'add' || $action == 'update') else { $reload = 0; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action= "edit"; } } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index b874eeefde5..3083ac9505c 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -105,7 +105,7 @@ if (empty($reshook)) $result=$object->fetch($id); $object->code_compta=$_POST["customeraccountancycode"]; $result=$object->update($object->id,$user,1,1,0); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // conditions de reglement @@ -113,7 +113,7 @@ if (empty($reshook)) { $object->fetch($id); $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // mode de reglement @@ -121,7 +121,7 @@ if (empty($reshook)) { $object->fetch($id); $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int')); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // assujetissement a la TVA @@ -130,7 +130,7 @@ if (empty($reshook)) $object->fetch($id); $object->tva_assuj=$_POST['assujtva_value']; $result=$object->update($object->id); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // set prospect level @@ -157,7 +157,7 @@ if (empty($reshook)) $object->fetch($id); $object->outstanding_limit=GETPOST('outstanding_limit'); $result=$object->set_OutstandingBill($user); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } } diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 2a892033865..e54aeb1c8a5 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -359,7 +359,7 @@ if (empty($reshook)) { $statut=2; // Status 'sent partially' (because at least one error) if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); - else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); + else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); } else { diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 408d01d8eaa..1107e3b9b4d 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2014 Juanjo Menent - * Copyright (C) 2010-2011 Philippe Grand + * Copyright (C) 2010-2015 Philippe Grand * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013-2014 Florian Henry @@ -131,7 +131,7 @@ if (empty($reshook)) { if (! GETPOST('socid', 3)) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { @@ -141,7 +141,7 @@ if (empty($reshook)) header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); } else { - if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); + if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } @@ -157,7 +157,7 @@ if (empty($reshook)) exit(); } else { $langs->load("errors"); - setEventMessage($langs->trans($object->error), 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -211,8 +211,8 @@ if (empty($reshook)) } } else { $langs->load("errors"); - if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); - else setEventMessage($langs->trans($object->error), 'errors'); + if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); + else setEventMessages($langs->trans($object->error), null, 'errors'); } } @@ -318,7 +318,7 @@ if (empty($reshook)) $id = $object->create_from($user); } else { - setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors'); + setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors'); } } else { $object->ref = GETPOST('ref'); @@ -507,7 +507,7 @@ if (empty($reshook)) if ($result < 0) { $error++; - setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); + setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors'); } } @@ -671,7 +671,7 @@ if (empty($reshook)) if ($object->id > 0) { $result = $object->insert_discount($_POST["remise_id"]); if ($result < 0) { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -875,7 +875,7 @@ if (empty($reshook)) if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessage($mesg, 'errors'); + setEventMessages($mesg, null, 'errors'); } else { // Insert line $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit); @@ -929,13 +929,13 @@ if (empty($reshook)) } else { $db->rollback(); - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } } - // Mise a jour d'une ligne dans la propale + // Update a line within proposal else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save')) { // Define info_bits @@ -991,7 +991,7 @@ if (empty($reshook)) $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error ++; } } else { @@ -1040,7 +1040,7 @@ if (empty($reshook)) } else { $db->rollback(); - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -1137,9 +1137,9 @@ if (empty($reshook)) } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -1636,13 +1636,13 @@ if ($action == 'create') else if ($action == 'validate') { $error = 0; - // on verifie si l'objet est en numerotation provisoire + // We verifie whether the object is provisionally numbering $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { $numref = $object->getNextNumRef($soc); if (empty($numref)) { $error ++; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else { $numref = $object->ref; diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 6a0a1076e62..544c5ab27e3 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Patrick Rouillon * Copyright (C) 2005-2009 Destailleur Laurent * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011-2012 Philippe Grand + * Copyright (C) 2011-2015 Philippe Grand * * 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 @@ -54,12 +54,12 @@ if ($id > 0 || ! empty($ref)) if ($ret == 0) { $langs->load("errors"); - setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors'); + setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors'); $error++; } else if ($ret < 0) { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $error++; } } @@ -75,7 +75,7 @@ else /* - * Ajout d'un nouveau contact + * Add a new contact */ if ($action == 'addcontact' && $user->rights->propale->creer) @@ -96,16 +96,16 @@ if ($action == 'addcontact' && $user->rights->propale->creer) if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } -// Bascule du statut d'un contact +// Toggle the status of a contact else if ($action == 'swapstatut' && $user->rights->propale->creer) { if ($object->id > 0) @@ -114,7 +114,7 @@ else if ($action == 'swapstatut' && $user->rights->propale->creer) } } -// Efface un contact +// Deletes a contact else if ($action == 'deletecontact' && $user->rights->propale->creer) { $result = $object->delete_contact($lineid); diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index e472c5fb848..ba85d593fce 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -65,17 +65,17 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') if (! $res > 0) { $error++; - setEventMessage($langs->trans("ErrorFailedToLoadDiscount"), 'errors'); + setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors'); } if (! $error && price2num($_POST["amount_ttc_1"]+$_POST["amount_ttc_2"]) != $discount->amount_ttc) { $error++; - setEventMessage($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), 'errors'); + setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors'); } if (! $error && $discount->fk_facture_line) { $error++; - setEventMessage($langs->trans("ErrorCantSplitAUsedDiscount"), 'errors'); + setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors'); } if (! $error) { @@ -166,13 +166,13 @@ if ($action == 'setremise') else { $error++; - setEventMessage($soc->error, 'errors'); + setEventMessages($soc->error, $soc->errors, 'errors'); } } } else { - setEventMessage($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), 'errors'); + setEventMessages($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), null, 'errors'); } } @@ -194,7 +194,7 @@ if (GETPOST("action") == 'confirm_remove' && GETPOST("confirm")=='yes') } else { - setEventMessage($discount->error, 'errors'); + setEventMessages($discount->error, $discount->errors, 'errors'); $db->rollback(); } } @@ -216,7 +216,7 @@ if ($socid > 0) $object->fetch($socid); /* - * Affichage onglets + * Display tabs */ $head = societe_prepare_head($object); @@ -300,7 +300,7 @@ if ($socid > 0) } /* - * Liste remises fixes restant en cours (= liees a acune facture ni ligne de facture) + * Liste remises fixes restant en cours (= liees a aucune facture ni ligne de facture) */ $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; $sql.= " rc.datec as dc, rc.description,"; From 3906cb79c5bb49236721558c44d76ce48197bacf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Nov 2015 23:41:45 +0100 Subject: [PATCH 36/60] NEW: Add parameter to add a link to use "date of invoice" in one click when fille a payment card. --- htdocs/compta/facture/class/facture.class.php | 1 + htdocs/compta/paiement.php | 2 +- htdocs/core/class/html.form.class.php | 10 +++++++++- htdocs/fourn/facture/paiement.php | 8 ++++---- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ede68b39324..ca7afeb7959 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -63,6 +63,7 @@ class Facture extends CommonInvoice var $author; var $fk_user_author; var $fk_user_valid; + var $date; // Date invoice var $date_creation; // Creation date var $date_validation; // Validation date var $datem; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 7466686239a..8c028b23aaa 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -415,7 +415,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6c586ffe9b7..d64b9971a27 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4057,10 +4057,11 @@ class Form * @param int $disabled Disable input fields * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. + * @param datetime $adddateof Add a link "Date of invoice" using the following date. * @return mixed Nothing or string if nooutput is 1 * @see form_date */ - function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='') + function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='') { global $conf,$langs; @@ -4318,6 +4319,13 @@ class Form } } + // Add a "Plus one hour" link + if ($conf->use_javascript_ajax && $adddateof) + { + $tmparray=dol_getdate($adddateof); + $retstring.=' - '; print ''; print ''; print ''; @@ -304,7 +304,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (! empty($conf->banque->enabled)) { print ''; } else From 031b33d582588aa44c4aac329715f25cba45a3da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Nov 2015 23:54:11 +0100 Subject: [PATCH 37/60] FIX Checkbox reconciliated no correctly checked with some Chrome versions --- htdocs/compta/bank/ligne.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index f1bb4eb9a62..d210e209b59 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Xavier DUTOIT - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro @@ -587,7 +587,7 @@ if ($result) if ($user->rights->banque->consolidate) { print ''; } else From b5c9602da426b590429bb458780e180314a5c107 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Nov 2015 00:08:50 +0100 Subject: [PATCH 38/60] Fix Use new look for left-right arrow --- htdocs/compta/bank/releve.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 9620b00098b..cd8442114dc 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -282,9 +282,14 @@ else $found=true; } - $mesprevnext ="id\">".img_previous()."  "; - $mesprevnext.= $langs->trans("AccountStatement")." $num"; - $mesprevnext.="   id\">".img_next().""; + $mesprevnext=''; + $mesprevnext.=''; print load_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0),$mesprevnext, 'title_bank.png'); print '
'; From 24dff1d8424dbbfcf0edee34ebc0ca9d261928ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Nov 2015 00:35:30 +0100 Subject: [PATCH 39/60] NEW Statistic graphs on products offer a filter on product type (product / service or both) --- htdocs/core/menus/init_menu_auguria.sql | 4 +- htdocs/product/class/product.class.php | 59 ++++++++++++++++--------- htdocs/product/stats/card.php | 35 +++++++++------ 3 files changed, 61 insertions(+), 37 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index df0b9e46488..a75be746ad1 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -98,12 +98,12 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?leftmenu=product&type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?type=0', 'Stocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassortlot.php?type=0', 'StocksByLotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 5, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/popuprop.php?leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 6, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stats/card.php?id=all&leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 6, __ENTITY__); -- Product - Services insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?leftmenu=service&type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2901__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/card.php?leftmenu=service&action=create&type=1', 'NewService', 1, 'products', '$user->rights->service->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2902__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/list.php?leftmenu=service&type=1', 'List', 1, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/popuprop.php?leftmenu=stats&type=1', 'Statistics', 1, 'main', '$user->rights->service->lire', '', 2, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2903__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/stats/card.php?id=all&leftmenu=stats&type=1', 'Statistics', 1, 'main', '$user->rights->service->lire', '', 2, 5, __ENTITY__); -- Product - Stocks insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3100__+MAX_llx_menu__, 'products', 'stock', 3__+MAX_llx_menu__, '/product/stock/index.php?leftmenu=stock', 'Stock', 0, 'stocks', '$user->rights->stock->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3101__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/card.php?action=create', 'MenuNewWarehouse', 1, 'stocks', '$user->rights->stock->creer', '', 2, 0, __ENTITY__); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3b653f9d919..4594baab7a2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2193,11 +2193,12 @@ class Product extends CommonObject /** * Return nb of units or customers invoices in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_vente($socid,$mode) + function get_nb_vente($socid, $mode, $filteronproducttype=-1) { global $conf; global $user; @@ -2205,9 +2206,11 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.rowid = d.fk_facture"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.entity IN (".getEntity('facture', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2222,11 +2225,12 @@ class Product extends CommonObject /** * Return nb of units or supplier invoices in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_achat($socid,$mode) + function get_nb_achat($socid, $mode, $filteronproducttype=-1) { global $conf; global $user; @@ -2234,9 +2238,11 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.rowid = d.fk_facture_fourn"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.entity IN (".getEntity('facture_fourn', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2251,11 +2257,12 @@ class Product extends CommonObject /** * Return nb of units or proposals in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_propal($socid,$mode) + function get_nb_propal($socid, $mode, $filteronproducttype=-1) { global $conf; global $user; @@ -2263,9 +2270,11 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.rowid = d.fk_propal"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2279,20 +2288,23 @@ class Product extends CommonObject /** * Return nb of units or orders in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_order($socid,$mode) + function get_nb_order($socid, $mode, $filteronproducttype=-1) { global $conf, $user; $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = d.fk_commande"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2306,20 +2318,23 @@ class Product extends CommonObject /** * Return nb of units or orders in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_ordersupplier($socid,$mode) + function get_nb_ordersupplier($socid, $mode, $filteronproducttype=-1) { global $conf, $user; $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = d.fk_commande"; if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.entity IN (".getEntity('commande_fournisseur', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 33390e51a70..79d33b1d884 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -27,6 +27,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; @@ -204,19 +205,19 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') $graphfiles=array( 'propal' =>array('modulepart'=>'productstats_proposals', - 'file' => $object->id.'/propal12m.png', + 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsProposals"):$langs->transnoentitiesnoconv("NumberOfProposals"))), 'orders' =>array('modulepart'=>'productstats_orders', - 'file' => $object->id.'/orders12m.png', + 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders"):$langs->transnoentitiesnoconv("NumberOfCustomerOrders"))), 'invoices' =>array('modulepart'=>'productstats_invoices', - 'file' => $object->id.'/invoices12m.png', + 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices"):$langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))), 'orderssuppliers'=>array('modulepart'=>'productstats_orderssuppliers', - 'file' => $object->id.'/orderssuppliers12m.png', + 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders"):$langs->transnoentitiesnoconv("NumberOfSupplierOrders"))), 'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers', - 'file' => $object->id.'/invoicessuppliers12m.png', + 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices"):$langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))), ); @@ -233,13 +234,21 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') $graph_data = array(); - // TODO Test si deja existant et recent, on ne genere pas - if ($key == 'propal') $graph_data = $object->get_nb_propal($socid,$mode); - if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode); - if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode); - if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode); - if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid,$mode); - + if (dol_is_file($dir . '/' . $graphfiles[$key]['file'])) + { + // TODO Load cachefile $graphfiles[$key]['file'] + } + else + { + if ($key == 'propal') $graph_data = $object->get_nb_propal($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid,$mode,((string) $type != '' ? $type : -1)); + + // TODO Save cachefile $graphfiles[$key]['file'] + } + if (is_array($graph_data)) { $px->SetData($graph_data); @@ -312,7 +321,7 @@ if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') { print '
'; } - print ''; + print ''; print ''; print '
'.$langs->trans('Date').''; $datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment); - $form->select_date($datepayment,'','','',0,"add_paiement",1,1); + $form->select_date($datepayment,'','','',0,"add_paiement",1,1,0,0,'','',$facture->date); print ''.$langs->trans('Comments').'
'.$langs->trans('Date').''; - $form->select_date($dateinvoice,'','','','',"addpaiement",1,1); + $form->select_date($dateinvoice,'','','','',"addpaiement",1,1,0,0,'','',$object->date); print ''.$langs->trans('Comments').'
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements(empty($_POST['paiementid'])?'':$_POST['paiementid'],'paiementid'); + $form->select_types_paiements(empty($_POST['paiementid'])?$obj->fk_mode_reglement:$_POST['paiementid'],'paiementid'); print ''; print '
'.$langs->trans('Account').''; - $form->select_comptes(empty($accountid)?'':$accountid,'accountid',0,'',2); + $form->select_comptes(empty($accountid)?$obj->fk_account:$accountid,'accountid',0,'',2); print '
'; - print 'rappro?' checked':'')).'">'; + print 'rappro?' checked="checked"':'')).'">'; print ''.($mesg?''.$mesg.'':$langs->trans("ChartNotGenerated")).'id).'&action=recalcul&mode='.$mode.'">'.img_picto($langs->trans("ReCalculate"),'refresh').'id).((string) $type != ''?'&type='.$type:'').'&action=recalcul&mode='.$mode.'">'.img_picto($langs->trans("ReCalculate"),'refresh').'
'; From e350b759d3c420ad50f3d1d7ed29c66c9c68670e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Nov 2015 00:52:25 +0100 Subject: [PATCH 40/60] Increase number of last bank receits visible links --- htdocs/compta/bank/rappro.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index 2bafa7e780e..a8791177954 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -186,7 +186,7 @@ if ($resql) print '
'; // Show last bank receipts - $nbmax=5; + $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year) $liste=""; $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank"; $sql.= " WHERE fk_account=".$acct->id." AND num_releve IS NOT NULL"; From fa8863d2eac449b2105419f610afae5c84ef9d66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Nov 2015 01:38:03 +0100 Subject: [PATCH 41/60] Fix sql migration requests --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 3 +-- htdocs/install/mysql/tables/llx_budget_lines.key.sql | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 0705512893e..a846eeff889 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -235,13 +235,12 @@ create table llx_budget_lines import_key integer )ENGINE=innodb; -ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project); +ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project_ids); -- Supprime orphelins pour permettre montee de la cle -- MYSQL V4 DELETE llx_budget_lines FROM llx_budget_lines LEFT JOIN llx_budget ON llx_budget.rowid = llx_budget_lines.fk_budget WHERE llx_budget_lines.rowid IS NULL; -- POSTGRESQL V8 DELETE FROM llx_budget_lines USING llx_budget WHERE llx_budget_lines.fk_budget NOT IN (SELECT llx_budget.rowid FROM llx_budget); -ALTER TABLE llx_budget_lines ADD INDEX idx_budget_lines (fk_project); ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (fk_budget) REFERENCES llx_budget (rowid); diff --git a/htdocs/install/mysql/tables/llx_budget_lines.key.sql b/htdocs/install/mysql/tables/llx_budget_lines.key.sql index 9a9771570b1..b31e74b324d 100644 --- a/htdocs/install/mysql/tables/llx_budget_lines.key.sql +++ b/htdocs/install/mysql/tables/llx_budget_lines.key.sql @@ -17,11 +17,10 @@ -- =================================================================== -ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project); +ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project_ids); -- Supprime orphelins pour permettre montee de la cle -- MYSQL V4 DELETE llx_budget_lines FROM llx_budget_lines LEFT JOIN llx_budget ON llx_budget.rowid = llx_budget_lines.fk_budget WHERE llx_budget_lines.rowid IS NULL; -- POSTGRESQL V8 DELETE FROM llx_budget_lines USING llx_budget WHERE llx_budget_lines.fk_budget NOT IN (SELECT llx_budget.rowid FROM llx_budget); -ALTER TABLE llx_budget_lines ADD INDEX idx_budget_lines (fk_project); ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (fk_budget) REFERENCES llx_budget (rowid); From 7a423c04d4e32deb5bf7d1437aa893649188b72f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Nov 2015 02:00:28 +0100 Subject: [PATCH 42/60] Fix The only default value is value we just entered --- htdocs/compta/bank/rappro.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index a8791177954..332e7fffe60 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -226,7 +226,7 @@ if ($resql) print ''; print ''.$langs->trans("InputReceiptNumber").': '; - print ''; + print ''; // The only default value is value we just entered print '
'; if ($options) { From 333dd108747b65a8269e9fbb2087688f74c28ca1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Nov 2015 02:09:32 +0100 Subject: [PATCH 43/60] Add a way to lin on bank receipt tab directly --- htdocs/compta/bank/account.php | 27 +++++++++++----------- htdocs/compta/bank/class/account.class.php | 7 +++++- htdocs/compta/bank/releve.php | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index e3bc2a3fc2c..b9c0d3821bc 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -378,19 +378,6 @@ if ($id > 0 || ! empty($ref)) { print '
'; - if ($object->type != 2 && $object->rappro) - { - // If not cash account and can be reconciliate - if ($user->rights->banque->consolidate) - { - print ''.$langs->trans("Conciliate").''; - } - else - { - print ''.$langs->trans("Conciliate").''; - } - } - if ($action != 'addline') { if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) @@ -409,6 +396,20 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("AddBankRecord").''; } } + + if ($object->type != 2 && $object->rappro) + { + // If not cash account and can be reconciliate + if ($user->rights->banque->consolidate) + { + print ''.$langs->trans("Conciliate").''; + } + else + { + print ''.$langs->trans("Conciliate").''; + } + } + print '
'; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index e8978310ca3..65661b3cce8 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -998,7 +998,12 @@ class Account extends CommonObject $link = ''; + } + if ($withpicto) $result.=($link.img_object($label, 'account', 'class="classfortooltip"').$linkend.' '); $result.=$link.$this->label.$linkend; return $result; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index cd8442114dc..88defbd8b04 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -290,7 +290,7 @@ else //$mesprevnext.='   '; $mesprevnext.=''; $mesprevnext.=''; - print load_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0),$mesprevnext, 'title_bank.png'); + print load_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0, 'receipts'), $mesprevnext, 'title_bank.png'); print '
'; print ""; From 1d2dab63a34a5eeefabb49b42324fa6ac019de96 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Nov 2015 02:32:22 +0100 Subject: [PATCH 44/60] More space --- htdocs/compta/bank/releve.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 88defbd8b04..84c2edde0dd 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -157,6 +157,7 @@ if (empty($num)) } print ''; + print '

'; print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows); From 04243510f3996d62957d64ea5ac82b101454d6d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 8 Nov 2015 14:54:29 +0100 Subject: [PATCH 45/60] Little changes --- htdocs/product/class/product.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index be23fa6f06c..64068652ca9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4089,11 +4089,15 @@ class Product extends CommonObject return 1; } + /** + * Returns the rights used for this class + * @return stdClass + */ public function getRights() { global $user; - if ($this->isproduct()) { + if ($this->isProduct()) { return $user->rights->produit; } else { return $user->rights->service; From bd56396394bb235e9b8303cd9d197ba8838ece3f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Nov 2015 15:38:57 +0100 Subject: [PATCH 46/60] Fix migration error --- htdocs/core/class/html.form.class.php | 1 + htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 2 +- htdocs/install/mysql/tables/llx_categorie_project.key.sql | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d64b9971a27..393560b4640 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4533,6 +4533,7 @@ class Form $out=''; + // TODO Use an internal dolibarr component instead of select2 $outdelayed='