diff --git a/COPYRIGHT b/COPYRIGHT index c6a629c5c7a..1631f85d321 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -13,6 +13,7 @@ Component Version License GPL Compatible ------------------------------------------------------------------------------------- PHP libraries: AdoDb-Date 0.32 Modified BSD License Yes Date convertion (not into rpm package) +ChromePHP 4.3.3 Apache Software License 2.0 Yes Return server log to chrome browser console CKEditor 4.3.3 LGPL-2.1+ Yes Editor WYSIWYG FPDI 1.4.2 Apache Software License 2.0 Yes PDF templates management FPDF_TPL 1.2 Apache Software License 2.0 Yes PDF templates management diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index a64e3856dbc..fc7fbc74f4d 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -230,7 +230,7 @@ $sql.= ", entity"; $sql.= " FROM ".MAIN_DB_PREFIX."const"; $sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; if (empty($user->entity) && $debug) {} // to force for superadmin -elseif ($user->entity || empty($conf->multicompany->enabled)) $sql.= " AND visible = 1"; +else $sql.= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits $sql.= " ORDER BY entity, name ASC"; dol_syslog("Const::listConstant", LOG_DEBUG); @@ -280,7 +280,6 @@ if ($result) if ($conf->use_javascript_ajax) { print ''; - print '   '; } else { diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 18de8bf6bfc..c1fc11add9b 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -81,33 +81,32 @@ if ($action == 'set') { $db->begin(); - $activeModules = array(); + $newActiveModules = array(); $selectedModules = (isset($_POST['SYSLOG_HANDLERS']) ? $_POST['SYSLOG_HANDLERS'] : array()); - - foreach ($selectedModules as $syslogHandler) + //var_dump($selectedModules); + foreach ($syslogModules as $syslogHandler) { if (in_array($syslogHandler, $syslogModules)) { $module = new $syslogHandler; - if ($module->isActive()) + if (in_array($syslogHandler, $selectedModules)) $newActiveModules[] = $syslogHandler; + foreach ($module->configure() as $option) { - $activeModules[] = $syslogHandler; - - foreach ($module->configure() as $option) + if (isset($_POST[$option['constant']])) { - if ($_POST[$option['constant']]) - { - dolibarr_del_const($db, $option['constant'], 0); - dolibarr_set_const($db, $option['constant'], $_POST[$option['constant']], 'chaine',0, '', 0); - } + $_POST[$option['constant']] = trim($_POST[$option['constant']]); + dolibarr_del_const($db, $option['constant'], 0); + dolibarr_set_const($db, $option['constant'], $_POST[$option['constant']], 'chaine',0, '', 0); } } } } + $activeModules = $newActiveModules; dolibarr_set_const($db, 'SYSLOG_HANDLERS', json_encode($activeModules), 'chaine',0,'',0); + if (! $error) { $db->commit(); @@ -165,6 +164,9 @@ if ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->entity) $option = 'disabled="disabled"'; } + +//print "conf->global->MAIN_FEATURES_LEVEL = ".$conf->global->MAIN_FEATURES_LEVEL."

\n"; + // Output mode print_titre($langs->trans("SyslogOutput")); @@ -190,7 +192,7 @@ foreach ($syslogModules as $moduleName) $var=!$var; print ''; print ''; - print ' '; + print ' '; print $module->getName(); print ''; @@ -205,6 +207,7 @@ foreach ($syslogModules as $moduleName) else $value = (isset($option['default']) ? $option['default'] : ''); print $option['name'].': '; + if (! empty($option['example'])) print '
'.$langs->trans("Example").': '.$option['example']; } } print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 8e74c674084..67ba28b4e47 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -563,10 +563,12 @@ if (empty($reshook)) // Boucle sur chaque taux de tva $i = 0; foreach ($object->lines as $line) { - $amount_ht [$line->tva_tx] += $line->total_ht; - $amount_tva [$line->tva_tx] += $line->total_tva; - $amount_ttc [$line->tva_tx] += $line->total_ttc; - $i ++; + if($line->total_ht!=0) { // no need to create discount if amount is null + $amount_ht [$line->tva_tx] += $line->total_ht; + $amount_tva [$line->tva_tx] += $line->total_tva; + $amount_ttc [$line->tva_tx] += $line->total_ttc; + $i ++; + } } // Insert one discount by VAT rate category @@ -583,6 +585,7 @@ if (empty($reshook)) $discount->fk_facture_source = $object->id; $error = 0; + foreach ($amount_ht as $tva_tx => $xxx) { $discount->amount_ht = abs($amount_ht [$tva_tx]); $discount->amount_tva = abs($amount_tva [$tva_tx]); diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index b586241c11e..83ad1495a9f 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -22,7 +22,7 @@ /** * \file htdocs/compta/resultat/index.php - * \brief Page reporting resultat + * \brief Page reporting result */ require '../../main.inc.php'; @@ -570,8 +570,8 @@ print ''; print ''.$langs->trans("Month").''; for ($annee = $year_start ; $annee <= $year_end ; $annee++) { - print ''.$langs->trans("Outcome").''; - print ''.$langs->trans("Income").''; + print ''.$langs->trans("Outcome").''; + print ''.$langs->trans("Income").''; } print ''; @@ -634,7 +634,7 @@ print "\n"; // Balance $var=!$var; -print ''.$langs->trans("Profit").''; +print ''.$langs->trans("AccountingResult").''; for ($annee = $year_start ; $annee <= $year_end ; $annee++) { print ' '; diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index c2620fd34df..5d8dce0fd73 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -35,6 +35,7 @@ $langs->load("bills"); $langs->load("compta"); $langs->load("companies"); $langs->load("products"); +$langs->load("other"); // Date range $year=GETPOST("year"); diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 681448e901e..f551e92cb9d 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -41,6 +41,7 @@ $langs->load("bills"); $langs->load("compta"); $langs->load("companies"); $langs->load("products"); +$langs->load("other"); // Date range $year=GETPOST("year"); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 30c97e9f1ef..1c7c3ffb634 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -100,7 +100,7 @@ class ExtraFields * @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour') * @param int $pos Position of attribute * @param int $size Size/length of attribute - * @param string $elementtype Element type ('member', 'product', 'company', ...) + * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not * @param string $default_value Defaulted value @@ -113,6 +113,8 @@ class ExtraFields if (empty($attrname)) return -1; if (empty($label)) return -1; + if ($elementtype == 'thirdparty') $elementtype='societe'; + // Create field into database except for separator type which is not stored in database if ($type != 'separate') { @@ -145,7 +147,7 @@ class ExtraFields * @param string $attrname code of attribute * @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour') * @param int $length Size/length of attribute - * @param string $elementtype Element type ('member', 'product', 'company', 'contact', ...) + * @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not * @param string $default_value Default value for field @@ -155,6 +157,8 @@ class ExtraFields */ private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='') { + if ($elementtype == 'thirdparty') $elementtype='societe'; + $table=$elementtype.'_extrafields'; if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9_]*$/",$attrname) && ! is_numeric($attrname)) @@ -216,7 +220,7 @@ class ExtraFields * @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour', 'float') * @param int $pos Position of attribute * @param int $size Size/length of attribute - * @param string $elementtype Element type ('member', 'product', 'company', ...) + * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not * @param array||string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) ) @@ -227,6 +231,8 @@ class ExtraFields { global $conf; + if ($elementtype == 'thirdparty') $elementtype='societe'; + // Clean parameters if (empty($pos)) $pos=0; @@ -277,11 +283,13 @@ class ExtraFields * Delete an optional attribute * * @param string $attrname Code of attribute to delete - * @param string $elementtype Element type ('member', 'product', 'company', 'contact', ...) + * @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...) * @return int < 0 if KO, 0 if nothing is done, 1 if OK */ function delete($attrname, $elementtype='member') { + if ($elementtype == 'thirdparty') $elementtype='societe'; + $table=$elementtype.'_extrafields'; if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) @@ -307,13 +315,15 @@ class ExtraFields * Delete description of an optional attribute * * @param string $attrname Code of attribute to delete - * @param string $elementtype Element type ('member', 'product', 'company', ...) + * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) * @return int < 0 if KO, 0 if nothing is done, 1 if OK */ private function delete_label($attrname, $elementtype='member') { global $conf; + if ($elementtype == 'thirdparty') $elementtype='societe'; + if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; @@ -347,7 +357,7 @@ class ExtraFields * @param string $label Label of attribute * @param string $type Type of attribute * @param int $length Length of attribute - * @param string $elementtype Element type ('member', 'product', 'company', 'contact', ...) + * @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not * @param int $pos Position of attribute @@ -357,6 +367,8 @@ class ExtraFields */ function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0) { + if ($elementtype == 'thirdparty') $elementtype='societe'; + $table=$elementtype.'_extrafields'; if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) @@ -433,7 +445,7 @@ class ExtraFields * @param string $label Label of attribute * @param string $type Type of attribute * @param int $size Length of attribute - * @param string $elementtype Element type ('member', 'product', 'company', ...) + * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not * @param int $pos Position of attribute @@ -446,6 +458,8 @@ class ExtraFields global $conf; dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required); + if ($elementtype == 'thirdparty') $elementtype='societe'; + if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { $this->db->begin(); @@ -513,7 +527,7 @@ class ExtraFields /** * Load array this->attribute_xxx like attribute_label, attribute_type, ... * - * @param string $elementtype Type of element ('adherent', 'commande', societe', 'facture', 'propal', 'product', ...) + * @param string $elementtype Type of element ('adherent', 'commande', thirdparty', 'facture', 'propal', 'product', ...) * @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED * @return array Array of attributes for all extra fields */ @@ -521,6 +535,8 @@ class ExtraFields { global $conf; + if ($elementtype == 'thirdparty') $elementtype='societe'; + $array_name_label=array(); // For avoid conflicts with external modules diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 95436a51e29..dc844ee3f02 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -176,7 +176,10 @@ class Ldap if (is_resource($this->connection)) { + // Execute the ldap_set_option here (after connect and before bind) $this->setVersion(); + ldap_set_option($this->connection, LDAP_OPT_SIZELIMIT, 0); // no limit here. should return true. + if ($this->serverType == "activedirectory") { diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 7381fd77b93..58e79da87b9 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Yann Droneaud * Copyright (C) 2012 Florian Henry + * 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 @@ -255,7 +256,7 @@ class DoliDBPgsql extends DoliDB $newreg3=preg_replace('/ NOT NULL/i','',$newreg3); $newreg3=preg_replace('/ NULL/i','',$newreg3); $newreg3=preg_replace('/ DEFAULT 0/i','',$newreg3); - $newreg3=preg_replace('/ DEFAULT \'[0-9a-zA-Z_@]*\'/i','',$newreg3); + $newreg3=preg_replace('/ DEFAULT \'?[0-9a-zA-Z_@]*\'?/i','',$newreg3); $line.= "ALTER TABLE ".$reg[1]." ALTER COLUMN ".$reg[2]." TYPE ".$newreg3; // TODO Add alter to set default value or null/not null if there is this in $reg[3] } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 741dd98de6d..1aea8f9e37b 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -57,11 +57,6 @@ function product_prepare_head($object, $user) $h++; } - $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id; - $head[$h][1] = $langs->trans("Photos"); - $head[$h][2] = 'photos'; - $h++; - // Show category tab if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { @@ -116,14 +111,19 @@ function product_prepare_head($object, $user) // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf,$langs,$object,$head,$h,'product'); - // Attachments + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id; + $head[$h][1] = $langs->trans("Photos"); + $head[$h][2] = 'photos'; + $h++; + + // Attachments require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if($nbFiles > 0) $head[$h][1].= ' ('.$nbFiles.')'; + if($nbFiles > 0) $head[$h][1].= ' '.$nbFiles.''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/modules/syslog/mod_syslog_chromephp.php b/htdocs/core/modules/syslog/mod_syslog_chromephp.php index 06d37dfa431..b2520d27d7b 100644 --- a/htdocs/core/modules/syslog/mod_syslog_chromephp.php +++ b/htdocs/core/modules/syslog/mod_syslog_chromephp.php @@ -42,7 +42,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface /** * Is the module active ? * - * @return boolean + * @return int */ public function isActive() { @@ -51,8 +51,13 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface { if (empty($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH)) $conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH='/usr/share/php'; set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH); - $res = @include_once 'ChromePhp.class.php'; + + //print 'rrrrr'.get_include_path(); + $res = include_once('ChromePhp.php'); + if (! $res) $res=@include_once('ChromePhp.class.php'); + restore_include_path(); + if ($res) { return 1; @@ -77,10 +82,11 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface return array( array( - 'name' => $langs->trans('IncludePath'), + 'name' => $langs->trans('IncludePath','SYSLOG_CHROMEPHP_INCLUDEPATH'), 'constant' => 'SYSLOG_CHROMEPHP_INCLUDEPATH', 'default' => '/usr/share/php', - 'attr' => 'size="40"' + 'attr' => 'size="60"', + 'example' => DOL_DOCUMENT_ROOT.'/includes/chromephp' ) ); } @@ -88,24 +94,19 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface /** * Return if configuration is valid * - * @return boolean True if configuration ok + * @return array Array of errors. Empty array if ok. */ public function checkConfiguration() { - global $langs; + global $langs,$conf; $errors = array(); - $oldinclude = get_include_path(); - set_include_path(SYSLOG_CHROMEPHP_INCLUDEPATH); - - if (!file_exists('ChromePhp.class.php')) + if (! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.php') && ! file_exists($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH.'/ChromePhp.class.php')) { - $errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php'); + $errors[] = $langs->trans("ErrorFailedToOpenFile", 'ChromePhp.class.php or ChromePhp.php'); } - set_include_path($oldinclude); - return $errors; } @@ -122,16 +123,18 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface if (! empty($conf->global->MAIN_SYSLOG_DISABLE_CHROMEPHP)) return; // Global option to disable output of this handler //We check the configuration to avoid showing PHP warnings - if (count($this->checkConfiguration())) return false; + if (count($this->checkConfiguration()) > 0) return false; try { // Warning ChromePHP must be into PHP include path. It is not possible to use into require_once() a constant from // database or config file because we must be able to log data before database or config file read. $oldinclude=get_include_path(); - set_include_path(SYSLOG_CHROMEPHP_INCLUDEPATH); - include_once 'ChromePhp.class.php'; + set_include_path($conf->global->SYSLOG_CHROMEPHP_INCLUDEPATH); + $res = @include_once('ChromePhp.php'); + if (! $res) $res=@include_once('ChromePhp.class.php'); set_include_path($oldinclude); + ob_start(); // To be sure headers are not flushed until all page is completely processed if ($content['level'] == LOG_ERR) ChromePhp::error($content['message']); elseif ($content['level'] == LOG_WARNING) ChromePhp::warn($content['message']); diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index 331b7331194..92d2302bea7 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -45,11 +45,11 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface /** * Is the module active ? * - * @return boolean + * @return int */ public function isActive() { - return true; + return 1; } /** @@ -74,7 +74,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface /** * Return if configuration is valid * - * @return boolean True if configuration ok + * @return array Array of errors. Empty array if ok. */ public function checkConfiguration() { diff --git a/htdocs/core/modules/syslog/mod_syslog_firephp.php b/htdocs/core/modules/syslog/mod_syslog_firephp.php index 31a3fb13431..31addd8b17a 100644 --- a/htdocs/core/modules/syslog/mod_syslog_firephp.php +++ b/htdocs/core/modules/syslog/mod_syslog_firephp.php @@ -42,7 +42,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface /** * Is the module active ? * - * @return boolean + * @return int */ public function isActive() { @@ -53,7 +53,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface restore_include_path(); if ($res) { - return true; + return 1; } } catch(Exception $e) @@ -61,7 +61,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface print ''."\n"; } - return false; + return -1; } ///** @@ -86,7 +86,7 @@ class mod_syslog_firephp extends LogHandler implements LogHandlerInterface /** * Return if configuration is valid * - * @return boolean True if configuration ok + * @return array Array of errors. Empty array if ok. */ public function checkConfiguration() { diff --git a/htdocs/core/modules/syslog/mod_syslog_syslog.php b/htdocs/core/modules/syslog/mod_syslog_syslog.php index 58ac241695c..2043225857b 100644 --- a/htdocs/core/modules/syslog/mod_syslog_syslog.php +++ b/htdocs/core/modules/syslog/mod_syslog_syslog.php @@ -42,14 +42,14 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface /** * Is the module active ? * - * @return boolean + * @return int */ public function isActive() { // This function does not exists on some ISP (Ex: Free in France) - if (!function_exists('openlog')) return false; + if (!function_exists('openlog')) return 0; - return true; + return 1; } /** @@ -73,7 +73,7 @@ class mod_syslog_syslog extends LogHandler implements LogHandlerInterface /** * Return if configuration is valid * - * @return boolean True if configuration ok + * @return array Array of errors. Empty array if ok. */ public function checkConfiguration() { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index f3e752ed9d4..26aeffad655 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1270,14 +1270,14 @@ if ($action == 'create') print ''.$langs->trans('Supplier').''; print ''; - if ($_REQUEST['socid'] > 0) + if (GETPOST('socid') > 0) { print $societe->getNomUrl(1); - print ''; + print ''; } else { - print $form->select_company((empty($_GET['socid'])?'':$_GET['socid']),'socid','s.fournisseur = 1',1); + print $form->select_company(GETPOST('socid','int'),'socid','s.fournisseur = 1',1); } print ''; @@ -1392,12 +1392,13 @@ if ($action == 'create') print ''; // Project - if (! empty($conf->projet->enabled)) { + if (! empty($conf->projet->enabled)) + { $formproject = new FormProjets($db); $langs->load('projects'); print '' . $langs->trans('Project') . ''; - $formproject->select_projects($soc->id, $projectid, 'projectid'); + $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$soc->id:-1), $projectid, 'projectid'); print ''; } diff --git a/htdocs/includes/chromephp/ChromePhp.php b/htdocs/includes/chromephp/ChromePhp.php new file mode 100644 index 00000000000..577b1cecb9d --- /dev/null +++ b/htdocs/includes/chromephp/ChromePhp.php @@ -0,0 +1,446 @@ + + */ +class ChromePhp +{ + /** + * @var string + */ + const VERSION = '4.1.0'; + + /** + * @var string + */ + const HEADER_NAME = 'X-ChromeLogger-Data'; + + /** + * @var string + */ + const BACKTRACE_LEVEL = 'backtrace_level'; + + /** + * @var string + */ + const LOG = 'log'; + + /** + * @var string + */ + const WARN = 'warn'; + + /** + * @var string + */ + const ERROR = 'error'; + + /** + * @var string + */ + const GROUP = 'group'; + + /** + * @var string + */ + const INFO = 'info'; + + /** + * @var string + */ + const GROUP_END = 'groupEnd'; + + /** + * @var string + */ + const GROUP_COLLAPSED = 'groupCollapsed'; + + /** + * @var string + */ + const TABLE = 'table'; + + /** + * @var string + */ + protected $_php_version; + + /** + * @var int + */ + protected $_timestamp; + + /** + * @var array + */ + protected $_json = array( + 'version' => self::VERSION, + 'columns' => array('log', 'backtrace', 'type'), + 'rows' => array() + ); + + /** + * @var array + */ + protected $_backtraces = array(); + + /** + * @var bool + */ + protected $_error_triggered = false; + + /** + * @var array + */ + protected $_settings = array( + self::BACKTRACE_LEVEL => 1 + ); + + /** + * @var ChromePhp + */ + protected static $_instance; + + /** + * Prevent recursion when working with objects referring to each other + * + * @var array + */ + protected $_processed = array(); + + /** + * constructor + */ + private function __construct() + { + $this->_php_version = phpversion(); + $this->_timestamp = $this->_php_version >= 5.1 ? $_SERVER['REQUEST_TIME'] : time(); + $this->_json['request_uri'] = $_SERVER['REQUEST_URI']; + } + + /** + * gets instance of this class + * + * @return ChromePhp + */ + public static function getInstance() + { + if (self::$_instance === null) { + self::$_instance = new self(); + } + return self::$_instance; + } + + /** + * logs a variable to the console + * + * @param mixed $data,... unlimited OPTIONAL number of additional logs [...] + * @return void + */ + public static function log() + { + $args = func_get_args(); + return self::_log('', $args); + } + + /** + * logs a warning to the console + * + * @param mixed $data,... unlimited OPTIONAL number of additional logs [...] + * @return void + */ + public static function warn() + { + $args = func_get_args(); + return self::_log(self::WARN, $args); + } + + /** + * logs an error to the console + * + * @param mixed $data,... unlimited OPTIONAL number of additional logs [...] + * @return void + */ + public static function error() + { + $args = func_get_args(); + return self::_log(self::ERROR, $args); + } + + /** + * sends a group log + * + * @param string value + */ + public static function group() + { + $args = func_get_args(); + return self::_log(self::GROUP, $args); + } + + /** + * sends an info log + * + * @param mixed $data,... unlimited OPTIONAL number of additional logs [...] + * @return void + */ + public static function info() + { + $args = func_get_args(); + return self::_log(self::INFO, $args); + } + + /** + * sends a collapsed group log + * + * @param string value + */ + public static function groupCollapsed() + { + $args = func_get_args(); + return self::_log(self::GROUP_COLLAPSED, $args); + } + + /** + * ends a group log + * + * @param string value + */ + public static function groupEnd() + { + $args = func_get_args(); + return self::_log(self::GROUP_END, $args); + } + + /** + * sends a table log + * + * @param string value + */ + public static function table() + { + $args = func_get_args(); + return self::_log(self::TABLE, $args); + } + + /** + * internal logging call + * + * @param string $type + * @return void + */ + protected static function _log($type, array $args) + { + // nothing passed in, don't do anything + if (count($args) == 0 && $type != self::GROUP_END) { + return; + } + + $logger = self::getInstance(); + + $logger->_processed = array(); + + $logs = array(); + foreach ($args as $arg) { + $logs[] = $logger->_convert($arg); + } + + $backtrace = debug_backtrace(false); + $level = $logger->getSetting(self::BACKTRACE_LEVEL); + + $backtrace_message = 'unknown'; + if (isset($backtrace[$level]['file']) && isset($backtrace[$level]['line'])) { + $backtrace_message = $backtrace[$level]['file'] . ' : ' . $backtrace[$level]['line']; + } + + $logger->_addRow($logs, $backtrace_message, $type); + } + + /** + * converts an object to a better format for logging + * + * @param Object + * @return array + */ + protected function _convert($object) + { + // if this isn't an object then just return it + if (!is_object($object)) { + return $object; + } + + //Mark this object as processed so we don't convert it twice and it + //Also avoid recursion when objects refer to each other + $this->_processed[] = $object; + + $object_as_array = array(); + + // first add the class name + $object_as_array['___class_name'] = get_class($object); + + // loop through object vars + $object_vars = get_object_vars($object); + foreach ($object_vars as $key => $value) { + + // same instance as parent object + if ($value === $object || in_array($value, $this->_processed, true)) { + $value = 'recursion - parent object [' . get_class($value) . ']'; + } + $object_as_array[$key] = $this->_convert($value); + } + + $reflection = new ReflectionClass($object); + + // loop through the properties and add those + foreach ($reflection->getProperties() as $property) { + + // if one of these properties was already added above then ignore it + if (array_key_exists($property->getName(), $object_vars)) { + continue; + } + $type = $this->_getPropertyKey($property); + + if ($this->_php_version >= 5.3) { + $property->setAccessible(true); + } + + try { + $value = $property->getValue($object); + } catch (ReflectionException $e) { + $value = 'only PHP 5.3 can access private/protected properties'; + } + + // same instance as parent object + if ($value === $object || in_array($value, $this->_processed, true)) { + $value = 'recursion - parent object [' . get_class($value) . ']'; + } + + $object_as_array[$type] = $this->_convert($value); + } + return $object_as_array; + } + + /** + * takes a reflection property and returns a nicely formatted key of the property name + * + * @param ReflectionProperty + * @return string + */ + protected function _getPropertyKey(ReflectionProperty $property) + { + $static = $property->isStatic() ? ' static' : ''; + if ($property->isPublic()) { + return 'public' . $static . ' ' . $property->getName(); + } + + if ($property->isProtected()) { + return 'protected' . $static . ' ' . $property->getName(); + } + + if ($property->isPrivate()) { + return 'private' . $static . ' ' . $property->getName(); + } + } + + /** + * adds a value to the data array + * + * @var mixed + * @return void + */ + protected function _addRow(array $logs, $backtrace, $type) + { + // if this is logged on the same line for example in a loop, set it to null to save space + if (in_array($backtrace, $this->_backtraces)) { + $backtrace = null; + } + + // for group, groupEnd, and groupCollapsed + // take out the backtrace since it is not useful + if ($type == self::GROUP || $type == self::GROUP_END || $type == self::GROUP_COLLAPSED) { + $backtrace = null; + } + + if ($backtrace !== null) { + $this->_backtraces[] = $backtrace; + } + + $row = array($logs, $backtrace, $type); + + $this->_json['rows'][] = $row; + $this->_writeHeader($this->_json); + } + + protected function _writeHeader($data) + { + header(self::HEADER_NAME . ': ' . $this->_encode($data)); + } + + /** + * encodes the data to be sent along with the request + * + * @param array $data + * @return string + */ + protected function _encode($data) + { + return base64_encode(utf8_encode(json_encode($data))); + } + + /** + * adds a setting + * + * @param string key + * @param mixed value + * @return void + */ + public function addSetting($key, $value) + { + $this->_settings[$key] = $value; + } + + /** + * add ability to set multiple settings in one call + * + * @param array $settings + * @return void + */ + public function addSettings(array $settings) + { + foreach ($settings as $key => $value) { + $this->addSetting($key, $value); + } + } + + /** + * gets a setting + * + * @param string key + * @return mixed + */ + public function getSetting($key) + { + if (!isset($this->_settings[$key])) { + return null; + } + return $this->_settings[$key]; + } +} diff --git a/htdocs/includes/chromephp/README.md b/htdocs/includes/chromephp/README.md new file mode 100644 index 00000000000..3dd7dbe19dd --- /dev/null +++ b/htdocs/includes/chromephp/README.md @@ -0,0 +1,23 @@ +## Overview +ChromePhp is a PHP library for the Chrome Logger Google Chrome extension. + +This library allows you to log variables to the Chrome console. + +## Requirements +- PHP 5 or later + +## Installation +1. Install the Chrome extension from: https://chrome.google.com/extensions/detail/noaneddfkdjfnfdakjjmocngnfkfehhd +2. Click the extension icon in the browser to enable it for the current tab's domain +3. Put ChromePhp.php somewhere in your PHP include path +4. Log some data + + ```php + include 'ChromePhp.php'; + ChromePhp::log('Hello console!'); + ChromePhp::log($_SERVER); + ChromePhp::warn('something went wrong!'); + ``` + +More information can be found here: +http://www.chromelogger.com diff --git a/htdocs/includes/chromephp/composer.json b/htdocs/includes/chromephp/composer.json new file mode 100644 index 00000000000..dc16853d3ec --- /dev/null +++ b/htdocs/includes/chromephp/composer.json @@ -0,0 +1,24 @@ +{ + "name": "ccampbell/chromephp", + "type": "library", + "description": "Log variables to the Chrome console (via Chrome Logger Google Chrome extension).", + "keywords": ["log","logging"], + "homepage": "http://github.com/ccampbell/chromephp", + "license": "Apache-2.0", + "authors": [ + { + "name": "Craig Campbell", + "email": "iamcraigcampbell@gmail.com", + "homepage": "http://craig.is", + "role": "Developer" + } + ], + "require": { + "php": ">=5.0.0" + }, + "autoload": { + "psr-0": { + "ChromePhp": "" + } + } +} diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d262b835794..59579237d33 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1558,3 +1558,4 @@ SalariesSetup=Setup of module salaries SortOrder=Sort order Format=Format TypePaymentDesc=0:Customer payment type, 1:Supplier payment type, 2:Both customers and suppliers payment type +IncludePath=Include path (defined into variable %s) \ No newline at end of file diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 89a32876dc3..116b2c52fa8 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -29,6 +29,7 @@ ReportTurnover=Turnover PaymentsNotLinkedToInvoice=Payments not linked to any invoice, so not linked to any third party PaymentsNotLinkedToUser=Payments not linked to any user Profit=Profit +AccountingResult=Accounting result Balance=Balance Debit=Debit Credit=Credit diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ba179aef616..0778046c431 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3101,10 +3101,14 @@ class Product extends CommonObject */ function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120) { + global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $result = 0; - $dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/photos"; + + $dir = $sdir; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos"; dol_mkdir($dir); @@ -3156,8 +3160,8 @@ class Product extends CommonObject { include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; - $pdir = get_exdir($this->id,2) . $this->id ."/photos/"; - $dir = $sdir . '/'. $pdir; + $dir = $sdir; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos"; $nbphoto=0; @@ -3199,8 +3203,19 @@ class Product extends CommonObject include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; - $pdir = get_exdir($this->id,2) . $this->id ."/photos/"; - $dir = $sdir . '/'. $pdir; + $dir = $sdir . '/'; + $pdir = '/'; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $dir .= get_exdir($this->id,2) . $this->id ."/photos/"; + $pdir .= get_exdir($this->id,2) . $this->id ."/photos/"; + } + else + { + $dir .= $this->ref.'/'; + $pdir .= $this->ref.'/'; + } + $dirthumb = $dir.'thumbs/'; $pdirthumb = $pdir.'thumbs/'; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d738256e7d4..5c54cae4174 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -768,9 +768,9 @@ class Project extends CommonObject if ($statut == 0) return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); if ($statut == 1) - return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut1'); + return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); if ($statut == 2) - return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6') . ' ' . $langs->trans($this->statuts_short[$statut]); + return $langs->trans($this->statuts_short[$statut]) . ' ' . img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); } } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index b4260e8ea91..d52ba362532 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -198,7 +198,7 @@ if ($resql) // Status $projectstatic->statut = $objp->fk_statut; - print ''.$projectstatic->getLibStatut(3).''; + print ''.$projectstatic->getLibStatut(5).''; print "\n"; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 850b76bd3b3..1b69fd5757e 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -133,8 +133,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) } else { - setEventMessage($task->error,'errors'); - setEventMessage($task->errors,'errors'); + setEventMessages($task->error,$task->errors,'errors'); } } @@ -150,6 +149,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) header("Location: ".DOL_URL_ROOT.'/projet/tasks/index.php'.(empty($mode)?'':'?mode='.$mode)); exit; } + $id = $projectid; } } else @@ -168,9 +168,10 @@ if ($action == 'createtask' && $user->rights->projet->creer) } } + /* * View -*/ + */ $form=new Form($db); $formother=new FormOther($db);