diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a13037402f8..19c076242f8 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -115,12 +115,14 @@ Also, some code changes need a prior approbation: Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR. +If the label of PR start with "WIP" (Work In Progress), it will not be analyzed (until you change the label of PR). + If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration. If the PR is valid, and is kept open for a long time, a tag will also be added on the PR to describe the status of your PR and why the PR is kept open. By putting your mouse on the tag, you will get a full explanation of the tag/status that explain why your PR has not been integrated yet. -In most cases, it give you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the flag ask you. The majority of PR are waiting a developer action. +In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the flag ask you. The majority of PR are waiting an action of the developer/author. -Around 95% of submitted PR are reviewed and tagged. Even if this is one of the most important ratio of answered PR in Open Source world, don't expect the core team to reach the 100%. With the increasing popularity of Dolibarr, this ratio will probably decrease in future. +Statistics on Dolibarr project shows that around 95% of submitted PR are reviewed and tagged. This is one of the most important ratio of answered PR in Open Source world. Don't expect the core team to reach the 100%. With the increasing popularity of Dolibarr, this ratio will probably decrease in future. ### Resources diff --git a/.travis.yml b/.travis.yml index b710e17c773..1521035578b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -288,7 +288,7 @@ script: # Ensure we catch errors set -e #parallel-lint --exclude htdocs/includes --blame . - parallel-lint --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer/tests --exclude htdocs/includes/jakub-onderka/php-parallel-lint/tests --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/php-token-stream/tests --exclude htdocs/includes/composer/autoload_static.php --blame . + parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer/tests --exclude htdocs/includes/jakub-onderka/php-parallel-lint/tests --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/php-token-stream/tests --exclude htdocs/includes/composer/autoload_static.php --blame . set +e echo diff --git a/ChangeLog b/ChangeLog index 0839fd77e95..6ca4df10d38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,116 @@ Following changes may create regressions for some external modules, but were nec * Properties ->libelle_incoterms were renamed into ->label_incoterms * Removed the method liste_array() of project class. It was not used by core code. * The function show_theme() hase been renamed into showSkins() +* Rename 'module_part' parameter into 'modulepart' into document APIs, for consistency. + + +***** ChangeLog for 10.0.1 compared to 10.0.0 ***** +FIX: #10930 +FIX: #10984 +FIX: reposition on "Build backup" button +FIX: #11400 +FIX: #11412 +FIX: #11460 +FIX: #11463 +FIX: #11466 +FIX: #11492 +FIX: #11498 +FIX: #11505 +FIX: #11506 +FIX: #11507 +FIX: #11509 +FIX: #11537 +FIX: #11543 +FIX: #11553 +FIX: #11576 +FIX: #11584 +FIX: #11590 +FIX: accounting mode must be taken from global conf, because there's no way to choose a mode with interface +FIX: Add message from public interface +FIX: add missing hook calls +FIX: Add warning when setup is strange +FIX: ajax call for line positioning when CSRFCHECK_WITH_TOKEN is on +FIX: API return 404 sometimes even if API exists +FIX: Attachment was lost when we validate an expense report +FIX: avoid conflict with "$classname" in card.php +FIX: Bad sql request +FIX: better compatibility with multicompany transverse mode +FIX: Better PHP compatibility +FIX: Block to link with tickets +FIX: Can't submit a ticket from public interface +FIX: categories import: prevent mismatch between category type and object type +FIX: Closing ticket from public interface +FIX: Column 'paid' missing in expense report +FIX: compatibility mysql 8. rank is reserved +FIX: Computed field were not calculated into lists. +FIX: Content of email for subscription +FIX: correct error in files with multiple spaces +FIX: CVE-2019-11199 +FIX: delete of links between objects +FIX: div not balanced +FIX: do not return formatted prices in json string +FIX: duplicate on the check (TODO field $onetrtd not used ?) +FIX: element name in update_price +FIX: empty product_use_units in product configuration +FIX: expedition card: infinite loop for printObjectLine hook if return > 0 +FIX: extrafield loading bug due to assumption that an object is a third party while it may be a contact if MAIN_USE_COMPANY_NAME_OF_CONTACT is set. +FIX: Fatal error on dol_htmloutput_mesg with corrupted array +FIX: Fatal situation if payment removed on expense report. Action +FIX: FEC Format - Missing date_creation in general ledger when you add a new transaction +FIX: FEC Format - Save translation of the journal label in database & nowrap on amount +FIX: floating point precision errors in the triggers of the workflow module +FIX: for #11232 +FIX: format of field with type timestamp +FIX: fournrprice log for insert +FIX: help text +FIX: import filter error +FIX: __INFOS__ tag not exists +FIX: issue #9300: install error with PostgreSQL when using custom table prefix +FIX: Language key +FIX: Limit of uploaded files (max_post_size was not used) +FIX: list of balance of leaves +FIX: minor spelling issues +FIX: missing "dropdown-icon" replacement +FIX: Missing field "Conciliated" into bank transaction export +FIX: missing filter by current contact +FIX: missing token +FIX: Missing where on entity +FIX: move sql request in INNER JOIN +FIX: name was able to be in field but went back to new line +FIX: Nowrap on amount +FIX: Online payment +FIX: on shipment delete confirm dialog, a new checkbox allows the user to choose if they want their stock re-incremented after the deletion. +FIX: option EXPORT_LABEL_FOR_SELECT to restore compatibility in export +FIX: Option THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION +FIX: outdated phpdoc +FIX: Permission for BOM menu +FIX: permission to delete a draft purchase order +FIX: phpcs +FIX: Position was lost when we edit the line of template invoice +FIX: product_use_units was set to 0 each time a conf in block other was set +FIX: propal createFrom hook: undefined parameter attached +FIX: Responsive of public interface of ticket +FIX: search by phone pro +FIX: Setup of TakePos was not possible after a clean install +FIX: Show list of events on tickets +FIX: socpeople assigned list in action com list +FIX: SQL problem on donation & nowrap on amount +FIX: stock increase on shipment deletion if STOCK_CALCULATE_ON_SHIPMENT_NEW: is set +FIX: stripe webhook ID constant set +FIX: summary of time spent in preview tab of projects +FIX: the feature to bill time spent was not enabled. +FIX: The new feature to attach document on lines was not correclty +FIX: The proposed new supplier code does not work +FIX: this function can not be private +FIX: tk9877 - PDF rouget requires product.lib.php (otherwise measuring_units_string() is not defined) +FIX: Update the file index table when we validate/rename a ref. +FIX: use rounding to compare the amounts +FIX: We must save code instead of value in database for template invoice modelpdf +FIX: we need to be able to add freeline with qty between 0 & 1 in supplierorder line +FIX: We should remove property comments only for project and task api. +FIX: When saving an action it didn't save the label based on the type of event if the label is empty and the type is customized +FIX: when STOCK_CALCULATE_ON_SHIPMENT_NEW: is set, deleting a "closed" shipment now increases stock as expected +FIX: wrong path sociales/index.php doesnt exist anymore ***** ChangeLog for 10.0.1 compared to 10.0.0 ***** diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000000..e5493805733 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Supported Versions + +| Version | Supported | +| -------- | ------------------ | +| <= 8.0.* | :x: | +| >= 9.0.* | :white_check_mark: | + +## Reporting a Vulnerability + +To report a vulnerability, please send an email to security@dolibarr.org +In most cases, after fixing the security, we make an answer by email to say the issue has been fixed. diff --git a/build/exe/doliwamp/php.ini.install b/build/exe/doliwamp/php.ini.install index 04191a71f5a..af8ef607112 100644 --- a/build/exe/doliwamp/php.ini.install +++ b/build/exe/doliwamp/php.ini.install @@ -458,16 +458,6 @@ variables_order = "GPCS" ; with user data. This makes most sense when coupled with track_vars - in which ; case you can access all of the GPC variables through the $HTTP_*_VARS[], ; variables. -; -; You should do your best to write your scripts so that they do not require -; register_globals to be on; Using form variables as globals can easily lead -; to possible security problems, if the code is not very well thought of. -register_globals = Off - -; Whether or not to register the old-style input arrays, HTTP_GET_VARS -; and friends. If you're not using them, it's recommended to turn them off, -; for performance reasons. -register_long_arrays = Off ; This directive tells PHP whether to declare the argv&argc variables (that ; would contain the GET information). If you don't use these variables, you @@ -477,8 +467,7 @@ register_argc_argv = Off ; When enabled, the SERVER and ENV variables are created when they're first ; used (Just In Time) instead of when the script starts. If these variables ; are not used within a script, having this directive on will result in a -; performance gain. The PHP directives register_globals, register_long_arrays, -; and register_argc_argv must be disabled for this directive to have any affect. +; performance gain. auto_globals_jit = On ; Maximum size of POST data that PHP will accept. @@ -1101,14 +1090,6 @@ session.gc_maxlifetime = 1800 ; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): ; cd /path/to/sessions; find -cmin +24 | xargs rm -; PHP 4.2 and less have an undocumented feature/bug that allows you to -; to initialize a session variable in the global scope, albeit register_globals -; is disabled. PHP 4.3 and later will warn you, if this feature is used. -; You can disable the feature and the warning separately. At this time, -; the warning is only displayed, if bug_compat_42 is enabled. - -session.bug_compat_42 = 0 -session.bug_compat_warn = 1 ; Check HTTP Referer to invalidate externally stored URLs containing ids. ; HTTP_REFERER has to contain this substring for the session to be diff --git a/build/rpm/httpd-dolibarr.conf b/build/rpm/httpd-dolibarr.conf index 1126d4fe442..ebda2b3ddfc 100644 --- a/build/rpm/httpd-dolibarr.conf +++ b/build/rpm/httpd-dolibarr.conf @@ -29,16 +29,6 @@ Alias /dolibarr /usr/share/dolibarr/htdocs ErrorDocument 401 /public/error-401.php ErrorDocument 404 /public/error-404.php - - php_flag magic_quotes_gpc Off - php_flag register_globals Off - - - - php_flag magic_quotes_gpc Off - php_flag register_globals Off - - # OPTIMIZE: To use gzip compressed files (for Dolibarr already compressed files). # Note that constant MAIN_OPTIMIZE_SPEED must have a value with bit 0 set. diff --git a/dev/namespacemig/README.md b/dev/namespacemig/README.md new file mode 100644 index 00000000000..981292355ab --- /dev/null +++ b/dev/namespacemig/README.md @@ -0,0 +1,4 @@ +Test to migrate Dolibarr to namespace "Dolibarr". + +Script bbb.php is a script of an external module with current code writing. +It must works after migration. \ No newline at end of file diff --git a/dev/namespacemig/aaa.class.php b/dev/namespacemig/aaa.class.php new file mode 100644 index 00000000000..1070e96f875 --- /dev/null +++ b/dev/namespacemig/aaa.class.php @@ -0,0 +1,23 @@ +do(); + +$aaa = new Aaa(); +$aaa->do(); + +echo $aaa::AAA."\n"; +echo $bbb::BBB."\n"; + +echo Aaa::AAA."\n"; +echo Bbb::BBB."\n"; + +echo faaa()."\n"; +echo fbbb()."\n"; + +echo "globalaaa=$globalaaa\n"; +echo "globalbbb=$globalbbb\n"; diff --git a/dev/namespacemig/main.inc.php b/dev/namespacemig/main.inc.php new file mode 100644 index 00000000000..5709a31f733 --- /dev/null +++ b/dev/namespacemig/main.inc.php @@ -0,0 +1,7 @@ +build/html build/aps + dev/namespacemig documents + htdocs/core/class/lessc.class.php htdocs/custom htdocs/includes htdocs/install/doctemplates/websites diff --git a/htdocs/accountancy/bookkeeping/balancebymonth.php b/htdocs/accountancy/bookkeeping/balancebymonth.php index b9568228a36..1141accd476 100644 --- a/htdocs/accountancy/bookkeeping/balancebymonth.php +++ b/htdocs/accountancy/bookkeeping/balancebymonth.php @@ -73,19 +73,11 @@ $y = $year_current; print ''; print ''; print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +for($i = 1; $i <= 12; $i++) +{ + print ''; +} +print ''; print ''; $sql = "SELECT bk.numero_compte AS 'compte',"; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index dc894663e4c..12825d9a780 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2315,6 +2315,7 @@ class Adherent extends CommonObject $response = new WorkboardResponse(); $response->warning_delay=$conf->adherent->subscription->warning_delay/60/60/24; $response->label=$langs->trans("MembersWithSubscriptionToReceive"); + $response->labelShort=$langs->trans("MembersWithSubscriptionToReceiveShort"); $response->url=DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=1&filter=outofdate'; $response->img=img_object('', "user"); diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index 6ac210c1ddb..032c4f07e56 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -35,7 +35,10 @@ if (!$user->admin) $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); + + $arrayofparameters=array( + 'DAV_RESTICT_ON_IP'=>array('css'=>'minwidth200', 'enabled'=>1), 'DAV_ALLOW_PRIVATE_DIR'=>array('css'=>'minwidth200', 'enabled'=>2), 'DAV_ALLOW_PUBLIC_DIR'=>array('css'=>'minwidth200', 'enabled'=>1), 'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled) @@ -68,7 +71,6 @@ $head=dav_admin_prepare_head(); dol_fiche_head($head, 'webdav', '', -1, 'action'); - if ($action == 'edit') { print ''; @@ -76,14 +78,17 @@ if ($action == 'edit') print ''; print '
' . $langs->trans("Label") . '' . $langs->trans("JanuaryMin") . '' . $langs->trans("FebruaryMin") . '' . $langs->trans("MarchMin") . '' . $langs->trans("AprilMin") . '' . $langs->trans("MayMin") . '' . $langs->trans("JuneMin") . '' . $langs->trans("JulyMin") . '' . $langs->trans("AugustMin") . '' . $langs->trans("SeptemberMin") . '' . $langs->trans("OctoberMin") . '' . $langs->trans("NovemberMin") . '' . $langs->trans("DecemberMin") . 'Total' . $langs->trans("MonthShort".sprintf("%02s", $i)) . ''.$langs->trans("Total").'
'; - print ''; + print ''; foreach($arrayofparameters as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) continue; print ''; + //Invert sender and recipient + + print ''; + // Place customer adress to the ISO location print '"; // Modify link print ''; // Delete link - if ($iserasable) print ''; + if ($iserasable) print ''; else print ''; print "\n"; diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index ed23151d99b..cbf18f92222 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -78,6 +78,12 @@ if ($action == 'setproductionmode') } } +if ($action == 'save') +{ + dolibarr_set_const($db, 'API_RESTRICT_ON_IP', GETPOST('API_RESTRICT_ON_IP', 'alpha')); +} + + dol_mkdir(DOL_DATA_ROOT.'/api/temp'); // May have been deleted by a purge @@ -93,37 +99,50 @@ print load_fiche_titre($langs->trans("ApiSetup"), $linkback, 'title_setup'); print $langs->trans("ApiDesc")."
\n"; print "
\n"; -//print ''; +print ''; print ''; +print ''; + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + $label = $langs->trans($key); + if ($key == 'DAV_RESTICT_ON_IP') $label = $langs->trans("RESTRICT_ON_IP"); + print $form->textwithpicto($label, $tooltiphelp); print ''; if ($key == 'DAV_ALLOW_PRIVATE_DIR') { @@ -112,12 +117,13 @@ if ($action == 'edit') else { print ''; - print ''; + print ''; foreach($arrayofparameters as $key => $val) { print ''; print ''; @@ -235,7 +234,6 @@ else { foreach($delays as $delay) { - $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); print ''; print ''; @@ -264,7 +262,7 @@ else print '
'; // Show logo for weather -print $langs->trans("DescWeather").'
'; +print ''.$langs->trans("DescWeather").' '; if($action == 'edit') { @@ -300,16 +298,16 @@ if ($action == 'edit') { print '
'; print '
'; - print img_weather($text, 'weather-clear.png', $options); + print img_weather($text, 0, $options); print '= '; print '
'; - print img_weather($text, 'weather-few-clouds.png', $options); + print img_weather($text, 1, $options); print '<= '; print '
'; - print img_weather($text, 'weather-clouds.png', $options); + print img_weather($text, 2, $options); print '<= '; print '
'; - print img_weather($text, 'weather-many-clouds.png', $options); + print img_weather($text, 3, $options); print '<= '; print '
'; print '
'; @@ -320,16 +318,16 @@ if ($action == 'edit') { print '
'; print '
'; - print img_weather($text, 'weather-clear.png', $options); - print '=  %'; + print img_weather($text, 0, $options); + print '<=  %'; print '
'; - print img_weather($text, 'weather-few-clouds.png', $options); + print img_weather($text, 1, $options); print '<=  %'; print '
'; - print img_weather($text, 'weather-clouds.png', $options); + print img_weather($text, 2, $options); print '<=  %'; print '
'; - print img_weather($text, 'weather-many-clouds.png', $options); + print img_weather($text, 3, $options); print '<=  %'; print '
'; print '
'; @@ -371,19 +369,19 @@ if ($action == 'edit') { print '
'; print '
'; - print img_weather($text, 'weather-clear.png', $options); + print img_weather($text, 0, $options); print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.' %'; print '
'; - print img_weather($text, 'weather-few-clouds.png', $options); + print img_weather($text, 1, $options); print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.' %'; print '
'; - print img_weather($text, 'weather-clouds.png', $options); + print img_weather($text, 2, $options); print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.' %'; print '
'; - print img_weather($text, 'weather-many-clouds.png', $options); + print img_weather($text, 3, $options); print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %'; print '
'; - print img_weather($text, 'weather-storm.png', $options); + print img_weather($text, 4, $options); print '> '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %'; print '
'; print '
'; @@ -391,19 +389,19 @@ if ($action == 'edit') { print '
'; print '
'; - print img_weather($text, 'weather-clear.png', $options); + print img_weather($text, 0, $options); print '= '.$level0; print '
'; - print img_weather($text, 'weather-few-clouds.png', $options); + print img_weather($text, 1, $options); print '<= '.$level1; print '
'; - print img_weather($text, 'weather-clouds.png', $options); + print img_weather($text, 2, $options); print '<= '.$level2; print '
'; - print img_weather($text, 'weather-many-clouds.png', $options); + print img_weather($text, 3, $options); print '<= '.$level3; print '
'; - print img_weather($text, 'weather-storm.png', $options); + print img_weather($text, 4, $options); print '> '.$level3; print '
'; print '
'; diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php index fc55b27d7e1..8f8cbf98607 100644 --- a/htdocs/admin/geoipmaxmind.php +++ b/htdocs/admin/geoipmaxmind.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2009-2019 Laurent Destailleur * Copyright (C) 2011-2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -36,9 +36,11 @@ $langs->loadLangs(array("admin","errors")); $action = GETPOST('action', 'aZ09'); + /* * Actions */ + if ($action == 'set') { $error=0; @@ -53,8 +55,11 @@ if ($action == 'set') if (! $error) { - $res = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + $res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity); + if (! $res1 > 0) $error++; + + $res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity); + if (! $res2 > 0) $error++; if (! $error) { @@ -67,6 +72,8 @@ if ($action == 'set') } } +if (! isset($conf->global->GEOIP_VERSION)) $conf->global->GEOIP_VERSION = '2'; + /* * View @@ -85,13 +92,6 @@ $geoip=''; if (! empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) { $geoip=new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE); - //if ($geoip->error) print dol_htmloutput_errors($geoip->errorlabel,'',1); - if ($geoip->gi == 'NOGI') $geointernal=true; - else $geointernal=false; -} -else -{ - if (function_exists('geoip_country_code_by_name')) $geointernal=true; } // Mode @@ -105,16 +105,30 @@ print ''; print "\n"; -print ''; +// Lib version +print ''; +print ''; + +// Path to database file +print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); + $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); + print $form->textwithpicto($langs->trans($key), $tooltiphelp); print ''; if ($key == 'DAV_ALLOW_PRIVATE_DIR') { @@ -177,6 +183,13 @@ if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) } print $message; +print '


'; + +require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php'; +$version = Sabre\DAV\Version::VERSION; +print ''.$langs->trans("BaseOnSabeDavVersion").' : '.$version.''; + + // End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 6b46468b916..1fe8b2285c3 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -195,7 +195,6 @@ if ($action == 'edit') { foreach($delays as $delay) { - $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); print '
'.img_object('', $delay['img']).'
'.img_object('', $delay['img']).''.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").'
'.$langs->trans("GeoIPLibVersion").''; +$arrayofvalues = array('php' => 'Native PHP functions', '1' => 'Embedded GeoIP v1', '2' => 'Embedded GeoIP v2'); +print $form->selectarray('geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION : '2')); +if ($conf->global->GEOIP_VERSION == 'php') +{ + if ($geoip) $version=$geoip->getVersion(); + if ($version) + { + print '
'.$langs->trans("Version").': '.$version; + } +} +print '
'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").''; -if ($geointernal) print 'Using geoip PHP internal functions. Value must be '.geoip_db_filename(GEOIP_COUNTRY_EDITION).' or '.geoip_db_filename(GEOIP_CITY_EDITION_REV1).'
'; -print ''; -if ($geoip) $version=$geoip->getVersion(); -if ($version) +if ($conf->global->GEOIP_VERSION == 'php') { - print '
'.$langs->trans("Version").': '.$version; + print 'Using geoip PHP internal functions. Value must be '.geoip_db_filename(GEOIP_COUNTRY_EDITION).' or '.geoip_db_filename(GEOIP_CITY_EDITION_REV1).' or /pathtodatafile/GeoLite2-Country.mmdb
'; } +print ''; print '
'; @@ -144,6 +158,13 @@ if ($geoip) if ($result) print $result; else print $langs->trans("Error"); + $ip='2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a'; // should be France + print '
'.$ip.' -> '; + $result=dol_print_ip($ip, 1); + if ($result) print $result; + else print $langs->trans("Error"); + + /* We disable this test because dol_print_ip need an ip as input $ip='www.google.com'; print '
'.$ip.' -> '; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 5fd40fb032a..07352921154 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -130,13 +130,13 @@ if ($action=='install') } else { - if (! preg_match('/\.zip$/i', $original_file)) + if (! $error && ! preg_match('/\.zip$/i', $original_file)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFileMustBeADolibarrPackage", $original_file), null, 'errors'); $error++; } - if (! preg_match('/module_.*\-[\d]+\.[\d]+.*$/i', $original_file)) + if (! $error && ! preg_match('/^(module[a-zA-Z0-9]*|theme)_.*\-([0-9][0-9\.]*)\.zip$/i', $original_file)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFilenameDosNotMatchDolibarrPackageRules", $original_file, 'module_*-x.y*.zip'), null, 'errors'); @@ -180,13 +180,13 @@ if ($action=='install') { // Now we move the dir of the module $modulename=preg_replace('/module_/', '', $original_file); - $modulename=preg_replace('/\-[\d]+\.[\d]+.*$/', '', $modulename); + $modulename=preg_replace('/\-([0-9][0-9\.]*)\.zip$/i', '', $modulename); // Search dir $modulename - $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; + $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/'.$modulename; // Example .../mymodule //var_dump($modulenamedir); if (! dol_is_dir($modulenamedir)) { - $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; + $modulenamedir=$conf->admin->dir_temp.'/'.$tmpdir.'/htdocs/'.$modulename; // Example .../htdocs/mymodule //var_dump($modulenamedir); if (! dol_is_dir($modulenamedir)) { @@ -195,10 +195,16 @@ if ($action=='install') } } + if (! $error) + { + // TODO Make more test + } + + // Now we install the module if (! $error) { //var_dump($dirins); - @dol_delete_dir_recursive($dirins.'/'.$modulename); + @dol_delete_dir_recursive($dirins.'/'.$modulename); // delete the zip file dol_syslog("Uncompress of module file is a success. We copy it from ".$modulenamedir." into target dir ".$dirins.'/'.$modulename); $result=dolCopyDir($modulenamedir, $dirins.'/'.$modulename, '0444', 1); if ($result <= 0) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index bd2d7782cef..56c6f977827 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2012-2107 Juanjo Menent + * Copyright (C) 2019 Ferran Marcet * * 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 @@ -279,6 +280,12 @@ if ($action == 'edit') // Edit print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS', (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0, 1); print '
'.$langs->trans("SwapSenderAndRecipientOnPDF").''; + print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT))?$conf->global->MAIN_INVERT_SENDER_RECIPIENT:0, 1); + print '
'.$langs->trans("PlaceCustomerAddressToIsoLocation").''; diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index 61ae6bcf17f..b37e10ca2e7 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -118,14 +118,14 @@ function create_script_table($list) { global $sortby,$langs; - if (GETPOT('order') == "asc" || GETPOST('order') =="desc") { - $order = GETPOST('order'); + if (GETPOT('order', 'alpha') == "asc" || GETPOST('order', 'alpha') == "desc") { + $order = GETPOST('order', 'alpha'); } else { $order = "asc"; } - if (GETPOST('order')) { - switch (GETPOST('order')) { + if (GETPOST('order', 'alpha')) { + switch (GETPOST('order', 'alpha')) { case "mtime": case "size": case "reloads": diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 5096563ad76..8bcc6cc5417 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -618,14 +618,14 @@ if ($id) // Active print ''; - print ''.$actl[($obj->status?1:0)].''; + print ''.$actl[($obj->status?1:0)].''; print "'.img_edit().''.img_delete().''.img_delete().''.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'
'; print ''; print ""; -print '"; +print '"; print ""; print ""; -print ''; +print ''; print ''; $production_mode=(empty($conf->global->API_PRODUCTION_MODE)?false:true); if ($production_mode) { - print ''; } else { - print ''; } print ''; print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + print '
".$langs->trans("Parameter")."'.$langs->trans("Value")."'.$langs->trans("Value")." 
'.$langs->trans("ApiProductionMode").''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ' 
'.$langs->trans("RESTRICT_API_ON_IP").''; +print '
'; print '

'; +print ''; + + // 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 diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 223d62e248b..1b79f661dd6 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -32,7 +32,7 @@ class DolibarrApi /** * @var DoliDb $db Database object */ - static protected $db; + protected static $db; /** * @var Restler $r Restler object diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 48d6bf5b903..1b98ad5f2ec 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -56,7 +56,7 @@ class Documents extends DolibarrApi * Note that, this API is similar to using the wrapper link "documents.php" to download a file (used for * internal HTML links of documents into application), but with no need to have a session cookie (the token is used instead). * - * @param string $module_part Name of module or area concerned by file download ('facture', ...) + * @param string $modulepart Name of module or area concerned by file download ('facture', ...) * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf) * @return array List of documents * @@ -67,11 +67,11 @@ class Documents extends DolibarrApi * * @url GET /download */ - public function index($module_part, $original_file = '') + public function index($modulepart, $original_file = '') { global $conf, $langs; - if (empty($module_part)) { + if (empty($modulepart)) { throw new RestException(400, 'bad value for parameter modulepart'); } if (empty($original_file)) { @@ -81,7 +81,7 @@ class Documents extends DolibarrApi //--- Finds and returns the document $entity=$conf->entity; - $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; @@ -98,6 +98,7 @@ class Documents extends DolibarrApi if (! file_exists($original_file_osencoded)) { + dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); throw new RestException(404, 'File not found'); } @@ -111,7 +112,7 @@ class Documents extends DolibarrApi * * Test sample 1: { "module_part": "invoice", "original_file": "FA1701-001/FA1701-001.pdf", "doctemplate": "crabe", "langcode": "fr_FR" }. * - * @param string $module_part Name of module or area concerned by file download ('invoice', 'order', ...). + * @param string $modulepart Name of module or area concerned by file download ('invoice', 'order', ...). * @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf). * @param string $doctemplate Set here the doc template to use for document generation (If not set, use the default template). * @param string $langcode Language code like 'en_US', 'fr_FR', 'es_ES', ... (If not set, use the default language). @@ -126,11 +127,11 @@ class Documents extends DolibarrApi * * @url PUT /builddoc */ - public function builddoc($module_part, $original_file = '', $doctemplate = '', $langcode = '') + public function builddoc($modulepart, $original_file = '', $doctemplate = '', $langcode = '') { global $conf, $langs; - if (empty($module_part)) { + if (empty($modulepart)) { throw new RestException(400, 'bad value for parameter modulepart'); } if (empty($original_file)) { @@ -147,7 +148,7 @@ class Documents extends DolibarrApi //--- Finds and returns the document $entity=$conf->entity; - $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; @@ -166,7 +167,7 @@ class Documents extends DolibarrApi $templateused=''; - if ($module_part == 'facture' || $module_part == 'invoice') + if ($modulepart == 'facture' || $modulepart == 'invoice') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $this->invoice = new Facture($this->db); @@ -181,7 +182,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Error generating document'); } } - elseif ($module_part == 'commande' || $module_part == 'order') + elseif ($modulepart == 'commande' || $modulepart == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $this->order = new Commande($this->db); @@ -195,7 +196,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Error generating document'); } } - elseif ($module_part == 'propal' || $module_part == 'proposal') + elseif ($modulepart == 'propal' || $modulepart == 'proposal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $this->propal = new Propal($this->db); diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 2bf464f7296..9d8b90a0123 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -57,12 +57,13 @@ class Login */ public function index($login, $password, $entity = '', $reset = 0) { - global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; - // Authentication mode - if (empty($dolibarr_main_authentication)) - $dolibarr_main_authentication = 'http,dolibarr'; + // TODO Remove the API login. The token must be generated from backoffice only. + + // Authentication mode + if (empty($dolibarr_main_authentication)) $dolibarr_main_authentication = 'dolibarr'; + // Authentication mode: forceuser if ($dolibarr_main_authentication == 'forceuser') { @@ -73,6 +74,7 @@ class Login throw new RestException(403, "Your instance is set to use the automatic login '".$dolibarr_auto_user."' that is not the requested login. API usage is forbidden in this mode."); } } + // Set authmode $authmode = explode(',', $dolibarr_main_authentication); @@ -83,7 +85,7 @@ class Login if ($entity == '') $entity=1; include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; - $login = checkLoginPassEntity($login, $password, $entity, $authmode); + $login = checkLoginPassEntity($login, $password, $entity, $authmode, 'api'); if (empty($login)) { throw new RestException(403, 'Access denied'); diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 9d42b9995f6..dd9ff7aadcb 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -24,6 +24,8 @@ * \file htdocs/api/index.php */ +use Luracast\Restler\Format\UploadFormat; + if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not check anti POST attack test if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu @@ -117,6 +119,21 @@ $api->r->addAuthenticationClass('DolibarrApiAccess', ''); UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain', 'application/octet-stream'); +// Restrict API to some IPs +if (! empty($conf->global->API_RESTRICT_ON_IP)) +{ + $allowedip=explode(' ', $conf->global->API_RESTRICT_ON_IP); + $ipremote = getUserRemoteIP(); + if (! in_array($ipremote, $allowedip)) + { + dol_syslog('Remote ip is '.$ipremote.', not into list '.$conf->global->API_RESTRICT_ON_IP); + print 'APIs are not allowed from the IP '.$ipremote; + header('HTTP/1.1 503 API not allowed from your IP '.$ipremote); + //print $conf->global->API_RESTRICT_ON_IP; + exit(0); + } +} + // Call Explorer file for all APIs definitions (this part is slow) if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root')) @@ -136,6 +153,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || { while (($file = readdir($handle))!==false) { + $regmod=array(); if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i", $file, $regmod)) { $module = strtolower($regmod[1]); @@ -165,6 +183,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || { if ($file_searched == 'api_access.class.php') continue; + $regapi = array(); if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) { $classname = ucwords($regapi[1]); @@ -204,6 +223,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || } // Call one APIs or one definition of an API +$regbis = array(); if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root'))) { $module = $reg[1]; @@ -253,7 +273,6 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $api->r->addAPIClass($classname); } -// TODO If not found, redirect to explorer //var_dump($api->r->apiVersionMap); //exit; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 6e4e3fb941b..07db3b5a5d8 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1103,6 +1103,7 @@ class ActionComm extends CommonObject $response = new WorkboardResponse(); $response->warning_delay = $conf->agenda->warning_delay/60/60/24; $response->label = $langs->trans("ActionsToDo"); + $response->labelShort = $langs->trans("ActionsToDoShort"); $response->url = DOL_URL_ROOT.'/comm/action/list.php?actioncode=0&status=todo&mainmenu=agenda'; if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1'; $response->img = img_object('', "action", 'class="inline-block valigntextmiddle"'); @@ -1286,8 +1287,10 @@ class ActionComm extends CommonObject if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - if ((!$user->rights->agenda->allactions->read && $this->authorid != $user->id) || (!$user->rights->agenda->myactions->read && $this->authorid == $user->id)) + if ((!$user->rights->agenda->allactions->read && $this->authorid != $user->id) || (!$user->rights->agenda->myactions->read && $this->authorid == $user->id)) + { $option = 'nolink'; + } $label = $this->label; if (empty($label)) $label=$this->libelle; // For backward compatibility diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8b52aedcaad..2ae67888658 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -380,7 +380,6 @@ if (empty($reshook)) } } else { $object->ref = GETPOST('ref'); - $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); $object->ref_client = GETPOST('ref_client'); $object->datep = $datep; $object->date_livraison = $date_delivery; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 598d34f7093..49173eff5fd 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2010-2019 Juanjo Menent * Copyright (C) 2010-2017 Philippe Grand * Copyright (C) 2012-2014 Christophe Battarel * Copyright (C) 2012 Cedric Salvador @@ -890,7 +890,6 @@ class Propal extends CommonObject $now=dol_now(); // Clean parameters - if (empty($this->entity)) $this->entity = $conf->entity; if (empty($this->date)) $this->date=$this->datep; $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); if (empty($this->availability_id)) $this->availability_id=0; @@ -1000,7 +999,7 @@ class Propal extends CommonObject $sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".(int) $this->fk_incoterms; $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".$this->entity; + $sql.= ", ".setEntity($this); $sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", ".(double) $this->multicurrency_tx; @@ -1056,14 +1055,6 @@ class Propal extends CommonObject } } - // Add linked object (deprecated, use ->linkedObjectsIds instead) - if (! $error && $this->origin && $this->origin_id) - { - dol_syslog('Deprecated use of linked object, use ->linkedObjectsIds instead', LOG_WARNING); - $ret = $this->add_object_linked(); - if (! $ret) dol_print_error($this->db); - } - /* * Insertion du detail des produits dans la base * Insert products detail in database @@ -1091,7 +1082,7 @@ class Propal extends CommonObject $vatrate = $line->tva_tx; if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; - $result = $this->addline( + $result = $this->addline( $line->desc, $line->subprice, $line->qty, @@ -1138,7 +1129,7 @@ class Propal extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql.= " SET fk_delivery_address = ".$this->fk_delivery_address; $sql.= " WHERE ref = '".$this->db->escape($this->ref)."'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".setEntity($this); $result=$this->db->query($sql); } @@ -3277,21 +3268,24 @@ class Propal extends CommonObject $delay_warning = 0; $statut = 0; - $label = ''; + $label = $labelShort = ''; if ($mode == 'opened') { $delay_warning=$conf->propal->cloture->warning_delay; $statut = self::STATUS_VALIDATED; $label = $langs->trans("PropalsToClose"); + $labelShort = $langs->trans("ToAcceptRefuse"); } if ($mode == 'signed') { $delay_warning=$conf->propal->facturation->warning_delay; $statut = self::STATUS_SIGNED; $label = $langs->trans("PropalsToBill"); // We set here bill but may be billed or ordered + $labelShort = $langs->trans("ToBill"); } $response = new WorkboardResponse(); $response->warning_delay = $delay_warning/60/60/24; $response->label = $label; + $response->labelShort = $labelShort; $response->url = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut.'&mainmenu=commercial&leftmenu=propals'; $response->url_late = DOL_URL_ROOT.'/comm/propal/list.php?viewstatut='.$statut.'&mainmenu=commercial&leftmenu=propals&sortfield=p.datep&sortorder=asc'; $response->img = img_object('', "propal"); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index c6af61acab9..2964ff98690 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1062,7 +1062,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0f875b68f22..a44054cdfd0 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -96,9 +96,17 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('ordercard','globalcard')); -$permissionnote = $user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->commande->creer; // Used by the include of actions_dellink.inc.php -$permissionedit = $user->rights->commande->creer; // Used by the include of actions_lineupdown.inc.php +$usercanread = $user->rights->commande->lire; +$usercancreate = $user->rights->commande->creer; +$usercanclose = $user->rights->commande->cloturer; +$usercandelete = $user->rights->commande->supprimer; +$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))); +$usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler))); +$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send); + +$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php +$permissionedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php /* @@ -129,7 +137,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer) + if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { @@ -159,7 +167,7 @@ if (empty($reshook)) } // Reopen a closed order - elseif ($action == 'reopen' && $user->rights->commande->creer) + elseif ($action == 'reopen' && $usercancreate) { if ($object->statut == Commande::STATUS_CANCELED || $object->statut == Commande::STATUS_CLOSED) { @@ -176,7 +184,7 @@ if (empty($reshook)) } // Remove order - elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) + elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { $result = $object->delete($user); if ($result > 0) @@ -191,7 +199,7 @@ if (empty($reshook)) } // Remove a product line - elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer) + elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { $result = $object->deleteline($user, $lineid); if ($result > 0) @@ -222,13 +230,13 @@ if (empty($reshook)) } // Link to a project - elseif ($action == 'classin' && $user->rights->commande->creer) + elseif ($action == 'classin' && $usercancreate) { $object->setProject(GETPOST('projectid', 'int')); } // Add order - elseif ($action == 'add' && $user->rights->commande->creer) + elseif ($action == 'add' && $usercancreate) { $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); @@ -481,7 +489,7 @@ if (empty($reshook)) } } - elseif ($action == 'classifybilled' && $user->rights->commande->creer) + elseif ($action == 'classifybilled' && $usercancreate) { $ret=$object->classifyBilled($user); @@ -489,7 +497,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - elseif ($action == 'classifyunbilled' && $user->rights->commande->creer) + elseif ($action == 'classifyunbilled' && $usercancreate) { $ret=$object->classifyUnBilled(); if ($ret < 0) { @@ -498,7 +506,7 @@ if (empty($reshook)) } // Positionne ref commande client - elseif ($action == 'setref_client' && $user->rights->commande->creer) { + elseif ($action == 'setref_client' && $usercancreate) { $result = $object->set_ref_client($user, GETPOST('ref_client')); if ($result < 0) { @@ -506,7 +514,7 @@ if (empty($reshook)) } } - elseif ($action == 'setremise' && $user->rights->commande->creer) { + elseif ($action == 'setremise' && $usercancreate) { $result = $object->set_remise($user, GETPOST('remise')); if ($result < 0) { @@ -514,7 +522,7 @@ if (empty($reshook)) } } - elseif ($action == 'setabsolutediscount' && $user->rights->commande->creer) { + elseif ($action == 'setabsolutediscount' && $usercancreate) { if (GETPOST('remise_id')) { if ($object->id > 0) { $object->insert_discount(GETPOST('remise_id')); @@ -524,7 +532,7 @@ if (empty($reshook)) } } - elseif ($action == 'setdate' && $user->rights->commande->creer) { + elseif ($action == 'setdate' && $usercancreate) { // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year')); @@ -534,7 +542,7 @@ if (empty($reshook)) } } - elseif ($action == 'setdate_livraison' && $user->rights->commande->creer) { + elseif ($action == 'setdate_livraison' && $usercancreate) { // print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); @@ -544,35 +552,35 @@ if (empty($reshook)) } } - elseif ($action == 'setmode' && $user->rights->commande->creer) { + elseif ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Multicurrency Code - elseif ($action == 'setmulticurrencycode' && $user->rights->commande->creer) { + elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); } // Multicurrency rate - elseif ($action == 'setmulticurrencyrate' && $user->rights->commande->creer) { + elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); } - elseif ($action == 'setavailability' && $user->rights->commande->creer) { + elseif ($action == 'setavailability' && $usercancreate) { $result = $object->availability(GETPOST('availability_id')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - elseif ($action == 'setdemandreason' && $user->rights->commande->creer) { + elseif ($action == 'setdemandreason' && $usercancreate) { $result = $object->demand_reason(GETPOST('demand_reason_id')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - elseif ($action == 'setconditions' && $user->rights->commande->creer) { + elseif ($action == 'setconditions' && $usercancreate) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); if ($result < 0) { dol_print_error($db, $object->error); @@ -604,7 +612,7 @@ if (empty($reshook)) } // bank account - elseif ($action == 'setbankaccount' && $user->rights->commande->creer) { + elseif ($action == 'setbankaccount' && $usercancreate) { $result=$object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -612,7 +620,7 @@ if (empty($reshook)) } // shipping method - elseif ($action == 'setshippingmethod' && $user->rights->commande->creer) { + elseif ($action == 'setshippingmethod' && $usercancreate) { $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -620,23 +628,23 @@ if (empty($reshook)) } // warehouse - elseif ($action == 'setwarehouse' && $user->rights->commande->creer) { + elseif ($action == 'setwarehouse' && $usercancreate) { $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - elseif ($action == 'setremisepercent' && $user->rights->commande->creer) { + elseif ($action == 'setremisepercent' && $usercancreate) { $result = $object->set_remise($user, GETPOST('remise_percent')); } - elseif ($action == 'setremiseabsolue' && $user->rights->commande->creer) { + elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); } // Add a new line - elseif ($action == 'addline' && $user->rights->commande->creer) + elseif ($action == 'addline' && $usercancreate) { $langs->load('errors'); $error = 0; @@ -999,7 +1007,7 @@ if (empty($reshook)) /* * Update a line */ - elseif ($action == 'updateline' && $user->rights->commande->creer && GETPOST('save')) + elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) { // Clean parameters $date_start=''; @@ -1133,15 +1141,12 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - } elseif ($action == 'updateline' && $user->rights->commande->creer && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { + } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } - elseif ($action == 'confirm_validate' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))) - ) + elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { $idwarehouse = GETPOST('idwarehouse'); @@ -1195,7 +1200,7 @@ if (empty($reshook)) } // Go back to draft status - elseif ($action == 'confirm_modif' && $user->rights->commande->creer) { + elseif ($action == 'confirm_modif' && $usercancreate) { $idwarehouse = GETPOST('idwarehouse'); $qualified_for_stock_change=0; @@ -1243,17 +1248,14 @@ if (empty($reshook)) } } - elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { + elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $usercanclose) { $result = $object->cloture($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - elseif ($action == 'confirm_cancel' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))) - ) + elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate) { $idwarehouse = GETPOST('idwarehouse'); @@ -1310,7 +1312,7 @@ if (empty($reshook)) if ($error) $action = 'edit_extras'; } - if ($action == 'set_thirdparty' && $user->rights->commande->creer) + if ($action == 'set_thirdparty' && $usercancreate) { $object->fetch($id); $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); @@ -1321,7 +1323,7 @@ if (empty($reshook)) // add lines from objectlinked if($action == 'import_lines_from_object' - && $user->rights->commande->creer + && $usercancreate && $object->statut == Commande::STATUS_DRAFT ) { @@ -1405,8 +1407,8 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to build doc - $upload_dir = $conf->commande->dir_output; - $permissioncreate = $user->rights->commande->creer; + $upload_dir = $conf->commande->multidir_output[$object->entity]; + $permissioncreate = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails @@ -1417,7 +1419,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer) + if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { if ($action == 'addcontact') { @@ -1478,7 +1480,7 @@ $formmargin = new FormMargin($db); if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } // Mode creation -if ($action == 'create' && $user->rights->commande->creer) +if ($action == 'create' && $usercancreate) { print load_fiche_titre($langs->trans('CreateOrder'), '', 'title_commercial.png'); @@ -2069,8 +2071,8 @@ if ($action == 'create' && $user->rights->commande->creer) $morehtmlref='
'; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherOrders").')'; @@ -2079,7 +2081,7 @@ if ($action == 'create' && $user->rights->commande->creer) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->commande->creer) + if ($usercancreate) { if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; @@ -2159,7 +2161,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Date print ''; - $editenable = $user->rights->commande->creer && $object->statut == Commande::STATUS_DRAFT; + $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; print $form->editfieldkey("Date", 'date', '', $object, $editenable); print ''; if ($action == 'editdate') { @@ -2180,7 +2182,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Delivery date planed print ''; - $editenable = $user->rights->commande->creer; + $editenable = $usercancreate; print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); print ''; if ($action == 'editdate_livraison') { @@ -2202,7 +2204,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Shipping Method if (! empty($conf->expedition->enabled)) { print ''; - $editenable = $user->rights->commande->creer; + $editenable = $usercancreate; print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); print ''; if ($action == 'editshippingmethod') { @@ -2220,7 +2222,7 @@ if ($action == 'create' && $user->rights->commande->creer) require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct=new FormProduct($db); print ''; - $editenable = $user->rights->commande->creer; + $editenable = $usercancreate; print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); print ''; if ($action == 'editwarehouse') { @@ -2234,7 +2236,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Terms of payment print ''; - $editenable = $user->rights->commande->creer; + $editenable = $usercancreate; print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); print ''; if ($action == 'editconditions') { @@ -2248,7 +2250,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Mode of payment print ''; - $editenable = $user->rights->commande->creer; + $editenable = $usercancreate; print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); print ''; if ($action == 'editmode') { @@ -2264,7 +2266,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Multicurrency code print ''; print ''; - $editenable = $user->rights->commande->creer && $object->statut == Commande::STATUS_DRAFT; + $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT; print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable); print ''; if ($action == 'editmulticurrencycode') { @@ -2277,7 +2279,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Multicurrency rate print ''; print ''; - $editenable = $user->rights->commande->creer && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == Commande::STATUS_DRAFT; + $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == Commande::STATUS_DRAFT; print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { @@ -2298,7 +2300,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Delivery delay print ''; - $editenable = $user->rights->commande->creer; + $editenable = $usercancreate; print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); print ''; if ($action == 'editavailability') { @@ -2310,7 +2312,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Source reason (why we have an ordrer) print ''; - $editenable = $user->rights->commande->creer; + $editenable = $usercancreate; print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable); print ''; if ($action == 'editdemandreason') { @@ -2323,7 +2325,7 @@ if ($action == 'create' && $user->rights->commande->creer) // TODO Order mode (how we receive order). Not yet implemented /* print ''; - $editenable = $user->rights->commande->creer; + $editenable = $usercancreate; print $form->editfieldkey("SourceMode", 'inputmode', '', $object, $editenable); print ''; if ($action == 'editinputmode') { @@ -2355,7 +2357,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Incoterms if (!empty($conf->incoterm->enabled)) { print ''; - $editenable = $user->rights->commande->creer; + $editenable = $usercancreate; print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); print ''; print ''; @@ -2373,7 +2375,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Bank Account if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) { print ''; - $editenable = $user->rights->commande->creer; + $editenable = $usercancreate; print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); print ''; if ($action == 'editbankaccount') { @@ -2497,7 +2499,7 @@ if ($action == 'create' && $user->rights->commande->creer) /* * Form to add new line */ - if ($object->statut == Commande::STATUS_DRAFT && $user->rights->commande->creer && $action != 'selectlines') + if ($object->statut == Commande::STATUS_DRAFT && $usercancreate && $action != 'selectlines') { if ($action != 'editline') { @@ -2528,22 +2530,19 @@ if ($action == 'create' && $user->rights->commande->creer) if (empty($reshook)) { // Send if ($object->statut > Commande::STATUS_DRAFT) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { + if ($usercansend) { print ''; } else print ''; } // Valid - if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))) - ) + if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && $usercanvalidate) { print ''; } // Edit - if ($object->statut == Commande::STATUS_VALIDATED && $user->rights->commande->creer) { + if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) { print ''; } // Create event @@ -2597,12 +2596,12 @@ if ($action == 'create' && $user->rights->commande->creer) } // Reopen a closed order - if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $user->rights->commande->creer) { + if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $usercancreate) { print ''; } // Set to shipped - if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $user->rights->commande->cloturer) { + if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $usercanclose) { print ''; } @@ -2612,31 +2611,28 @@ if ($action == 'create' && $user->rights->commande->creer) if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { print ''; } - if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { + if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { print ''; } } if ($object->statut > Commande::STATUS_DRAFT && $object->billed) { - if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { + if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { print ''; } } // Clone - if ($user->rights->commande->creer) { + if ($usercancreate) { print ''; } // Cancel order - if ($object->statut == Commande::STATUS_VALIDATED && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->cloturer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler))) - ) + if ($object->statut == Commande::STATUS_VALIDATED && (! empty($usercanclose) || ! empty($usercancancel))) { print ''; } // Delete order - if ($user->rights->commande->supprimer) { + if ($usercandelete) { if ($numshipping == 0) { print ''; } else { @@ -2659,18 +2655,18 @@ if ($action == 'create' && $user->rights->commande->creer) // Documents $comref = dol_sanitizeFileName($object->ref); $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->commande->dir_output . '/' . $comref; + $filedir = $conf->commande->multidir_output[$object->entity] . '/' . $comref; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->commande->lire; - $delallowed = $user->rights->commande->creer; - print $formfile->showdocuments('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + $genallowed = $usercanread; + $delallowed = $usercancreate; + print $formfile->showdocuments('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); $compatibleImportElementsList = false; - if($user->rights->commande->creer + if($usercancreate && $object->statut == Commande::STATUS_DRAFT) { $compatibleImportElementsList = array('commande','propal'); // import from linked elements @@ -2707,7 +2703,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Presend form $modelmail='order_send'; $defaulttopic='SendOrderRef'; - $diroutput = $conf->commande->dir_output; + $diroutput = $conf->commande->multidir_output[$object->entity]; $trackid = 'ord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 23d9db8f246..de93ff778c4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -433,8 +433,8 @@ class Commande extends CommonOrder // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); - $dirsource = $conf->commande->dir_output.'/'.$oldref; - $dirdest = $conf->commande->dir_output.'/'.$newref; + $dirsource = $conf->commande->multidir_output[$this->entity].'/'.$oldref; + $dirdest = $conf->commande->multidir_output[$this->entity].'/'.$newref; if (! $error && file_exists($dirsource)) { dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); @@ -443,7 +443,7 @@ class Commande extends CommonOrder { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + $listoffiles=dol_dir_list($conf->commande->multidir_output[$this->entity].'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); foreach($listoffiles as $fileentry) { $dirsource=$fileentry['name']; @@ -865,7 +865,7 @@ class Commande extends CommonOrder $sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0); $sql.= ", ".(int) $this->fk_incoterms; $sql.= ", '".$this->db->escape($this->location_incoterms)."'"; - $sql.= ", ".$conf->entity; + $sql.= ", ".setEntity($this); $sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); $sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); $sql.= ", ".(int) $this->fk_multicurrency; @@ -1238,6 +1238,7 @@ class Commande extends CommonOrder $this->lines[$i] = $line; } + $this->entity = $object->entity; $this->socid = $object->socid; $this->fk_project = $object->fk_project; $this->cond_reglement_id = $object->cond_reglement_id; @@ -3335,10 +3336,10 @@ class Commande extends CommonOrder { // Remove directory with files $comref = dol_sanitizeFileName($this->ref); - if ($conf->commande->dir_output && !empty($this->ref)) + if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref)) { - $dir = $conf->commande->dir_output . "/" . $comref ; - $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf"; + $dir = $conf->commande->multidir_output[$this->entity] . "/" . $comref ; + $file = $conf->commande->multidir_output[$this->entity] . "/" . $comref . "/" . $comref . ".pdf"; if (file_exists($file)) // We must delete all files before deleting directory { dol_delete_preview($this); @@ -3411,6 +3412,7 @@ class Commande extends CommonOrder $response = new WorkboardResponse(); $response->warning_delay=$conf->commande->client->warning_delay/60/60/24; $response->label=$langs->trans("OrdersToProcess"); + $response->labelShort = $langs->trans("Opened"); $response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3&mainmenu=commercial&leftmenu=orders'; $response->img=img_object('', "order"); diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 37cbc70cd40..ec6ed2fd91b 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -72,7 +72,7 @@ $object = new Commande($db); if ($object->fetch($id)) { $object->fetch_thirdparty(); - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); + $upload_dir = $conf->commande->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); } include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; @@ -92,7 +92,7 @@ if ($id > 0 || ! empty($ref)) { $object->fetch_thirdparty(); - $upload_dir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->commande->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $head = commande_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), -1, 'order'); @@ -174,7 +174,7 @@ if ($id > 0 || ! empty($ref)) $modulepart = 'commande'; $permission = $user->rights->commande->creer; $permtoedit = $user->rights->commande->creer; - $param = '&id=' . $object->id; + $param = '&id=' . $object->id.'&entity=' . (! empty($object->entity)?$object->entity:$conf->entity); include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } else diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index a0e87bf63a3..160b6f70627 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -241,7 +241,7 @@ $max=5; * Last modified orders */ -$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,"; +$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,"; $sql.= " s.nom as name, s.rowid as socid"; $sql.= ", s.client"; $sql.= ", s.code_client"; @@ -297,7 +297,7 @@ if ($resql) print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print ''; @@ -323,7 +323,7 @@ else dol_print_error($db); */ if (! empty($conf->commande->enabled)) { - $sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; + $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; $sql.= ", s.client"; $sql.= ", s.code_client"; $sql.= ", s.canvas"; @@ -377,7 +377,7 @@ if (! empty($conf->commande->enabled)) print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print ''; @@ -405,7 +405,7 @@ if (! empty($conf->commande->enabled)) */ if (! empty($conf->commande->enabled)) { - $sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; + $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; $sql.= ", s.client"; $sql.= ", s.code_client"; $sql.= ", s.canvas"; @@ -459,7 +459,7 @@ if (! empty($conf->commande->enabled)) print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print ''; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index a25d863176e..66a3862bd2c 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -91,7 +91,7 @@ $id = (GETPOST('orderid')?GETPOST('orderid', 'int'):GETPOST('id', 'int')); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'commande', $id, ''); -$diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction=$conf->commande->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id; // Load variable for pagination $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -218,7 +218,7 @@ if (empty($reshook)) $objectlabel='Orders'; $permtoread = $user->rights->commande->lire; $permtodelete = $user->rights->commande->supprimer; - $uploaddir = $conf->commande->dir_output; + $uploaddir = $conf->commande->multidir_output[$conf->entity]; $trigger_name='ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -934,7 +934,7 @@ if ($resql) print ''; $filename=dol_sanitizeFileName($obj->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->multidir_output[$conf->entity] . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print ''; @@ -1081,7 +1081,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 33acc2b4969..fa983e46f8e 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -548,7 +548,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) '; $filename=dol_sanitizeFileName($objp->ref); - $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref); + $filedir=$conf->commande->multidir_output[$objp->entity] . '/' . dol_sanitizeFileName($objp->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid; print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print ''; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index f6633f279d5..883018b259b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -236,8 +236,13 @@ if ($action == 'update') $error++; } - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $db->begin(); + + if (! $error) + { + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + } if (! $error) { @@ -252,10 +257,20 @@ if ($action == 'update') } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); $action='edit'; // Force chargement page edition } } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } } if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer) @@ -412,7 +427,7 @@ if ($action == 'create') $doleditor->Create(); print ''; - // Other attributes + // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -639,12 +654,12 @@ else print ''.$langs->trans("AccountancyJournal").''; print ''; - if ($object->fk_accountancy_journal > 0) { - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($object->fk_accountancy_journal); + if ($object->fk_accountancy_journal > 0) { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($object->fk_accountancy_journal); - print $accountingjournal->getNomUrl(0, 1, 1, '', 1); - } + print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } print ''; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 5724178e9de..282a296a5f1 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -749,7 +749,6 @@ class Account extends CommonObject $sql.= ",fk_pays = ".$this->country_id; $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND entity = ".$conf->entity; dol_syslog(get_class($this)."::update", LOG_DEBUG); $result = $this->db->query($sql); @@ -1225,6 +1224,7 @@ class Account extends CommonObject $response = new WorkboardResponse(); $response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24; $response->label=$langs->trans("TransactionsToConciliate"); + $response->labelShort = $langs->trans("TransactionsToConciliateShort"); $response->url=DOL_URL_ROOT.'/compta/bank/list.php?leftmenu=bank&mainmenu=bank'; $response->img=img_object('', "payment"); @@ -1276,7 +1276,6 @@ class Account extends CommonObject $this->nb["banklines"]=$obj->nb; } $this->db->free($resql); - return 1; } else { diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 72ba4c82db1..ba21b6c09c1 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -23,6 +23,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; /** * API class for accounts * + * @property DoliDB db * @access protected * @class DolibarrApiAccess {@requires user,external} */ @@ -166,6 +167,142 @@ class BankAccounts extends DolibarrApi return $account->id; } + /** + * Create an internal wire transfer between two bank accounts + * + * @param int $bankaccount_from_id BankAccount ID to use as the source of the internal wire transfer {@from body}{@required true} + * @param int $bankaccount_to_id BankAccount ID to use as the destination of the internal wire transfer {@from body}{@required true} + * @param string $date Date of the internal wire transfer (UNIX timestamp) {@from body}{@required true}{@type timestamp} + * @param string $description Description of the internal wire transfer {@from body}{@required true} + * @param float $amount Amount to transfer from the source to the destination BankAccount {@from body}{@required true} + * @param float $amount_to Amount to transfer to the destination BankAccount (only when accounts does not share the same currency) {@from body}{@required false} + * + * @url POST /transfer + * + * @return array + * + * @status 201 + * + * @throws 401 Unauthorized: User does not have permission to configure bank accounts + * @throws 404 Not Found: Either the source or the destination bankaccount for the provided id does not exist + * @throws 422 Unprocessable Entity: Refer to detailed exception message for the cause + * @throws 500 Internal Server Error: Error(s) returned by the RDBMS + */ + public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0) + { + if (! DolibarrApiAccess::$user->rights->banque->configurer) { + throw new RestException(401); + } + + if ($bankaccount_from_id === $bankaccount_to_id) { + throw new RestException(422, 'bankaccount_from_id and bankaccount_to_id must be different !'); + } + + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $accountfrom = new Account($this->db); + $resultAccountFrom = $accountfrom->fetch($bankaccount_from_id); + + if ($resultAccountFrom === 0) { + throw new RestException(404, 'The BankAccount for bankaccount_from_id provided does not exist.'); + } + + $accountto = new Account($this->db); + $resultAccountTo = $accountto->fetch($bankaccount_to_id); + + if ($resultAccountTo === 0) { + throw new RestException(404, 'The BankAccount for bankaccount_to_id provided does not exist.'); + } + + if ($accountto->currency_code == $accountfrom->currency_code) + { + $amount_to = $amount; + } + else + { + if (!$amount_to || empty($amount_to)) + { + throw new RestException(422, 'You must provide amount_to value since bankaccount_from and bankaccount_to does not share the same currency.'); + } + } + + $this->db->begin(); + + $error = 0; + $bank_line_id_from = 0; + $bank_line_id_to = 0; + $result = 0; + $user = DolibarrApiAccess::$user; + + // By default, electronic transfert from bank to bank + $typefrom='PRE'; + $typeto='VIR'; + + if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) + { + // This is transfer of change + $typefrom='LIQ'; + $typeto='LIQ'; + } + + /** + * Creating bank line records + */ + + if (!$error) { + $bank_line_id_from = $accountfrom->addline($date, $typefrom, $description, -1*price2num($amount), '', '', $user); + } + if (!($bank_line_id_from > 0)) { + $error++; + } + + if (!$error) { + $bank_line_id_to = $accountto->addline($date, $typeto, $description, price2num($amount_to), '', '', $user); + } + if (!($bank_line_id_to > 0)) { + $error++; + } + + /** + * Creating links between bank line record and its source + */ + + $url = DOL_URL_ROOT.'/compta/bank/line.php?rowid='; + $label = '(banktransfert)'; + $type = 'banktransfert'; + + if (!$error) { + $result = $accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, $url, $label, $type); + } + if (!($result > 0)) { + $error++; + } + + if (!$error) { + $result = $accountto->add_url_line($bank_line_id_to, $bank_line_id_from, $url, $label, $type); + } + if (!($result > 0)) { + $error++; + } + + if (!$error) + { + $this->db->commit(); + + return array( + 'success' => array( + 'code' => 201, + 'message' => 'Internal wire transfer created successfully.' + ) + ); + } + else + { + $this->db->rollback(); + throw new RestException(500, $accountfrom->error.' '.$accountto->error); + } + } + /** * Update account * diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index f17e622210e..d89eecfed1a 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -267,9 +267,9 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $parameters = array('obj' => $obj); $reshook = $hookmanager->executeHooks('moreFamily', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if(empty($reshook)){ - $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : ''; - $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : ''; - $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : 0; + $ref = isset($hookmanager->resArray['ref']) ? $hookmanager->resArray['ref'] : $ref; + $refcomp = isset($hookmanager->resArray['refcomp']) ? $hookmanager->resArray['refcomp'] : $refcomp; + $paiement = isset($hookmanager->resArray['paiement']) ? $hookmanager->resArray['paiement'] : $paiement; } $total_ttc = $obj->total_ttc; @@ -312,7 +312,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if(empty($reshook)){ print $hookmanager->resPrint; - $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; + $solde = isset($hookmanager->resArray['solde']) ? $hookmanager->resArray['solde'] : $solde; } // solde diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 378d6087cc7..3e433b460f1 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -88,7 +88,7 @@ if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcon $backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php', 1); $triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record -if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH)) +if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH1)) { setEventMessages($langs->trans("CashDesk")." - ".$langs->trans("NotConfigured"), null, 'errors'); } @@ -132,16 +132,7 @@ elseif ($action=="add") $error=0; foreach($arrayofpaymentmode as $key=>$val) { - if (GETPOST($key.'_amount', 'alpha') == '') - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors'); - $action='start'; - $error++; - } - else - { - $object->$key = price2num(GETPOST($key.'_amount', 'alpha')); - } + $object->$key = price2num(GETPOST($key.'_amount', 'alpha')); } if (! $error) @@ -235,7 +226,14 @@ if ($action=="create" || $action=="start") $posmodule = GETPOST('posmodule', 'alpha'); $terminalid = GETPOST('posnumber', 'alpha'); $terminaltouse = $terminalid; - if ($terminaltouse == '1') $terminaltouse = ''; + + if ($terminaltouse == '1' && $posmodule=='cashdesk') $terminaltouse = ''; + + if ($posmodule=='cashdesk' && $terminaltouse != '' && $terminaltouse != '1') { + $terminaltouse = ''; + setEventMessages($langs->trans("OnlyTerminal1IsAvailableForCashDeskModule"), null, 'errors'); + $error++; + } // Calculate $initialbalanceforterminal for terminal 0 foreach($arrayofpaymentmode as $key => $val) @@ -271,7 +269,7 @@ if ($action=="create" || $action=="start") } else { - setEventMessages($langs->trans("SetupOfTerminalNotComplete", $terminalid), null, 'errors'); + setEventMessages($langs->trans("SetupOfTerminalNotComplete", $terminaltouse), null, 'errors'); $error++; } } diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 6584af5db98..ce0cdeed9fb 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -196,10 +196,18 @@ if ($resql) // Bank account print ''; print $bankaccount->getNomUrl(1); - if ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH==$bankaccount->id) $cash+=$objp->amount; - elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CB==$bankaccount->id) $bank+=$objp->amount; - elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE==$bankaccount->id) $cheque+=$objp->amount; - else $other+=$objp->amount; + if ($cashcontrol->posmodule=="takepos"){ + if ($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$cashcontrol->posnumber}==$bankaccount->id) $cash+=$objp->amount; + elseif ($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$cashcontrol->posnumber}==$bankaccount->id) $bank+=$objp->amount; + elseif ($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$cashcontrol->posnumber}==$bankaccount->id) $cheque+=$objp->amount; + else $other+=$objp->amount; + } + else{ + if ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH==$bankaccount->id) $cash+=$objp->amount; + elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CB==$bankaccount->id) $bank+=$objp->amount; + elseif ($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE==$bankaccount->id) $cheque+=$objp->amount; + else $other+=$objp->amount; + } print "\n"; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index bfa21a9c759..54c339284a5 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -945,7 +945,6 @@ if (empty($reshook)) $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); - $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); // Proprietes particulieres a facture de remplacement $object->fk_facture_source = $_POST['fac_replacement']; @@ -979,7 +978,7 @@ if (empty($reshook)) if (! $error) { - if(!empty($originentity)){ + if (!empty($originentity)) { $object->entity = $originentity; } $object->socid = GETPOST('socid', 'int'); @@ -1001,7 +1000,6 @@ if (empty($reshook)) $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); - $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); // Proprietes particulieres a facture avoir $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; @@ -1183,7 +1181,6 @@ if (empty($reshook)) $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); - $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); // Source facture $object->fac_rec = GETPOST('fac_rec', 'int'); @@ -1234,7 +1231,6 @@ if (empty($reshook)) $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); - $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); if (GETPOST('type') == Facture::TYPE_SITUATION) { @@ -2491,7 +2487,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc - $upload_dir = $conf->facture->dir_output; + $upload_dir = $conf->facture->multidir_output[$object->entity]; $permissioncreate=$usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -3316,8 +3312,8 @@ if ($action == 'create') '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B').')', '__INVOICE_MONTH_TEXT__' => $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')', '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')', - '__INVOICE_PREVIOUS_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')', - '__INVOICE_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')', + '__INVOICE_PREVIOUS_YEAR__' => $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')', + '__INVOICE_YEAR__' => $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')', '__INVOICE_NEXT_YEAR__' => $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')' ); @@ -5136,12 +5132,12 @@ elseif ($id > 0 || ! empty($ref)) // Documents generes $filename = dol_sanitizeFileName($object->ref); - $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); + $filedir = $conf->facture->multidir_output[$object->entity] . '/' . dol_sanitizeFileName($object->ref); $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id; $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object); $somethingshown = $formfile->numoffiles; // Show links to link elements @@ -5188,7 +5184,7 @@ elseif ($id > 0 || ! empty($ref)) // Presend form $modelmail='facture_send'; $defaulttopic='SendBillRef'; - $diroutput = $conf->facture->dir_output; + $diroutput = $conf->facture->multidir_output[$object->entity]; $trackid = 'inv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7f5dde15c59..33de9d47e18 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -318,7 +318,6 @@ class Facture extends CommonInvoice if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; $this->brouillon = 1; - if (empty($this->entity)) $this->entity = $conf->entity; // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); @@ -493,7 +492,7 @@ class Facture extends CommonInvoice $sql.= ")"; $sql.= " VALUES ("; $sql.= "'(PROV)'"; - $sql.= ", ".$this->entity; + $sql.= ", ".setEntity($this); $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); $sql.= ", '".$this->db->escape($this->type)."'"; $sql.= ", '".$socid."'"; @@ -936,8 +935,8 @@ class Facture extends CommonInvoice $facture->remise_absolue = $this->remise_absolue; $facture->remise_percent = $this->remise_percent; - $facture->origin = $this->origin; - $facture->origin_id = $this->origin_id; + $facture->origin = $this->origin; + $facture->origin_id = $this->origin_id; $facture->lines = $this->lines; // Array of lines of invoice $facture->products = $this->lines; // Tant que products encore utilise @@ -1624,7 +1623,11 @@ class Facture extends CommonInvoice $this->tab_previous_situation_invoice = array(); $this->tab_next_situation_invoice = array(); - $sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture WHERE rowid <> '.$this->id.' AND entity = '.$conf->entity.' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref.' ORDER BY situation_counter ASC'; + $sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture'; + $sql.= ' WHERE rowid <> '.$this->id; + $sql.= ' AND entity = '.$this->entity; + $sql.= ' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref; + $sql.= ' ORDER BY situation_counter ASC'; dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG); $result = $this->db->query($sql); @@ -3700,11 +3703,11 @@ class Facture extends CommonInvoice $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir - if($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE){ + if (! empty($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE)) { // Select the last situation invoice $sqlSit = 'SELECT MAX(fs.rowid)'; $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; - $sqlSit.= " WHERE fs.entity = ".$conf->entity; + $sqlSit.= " WHERE fs.entity IN (".getEntity('invoice').")"; $sqlSit.= " AND fs.type = ".self::TYPE_SITUATION; $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; $sqlSit.= " GROUP BY fs.situation_cycle_ref"; @@ -3921,6 +3924,7 @@ class Facture extends CommonInvoice $response = new WorkboardResponse(); $response->warning_delay=$conf->facture->client->warning_delay/60/60/24; $response->label=$langs->trans("CustomerBillsUnpaid"); + $response->labelShort=$langs->trans("Unpaid"); $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=billing&leftmenu=customers_bills'; $response->img=img_object('', "bill"); @@ -4230,7 +4234,7 @@ class Facture extends CommonInvoice public function newCycle() { $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; - $sql.= " WHERE f.entity in (".getEntity('invoice', 0).")"; + $sql.= " WHERE f.entity IN (".getEntity('invoice', 0).")"; $resql = $this->db->query($sql); if ($resql) { if ($resql->num_rows > 0) @@ -4274,8 +4278,8 @@ class Facture extends CommonInvoice global $conf; $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; - $sql .= ' where situation_cycle_ref = ' . $this->situation_cycle_ref; - $sql .= ' and situation_counter < ' . $this->situation_counter; + $sql .= ' WHERE situation_cycle_ref = ' . $this->situation_cycle_ref; + $sql .= ' AND situation_counter < ' . $this->situation_counter; $sql .= ' AND entity = '. ($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); $res = array(); @@ -4356,7 +4360,9 @@ class Facture extends CommonInvoice if (!empty($this->situation_cycle_ref)) { // No point in testing anything if we're not inside a cycle - $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref . ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); + $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture'; + $sql.= ' WHERE situation_cycle_ref = ' . $this->situation_cycle_ref; + $sql.= ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 44f69f512bd..9a8f308a0d1 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -97,7 +97,7 @@ if ($id > 0 || ! empty($ref)) { $object->fetch_thirdparty(); - $upload_dir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->facture->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref); $head = facture_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill'); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 25cf3f45fb1..aadedd3c5f7 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1017,8 +1017,8 @@ if ($action == 'create') $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%B').')'; $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%B').')'; $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')'; - $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y').')'; - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')'; + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y').')'; + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')'; $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y').')'; // Only on template invoices $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')'; @@ -1359,8 +1359,8 @@ else $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B').')'; $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')'; $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')'; - $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')'; - $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')'; + $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')'; + $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')'; $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')'; // Only on template invoices $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')'; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index eca39ade98c..71e0de738fa 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1231,7 +1231,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i); $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 920acd1c22f..30c31109224 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -744,6 +744,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print ""; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + // Warning print ''; //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
"; @@ -754,9 +757,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook - print "\n"; $total+=$objp->total; @@ -893,12 +893,13 @@ if (! GETPOST('action', 'aZ09')) print ''.$objp->ref."\n"; print ''.dol_print_date($db->jdate($objp->dp))."\n"; print ''.$objp->paiement_type.' '.$objp->num_paiement."\n"; - print ''.price($objp->amount).' '; - - $parameters=array(); - $reshook=$hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook - + print ''.price($objp->amount).''; + print ' '; print ''; + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + $i++; } print ''; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 26e3f2792d6..316215a5caf 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -527,6 +527,7 @@ class RemiseCheque extends CommonObject $response = new WorkboardResponse(); $response->warning_delay=$conf->bank->cheque->warning_delay/60/60/24; $response->label=$langs->trans("BankChecksToReceipt"); + $response->labelShort=$langs->trans("BankChecksToReceiptShort"); $response->url=DOL_URL_ROOT.'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank'; $response->img=img_object('', "payment"); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 2182375ff1a..2adb0e445bd 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -130,21 +130,6 @@ $AccCat = new AccountancyCategory($db); * View */ -$months = array( - $langs->trans("JanuaryMin"), - $langs->trans("FebruaryMin"), - $langs->trans("MarchMin"), - $langs->trans("AprilMin"), - $langs->trans("MayMin"), - $langs->trans("JuneMin"), - $langs->trans("JulyMin"), - $langs->trans("AugustMin"), - $langs->trans("SeptemberMin"), - $langs->trans("OctoberMin"), - $langs->trans("NovemberMin"), - $langs->trans("DecemberMin"), -); - llxHeader(); $form=new Form($db); diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 317531884c0..9bbf0501dbd 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -143,18 +143,18 @@ $AccCat = new AccountancyCategory($db); */ $months = array( - $langs->trans("JanuaryMin"), - $langs->trans("FebruaryMin"), - $langs->trans("MarchMin"), - $langs->trans("AprilMin"), - $langs->trans("MayMin"), - $langs->trans("JuneMin"), - $langs->trans("JulyMin"), - $langs->trans("AugustMin"), - $langs->trans("SeptemberMin"), - $langs->trans("OctoberMin"), - $langs->trans("NovemberMin"), - $langs->trans("DecemberMin"), + $langs->trans("MonthShort01"), + $langs->trans("MonthShort02"), + $langs->trans("MonthShort03"), + $langs->trans("MonthShort04"), + $langs->trans("MonthShort05"), + $langs->trans("MonthShort06"), + $langs->trans("MonthShort07"), + $langs->trans("MonthShort08"), + $langs->trans("MonthShort09"), + $langs->trans("MonthShort10"), + $langs->trans("MonthShort11"), + $langs->trans("MonthShort12"), ); llxheader('', $langs->trans('ReportInOut')); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 41c9555ccfc..4fd157de9e6 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -317,7 +317,7 @@ class ChargeSociales extends CommonObject $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'"; $sql.= ", periode='".$this->db->idate($this->periode)."'"; $sql.= ", amount='".price2num($this->amount, 'MT')."'"; - $sql.= ", fk_projet='".$this->db->escape($this->fk_project)."'"; + $sql.= ", fk_projet=".($this->fk_project > 0 ? $this->fk_project : null); $sql.= ", fk_user_modif=".$user->id; $sql.= " WHERE rowid=".$this->id; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 19437fe1aee..e064b93504d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1217,11 +1217,12 @@ class Contact extends CommonObject public function getCivilityLabel() { global $langs; - $langs->load("dict"); - $code=(! empty($this->civility_id)?$this->civility:(! empty($this->civilite)?$this->civilite:'')); + $code=($this->civility_code ? $this->civility_code : (! empty($this->civility_id)?$this->civility:(! empty($this->civilite)?$this->civilite:''))); if (empty($code)) return ''; - return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); + + $langs->load("dict"); + return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code); } /** diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e6e9b7f2e4d..2bb6ece49e6 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -96,6 +96,12 @@ class Contrat extends CommonObject */ public $ref_supplier; + /** + * Entity of the contract + * @var int + */ + public $entity; + /** * Client id linked to the contract * @var int @@ -617,13 +623,14 @@ class Contrat extends CommonObject * @param string $ref Ref * @param string $ref_customer Customer ref * @param string $ref_supplier Supplier ref - * @return int <0 if KO, 0 if not found, Id of contract if OK + * @return int <0 if KO, 0 if not found or if two records found for same ref, Id of contract if OK */ public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') { $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; $sql.= " ref_supplier, ref_customer,"; $sql.= " ref_ext,"; + $sql.= " entity,"; $sql.= " fk_user_mise_en_service, date_contrat as datecontrat,"; $sql.= " fk_user_author, fin_validite, date_cloture,"; $sql.= " fk_projet as fk_project,"; @@ -649,57 +656,67 @@ class Contrat extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $obj = $this->db->fetch_object($resql); - - if ($obj) + $num=$this->db->num_rows($resql); + if ($num > 1) { - $this->id = $obj->rowid; - $this->ref = (!isset($obj->ref) || !$obj->ref) ? $obj->rowid : $obj->ref; - $this->ref_customer = $obj->ref_customer; - $this->ref_supplier = $obj->ref_supplier; - $this->ref_ext = $obj->ref_ext; - $this->statut = $obj->statut; - $this->mise_en_service = $this->db->jdate($obj->datemise); - - $this->date_contrat = $this->db->jdate($obj->datecontrat); - $this->date_creation = $this->db->jdate($obj->datecontrat); - - $this->fin_validite = $this->db->jdate($obj->fin_validite); - $this->date_cloture = $this->db->jdate($obj->date_cloture); - - - $this->user_author_id = $obj->fk_user_author; - - $this->commercial_signature_id = $obj->fk_commercial_signature; - $this->commercial_suivi_id = $obj->fk_commercial_suivi; - - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->modelpdf = $obj->model_pdf; - - $this->fk_projet = $obj->fk_project; // deprecated - $this->fk_project = $obj->fk_project; - - $this->socid = $obj->fk_soc; - $this->fk_soc = $obj->fk_soc; - - $this->extraparams = (array) json_decode($obj->extraparams, true); - - $this->db->free($resql); - - // Retreive all extrafields - // fetch optionals attributes and labels - $this->fetch_optionals(); - - // Lines - $result=$this->fetch_lines(); - if ($result < 0) + $this->error='Fetch found several records.'; + dol_syslog($this->error, LOG_ERR); + $result = -2; + } + elseif ($num) // $num = 1 + { + $obj = $this->db->fetch_object($resql); + if ($obj) { - $this->error=$this->db->lasterror(); - return -3; - } + $this->id = $obj->rowid; + $this->ref = (!isset($obj->ref) || !$obj->ref) ? $obj->rowid : $obj->ref; + $this->ref_customer = $obj->ref_customer; + $this->ref_supplier = $obj->ref_supplier; + $this->ref_ext = $obj->ref_ext; + $this->entity = $obj->entity; + $this->statut = $obj->statut; + $this->mise_en_service = $this->db->jdate($obj->datemise); - return $this->id; + $this->date_contrat = $this->db->jdate($obj->datecontrat); + $this->date_creation = $this->db->jdate($obj->datecontrat); + + $this->fin_validite = $this->db->jdate($obj->fin_validite); + $this->date_cloture = $this->db->jdate($obj->date_cloture); + + + $this->user_author_id = $obj->fk_user_author; + + $this->commercial_signature_id = $obj->fk_commercial_signature; + $this->commercial_suivi_id = $obj->fk_commercial_suivi; + + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->modelpdf = $obj->model_pdf; + + $this->fk_projet = $obj->fk_project; // deprecated + $this->fk_project = $obj->fk_project; + + $this->socid = $obj->fk_soc; + $this->fk_soc = $obj->fk_soc; + + $this->extraparams = (array) json_decode($obj->extraparams, true); + + $this->db->free($resql); + + // Retreive all extrafields + // fetch optionals attributes and labels + $this->fetch_optionals(); + + // Lines + $result=$this->fetch_lines(); + if ($result < 0) + { + $this->error=$this->db->lasterror(); + return -3; + } + + return $this->id; + } } else { @@ -2186,23 +2203,27 @@ class Contrat extends CommonObject if ($mode == 'inactive') { $warning_delay = $conf->contrat->services->inactifs->warning_delay; $label = $langs->trans("BoardNotActivatedServices"); + $labelShort = $langs->trans("BoardNotActivatedServicesShort"); $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=0&sortfield=cd.date_fin_validite&sortorder=asc'; } elseif ($mode == 'expired') { $warning_delay = $conf->contrat->services->expires->warning_delay; $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; $label = $langs->trans("BoardExpiredServices"); + $labelShort = $langs->trans("BoardExpiredServicesShort"); } else { $warning_delay = $conf->contrat->services->expires->warning_delay; $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&sortfield=cd.date_fin_validite&sortorder=asc'; //$url.= '&op2day='.$arraydatetouse['mday'].'&op2month='.$arraydatetouse['mon'].'&op2year='.$arraydatetouse['year']; //if ($warning_delay >= 0) $url.='&filter=expired'; $label = $langs->trans("BoardRunningServices"); + $labelShort = $langs->trans("BoardRunningServicesShort"); } $response = new WorkboardResponse(); $response->warning_delay = $warning_delay/60/60/24; $response->label = $label; + $response->labelShort = $labelShort; $response->url = $url; $response->img = img_object('', "contract"); diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 72c78cb8a4d..54243494de4 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -125,8 +125,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $link = new Link($db); - $link->id = $linkid; - $link->fetch(); + $link->fetch($linkid); $res = $link->delete($user); $langs->load('link'); @@ -160,8 +159,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST(' require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $langs->load('link'); $link = new Link($db); - $link->id = GETPOST('linkid', 'int'); - $f = $link->fetch(); + $f = $link->fetch(GETPOST('linkid', 'int')); if ($f) { $link->url = GETPOST('link', 'alpha'); @@ -169,7 +167,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST(' { $link->url = 'http://' . $link->url; } - $link->label = GETPOST('label', 'alpha'); + $link->label = GETPOST('label', 'alphanohtml'); $res = $link->update($user); if (!$res) { diff --git a/htdocs/core/ajax/pingresult.php b/htdocs/core/ajax/pingresult.php index 3055942f89a..67608c24162 100644 --- a/htdocs/core/ajax/pingresult.php +++ b/htdocs/core/ajax/pingresult.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $action=GETPOST('action', 'alpha'); $hash_unique_id=GETPOST('hash_unique_id', 'alpha'); -$hash_algo=GETPOST('hash', 'alpha'); +$hash_algo=GETPOST('hash_algo', 'alpha'); // Security check @@ -53,7 +53,7 @@ print ''; $out .= ''; + +print $out; + pFooter($ok?0:1, $setuplang); if (isset($db) && is_object($db)) $db->close(); diff --git a/htdocs/install/step4.php b/htdocs/install/step4.php index dceb32a3d3a..342ec82d0fd 100644 --- a/htdocs/install/step4.php +++ b/htdocs/install/step4.php @@ -80,11 +80,11 @@ $db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf-> if ($db->ok) { print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; if (isset($_GET["error"]) && $_GET["error"] == 1) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d408cddc5c8..1b4badc39b5 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -432,7 +432,7 @@ ExtrafieldParamHelpradio=List of values must be lines with format key,value (whe ExtrafieldParamHelpsellist=List of values comes from a table
Syntax: table_name:label_field:id_field::filter
Example: c_typent:libelle:id::filter

- idfilter is necessarly a primary int key
- filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another complementary attribute list:
c_typent:libelle:id:options_parent_list_code|parent_column:filter

In order to have the list depending on another list:
c_typent:libelle:id:parent_list_code|parent_column:filter ExtrafieldParamHelpchkbxlst=List of values comes from a table
Syntax: table_name:label_field:id_field::filter
Example: c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
You can also use $ID$ in filter witch is the current id of current object
To do a SELECT in filter use $SEL$
if you want to filter on extrafields use syntax extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another complementary attribute list:
c_typent:libelle:id:options_parent_list_code|parent_column:filter

In order to have the list depending on another list:
c_typent:libelle:id:parent_list_code|parent_column:filter ExtrafieldParamHelplink=Parameters must be ObjectName:Classpath
Syntax: ObjectName:Classpath
Examples:
Societe:societe/class/societe.class.php
Contact:contact/class/contact.class.php -ExtrafieldParamHelpSeparator=Keep empty for a simple separator
Set this to 1 for a collapsing separator (open by default)
Set this to 2 for a collapsing separator (collapsed by default) +ExtrafieldParamHelpSeparator=Keep empty for a simple separator
Set this to 1 for a collapsing separator (open by default for new session, then status is kept for each user session)
Set this to 2 for a collapsing separator (collapsed by default for new session, then status is kept fore each user session) LibraryToBuildPDF=Library used for PDF generation LocalTaxDesc=Some countries may apply two or three taxes on each invoice line. If this is the case, choose the type for the second and third tax and its rate. Possible type are:
1: local tax apply on products and services without vat (localtax is calculated on amount without tax)
2: local tax apply on products and services including vat (localtax is calculated on amount + main tax)
3: local tax apply on products without vat (localtax is calculated on amount without tax)
4: local tax apply on products including vat (localtax is calculated on amount + main vat)
5: local tax apply on services without vat (localtax is calculated on amount without tax)
6: local tax apply on services including vat (localtax is calculated on amount + tax) SMS=SMS @@ -1696,7 +1696,7 @@ SuppliersInvoiceNumberingModel=Vendor invoices numbering models IfSetToYesDontForgetPermission=If set to yes, don't forget to provide permissions to groups or users allowed for the second approval ##### GeoIPMaxmind ##### GeoIPMaxmindSetup=GeoIP Maxmind module setup -PathToGeoIPMaxmindCountryDataFile=Path to file containing Maxmind ip to country translation.
Examples:
/usr/local/share/GeoIP/GeoIP.dat
/usr/share/GeoIP/GeoIP.dat +PathToGeoIPMaxmindCountryDataFile=Path to file containing Maxmind ip to country translation.
Examples:
/usr/local/share/GeoIP/GeoIP.dat
/usr/share/GeoIP/GeoIP.dat
/usr/share/GeoIP/GeoLite2-Country.mmdb NoteOnPathLocation=Note that your ip to country data file must be inside a directory your PHP can read (Check your PHP open_basedir setup and filesystem permissions). YouCanDownloadFreeDatFileTo=You can download a free demo version of the Maxmind GeoIP country file at %s. YouCanDownloadAdvancedDatFileTo=You can also download a more complete version, with updates, of the Maxmind GeoIP country file at %s. @@ -1932,3 +1932,8 @@ DeleteEmailCollector=Delete email collector ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector? RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined +RESTRICT_API_ON_IP=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs. +RESTRICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access. +BaseOnSabeDavVersion=Based on the library SabreDAV version +NotAPublicIp=Not a public IP +MakeAnonymousPing=Make an anonymous Ping '+1' to the Dolibarr foundation server (done 1 time only after installation) to allow the foundation to count the number of Dolibarr installation. \ No newline at end of file diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index c77158e07b7..47295ec7e31 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -73,6 +73,7 @@ BankTransaction=Bank entry ListTransactions=List entries ListTransactionsByCategory=List entries/category TransactionsToConciliate=Entries to reconcile +TransactionsToConciliateShort=To reconcile Conciliable=Can be reconciled Conciliate=Reconcile Conciliation=Reconciliation @@ -116,6 +117,7 @@ DeleteCheckReceipt=Delete this check receipt? ConfirmDeleteCheckReceipt=Are you sure you want to delete this check receipt? BankChecks=Bank checks BankChecksToReceipt=Checks awaiting deposit +BankChecksToReceiptShort=Checks awaiting deposit ShowCheckReceipt=Show check deposit receipt NumberOfCheques=No. of check DeleteTransaction=Delete entry diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 83c217b06f7..628de17efcc 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -68,4 +68,7 @@ Terminal=Terminal NumberOfTerminals=Number of Terminals TerminalSelect=Select terminal you want to use: POSTicket=POS Ticket -BasicPhoneLayout=Use basic layout for phones \ No newline at end of file +BasicPhoneLayout=Use basic layout for phones +SetupOfTerminalNotComplete=Setup of terminal %s is not complete +DirectPayment=Direct payment +DirectPaymentButton=Direct cash payment button diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang index 129b7d8416a..47572c355ab 100644 --- a/htdocs/langs/en_US/contracts.lang +++ b/htdocs/langs/en_US/contracts.lang @@ -51,6 +51,7 @@ ListOfClosedServices=List of closed services ListOfRunningServices=List of running services NotActivatedServices=Inactive services (among validated contracts) BoardNotActivatedServices=Services to activate among validated contracts +BoardNotActivatedServicesShort=Services to activate LastContracts=Latest %s contracts LastModifiedServices=Latest %s modified services ContractStartDate=Start date @@ -65,7 +66,9 @@ DateEndReal=Real end date DateEndRealShort=Real end date CloseService=Close service BoardRunningServices=Services running +BoardRunningServicesShort=Services running BoardExpiredServices=Services expired +BoardExpiredServicesShort=Services expired ServiceStatus=Status of service DraftContracts=Drafts contracts CloseRefusedBecauseOneServiceActive=Contract can't be closed as there is at least one open service on it diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 880978a13e5..5c3e30967de 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -705,6 +705,7 @@ DateOfSignature=Date of signature HidePassword=Show command with password hidden UnHidePassword=Show real command with clear password Root=Root +RootOfMedias=Root of public medias (/medias) Informations=Information Page=Page Notes=Notes @@ -982,3 +983,10 @@ PaymentInformation=Payment information ValidFrom=Valid from ValidUntil=Valid until NoRecordedUsers=No users +ToClose=To close +ToProcess=To process +ToApprove=To approve +GlobalOpenedElemView=Global view +NoArticlesFoundForTheKeyword=No article found for the keyword '%s' +NoArticlesFoundForTheCategory=No article found for the category +ToAcceptRefuse=To accept | refuse \ No newline at end of file diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 9993e05428f..5886c598d52 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -29,6 +29,7 @@ MenuMembersUpToDate=Up to date members MenuMembersNotUpToDate=Out of date members MenuMembersResiliated=Terminated members MembersWithSubscriptionToReceive=Members with subscription to receive +MembersWithSubscriptionToReceiveShort=Subscription to receive DateSubscription=Subscription date DateEndSubscription=Subscription end date EndSubscription=End subscription diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 36ca0ede002..73e672284de 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -340,4 +340,4 @@ ErrorCopyProductCombinations=There was an error while copying the product varian ErrorDestinationProductNotFound=Destination product not found ErrorProductCombinationNotFound=Product variant not found ActionAvailableOnVariantProductOnly=Action only available on the variant of product -ProductsPricePerCustomer=Product prices per customers \ No newline at end of file +ProductsPricePerCustomer=Product prices per customers diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index ca9a1e2452f..4b4a787b6ad 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -76,7 +76,13 @@ MyProjects=My projects MyProjectsArea=My projects Area DurationEffective=Effective duration ProgressDeclared=Declared progress +TaskProgressSummary=Task progress +CurentlyOpenedTasks=Curently opened tasks +TheReportedProgressIsLessThanTheCalculatedProgressionByX=The declared progress is less %s than the calculated progression +TheReportedProgressIsMoreThanTheCalculatedProgressionByX=The declared progress is more %s than the calculated progression ProgressCalculated=Calculated progress +WhichIamLinkedTo=which I'm linked to +WhichIamLinkedToProject=which I'm linked to project Time=Time ListOfTasks=List of tasks GoToListOfTimeConsumed=Go to list of time consumed diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index f01494fcdac..6b5c0a300e8 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -2,7 +2,7 @@ Shortname=Code WebsiteSetupDesc=Create here the websites you wish to use. Then go into menu Websites to edit them. DeleteWebsite=Delete website -ConfirmDeleteWebsite=Are you sure you want to delete this web site? All its pages and content will also be removed. +ConfirmDeleteWebsite=Are you sure you want to delete this web site? All its pages and content will also be removed. The files uploaded (like into the medias directory, the ECM module, ...) will remain. WEBSITE_TYPE_CONTAINER=Type of page/container WEBSITE_PAGE_EXAMPLE=Web page to use as example WEBSITE_PAGENAME=Page name/alias @@ -15,6 +15,8 @@ WEBSITE_HTML_HEADER=Addition at bottom of HTML Header (common to all pages) WEBSITE_ROBOT=Robot file (robots.txt) WEBSITE_HTACCESS=Website .htaccess file WEBSITE_MANIFEST_JSON=Website manifest.json file +WEBSITE_README=README.md file +EnterHereLicenseInformation=Enter here meta data or license information to fille a README.md file. if you distribute your website as a template, the file will be included into the temptate package. HtmlHeaderPage=HTML header (specific to this page only) PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is ran from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias. EditTheWebSiteForACommonHeader=Note: If you want to define a personalized header for all pages, edit the header on the site level instead of on the page/container. @@ -42,6 +44,7 @@ RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs SetHereVirtualHost=Use with Apache/NGinx/...
If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on
%s
then set the name of the virtual host you have created in the properties of web site, so the preview can be done also using this dedicated web server access instead of the internal Dolibarr server. YouCanAlsoTestWithPHPS=Use with PHP embedded server
On develop environment, you may prefer to test the site with the PHP embedded web server (PHP 5.5 required) by running
php -S 0.0.0.0:8080 -t %s +YouCanAlsoDeployToAnotherWHP=Run your web site with another Dolibarr Hosting provider
If you don't have a web server like Apache or NGinx available on internet, you can export and import your web site onto another Dolibarr instance provided by another Dolibarr hosting provider that provide full integration with the Website module. You can find a list of some Dolibarr hosting providers on https://saas.dolibarr.org CheckVirtualHostPerms=Check also that virtual host has permission %s on files into
%s ReadPerm=Read WritePerm=Write @@ -76,7 +79,7 @@ AddWebsiteAccount=Create web site account BackToListOfThirdParty=Back to list for Third Party DisableSiteFirst=Disable website first MyContainerTitle=My web site title -AnotherContainer=Another container +AnotherContainer=This is how to include content of another page/container (you may have an error here if you enable dynamic code because the embedded subcontainer may not exists) SorryWebsiteIsCurrentlyOffLine=Sorry, this website is currently off line. Please comme back later... WEBSITE_USE_WEBSITE_ACCOUNTS=Enable the web site account table WEBSITE_USE_WEBSITE_ACCOUNTSTooltip=Enable the table to store web site accounts (login/pass) for each website / third party @@ -106,4 +109,8 @@ DeleteAlsoJs=Delete also all javascript files specific to this website? DeleteAlsoMedias=Delete also all medias files specific to this website? MyWebsitePages=My website pages SearchReplaceInto=Search | Replace into -ReplaceString=New string \ No newline at end of file +ReplaceString=New string +CSSContentTooltipHelp=Enter here CSS content. To avoid any conflict with the CSS of the application, be sure to prepend all declaration with the .bodywebsite class. For example:

#mycssselector, input.myclass:hover { ... }
must be
.bodywebsite #mycssselector, .bodywebsite input.myclass:hover { ... }

Note: If you have a large file without this prefix, you can use 'lessc' to convert it to append the .bodywebsite prefix everywhere. +LinkAndScriptsHereAreNotLoadedInEditor=Warning: This content is output only when site is accessed from a server. It is not used in Edit mode so if you need to load javascript files also in edit mode, just add your tag 'script src=...' into the page. +Dynamiccontent=Sample of a page with dynamic content +ImportSite=Import site \ No newline at end of file diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 097e2e3fc8d..6ad580cfcd9 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -340,4 +340,4 @@ ErrorCopyProductCombinations=Une erreur s'est produite lors de la copie des vari ErrorDestinationProductNotFound=Produit destination non trouvé ErrorProductCombinationNotFound=Variante du produit non trouvé ActionAvailableOnVariantProductOnly=Action disponible uniquement sur la variante du produit -ProductsPricePerCustomer=Prix produit par clients +ProductsPricePerCustomer=Prix produit par clients \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2ba5e3b484a..620a4b4e7f6 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -624,7 +624,7 @@ if (! defined('NOLOGIN')) session_destroy(); session_name($sessionname); session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie - session_start(); // Fixing the bug of register_globals here is useless since session is empty + session_start(); if ($resultFetchUser == 0) { @@ -681,7 +681,7 @@ if (! defined('NOLOGIN')) session_destroy(); session_name($sessionname); session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie - session_start(); // Fixing the bug of register_globals here is useless since session is empty + session_start(); if ($resultFetchUser == 0) { @@ -1217,7 +1217,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr if (GETPOST('dol_basehref', 'alpha')) print ''."\n"; // Displays meta - print ''."\n"; + print ''."\n"; print ''."\n"; // Do not index print ''."\n"; // Scale for mobile device print ''."\n"; @@ -1258,11 +1258,12 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr $themeparam='?lang='.$langs->defaultlang.'&theme='.$conf->theme.(GETPOST('optioncss', 'aZ09')?'&optioncss='.GETPOST('optioncss', 'aZ09', 1):'').'&userid='.$user->id.'&entity='.$conf->entity; $themeparam.=($ext?'&'.$ext:'').'&revision='.$conf->global->MAIN_IHM_PARAMS_REV; if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&dol_resetcache='.$_SESSION['dol_resetcache']; - if (GETPOST('dol_hide_topmenu', 'int')) { $themeparam.='&dol_hide_topmenu='.GETPOST('dol_hide_topmenu', 'int'); } - if (GETPOST('dol_hide_leftmenu', 'int')) { $themeparam.='&dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu', 'int'); } - if (GETPOST('dol_optimize_smallscreen', 'int')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen', 'int'); } - if (GETPOST('dol_no_mouse_hover', 'int')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover', 'int'); } - if (GETPOST('dol_use_jmobile', 'int')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile', 'int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); } + if (GETPOSTISSET('dol_hide_topmenu')) { $themeparam.='&dol_hide_topmenu='.GETPOST('dol_hide_topmenu', 'int'); } + if (GETPOSTISSET('dol_hide_leftmenu')) { $themeparam.='&dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu', 'int'); } + if (GETPOSTISSET('dol_optimize_smallscreen')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen', 'int'); } + if (GETPOSTISSET('dol_no_mouse_hover')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover', 'int'); } + if (GETPOSTISSET('dol_use_jmobile')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile', 'int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); } + if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) { $themeparam.='&THEME_AGRESSIVITY_RATIO='.GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); } if (! defined('DISABLE_JQUERY') && ! $disablejs && $conf->use_javascript_ajax) { @@ -1441,6 +1442,9 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr print 'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n"; print ''."\n"; print ''."\n"; + print ''."\n"; } // Browser notifications @@ -1814,11 +1818,11 @@ function top_menu_user(User $user, Translate $langs) } else $appli.=" ".DOL_VERSION; - $btnUser = ' + $btnUser = ' '; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index daf77674190..db37b15345b 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1834,7 +1834,8 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment print '
'; - print '
'; + print ''."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; @@ -1852,7 +1853,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment print ''; print ''; - if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) + if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) // Use a SCA ready method { require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; @@ -1876,8 +1877,8 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment } } - if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) - { + //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) + //{ print '
'; @@ -1914,7 +1915,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment print '
'; - } + //} if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { @@ -1942,6 +1943,8 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment { print ''; print ''."\n"; + $urllogofull = 'http://home.destailleur.fr:805/dolibarr_dev/htdocs/viewimage.php?modulepart=mycompany&entity=1&file=logos%2Fthumbs%2Ffbm+logo_small.png'; + print ''."\n"; // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. print ''; */ - print 'ref.'" class="button nobordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("ReplaceWebsiteContent")).'">'; + print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("ReplaceWebsiteContent")).'">'; } print '
'; @@ -2011,6 +2041,9 @@ if (! GETPOST('hide_websitemenu')) $htmltext.='
'; $htmltext.='
'; $htmltext.=$langs->trans("YouCanAlsoTestWithPHPS", $dataroot); + $htmltext.='
'; + $htmltext.='
'; + $htmltext.=$langs->trans("YouCanAlsoDeployToAnotherWHP"); } print $form->textwithpicto($linktotestonwebserver, $htmltext, 1, 'none', 'valignmiddle', 0, 2, 'helpvirtualhost'); print ''; @@ -2198,17 +2231,63 @@ if (! GETPOST('hide_websitemenu')) print '   '; - print ''; + print ''; - print ''; + print ''; print ''."\n"; print '
'; print '
'; + + print ''; + print ''; print $langs->trans("EditInLine"); + print ''; + if ($websitepage->grabbed_from) { - //print ''; + //print ''; print ''.img_picto($langs->trans("OnlyEditionOfSourceForGrabbedContent"), 'switch_off', '', false, 0, 0, '', 'nomarginleft').''; } else @@ -2223,6 +2302,7 @@ if (! GETPOST('hide_websitemenu')) print ''.img_picto($langs->trans("EditInLineOn"), 'switch_on', '', false, 0, 0, '', 'nomarginleft').''; } } + print '
'; print '
'; print $langs->trans("ShowSubcontainers"); @@ -2248,17 +2328,17 @@ if (! GETPOST('hide_websitemenu')) if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) { //$disabled=' disabled="disabled"'; - //print ''; - print ''; + //print ''; + print ''; } else { //$disabled=''; - //print 'ref.'" class="button nobordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'">'; - print ''; + //print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'">'; + print ''; } - print ''; - print ''; + print ''; + print ''; } } @@ -2316,7 +2396,8 @@ if (! GETPOST('hide_websitemenu')) } else { - print $form->textwithpicto($langs->trans("SyntaxHelp"), $htmltext, 1, 'help', 'inline-block', 1, 2, 'tooltipsubstitution'); + //img_help(($tooltiptrigger != '' ? 2 : 1), $alt) + print $form->textwithpicto($langs->trans("SyntaxHelp").' '.img_help(2, $langs->trans("SyntaxHelp")), $htmltext, 1, 'none', 'inline-block', 1, 2, 'tooltipsubstitution'); } } print '
'; // end websitehelp @@ -2488,6 +2569,21 @@ if ($action == 'editcss') //$manifestjsoncontent.=""; } + if (GETPOST('editcss', 'alpha') || GETPOST('refreshpage', 'alpha')) + { + $readmecontent = @file_get_contents($filereadme); + // Clean the readme file to remove php code and get only html part + $readmecontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $readmecontent); + } + else + { + $readmecontent = GETPOST('WEBSITE_README'); + } + if (! trim($readmecontent)) + { + //$readmecontent.=""; + } + dol_fiche_head(); print ''."\n"; @@ -2516,7 +2612,8 @@ if ($action == 'editcss') // CSS file print ''; - print $langs->trans('WEBSITE_CSS_INLINE'); + $htmlhelp=$langs->trans("CSSContentTooltipHelp"); + print $form->textwithpicto($langs->trans('WEBSITE_CSS_INLINE'), $htmlhelp, 1, 'help', '', 0, 2, 'csstooltip'); print ''; $doleditor=new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); @@ -2536,9 +2633,12 @@ if ($action == 'editcss') // Common HTML header print ''; + print $langs->trans('WEBSITE_HTML_HEADER'); $htmlhelp=$langs->trans("Example").' :
'; $htmlhelp.=dol_htmlentitiesbr($htmlheadercontentdefault); - print $form->textwithpicto($langs->trans('WEBSITE_HTML_HEADER'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip'); + $textwithhelp = $form->textwithpicto('', $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip'); + $htmlhelp2=$langs->trans("LinkAndScriptsHereAreNotLoadedInEditor").'
'; + print $form->textwithpicto($textwithhelp, $htmlhelp2, 1, 'warning', '', 0, 2, 'htmlheadertooltip2'); print ''; $doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheadercontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); @@ -2578,6 +2678,17 @@ if ($action == 'editcss') print ''; + // README.md + print ''; + $htmlhelp=$langs->trans("EnterHereLicenseInformation"); + print $form->textwithpicto($langs->trans('WEBSITE_README'), $htmlhelp, 1, 'help', '', 0, 2, 'readmetooltip'); + print ''; + + $doleditor=new DolEditor('WEBSITE_README', $readmecontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + print $doleditor->Create(1, '', true, $langs->trans("File").' README.md', 'text'); + + print ''; + print ''; dol_fiche_end(); @@ -2819,7 +2930,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; print $langs->trans('WEBSITE_PAGE_EXAMPLE'); print ''; - print $formwebsite->selectSampleOfContainer('sample', (GETPOST('sample', 'alpha')?GETPOST('sample', 'alpha'):'corporatehomepage')); + print $formwebsite->selectSampleOfContainer('sample', (GETPOSTISSET('sample')?GETPOST('sample', 'alpha'):'empty')); print ''; } @@ -2924,7 +3035,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') if ($action != 'createcontainer') { print ''; - print $langs->trans('LastModificationAuthor'); + print $langs->trans('UserModif'); print ''; if ($pageusermodifid > 0) { @@ -2969,7 +3080,10 @@ if ($action == 'editmeta' || $action == 'createcontainer') jQuery("#WEBSITE_TITLE").keyup(function() { if (disableautofillofalias == 0) { - var valnospecial = jQuery("#WEBSITE_TITLE").val().replace(/[^\w]/gi, \'-\').toLowerCase(); + var valnospecial = jQuery("#WEBSITE_TITLE").val(); + valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\'); + valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\'); + valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase(); valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\'); console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial); jQuery("#WEBSITE_PAGENAME").val(valnospecial); @@ -3057,9 +3171,10 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''; print ''; print ''; + print ''; - print ''."\n"; + print ''."\n"; print '

'; print load_fiche_titre($langs->trans("ReplaceWebsiteContent")); @@ -3141,6 +3256,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa // Ouput page under the Dolibarr top menu $objectpage->fetch($pageid); + $jscontent = @file_get_contents($filejs); $out = ''."\n"; @@ -3155,6 +3271,25 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out.="\n\n"; $out.="\n"; $out.=dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1, 'htmlheader'); + + $out.="\n"; + // TODO Keep only the or the