diff --git a/.travis.yml b/.travis.yml index b48a3667bb0..92cd2059b15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ jobs: env: DB=postgresql - stage: PHP 5.6-7.4 if: type = pull_request OR type = push - php: '7.4' + php: '7.4.22' env: DB=mysql - stage: PHP Dev if: type = push AND branch = develop @@ -106,7 +106,7 @@ install: php-parallel-lint/php-console-highlighter ^0 \ squizlabs/php_codesniffer ^3 fi - if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '7.4.22' ]; then composer -n require phpunit/phpunit ^7 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ @@ -241,7 +241,7 @@ before_script: # enable php-fpm - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - | - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '7.4.22' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then # Copy the included pool sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf fi @@ -276,7 +276,7 @@ script: set -e #parallel-lint --exclude htdocs/includes --blame . # Exclusions are defined in the ruleset.xml file - if [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then + if [ "$TRAVIS_PHP_VERSION" = "7.4.22" ]; then parallel-lint -e php --exclude dev/tools/test/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ @@ -291,7 +291,7 @@ script: # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then + if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4.22" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi set +e diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index c156a388735..efa9fc03c78 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -260,7 +260,7 @@ if ($action == "confirm_update") { if ($mode != '_tmp') { setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } - $action = 'update'; + $action = ''; $id = $object->id; $piece_num = $object->piece_num; } @@ -537,7 +537,7 @@ if ($action == 'create') { print ''; print ''; - // Date document creation + // Date document export print ''; print ''.$langs->trans("DateExport").''; print ''; @@ -545,7 +545,7 @@ if ($action == 'create') { print ''; print ''; - // Date document creation + // Date document validation print ''; print ''.$langs->trans("DateValidation").''; print ''; @@ -604,6 +604,7 @@ if ($action == 'create') { print '
'; $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { @@ -643,6 +644,15 @@ if ($action == 'create') { print "\n"; + // Add an empty line if there is not yet + if (!empty($object->linesmvt[0])) { + $tmpline = $object->linesmvt[0]; + if (!empty($tmpline->numero_compte)) { + $line = new BookKeepingLine(); + $object->linesmvt[] = $line; + } + } + foreach ($object->linesmvt as $line) { print ''; $total_debit += $line->debit; @@ -673,7 +683,33 @@ if ($action == 'create') { print ''."\n"; print ''; print ''; + } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) { + if ($action == "" || $action == 'add') { + print ''; + print ''; + print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); + print ''; + print ''; + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + } else { + print ''; + } + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } } else { + print ''; $accountingaccount->fetch(null, $line->numero_compte, true); print ''.$accountingaccount->getNomUrl(0, 1, 1, '', 0).''; print ''.length_accounta($line->subledger_account); @@ -715,33 +751,8 @@ if ($action == 'create') { setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); } - if (empty($object->date_export) && empty($object->date_validation)) { - if ($action == "" || $action == 'add') { - print ''; - print ''; - print ''; - print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); - print ''; - print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: - // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. - // Also, it is not possible to use a value that is not in the list. - // Also, the label is not automatically filled when a value is selected. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount('', 'subledger_account', 1); - } else { - print ''; - } - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - print ''; - } + print ''; + print ''; if ($mode == '_tmp' && $action == '') { print '
'; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 5635df3c8e7..c6dd938ed78 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -597,9 +597,13 @@ class BookKeeping extends CommonObject if (empty($this->credit)) { $this->credit = 0; } + if (empty($this->montant)) { + $this->montant = 0; + } $this->debit = price2num($this->debit, 'MT'); $this->credit = price2num($this->credit, 'MT'); + $this->montant = price2num($this->montant, 'MT'); $now = dol_now(); @@ -1649,11 +1653,10 @@ class BookKeeping extends CommonObject $this->doc_date = $this->db->jdate($obj->doc_date); $this->doc_ref = $obj->doc_ref; $this->doc_type = $obj->doc_type; - $this->date_creation = $obj->date_creation; - $this->date_modification = $obj->date_modification; - $this->date_export = $obj->date_export; - $this->date_validation = $obj->date_validated; - $this->date_validation = $obj->date_validation; + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->date_modification = $this->db->jdate($obj->date_modification); + $this->date_export = $this->db->jdate($obj->date_export); + $this->date_validation = $this->db->jdate($obj->date_validation); } else { $this->error = "Error ".$this->db->lasterror(); dol_syslog(__METHOD__.$this->error, LOG_ERR); @@ -1857,7 +1860,7 @@ class BookKeeping extends CommonObject $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.$next_piecenum.", '".$this->db->idate($now)."'"; - $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity); + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND numero_compte IS NOT NULL AND entity = ' .((int) $conf->entity); $resql = $this->db->query($sql); if (!$resql) { $error++; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index c233134f562..33d94a34636 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -1,9 +1,9 @@ - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2021 Alexandre Spangaro - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry +/* Copyright (C) 2013 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -158,6 +158,7 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; + $sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 1e7c38b2607..a4945afca35 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -137,9 +137,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->acco if (!$error) { $db->begin(); - $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); - $sql1 .= ' WHERE l.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')'; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet"; + $sql1 .= " SET fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); + $sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')'; dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1); $resql1 = $db->query($sql1); diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 1842c23f418..8892c9af9f7 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -112,77 +112,78 @@ if ($conf->accounting->enabled) { print '
'; // hideobject is to start hidden print "
\n"; print ''.$langs->trans("AccountancyAreaDescIntro")."
\n"; - print "
\n"; print "
\n"; + if (!empty($user->rights->accounting->chartofaccount)) { + print "
\n"; print "
\n"; - print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; - print '
'; - print "
\n"; + print load_fiche_titre(' '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; + print '
'; + print "
\n"; - // STEPS - $step++; - $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}'); - $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").'', $s); - print $s; - print "
\n"; - $step++; - $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}'); - $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'', $s); - print $s; - print "
\n"; - $step++; - $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}'); - $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'', $s); - print $s; - print "
\n"; - - print "
\n"; - print $langs->trans("AccountancyAreaDescActionOnceBis"); - print "
\n"; - print "
\n"; - - $step++; - $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}'); - $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $s); - print $s; - print "
\n"; - - $step++; - $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n"; - $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'', $s); - print $s; - print "
\n"; - - $step++; - $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").''; - $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}'); - $s = str_replace('{s}', $textlink, $s); - print $s; - print "
\n"; - if (!empty($conf->tax->enabled)) { - $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").''; + // STEPS $step++; - $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}'); + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").'', $s); + print $s; + print "
\n"; + $step++; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'', $s); + print $s; + print "
\n"; + $step++; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'', $s); + print $s; + print "
\n"; + + print "
\n"; + print $langs->trans("AccountancyAreaDescActionOnceBis"); + print "
\n"; + print "
\n"; + + $step++; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'', $s); + print $s; + print "
\n"; + + $step++; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n"; + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'', $s); + print $s; + print "
\n"; + + $step++; + $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").''; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}'); $s = str_replace('{s}', $textlink, $s); print $s; print "
\n"; - } - if (!empty($conf->expensereport->enabled)) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several. + if (!empty($conf->tax->enabled)) { + $textlink = ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").''; + $step++; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}'); + $s = str_replace('{s}', $textlink, $s); + print $s; + print "
\n"; + } + if (!empty($conf->expensereport->enabled)) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several. + $step++; + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'', $s); + print $s; + print "
\n"; + } + $step++; - $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}'); - $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'', $s); + $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}'); + $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'', $s); print $s; print "
\n"; + + print '
'; } - $step++; - $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}'); - $s = str_replace('{s}', ''.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'', $s); - print $s; - print "
\n"; - - - print '
'; - // Step A - E print "
\n"; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index bdda4583d54..19a9ca63c07 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -288,8 +288,16 @@ if ($result) { // get_url may return -1 which is not traversable if (is_array($links) && count($links) > 0) { + $is_sc = false; + foreach ($links as $v) { + if ($v['type'] == 'sc') { + $is_sc = true; + break; + } + } // Now loop on each link of record in bank (code similar to bankentries_list.php) foreach ($links as $key => $val) { + if ($links[$key]['type'] == 'user' && !$is_sc) continue; if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) { // So we excluded 'company' and 'user' here. We want only payment lines diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 9ea8fd0a307..48462c38365 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -1,8 +1,8 @@ - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2020 Alexandre Spangaro - * Copyright (C) 2014 Juanjo Menent +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -166,6 +166,7 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_product_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; + $sql .= " AND f.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 61e17ab669c..861be65e1d8 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -140,9 +140,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->acco if (!$error) { $db->begin(); - $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as l"; - $sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); - $sql1 .= ' WHERE l.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')'; + $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; + $sql1 .= " SET fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0'); + $sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')'; dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1); $resql1 = $db->query($sql1); diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index fd500b34775..ee195da77be 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -920,8 +920,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->country = $tmparray['label']; } + $soc = new Societe($db); if (!empty($socid)) { - $soc = new Societe($db); if ($socid > 0) { $soc->fetch($socid); } diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index d9ab62336a1..04925dc0c0f 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -1061,12 +1061,12 @@ if ($rowid > 0) { // Bank account print ''.$langs->trans("FinancialAccount").''; print img_picto('', 'bank_account'); - $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); + $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2, '', 0, 'minwidth200'); print "\n"; // Payment mode print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); + $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2, 1, 0, 0, 1, 'minwidth200'); print "\n"; // Date of payment diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index 19a440520b1..ce3c43bd69d 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -93,15 +93,17 @@ print ''.$langs->trans("Parameter").''.$langs->trans("Value").''; print "\n"; -print ''.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").''; -print ''; // This slow seriously output -print ' '.$langs->trans("WarningValueHigherSlowsDramaticalyOutput"); +print ''.$langs->trans("DEBUGBAR_USE_LOG_FILE").''; +print ''; +print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1); +print ''; +print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower").''; print ''; -print ''.$langs->trans("DEBUGBAR_USE_LOG_FILE").''; -print ''; -print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1); -print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower"); +print ''.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").''; +print ''; // This slow seriously output +print ''; +print ''.$langs->trans("WarningValueHigherSlowsDramaticalyOutput").''; print ''; print ''; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 0adc526d69e..3abeb0bde54 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -205,7 +205,7 @@ if (!empty($conf->expedition->enabled)) { $elementList['shipping_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendShipment')); } if (!empty($conf->reception->enabled)) { - $elementList['reception_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendReception')); + $elementList['reception_send'] = img_picto('', 'dollyrevert', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendReception')); } if (!empty($conf->ficheinter->enabled)) { $elementList['fichinter_send'] = img_picto('', 'intervention', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendIntervention')); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 752868acb87..a5a898ef7f2 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -659,7 +659,7 @@ if (empty($reshook) && $action == 'update') { $categories = GETPOST('categories', 'array'); $object->setCategories($categories); - $object->loadReminders(); + $object->loadReminders($remindertype, 0, false); if (!empty($object->reminders) && $object->datep > dol_now()) { foreach ($object->reminders as $reminder) { $reminder->delete($user); @@ -1439,6 +1439,10 @@ if ($id > 0) { $("#fullday").change(function() { setdatefields(); }); + $("#actioncode").change(function() { + if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired"); + else $("#dateend").removeClass("fieldrequired"); + }); })'; print ''."\n"; } @@ -1483,7 +1487,12 @@ if ($id > 0) { print ''.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>'; // Date start - end - print ''.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").''; + print ''; + print ''.$langs->trans("DateActionStart").''; + print ' - '; + print 'type_code == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").''; + print ''; + //print ''.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").''; if (GETPOST("afaire") == 1) { print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuser'); } elseif (GETPOST("afaire") == 2) { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 722423c0cd9..51d0f99b6b8 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -979,8 +979,8 @@ if ($resql) { $event->type = 'holiday'; $event->type_picto = 'holiday'; - $event->datep = $db->jdate($obj->date_start); - $event->datef = $db->jdate($obj->date_end); + $event->datep = $db->jdate($obj->date_start) + (empty($halfday) || $halfday == 1 ? 0 : 12 * 60 * 60 - 1); + $event->datef = $db->jdate($obj->date_end) + (empty($halfday) || $halfday == -1 ? 24 : 12) * 60 * 60 - 1; $event->date_start_in_calendar = $event->datep; $event->date_end_in_calendar = $event->datef; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 63f2977acdb..cb7e512bc36 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -121,7 +121,7 @@ $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights-> $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; $usercancreatecontract = $user->rights->contrat->creer; -$usercancreateintervention = $user->rights->ficheinter->creer; +$usercancreateintervention = empty($conf->ficheinter->enabled) ? 0 : $user->rights->ficheinter->creer; $usercancreatepurchaseorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php @@ -231,8 +231,11 @@ if (empty($reshook)) { // Remove line $result = $object->deleteline($lineid); // reorder lines - if ($result) { + if ($result > 0) { $object->line_order(true); + } else { + $langs->load("errors"); + setEventMessages($object->error, $object->errors, 'errors'); } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0142d0c1b7a..65a2e60777f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -980,6 +980,8 @@ class Propal extends CommonObject $this->db->commit(); return 1; } else { + $this->error = $line->error; + $this->errors = $line->errors; $this->db->rollback(); return -1; } @@ -4166,36 +4168,40 @@ class PropaleLigne extends CommonObjectLine $error = 0; $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".((int) $this->rowid); - dol_syslog("PropaleLigne::delete", LOG_DEBUG); - if ($this->db->query($sql)) { - // Remove extrafields - if (!$error) { - $this->id = $this->rowid; - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('LINEPROPAL_DELETE', $user); + if ($result < 0) { + $error++; } + } + // End call triggers - if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('LINEPROPAL_DELETE', $user); - if ($result < 0) { - $this->db->rollback(); - return -1; + if (!$error) { + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "propaldet WHERE rowid = " . ((int) $this->rowid); + dol_syslog("PropaleLigne::delete", LOG_DEBUG); + if ($this->db->query($sql)) { + // Remove extrafields + if (!$error) { + $this->id = $this->rowid; + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this) . "::delete error -4 " . $this->error, LOG_ERR); + } } + } else { + $this->error = $this->db->error() . " sql=" . $sql; + $error++; } - // End call triggers + } - $this->db->commit(); - - return 1; - } else { - $this->error = $this->db->error()." sql=".$sql; + if ($error) { $this->db->rollback(); return -1; + } else { + $this->db->commit(); + return 1; } } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 3e467539c88..7a8fe187570 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -349,9 +349,9 @@ if ($action == 'validate' && $permissiontovalidate) { $db->begin(); $error = 0; foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { - if ($tmpproposal->statut == 0) { - if ($tmpproposal->valid($user)) { + if ($tmpproposal->fetch($checked) > 0) { + if ($tmpproposal->statut == $tmpproposal::STATUS_DRAFT) { + if ($tmpproposal->valid($user) > 0) { setEventMessage($tmpproposal->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); } else { setEventMessage($langs->trans('CantBeValidated'), 'errors'); @@ -362,7 +362,7 @@ if ($action == 'validate' && $permissiontovalidate) { $error++; } } else { - dol_print_error($db); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } @@ -380,13 +380,13 @@ if ($action == "sign" && $permissiontoclose) { $db->begin(); $error = 0; foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->fetch($checked) > 0) { if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) { - $tmpproposal->statut = $tmpproposal::STATUS_SIGNED;; - if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_SIGNED)) { + $tmpproposal->statut = $tmpproposal::STATUS_SIGNED; + if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_SIGNED) >= 0) { setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs'); } else { - dol_print_error($db); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } else { @@ -394,7 +394,7 @@ if ($action == "sign" && $permissiontoclose) { $error++; } } else { - dol_print_error($db); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } @@ -405,27 +405,28 @@ if ($action == "sign" && $permissiontoclose) { } } } + if ($action == "nosign" && $permissiontoclose) { if (GETPOST('confirm') == 'yes') { $tmpproposal = new Propal($db); $db->begin(); $error = 0; foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->fetch($checked) > 0) { if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) { $tmpproposal->statut = $tmpproposal::STATUS_NOTSIGNED; - if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_NOTSIGNED)) { + if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_NOTSIGNED) > 0) { setEventMessage($tmpproposal->ref." ".$langs->trans('NoSigned'), 'mesgs'); } else { - dol_print_error($db); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } else { - setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeClosed'), 'errors'); + setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeNoSign'), 'errors'); $error++; } } else { - dol_print_error($db); + setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors'); $error++; } } diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index f8a4c12fba7..1e3f56c30db 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -62,7 +62,7 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { exit; } -if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user->rights->societe->creer) { +if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && ($user->rights->societe->creer || $user->rights->facture->creer)) { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) @@ -153,7 +153,7 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $user- } } -if ($action == 'setremise' && $user->rights->societe->creer) { +if ($action == 'setremise' && ($user->rights->societe->creer || $user->rights->facture->creer)) { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) @@ -192,7 +192,7 @@ if ($action == 'setremise' && $user->rights->societe->creer) { } } -if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && $user->rights->societe->creer) { +if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && ($user->rights->societe->creer || $user->rights->facture->creer)) { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 3ed5ede556c..3e5ec08a0f3 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2525,7 +2525,7 @@ if ($action == 'create' && $usercancreate) { } // Create intervention - if ($conf->ficheinter->enabled) { + if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index b534d915914..2033b5626b2 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -337,15 +337,15 @@ if ($action == 'shipped' && $permissiontoadd) { $error = 0; foreach ($toselect as $checked) { if ($objecttmp->fetch($checked)) { - if ($objecttmp->statut == 1) { + if ($objecttmp->statut == 1 || $objecttmp->statut == 2) { if ($objecttmp->cloture($user)) { - setEventMessage($objecttmp->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); + setEventMessage($objecttmp->ref." ".$langs->trans('PassedInShippedStatus'), 'mesgs'); } else { - setEventMessage($langs->trans('CantBeValidated'), 'errors'); + setEventMessage($langs->trans('YouCantShipThis'), 'errors'); $error++; } } else { - setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); + setEventMessage($objecttmp->ref." ".$langs->trans('MustBeValidatedBefore'), 'errors'); $error++; } } else { diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index bd92dc084c7..7d0f9fb5a3a 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -45,8 +45,14 @@ if ($mode == 'customer' && !$user->rights->commande->lire) { if ($mode == 'supplier' && !$user->rights->fournisseur->commande->lire) { accessforbidden(); } +if ($mode == 'supplier') { + $object_status = GETPOST('object_status', 'array:int'); + $object_status = implode(',', $object_status); +} else { + $object_status = GETPOST('object_status', 'intcomma'); +} + -$object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index a06dd8dacaf..3942e7cb6dd 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -19,11 +19,11 @@ * along with this program. If not, see . */ - /** - * \file htdocs/compta/accounting-files.php - * \ingroup compta - * \brief Page to show portoflio and files of a thirdparty and download it - */ +/** + * \file htdocs/compta/accounting-files.php + * \ingroup compta + * \brief Page to show portoflio and files of a thirdparty and download it + */ if ((array_key_exists('action', $_GET) && $_GET['action'] == 'dl') || (array_key_exists('action', $_POST) && $_POST['action'] == 'dl')) { // To not replace token when downloading file if (!defined('NOTOKENRENEWAL')) { @@ -499,7 +499,7 @@ if ($result && $action == "dl" && !$error) { $zip->addFromString('transactions.csv', $log); $zip->close(); - ///Then download the zipped file. + // Then download the zipped file. header('Content-Type: application/zip'); header('Content-disposition: attachment; filename='.basename($zipname)); header('Content-Length: '.filesize($zipname)); @@ -578,7 +578,7 @@ print '
'; foreach ($listofchoices as $choice => $val) { if (empty($val['enabled'])) { - continue; // list not qualified + continue; // list not qualified } $disabled = ''; if (empty($val['perms'])) { @@ -588,14 +588,13 @@ foreach ($listofchoices as $choice => $val) { print '
'; } -print ''; +print ''; print ''."\n"; print dol_get_fiche_end(); if (!empty($date_start) && !empty($date_stop)) { - $param = 'action=searchfiles'; $param .= '&date_startday='.GETPOST('date_startday', 'int'); $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int'); $param .= '&date_startyear='.GETPOST('date_startyear', 'int'); @@ -603,25 +602,47 @@ if (!empty($date_start) && !empty($date_stop)) { $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); foreach ($listofchoices as $choice => $val) { - $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); + if (GETPOST($choice, 'int')) { + $param .= '&'.$choice.'=1'; + } } - print '
'."\n"; - print ''; + + $TData = dol_sort_array($filesarray, $sortfield, $sortorder); + + + $filename = dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip'; echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel'); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - foreach ($listofchoices as $choice => $val) { - print ''; + print ''."\n"; + print $langs->trans("Download"); + print '
'; - print ''; - print '
'."\n"; + $param .= '&action=searchfiles'; + + /* + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + foreach ($listofchoices as $choice => $val) { + print ''; + } + + print ''; + print ''."\n"; + */ print '
'; @@ -645,172 +666,181 @@ if (!empty($date_start) && !empty($date_stop)) { print ''.$langs->trans("Currency").''; } print ''; - if ($result) { - $TData = dol_sort_array($filesarray, $sortfield, $sortorder); - if (empty($TData)) { - print ''.$langs->trans("NoItem").''; - if (!empty($conf->multicurrency->enabled)) { - print ''; + if (empty($TData)) { + print ''.$langs->trans("NoRecordFound").''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } + print ''; + } else { + // Sort array by date ASC to calculate balance + + $totalET_debit = 0; + $totalIT_debit = 0; + $totalVAT_debit = 0; + $totalET_credit = 0; + $totalIT_credit = 0; + $totalVAT_credit = 0; + + // Display array + foreach ($TData as $data) { + $html_class = ''; + //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; + //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; + print ''; + + // Type + print ''.$langs->trans($data['item']).''; + + // Date + print ''; + print dol_print_date($data['date'], 'day'); + print "\n"; + + // Date due + print ''; + print dol_print_date($data['date_due'], 'day'); + print "\n"; + + // Ref + print ''; + + if ($data['item'] == 'Invoice') { + $invoice->id = $data['id']; + $invoice->ref = $data['ref']; + $invoice->total_ht = $data['amount_ht']; + $invoice->total_ttc = $data['amount_ttc']; + $invoice->total_tva = $data['amount_vat']; + $invoice->multicurrency_code = $data['currency']; + print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + } elseif ($data['item'] == 'SupplierInvoice') { + $supplier_invoice->id = $data['id']; + $supplier_invoice->ref = $data['ref']; + $supplier_invoice->total_ht = $data['amount_ht']; + $supplier_invoice->total_ttc = $data['amount_ttc']; + $supplier_invoice->total_tva = $data['amount_vat']; + $supplier_invoice->multicurrency_code = $data['currency']; + print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + } elseif ($data['item'] == 'ExpenseReport') { + $expensereport->id = $data['id']; + $expensereport->ref = $data['ref']; + print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); + } elseif ($data['item'] == 'SalaryPayment') { + $salary_payment->id = $data['id']; + $salary_payment->ref = $data['ref']; + print $salary_payment->getNomUrl(1); + } elseif ($data['item'] == 'Donation') { + $don->id = $data['id']; + $don->ref = $data['ref']; + print $don->getNomUrl(1, 0, '', 0); + } elseif ($data['item'] == 'SocialContributions') { + $charge_sociales->id = $data['id']; + $charge_sociales->ref = $data['ref']; + print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); + } elseif ($data['item'] == 'VariousPayment') { + $various_payment->id = $data['id']; + $various_payment->ref = $data['ref']; + print $various_payment->getNomUrl(1, '', 0, 0); + } elseif ($data['item'] == 'LoanPayment') { + $payment_loan->id = $data['id']; + $payment_loan->ref = $data['ref']; + print $payment_loan->getNomUrl(1, 0, 0, '', 0); + } else { + print $data['ref']; } - print ''; - } else { - // Sort array by date ASC to calculate balance + print ''; - $totalET_debit = 0; - $totalIT_debit = 0; - $totalVAT_debit = 0; - $totalET_credit = 0; - $totalIT_credit = 0; - $totalVAT_credit = 0; - - // Display array - foreach ($TData as $data) { - $html_class = ''; - //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; - //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; - print ''; - - // Type - print ''.$langs->trans($data['item']).''; - - // Date - print ''; - print dol_print_date($data['date'], 'day'); - print "\n"; - - // Date due - print ''; - print dol_print_date($data['date_due'], 'day'); - print "\n"; - - // Ref - print ''; - - if ($data['item'] == 'Invoice') { - $invoice->id = $data['id']; - $invoice->ref = $data['ref']; - $invoice->total_ht = $data['amount_ht']; - $invoice->total_ttc = $data['amount_ttc']; - $invoice->total_tva = $data['amount_vat']; - $invoice->multicurrency_code = $data['currency']; - print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); - } elseif ($data['item'] == 'SupplierInvoice') { - $supplier_invoice->id = $data['id']; - $supplier_invoice->ref = $data['ref']; - $supplier_invoice->total_ht = $data['amount_ht']; - $supplier_invoice->total_ttc = $data['amount_ttc']; - $supplier_invoice->total_tva = $data['amount_vat']; - $supplier_invoice->multicurrency_code = $data['currency']; - print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); - } elseif ($data['item'] == 'ExpenseReport') { - $expensereport->id = $data['id']; - $expensereport->ref = $data['ref']; - print $expensereport->getNomUrl(1, 0, 0, '', 0, 0); - } elseif ($data['item'] == 'SalaryPayment') { - $salary_payment->id = $data['id']; - $salary_payment->ref = $data['ref']; - print $salary_payment->getNomUrl(1); - } elseif ($data['item'] == 'Donation') { - $don->id = $data['id']; - $don->ref = $data['ref']; - print $don->getNomUrl(1, 0, '', 0); - } elseif ($data['item'] == 'SocialContributions') { - $charge_sociales->id = $data['id']; - $charge_sociales->ref = $data['ref']; - print $charge_sociales->getNomUrl(1, 0, 0, 0, 0); - } elseif ($data['item'] == 'VariousPayment') { - $various_payment->id = $data['id']; - $various_payment->ref = $data['ref']; - print $various_payment->getNomUrl(1, '', 0, 0); - } elseif ($data['item'] == 'LoanPayment') { - $payment_loan->id = $data['id']; - $payment_loan->ref = $data['ref']; - print $payment_loan->getNomUrl(1, 0, 0, '', 0); - } else { - print $data['ref']; - } - print ''; - - // File link - print ''; - if (!empty($data['files'])) { - foreach ($data['files'] as $id => $filecursor) { - print ''.($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']).' '.$formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name']).'
'; + // File link + print ''; + if (!empty($data['files'])) { + foreach ($data['files'] as $id => $filecursor) { + $tmppreview = $formfile->showPreview($filecursor, $filecursor['modulepart'], $filecursor['subdir'].'/'.$filecursor['name'], 0); + if ($tmppreview) { + print $tmppreview; } + $filename = ($filecursor['name'] ? $filecursor['name'] : $filecursor['ref']); + print ''; + if (empty($tmppreview)) { + print img_picto('', 'generic', '', false, 0, 0, '', 'pictonopreview pictofixedwidth paddingright'); + } + print $filename; + print '
'; } - print "\n"; + } + print "\n"; - // Paid - print ''.$data['paid'].''; + // Paid + print ''.($data['paid'] ? yn($data['paid']) : '').''; - // Total ET - print ''.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."\n"; - // Total IT - print ''.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."\n"; - // Total VAT - print ''.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."\n"; + // Total ET + print ''.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."\n"; + // Total IT + print ''.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."\n"; + // Total VAT + print ''.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."\n"; - print ''.dol_escape_htmltag($data['thirdparty_name'])."\n"; + print ''.dol_escape_htmltag($data['thirdparty_name'])."\n"; - print ''.$data['thirdparty_code']."\n"; + print ''.$data['thirdparty_code']."\n"; - print ''.$data['country_code']."\n"; + print ''.$data['country_code']."\n"; - print ''.dol_escape_htmltag($data['vatnum'])."\n"; + // VAT number + print ''.dol_escape_htmltag($data['vatnum'])."\n"; - if ($data['sens']) { - $totalET_credit += $data['amount_ht']; - $totalIT_credit += $data['amount_ttc']; - $totalVAT_credit += $data['amount_vat']; - } else { - $totalET_debit -= $data['amount_ht']; - $totalIT_debit -= $data['amount_ttc']; - $totalVAT_debit -= $data['amount_vat']; - } - - if (!empty($conf->multicurrency->enabled)) { - print ''.$data['currency']."\n"; - } - - print "\n"; + if ($data['sens']) { + $totalET_credit += $data['amount_ht']; + $totalIT_credit += $data['amount_ttc']; + $totalVAT_credit += $data['amount_vat']; + } else { + $totalET_debit -= $data['amount_ht']; + $totalIT_debit -= $data['amount_ttc']; + $totalVAT_debit -= $data['amount_vat']; } - // Total credits - print ''; - print ''.$langs->trans('Total').' '.$langs->trans('Income').''; - print ''.price(price2num($totalET_credit, 'MT')).''; - print ''.price(price2num($totalIT_credit, 'MT')).''; - print ''.price(price2num($totalVAT_credit, 'MT')).''; - print ''; if (!empty($conf->multicurrency->enabled)) { - print ''; - } - print "\n"; - // Total debits - print ''; - print ''.$langs->trans('Total').' '.$langs->trans('Outcome').''; - print ''.price(price2num($totalET_debit, 'MT')).''; - print ''.price(price2num($totalIT_debit, 'MT')).''; - print ''.price(price2num($totalVAT_debit, 'MT')).''; - print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; - } - print "\n"; - // Balance - print ''; - print ''.$langs->trans('Total').''; - print ''.price(price2num($totalET_credit + $totalET_debit, 'MT')).''; - print ''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).''; - print ''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).''; - print ''; - if (!empty($conf->multicurrency->enabled)) { - print ''; + print ''.$data['currency']."\n"; } + print "\n"; } + + // Total credits + print ''; + print ''.$langs->trans('Total').' '.$langs->trans('Income').''; + print ''.price(price2num($totalET_credit, 'MT')).''; + print ''.price(price2num($totalIT_credit, 'MT')).''; + print ''.price(price2num($totalVAT_credit, 'MT')).''; + print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; + // Total debits + print ''; + print ''.$langs->trans('Total').' '.$langs->trans('Outcome').''; + print ''.price(price2num($totalET_debit, 'MT')).''; + print ''.price(price2num($totalIT_debit, 'MT')).''; + print ''.price(price2num($totalVAT_debit, 'MT')).''; + print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; + // Balance + print ''; + print ''.$langs->trans('Total').''; + print ''.price(price2num($totalET_credit + $totalET_debit, 'MT')).''; + print ''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).''; + print ''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).''; + print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } + print "\n"; } + print ""; print '
'; } diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 62b97f6d100..a6e8a3824e7 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -759,6 +759,7 @@ if ($action == 'create') { print ''; } + // TODO ICS is not used with bank transfer ! if ($conf->paymentbybanktransfer->enabled) { print ''.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')'; print ''.$object->ics_transfer.''; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index b3675feb63e..90a35b30c86 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -52,11 +52,12 @@ if (!empty($conf->salaries->enabled)) { $id = GETPOST('rowid', 'int'); -$accountid = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int')); +$rowid = GETPOST("rowid", 'int'); +$accountoldid = GETPOST('account', 'int'); // GETPOST('account') is old account id +$accountid = GETPOST('accountid', 'int'); // GETPOST('accountid') is new account id $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -$rowid = GETPOST("rowid", 'int'); $orig_account = GETPOST("orig_account"); $backtopage = GETPOST('backtopage', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); @@ -68,7 +69,7 @@ if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'banque', $accountid, 'bank_account'); +$result = restrictedArea($user, 'banque', $accountoldid, 'bank_account'); if (!$user->rights->banque->lire && !$user->rights->banque->consolidate) { accessforbidden(); } @@ -126,15 +127,19 @@ if ($user->rights->banque->modifier && $action == "update") { $acline->fetch($rowid); $acsource = new Account($db); - $acsource->fetch($id); + $acsource->fetch($accountoldid); $actarget = new Account($db); if (GETPOST('accountid', 'int') > 0 && !$acline->rappro && !$acline->getVentilExportCompta()) { // We ask to change bank account $actarget->fetch(GETPOST('accountid', 'int')); } else { - $actarget->fetch($id); + $actarget->fetch($accountoldid); } + if (!($actarget->id > 0)) { + setEventMessages($langs->trans("ErrorFailedToLoadBankAccount"), null, 'errors'); + $error++; + } if ($actarget->courant == Account::TYPE_CASH && GETPOST('value', 'alpha') != 'LIQ') { setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors'); $error++; @@ -228,7 +233,7 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; - $sql .= " SET num_releve=".($num_rel ? "'".$db->escape($num_rel)."'" : "null"); + $sql .= " SET num_releve = ".($num_rel ? "'".$db->escape($num_rel)."'" : "null"); if (empty($num_rel)) { $sql .= ", rappro = 0"; } else { @@ -302,7 +307,6 @@ if ($result) { print ''; print ''; print ''; - print ''; print dol_get_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0); diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index dd734074481..a2c6c2b21ae 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -179,7 +179,7 @@ if (empty($reshook)) { $action = 'create'; } - if ($action == 'delete') { + if ($action == 'confirm_delete' && $confirm == 'yes') { $result = $object->fetch($id); if ($object->rappro == 0) { @@ -548,6 +548,12 @@ if ($id) { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 350); } + // Confirmation of the removal of the Various Payment + if ($action == 'delete') { + $text = $langs->trans('ConfirmDeleteVariousPayment'); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVariousPayment'), $text, 'confirm_delete', '', '', 2); + } + print dol_get_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto); $morehtmlref = '
'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3203332b137..81112e3c22e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -589,40 +589,6 @@ if (empty($reshook)) { $object->fetch($id); $object->fetch_thirdparty(); - // Check parameters - - // Check for mandatory fields in thirdparty (defined into setup) - $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); - foreach ($array_to_check as $key) { - $keymin = strtolower($key); - $i = (int) preg_replace('/[^0-9]/', '', $key); - $vallabel = $object->thirdparty->$keymin; - - if ($i > 0) { - if ($object->thirdparty->isACompany()) { - // Check for mandatory prof id (but only if country is other than ours) - if ($mysoc->country_id > 0 && $object->thirdparty->country_id == $mysoc->country_id) { - $idprof_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; - if (!$vallabel && !empty($conf->global->$idprof_mandatory)) { - $langs->load("errors"); - $error++; - setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId'.$i, $object->thirdparty->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").')', null, 'errors'); - } - } - } - } else { - //var_dump($conf->global->SOCIETE_EMAIL_MANDATORY); - if ($key == 'EMAIL') { - // Check for mandatory - if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($object->thirdparty->email)) { - $langs->load("errors"); - $error++; - setEventMessages($langs->trans("ErrorBadEMail", $object->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").')', null, 'errors'); - } - } - } - } - // Check for mandatory fields in invoice $array_to_check = array('REF_CLIENT'=>'RefCustomer'); foreach ($array_to_check as $key => $val) { @@ -1030,7 +996,7 @@ if (empty($reshook)) { $object->date = $dateinvoice; $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'restricthtml')); - // We do not copy the private note + $object->note_private = trim(GETPOST('note_private', 'restricthtml')); $object->ref_client = GETPOST('ref_client', 'alphanohtml'); $object->model_pdf = GETPOST('model', 'alphanohtml'); $object->fk_project = GETPOST('projectid', 'int'); @@ -1083,7 +1049,7 @@ if (empty($reshook)) { $object->date = $dateinvoice; $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'restricthtml')); - // We do not copy the private note + $object->note_private = trim(GETPOST('note_private', 'restricthtml')); $object->ref_client = GETPOST('ref_client'); $object->model_pdf = GETPOST('model'); $object->fk_project = GETPOST('projectid', 'int'); @@ -2877,6 +2843,7 @@ if ($action == 'create') { } $currency_code = $conf->currency; + $fk_account = 0; // Load objectsrc $remise_absolue = 0; @@ -3191,7 +3158,7 @@ if ($action == 'create') { // Standard invoice print '
'; - $tmp = ' '; + $tmp = ' '; $tmp = $tmp.''; $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceStandardDesc"), 1, 'help', '', 0, 3); print ''; @@ -3614,7 +3581,7 @@ if ($action == 'create') { if (!empty($conf->banque->enabled)) { print ''; } @@ -4680,7 +4647,7 @@ if ($action == 'create') { } if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { // Localtax2 print ''; - print ''; + print ''; } // Revenue stamp diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4feeb3d60b6..b1eb8656645 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -800,6 +800,10 @@ class Facture extends CommonInvoice $fk_parent_line = 0; } + // Complete vat rate with code + $vatrate = $newinvoiceline->tva_tx; + if ($newinvoiceline->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$newinvoiceline->vat_src_code.')'; + $newinvoiceline->fk_parent_line = $fk_parent_line; if ($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except) { @@ -810,7 +814,37 @@ class Facture extends CommonInvoice $newinvoiceline->fk_remise_except = $discountId; } - $result = $newinvoiceline->insert(); + $result = $this->addline( + $newinvoiceline->desc, + $newinvoiceline->subprice, + $newinvoiceline->qty, + $vatrate, + $newinvoiceline->localtax1_tx, + $newinvoiceline->localtax2_tx, + $newinvoiceline->fk_product, + $newinvoiceline->remise_percent, + $newinvoiceline->date_start, + $newinvoiceline->date_end, + $newinvoiceline->fk_code_ventilation, + $newinvoiceline->info_bits, + $newinvoiceline->fk_remise_except, + 'HT', + 0, + $newinvoiceline->product_type, + $newinvoiceline->rang, + $newinvoiceline->special_code, + $newinvoiceline->element, + $newinvoiceline->id, + $fk_parent_line, + $newinvoiceline->fk_fournprice, + $newinvoiceline->pa_ht, + $newinvoiceline->label, + $newinvoiceline->array_options, + $newinvoiceline->situation_percent, + $newinvoiceline->fk_prev_id, + $newinvoiceline->fk_unit, + $newinvoiceline->multicurrency_subprice + ); // Defined the new fk_parent_line if ($result > 0 && $newinvoiceline->product_type == 9) { @@ -2619,7 +2653,7 @@ class Facture extends CommonInvoice */ public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0, $batch_rule = 0) { - global $conf, $langs; + global $conf, $langs, $mysoc; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $productStatic = null; @@ -2658,6 +2692,53 @@ class Facture extends CommonInvoice return -1; } + // Check for mandatory fields in thirdparty (defined into setup) + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); + foreach ($array_to_check as $key) { + $keymin = strtolower($key); + $i = (int) preg_replace('/[^0-9]/', '', $key); + if ($i == 1) { + if (!is_object($this->thirdparty)) { + $langs->load('errors'); + $this->error = $langs->trans('ErrorInvoiceLoadThirdParty', $this->ref); + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + if (!property_exists($this->thirdparty, $keymin)) { + $langs->load('errors'); + $this->error = $langs->trans('ErrorInvoiceLoadThirdPartyKey', $keymin, $this->ref); + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + $vallabel = $this->thirdparty->$keymin; + + if ($i > 0) { + if ($this->thirdparty->isACompany()) { + // Check for mandatory prof id (but only if country is other than ours) + if ($mysoc->country_id > 0 && $this->thirdparty->country_id == $mysoc->country_id) { + $idprof_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; + if (!$vallabel && !empty($conf->global->$idprof_mandatory)) { + $langs->load("errors"); + $this->error = $langs->trans('ErrorProdIdIsMandatory', $langs->transcountry('ProfId'.$i, $this->thirdparty->country_code)).' ('.$langs->trans("ForbiddenBySetupRules").') ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + } + } else { + if ($key == 'EMAIL') { + // Check for mandatory + if (!empty($conf->global->SOCIETE_EMAIL_INVOICE_MANDATORY) && !isValidEMail($this->thirdparty->email)) { + $langs->load("errors"); + $this->error = $langs->trans("ErrorBadEMail", $this->thirdparty->email).' ('.$langs->trans("ForbiddenBySetupRules").') ['.$langs->trans('Company').' : '.$this->thirdparty->name.']'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } + } + } + $this->db->begin(); // Check parameters diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index ccf3c2f3f0c..f2cc5943e7a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -757,12 +757,28 @@ $sql .= ' f.rowid DESC '; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + /* This old and fast method to get and count full list returns all record so use a high amount of memory. $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + */ + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + if ($sall || $search_product_category > 0 || $search_user > 0) { + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords FROM', $sql); + } else { + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(f.rowid) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid/', '', $sqlforcount); + } + $sqlforcount = preg_replace('/GROUP BY.*$/', '', $sqlforcount); + + $resql = $db->query($sqlforcount); + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index e798eecaefa..2c31d37faa5 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -52,7 +52,7 @@ $hookmanager->initHooks(array('paymentcard', 'globalcard')); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$result = restrictedArea($user, $object->element, $object->id, 'paiement', ''); +$result = restrictedArea($user, $object->element, $object->id, 'paiement'); // Security check if ($user->socid) { diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 32f81532ecf..2fcd4d780ff 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -41,12 +41,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -// Security check -$fieldname = (!empty($ref) ? 'ref' : 'rowid'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname); +$object = new RemiseCheque($db); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -63,11 +58,22 @@ if (empty($page) || $page == -1) { $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; -$dir = $conf->bank->dir_output.'/checkdeposits/'; +$upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits"; + $filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear')); $filteraccountid = GETPOST('accountid', 'int'); -$object = new RemiseCheque($db); +// Security check +$fieldname = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname); + +$usercanread = $user->rights->banque->cheque; +$usercancreate = $user->rights->banque->cheque; +$usercandelete = $user->rights->banque->cheque; + /* @@ -242,7 +248,9 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) { $langs->load("other"); - $file = $dir.get_exdir($object->ref, 0, 1, 0, $object, 'cheque').GETPOST('file'); + $filetodelete = GETPOST('file', 'alpha'); + $file = $upload_dir.'/'.$filetodelete; + $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) { setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); @@ -633,6 +641,12 @@ if ($action == 'new') { $i = 1; if ($num > 0) { while ($objp = $db->fetch_object($resql)) { + $paymentstatic->id = $objp->pid; + $paymentstatic->ref = $objp->pref; + + $accountlinestatic->id = $objp->rowid; + $accountlinestatic->ref = $objp->ref; + print ''; print ''; print ''; // Operation date @@ -642,8 +656,6 @@ if ($action == 'new') { print ''; // Link to payment print ''; // Link to bank transaction print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 172cf020e34..4cf238b65f5 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -39,12 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills')); -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); // Get supervariables @@ -54,6 +48,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real'; $format = GETPOST('format', 'aZ09'); $id_bankaccount = GETPOST('id_bankaccount', 'int'); +$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { @@ -63,6 +59,17 @@ $offset = $limit * $page; $hookmanager->initHooks(array('directdebitcreatecard', 'globalcard')); +// Security check +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + +$error = 0; /* * Actions @@ -95,13 +102,15 @@ if (empty($reshook)) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $bank = new Account($db); $bank->fetch($conf->global->{$default_account}); - if ((empty($bank->ics) && $type !== 'bank-transfer') + // ICS is not mandatory with payment by bank transfer + /*if ((empty($bank->ics) && $type !== 'bank-transfer') || (empty($bank->ics_transfer) && $type === 'bank-transfer') - ) { + ) {*/ + if (empty($bank->ics) && $type !== 'bank-transfer') { $errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}')); setEventMessages($errormessage, null, 'errors'); - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/create.php'); - exit; + $action = ''; + $error++; } @@ -136,12 +145,16 @@ if (empty($reshook)) { setEventMessages($texttoshow, null); } - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$bprev->id); + header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.urlencode($bprev->id).'&type='.urlencode($type)); exit; } } $objectclass = "BonPrelevement"; - $uploaddir = $conf->prelevement->dir_output; + if ($type == 'bank-transfer') { + $uploaddir = $conf->paymentbybanktransfer->dir_output; + } else { + $uploaddir = $conf->prelevement->dir_output; + } include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 8711f663d55..e1850575dc0 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -40,7 +40,7 @@ if ($user->socid > 0) { } // Get supervariables -$prev_id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $type = GETPOST('type', 'aZ09'); @@ -77,8 +77,8 @@ if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transf llxHeader('', $langs->trans("WithdrawalsReceipts")); -if ($prev_id > 0 || $ref) { - if ($object->fetch($prev_id, $ref) >= 0) { +if ($id > 0 || $ref) { + if ($object->fetch($id, $ref) >= 0) { $head = prelevement_prepare_head($object); print dol_get_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 4a9bfbf6345..9336ad51370 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -38,7 +38,7 @@ if ($user->socid > 0) { } // Get supervariables -$prev_id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $type = GETPOST('type', 'aZ09'); @@ -76,8 +76,8 @@ if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transf llxHeader('', $langs->trans("WithdrawalsReceipts")); -if ($prev_id > 0 || $ref) { - if ($object->fetch($prev_id, $ref) >= 0) { +if ($id > 0 || $ref) { + if ($object->fetch($id, $ref) >= 0) { $head = prelevement_prepare_head($object); print dol_get_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index feb69bdc7fb..095d07460b9 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -42,13 +42,6 @@ $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'di $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -80,6 +73,17 @@ $company = new Societe($db); $hookmanager->initHooks(array('withdrawalsreceiptslineslist')); +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * Actions diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index 3ca9ce32fbe..2733223b5b5 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -33,13 +33,6 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals')); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlist'; // To manage different context of search -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -72,6 +65,17 @@ if ($type == 'bank-transfer') { $usercancreate = $user->rights->paymentbybanktransfer->create; } +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * Actions diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index ed8c704bcfa..3aa57a6f3e0 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -33,13 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - $type = GETPOST('type', 'aZ09'); // Get supervariables @@ -54,6 +47,17 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) { + $socid = $user->socid; +} +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} + /* * View diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index ae1dd54a13c..9c30db6e08a 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -31,14 +31,18 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); +$type = GETPOST('type', 'aZ09'); + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'prelevement', '', '', 'bons'); - -$type = GETPOST('type', 'aZ09'); +if ($type == 'bank-transfer') { + $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); +} else { + $result = restrictedArea($user, 'prelevement', '', '', 'bons'); +} /* diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 76dbc56beef..0bef7ff555a 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -57,6 +57,7 @@ $socid = GETPOST('socid', 'int'); // Category $selected_cat = (int) GETPOST('search_categ', 'int'); +if ($selected_cat == -1) $selected_cat = ''; $subcat = false; if (GETPOST('subcat', 'alpha') === 'yes') { $subcat = true; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 45d3d2e74b4..1b71cb261e1 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -125,6 +125,7 @@ class Tva extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva("; + $sql .= "entity,"; $sql .= "datec,"; $sql .= "datep,"; $sql .= "datev,"; @@ -136,6 +137,7 @@ class Tva extends CommonObject $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; $sql .= ") VALUES ("; + $sql .= " ".((int) $conf->entity).", "; $sql .= " '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datep)."',"; $sql .= " '".$this->db->idate($this->datev)."',"; @@ -144,8 +146,8 @@ class Tva extends CommonObject $sql .= " '".$this->db->escape($this->note)."',"; $sql .= " '".$this->db->escape($this->fk_account)."',"; $sql .= " '".$this->db->escape($this->type_payment)."',"; - $sql .= " '".($this->fk_user_creat > 0 ? (int) $this->fk_user_creat : (int) $user->id)."',"; - $sql .= " '".$this->db->escape($this->fk_user_modif)."'"; + $sql .= " ".($this->fk_user_creat > 0 ? (int) $this->fk_user_creat : (int) $user->id).","; + $sql .= " ".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : (int) $user->id); $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index bd2150b850d..27d9aa558f3 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -503,6 +503,29 @@ if (empty($reshook)) { } } + // Update extrafields + if ($action == 'update_extras' && ! empty($user->rights->societe->contact->creer)) { + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); + if ($ret < 0) { + $error++; + } + + if (!$error) { + $result = $object->insertExtraFields('CONTACT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + + if ($error) { + $action = 'edit_extras'; + } + } + // Actions to send emails $triggersendname = 'CONTACT_SENTBYMAIL'; $paramname = 'id'; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 1466f595b3d..624d59b0d94 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -236,10 +236,6 @@ if (empty($reshook)) { } $id = $object->create($user); - if ($id < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - if ($id > 0) { dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); @@ -351,6 +347,9 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } + if ($error) { + $action = 'create'; + } } else { $result = $object->create($user); if ($result > 0) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 64578ad68bb..ab431a15442 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1246,9 +1246,9 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) { $model = $objecttmp->model_pdf; $ret = $objecttmp->fetch($objecttmp->id); // Reload to get new records // To be sure vars is defined - $hidedetails = !empty($hidedetails) ? $hidedetails : 0; - $hidedesc = !empty($hidedesc) ? $hidedesc : 0; - $hideref = !empty($hideref) ? $hideref : 0; + $hidedetails = !empty($hidedetails) ? $hidedetails : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0); + $hidedesc = !empty($hidedesc) ? $hidedesc : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0); + $hideref = !empty($hideref) ? $hideref : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0); $moreparams = !empty($moreparams) ? $moreparams : null; $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1378,13 +1378,13 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) { // To be sure vars is defined if (empty($hidedetails)) { - $hidedetails = 0; + $hidedetails = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0); } if (empty($hidedesc)) { - $hidedesc = 0; + $hidedesc = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0); } if (empty($hideref)) { - $hideref = 0; + $hideref = (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0); } if (empty($moreparams)) { $moreparams = null; diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 62cfaa590ab..02c39c2f625 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -119,7 +119,7 @@ class box_birthdays extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($dateb, "day", 'gmt').' - '.$age.' '.$langs->trans('DurationYears') + 'text' => dol_print_date($dateb, "day", 'tzserver').' - '.$age.' '.$langs->trans('DurationYears') ); /*$this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 21bf58b859f..9661b1d363e 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -79,6 +79,9 @@ class box_dolibarr_state_board extends ModeleBoxes if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { $hookmanager = new HookManager($this->db); $hookmanager->initHooks(array('index')); + $object = new stdClass; + $action = ''; + $hookmanager->executeHooks('addStatisticLine', array(), $object, $action); $boxstatItems = array(); $boxstatFromHook = ''; $boxstatFromHook = $hookmanager->resPrint; diff --git a/htdocs/core/boxes/box_graph_nb_tickets_type.php b/htdocs/core/boxes/box_graph_nb_tickets_type.php index 2da54d84e7a..f4efce23797 100644 --- a/htdocs/core/boxes/box_graph_nb_tickets_type.php +++ b/htdocs/core/boxes/box_graph_nb_tickets_type.php @@ -131,7 +131,7 @@ class box_graph_nb_tickets_type extends ModeleBoxes } foreach ($listofoppcode as $rowid => $code) { $dataseries[] = array( - 'label' => $langs->getLabelFromKey($this->db, 'TicketTypeShort' . $code, 'c_ticket_category', 'code', 'label', $code), + 'label' => $langs->getLabelFromKey($this->db, 'TicketTypeShort' . $code, 'c_ticket_type', 'code', 'label', $code), 'data' => (empty($data[$code]) ? 0 : $data[$code]) ); } diff --git a/htdocs/core/boxes/box_graph_ticket_by_severity.php b/htdocs/core/boxes/box_graph_ticket_by_severity.php index 13cd0c40c86..a7fa571b6c7 100644 --- a/htdocs/core/boxes/box_graph_ticket_by_severity.php +++ b/htdocs/core/boxes/box_graph_ticket_by_severity.php @@ -152,7 +152,7 @@ class box_graph_ticket_by_severity extends ModeleBoxes } foreach ($listofoppcode as $rowid => $code) { $dataseries[] = array( - 'label' => $langs->getLabelFromKey($this->db, 'TicketSeverityShort' . $code, 'c_ticket_category', 'code', 'label', $code), + 'label' => $langs->getLabelFromKey($this->db, 'TicketSeverityShort' . $code, 'c_ticket_severity', 'code', 'label', $code), 'data' => (empty($data[$code]) ? 0 : $data[$code]) ); } diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 78d38455d83..6345e13cce0 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -162,7 +162,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="right"', - 'text' => $delayIcon.' '.dol_print_date($delivery_date, 'day', 'tzuserrel').'', + 'text' => $delayIcon.' '.dol_print_date($delivery_date, 'day', 'tzuserrel').'', 'asis' => 1 ); diff --git a/htdocs/core/class/commonincoterm.class.php b/htdocs/core/class/commonincoterm.class.php index 25745bb4c5c..bfcdf86b36c 100644 --- a/htdocs/core/class/commonincoterm.class.php +++ b/htdocs/core/class/commonincoterm.class.php @@ -116,7 +116,7 @@ trait CommonIncoterm $this->fk_incoterms = $id_incoterm; $this->location_incoterms = $location; - $sql = 'SELECT libelle as label_incotermsFROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; + $sql = 'SELECT libelle as label_incoterms FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; $res = $this->db->query($sql); if ($res) { $obj = $this->db->fetch_object($res); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 85987c8a3cf..4d09b8ae769 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4805,18 +4805,18 @@ abstract class CommonObject global $langs, $hookmanager, $conf, $form; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; if (!empty($conf->multicurrency->enabled)) { - print ''; + print ''; } - print ''; + print ''; if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''; + print ''; } - print ''; + print ''; print ''; print ''; $i = 0; @@ -5843,8 +5843,15 @@ abstract class CommonObject $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$attributeKey]; $attributeParam = $extrafields->attributes[$this->table_element]['param'][$attributeKey]; $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey]; + $attributeUnique = $extrafields->attributes[$this->table_element]['unique'][$attributeKey]; $attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey]; + // If we clone, we have to clean unique extrafields to prevent duplicates. + // This behaviour can be prevented by external code by changing $this->context['createfromclone'] value in createFrom hook + if (! empty($this->context['createfromclone']) && $this->context['createfromclone'] == 'createfromclone' && ! empty($attributeUnique)) { + $new_array_options[$key] = null; + } + // Similar code than into insertExtraFields if ($attributeRequired) { $mandatorypb = false; @@ -6753,7 +6760,7 @@ abstract class CommonObject $out .= ''; } elseif ($type == 'checkbox') { $value_arr = explode(',', $value); - $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, $morecss, 0, '100%'); } elseif ($type == 'radio') { $out = ''; foreach ($param['options'] as $keyopt => $val) { @@ -7403,7 +7410,7 @@ abstract class CommonObject $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); } - $colspan = ''; + $colspan = 0; if (is_array($params) && count($params) > 0 && $display_type=='card') { if (array_key_exists('cols', $params)) { $colspan = $params['cols']; @@ -7416,6 +7423,7 @@ abstract class CommonObject } } } + $colspan = intval($colspan); switch ($mode) { case "view": @@ -7461,7 +7469,7 @@ abstract class CommonObject } } - $out .= $extrafields->showSeparator($key, $this, ($colspan + 1), $display_type); + $out .= $extrafields->showSeparator($key, $this, ($colspan ? $colspan + 1 : 2), $display_type); } else { $class = (!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); $csstyle = ''; @@ -7482,7 +7490,7 @@ abstract class CommonObject $html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id); if ($display_type=='card') { if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { - $colspan = '0'; + $colspan = 0; } if ($action == 'selectlines') { @@ -7496,14 +7504,16 @@ abstract class CommonObject if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility $datenotinstring = $this->db->jdate($datenotinstring); } - $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(12, 0, 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring; + $datekey = $keyprefix.'options_'.$key.$keysuffix; + $value = (GETPOSTISSET($datekey)) ? dol_mktime(12, 0, 0, GETPOST($datekey.'month', 'int', 3), GETPOST($datekey.'day', 'int', 3), GETPOST($datekey.'year', 'int', 3)) : $datenotinstring; } if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('datetime'))) { $datenotinstring = $this->array_options['options_'.$key]; if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility $datenotinstring = $this->db->jdate($datenotinstring); } - $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."sec", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3), 'tzuserrel') : $datenotinstring; + $timekey = $keyprefix.'options_'.$key.$keysuffix; + $value = (GETPOSTISSET($timekey)) ? dol_mktime(GETPOST($timekey.'hour', 'int', 3), GETPOST($timekey.'min', 'int', 3), GETPOST($timekey.'sec', 'int', 3), GETPOST($timekey.'month', 'int', 3), GETPOST($timekey.'day', 'int', 3), GETPOST($timekey.'year', 'int', 3), 'tzuserrel') : $datenotinstring; } // Convert float submited string into real php numeric (value in memory must be a php numeric) if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double'))) { @@ -7511,7 +7521,7 @@ abstract class CommonObject } // HTML, text, select, integer and varchar: take into account default value in database if in create mode - if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'varchar', 'select', 'int'))) { + if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'varchar', 'select', 'int', 'boolean'))) { if ($action == 'create') { $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? $value : $extrafields->attributes[$this->table_element]['default'][$key]; } @@ -7562,7 +7572,7 @@ abstract class CommonObject if ($display_type == 'card') { $out .= ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; +print ''; if (!empty($conf->multicurrency->enabled)) { - print ''; + print ''; } -print ''; +print ''; if (!empty($conf->global->PRODUCT_USE_UNITS)) { - print ''; + print ''; } -print ''; +print ''; $selected = 1; if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) { diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 686bb8a52a9..152b947430c 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -353,6 +353,10 @@ if ($action == 'execute') { print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.'&securitykey='.$securitykey.$param, $langs->trans("CronExecute"), $langs->trans("CronConfirmExecute"), "confirm_execute", '', '', 1); } +if ($action == 'delete') { + print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id.$param, $langs->trans("CronDelete"), $langs->trans("CronConfirmDelete"), "confirm_delete", '', '', 1); +} + // List of mass actions available $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), diff --git a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php index 520a0a20a72..6796ff28c6a 100644 --- a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php @@ -73,7 +73,7 @@ class DolLogsCollector extends MessagesCollector { global $conf; - $uselogfile = $conf->global->DEBUGBAR_USE_LOGFILE; + $uselogfile = $conf->global->DEBUGBAR_USE_LOG_FILE; if ($uselogfile) { $this->getStorageLogs($this->path); diff --git a/htdocs/document.php b/htdocs/document.php index d6f6584bb6f..c13e8f42a73 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010 Pierre Morin * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2022 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 @@ -162,6 +163,11 @@ if (!empty($hashp)) { $modulepart = $moduleparttocheck; $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir } + $entity = $ecmfile->entity; + if ($entity != $conf->entity) { + $conf->entity = $entity; + $conf->setValues($db); + } } else { $langs->load("errors"); accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"), 0, 0, 1); diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 035a7aee9c6..a451a462ea3 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -327,7 +327,11 @@ class EcmFiles extends CommonObject $resql = $this->db->query($sql); if (!$resql) { $error++; - $this->errors[] = 'Error '.$this->db->lasterror(); + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $this->errors[] = 'Error DB_ERROR_RECORD_ALREADY_EXISTS : '.$this->db->lasterror(); + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + } dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 240fdcfb73c..31cf21c34ae 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1282,6 +1282,15 @@ if (empty($reshook)) { $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } + + unset($qty); + unset($value_unit_ht); + unset($value_unit); + unset($vatrate); + unset($comments); + unset($fk_c_type_fees); + unset($fk_project); + unset($date); } //header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); @@ -2059,7 +2068,8 @@ if ($action == 'create') { // IK if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; } diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 260bff00016..0dd1c4c2d4d 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -166,7 +166,7 @@ if ($action == 'add') { // on récupère les enregistrements $object->fetch($id); - + $res = $object->fetch_lines(); // on transfert les données de l'un vers l'autre if ($object->socid > 0) { $newinter->socid = $object->socid; @@ -178,6 +178,7 @@ if ($action == 'add') { $newinter->entity = $object->entity; $newinter->duree = $object->duree; + $newinter->datei = $object->date; $newinter->description = $object->description; $newinter->note_private = $object->note_private; @@ -194,7 +195,7 @@ if ($action == 'add') { if ($newfichinterid > 0) { // Now we add line of details foreach ($object->lines as $line) { - $newinter->addline($user, $newfichinterid, $line->desc, '', $line->duree, ''); + $newinter->addline($user, $newfichinterid, $line->desc, $line->datei, $line->duree, ''); } // on update le nombre d'inter crée à partir du modèle @@ -743,7 +744,7 @@ if ($action == 'create') { print ''; + print $langs->trans("AddIntervention").''; } if ($user->rights->ficheinter->supprimer) { diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 225f9ebacb8..8fb73d1b780 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -375,11 +375,15 @@ if (empty($reshook)) { } } } else { - $mesg = $srcobject->error; + $langs->load("errors"); + setEventMessages($srcobject->error, $srcobject->errors, 'errors'); + $action = 'create'; $error++; } } else { - $mesg = $object->error; + $langs->load("errors"); + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'create'; $error++; } } else { @@ -403,12 +407,14 @@ if (empty($reshook)) { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; + $error++; } } } } else { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")); $action = 'create'; + $error++; } } elseif ($action == 'update' && $user->rights->ficheinter->creer) { $object->socid = $socid; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 371853dc70c..000b654bf72 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -426,7 +426,7 @@ class Fichinter extends CommonObject $sql .= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,"; $sql .= " f.date_valid as datev,"; $sql .= " f.tms as datem,"; - $sql .= " f.duree, f.fk_projet as fk_project, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat"; + $sql .= " f.duree, f.fk_projet as fk_project, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat, f.entity as entity"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f"; if ($ref) { $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; @@ -459,6 +459,7 @@ class Fichinter extends CommonObject $this->model_pdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf; // deprecated $this->fk_contrat = $obj->fk_contrat; + $this->entity = $obj->entity; $this->user_creation = $obj->fk_user_author; @@ -1346,7 +1347,6 @@ class Fichinter extends CommonObject $line->fetch_optionals(); $this->lines[$i] = $line; - $i++; } $this->db->free($resql); diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 4fe35c32a2c..ed43bae8377 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -349,7 +349,7 @@ class FichinterRec extends Fichinter { // phpcs:enable $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, '; - $sql .= ' l.price, l.qty, l.tva_tx, l.remise, l.remise_percent, l.subprice, l.duree, '; + $sql .= ' l.price, l.qty, l.tva_tx, l.remise, l.remise_percent, l.subprice, l.duree, l.date, '; $sql .= ' l.total_ht, l.total_tva, l.total_ttc,'; $sql .= ' l.rang, l.special_code,'; $sql .= ' l.fk_unit, p.ref as product_ref, p.fk_product_type as fk_product_type,'; @@ -366,7 +366,6 @@ class FichinterRec extends Fichinter while ($i < $num) { $objp = $this->db->fetch_object($result); $line = new FichinterLigne($this->db); - $line->id = $objp->rowid; $line->label = $objp->custom_label; // Label line $line->desc = $objp->description; // Description line @@ -386,8 +385,6 @@ class FichinterRec extends Fichinter $line->fk_product = $objp->fk_product; $line->date_start = $objp->date_start; $line->date_end = $objp->date_end; - $line->date_start = $objp->date_start; - $line->date_end = $objp->date_end; $line->info_bits = $objp->info_bits; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 528bda30442..5f671599c50 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -32,7 +32,7 @@ * \brief File of class to manage suppliers orders */ -include_once DOL_DOCUMENT_ROOT.'/core/class/commonorder.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonorder.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; if (!empty($conf->productbatch->enabled)) { require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; @@ -431,6 +431,7 @@ class CommandeFournisseur extends CommonOrder * Lines */ $result = $this->fetch_lines(); + if ($result < 0) { return -1; } else { @@ -453,7 +454,7 @@ class CommandeFournisseur extends CommonOrder { global $conf; // phpcs:enable - //$result=$this->fetch_lines(); + $this->lines = array(); $sql = "SELECT l.rowid, l.ref as ref_supplier, l.fk_product, l.product_type, l.label, l.description, l.qty,"; @@ -464,22 +465,12 @@ class CommandeFournisseur extends CommonOrder $sql .= " l.fk_unit,"; $sql .= " l.date_start, l.date_end,"; $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc'; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $sql .= ", pfp.rowid as fk_pfp, pfp.packaging, MAX(pfp.quantity) as max_qty"; - } $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pfp.entity IN (".getEntity('product_fournisseur_price').") AND l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn AND l.qty >= pfp.quantity AND pfp.fk_soc = ".((int) $this->socid); - } - $sql .= " WHERE l.fk_commande = ".$this->id; + $sql .= " WHERE l.fk_commande = ".((int) $this->id); if ($only_product) { $sql .= ' AND p.fk_product_type = 0'; } - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $sql.= " GROUP BY l.rowid"; - $sql.= " HAVING (max_qty = MAX(pfp.quantity) OR max_qty IS NULL)"; - } $sql .= " ORDER BY l.rang, l.rowid"; //print $sql; @@ -527,11 +518,34 @@ class CommandeFournisseur extends CommonOrder $line->ref_supplier = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $line->fk_fournprice = $objp->fk_pfp; - $line->packaging = $objp->packaging; + // TODO We should not fetch this properties into the fetch_lines. This is NOT properties of a line. + // Move this into another method and call it when required. + + // Take better packaging for $objp->qty (first supplier ref quantity <= $objp->qty) + $sqlsearchpackage = 'SELECT rowid, packaging FROM '.MAIN_DB_PREFIX."product_fournisseur_price"; + $sqlsearchpackage .= ' WHERE entity IN ('.getEntity('product_fournisseur_price').")"; + $sqlsearchpackage .= " AND fk_product = ".((int) $objp->fk_product); + $sqlsearchpackage .= " AND ref_fourn = '".$this->db->escape($objp->ref_supplier)."'"; + $sqlsearchpackage .= " AND quantity <= ".((float) $objp->qty); // required to be qualified + $sqlsearchpackage .= " AND (packaging IS NULL OR packaging = 0 OR packaging <= ".((float) $objp->qty).")"; // required to be qualified + $sqlsearchpackage .= " AND fk_soc = ".((int) $this->socid); + $sqlsearchpackage .= " ORDER BY packaging ASC"; // Take the smaller package first + $sqlsearchpackage .= " LIMIT 1"; + + $resqlsearchpackage = $this->db->query($sqlsearchpackage); + if ($resqlsearchpackage) { + $objsearchpackage = $this->db->fetch_object($resqlsearchpackage); + if ($objsearchpackage) { + $line->fk_fournprice = $objsearchpackage->rowid; + $line->packaging = $objsearchpackage->packaging; + } + } else { + $this->error = $this->db->lasterror(); + return -1; + } } - $line->date_start = $this->db->jdate($objp->date_start); + $line->date_start = $this->db->jdate($objp->date_start); $line->date_end = $this->db->jdate($objp->date_end); $line->fk_unit = $objp->fk_unit; @@ -1807,6 +1821,7 @@ class CommandeFournisseur extends CommonOrder if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $prod = new Product($this->db, $fk_product); $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid)); + if ($qty < $prod->packaging) { $qty = $prod->packaging; } else { @@ -3515,25 +3530,18 @@ class CommandeFournisseurLigne extends CommonOrderLine global $conf; $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx, cd.special_code,'; - $sql .= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref,'; + $sql .= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref as ref_supplier,'; $sql .= ' cd.remise, cd.remise_percent, cd.subprice,'; $sql .= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; $sql .= ' cd.total_localtax1, cd.total_localtax2,'; $sql .= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; $sql .= ' cd.date_start, cd.date_end, cd.fk_unit,'; - $sql .= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc'; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $sql .= ", pfp.rowid as fk_pfp, pfp.packaging, MAX(pfp.quantity) as max_qty"; - } - $sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; + $sql .= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,'; + $sql .= ' c.fk_soc as socid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseur as c, '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pfp.entity IN (".getEntity('product_fournisseur_price').") AND cd.fk_product = pfp.fk_product and cd.ref = pfp.ref_fourn AND cd.qty >= pfp.quantity"; - } - $sql .= ' WHERE cd.rowid = '.((int) $rowid); - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $sql .= " GROUP BY cd.rowid HAVING (max_qty = MAX(pfp.quantity) OR max_qty IS NULL)"; - } + $sql .= ' WHERE cd.fk_commande = c.rowid AND cd.rowid = '.((int) $rowid); + $result = $this->db->query($sql); if ($result) { $objp = $this->db->fetch_object($result); @@ -3544,8 +3552,8 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->fk_commande = $objp->fk_commande; $this->desc = $objp->description; $this->qty = $objp->qty; - $this->ref_fourn = $objp->ref; - $this->ref_supplier = $objp->ref; + $this->ref_fourn = $objp->ref_supplier; + $this->ref_supplier = $objp->ref_supplier; $this->subprice = $objp->subprice; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; @@ -3569,9 +3577,33 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->product_ref = $objp->product_ref; $this->product_label = $objp->product_label; $this->product_desc = $objp->product_desc; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->packaging = $objp->packaging; - $this->fk_fournprice = $objp->fk_pfp; + // TODO We should not fetch this properties into the fetch_lines. This is NOT properties of a line. + // Move this into another method and call it when required. + + // Take better packaging for $objp->qty (first supplier ref quantity <= $objp->qty) + $sqlsearchpackage = 'SELECT rowid, packaging FROM '.MAIN_DB_PREFIX."product_fournisseur_price"; + $sqlsearchpackage .= ' WHERE entity IN ('.getEntity('product_fournisseur_price').")"; + $sqlsearchpackage .= " AND fk_product = ".((int) $objp->fk_product); + $sqlsearchpackage .= " AND ref_fourn = '".$this->db->escape($objp->ref_supplier)."'"; + $sqlsearchpackage .= " AND quantity <= ".((float) $objp->qty); // required to be qualified + $sqlsearchpackage .= " AND (packaging IS NULL OR packaging = 0 OR packaging <= ".((float) $objp->qty).")"; // required to be qualified + $sqlsearchpackage .= " AND fk_soc = ".((int) $objp->socid); + $sqlsearchpackage .= " ORDER BY packaging ASC"; // Take the smaller package first + $sqlsearchpackage .= " LIMIT 1"; + + $resqlsearchpackage = $this->db->query($sqlsearchpackage); + if ($resqlsearchpackage) { + $objsearchpackage = $this->db->fetch_object($resqlsearchpackage); + if ($objsearchpackage) { + $this->fk_fournprice = $objsearchpackage->rowid; + $this->packaging = $objsearchpackage->packaging; + } + } else { + $this->error = $this->db->lasterror(); + return -1; + } } $this->date_start = $this->db->jdate($objp->date_start); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 271a13c7e9e..cb8827c0800 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -262,7 +262,6 @@ class ProductFournisseur extends Product */ public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = '', $options = array()) { - // phpcs:enable global $conf, $langs; //global $mysoc; @@ -320,7 +319,9 @@ class ProductFournisseur extends Product $qty = price2num($qty, 'MS'); $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - $packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); + // We can have a puchase ref that need to buy 100 min for a given price and with a packaging of 50. + //$packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); + $packaging = price2num((empty($this->packaging) ? $qty : $this->packaging), 'MS'); $error = 0; $now = dol_now(); @@ -625,13 +626,7 @@ class ProductFournisseur extends Product $this->supplier_barcode = $obj->barcode; $this->supplier_fk_barcode_type = $obj->fk_barcode_type; } - - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $this->packaging = $obj->packaging; - if ($this->packaging < $this->fourn_qty) { - $this->packaging = $this->fourn_qty; - } - } + $this->packaging = $obj->packaging; if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression)) { $priceparser = new PriceParser($this->db); @@ -679,10 +674,7 @@ class ProductFournisseur extends Product $sql .= " pfp.rowid as product_fourn_pri_id, pfp.entity, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; $sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,"; $sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,"; - $sql .= " pfp.barcode, pfp.fk_barcode_type"; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $sql .= ", pfp.packaging"; - } + $sql .= " pfp.barcode, pfp.fk_barcode_type, pfp.packaging"; $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")"; $sql .= " AND pfp.fk_soc = s.rowid AND pfp.fk_product = p.rowid"; @@ -736,12 +728,7 @@ class ProductFournisseur extends Product $prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"]; $prodfourn->fourn_multicurrency_code = $record["multicurrency_code"]; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { - $prodfourn->packaging = $record["packaging"]; - if ($prodfourn->packaging < $prodfourn->fourn_qty) { - $prodfourn->packaging = $prodfourn->fourn_qty; - } - } + $prodfourn->packaging = $record["packaging"]; if (!empty($conf->barcode->enabled)) { $prodfourn->supplier_barcode = $record["barcode"]; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 72fc7a7439c..56ebfb5cbf7 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -274,6 +274,8 @@ if (empty($reshook)) { $db->begin(); + $default_ref_supplier=dol_print_date(dol_now(), '%Y%m%d%H%M%S'); + foreach ($orders as $id_order) { $cmd = new CommandeFournisseur($db); if ($cmd->fetch($id_order) <= 0) { @@ -290,9 +292,8 @@ if (empty($reshook)) { $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; $objecttmp->fk_project = $cmd->fk_project; $objecttmp->multicurrency_code = $cmd->multicurrency_code; - if (empty($createbills_onebythird)) { - $objecttmp->ref_client = $cmd->ref_client; - } + $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier; + $default_ref_supplier+=1; $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); if (empty($datefacture)) { diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index bbabc5327d8..c8343cfd20d 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -457,10 +457,9 @@ if (empty($reshook)) { $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysToValidate"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysToValidateBody")."\n"; + $message .= "

".$langs->transnoentities("HolidaysToValidateBody")."

\n"; $delayForRequest = $object->getConfCP('delayForRequest'); //$delayForRequest = $delayForRequest * (60*60*24); @@ -470,8 +469,7 @@ if (empty($reshook)) { // option to warn the validator in case of too short delay if ($object->getConfCP('AlertValidatorDelay')) { if ($object->date_debut < $nextMonth) { - $message .= "\n"; - $message .= $langs->transnoentities("HolidaysToValidateDelay", $object->getConfCP('delayForRequest'))."\n"; + $message .= "

".$langs->transnoentities("HolidaysToValidateDelay", $object->getConfCP('delayForRequest'))."

\n"; } } @@ -479,20 +477,21 @@ if (empty($reshook)) { if ($object->getConfCP('AlertValidatorSolde')) { $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) { - $message .= "\n"; - $message .= $langs->transnoentities("HolidaysToValidateAlertSolde")."\n"; + $message .= "

".$langs->transnoentities("HolidaysToValidateAlertSolde")."

\n"; } } - $message .= "\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id; + + $message .= "
    "; + $message .= "
  • ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; + $message .= "
\n"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // Sending the email $result = $mail->sendfile(); @@ -601,19 +600,20 @@ if (empty($reshook)) { $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysValidated"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; + $message .= "

".$langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; - $message .= "- ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $message .= "
    \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; + $message .= "
\n"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // Sending email $result = $mail->sendfile(); @@ -681,20 +681,21 @@ if (empty($reshook)) { $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysRefused"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; - $message .= GETPOST('detail_refuse', 'alpha')."\n\n"; + $message .= "

".$langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; + $message .= "

".GETPOST('detail_refuse', 'alpha')."

"; - $message .= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $message .= "
    \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; + $message .= "
"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // sending email $result = $mail->sendfile(); @@ -820,18 +821,20 @@ if (empty($reshook)) { $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysCanceled"); // Content - $message = $langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",\n"; - $message .= "\n"; + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - $message .= $langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."\n"; - $message .= "- ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."\n"; + $message .= "

".$langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; - $message .= "- ".$langs->transnoentitiesnoconv("Link")." : ".$dolibarr_main_url_root."/holiday/card.php?id=".$object->id."\n\n"; - $message .= "\n"; + $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; + + $message .= "
    \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; + $message .= "
\n"; $trackid = 'leav'.$object->id; - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 0, '', '', $trackid); + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); // sending email $result = $mail->sendfile(); diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index c70124d9d18..f6f0dd00c62 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page -$langs->loadLangs(array("holiday")); +$langs->loadLangs(array('holiday', 'hrm')); // Security check $socid = 0; @@ -112,7 +112,7 @@ if (empty($reshook)) { $arrayfields = array( 'cp.ref'=>array('label'=>$langs->trans('Ref'), 'checked'=>1), 'cp.fk_user'=>array('label'=>$langs->trans('Employee'), 'checked'=>1), - 'ct.label'=>array('label'=>$langs->trans('Type'), 'checked'=>1), + 'cp.fk_type'=>array('label'=>$langs->trans('Type'), 'checked'=>1), 'cp.date_debut'=>array('label'=>$langs->trans('DateDebCP'), 'checked'=>1), 'cp.date_fin'=>array('label'=>$langs->trans('DateFinCP'), 'checked'=>1), 'used_days'=>array('label'=>$langs->trans('NbUseDaysCPShort'), 'checked'=>1), @@ -141,10 +141,9 @@ $search_month = GETPOST("remonth", 'int') ?GETPOST("remonth", 'int') : date("m", $search_year = GETPOST("reyear", 'int') ?GETPOST("reyear", 'int') : date("Y", time()); $year_month = sprintf("%04d", $search_year).'-'.sprintf("%02d", $search_month); -$sql = "SELECT cp.rowid, cp.ref, cp.fk_user, cp.date_debut, cp.date_fin, ct.label, cp.description, cp.halfday"; +$sql = "SELECT cp.rowid, cp.ref, cp.fk_user, cp.date_debut, cp.date_fin, cp.fk_type, cp.description, cp.halfday"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday cp"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid"; $sql .= " WHERE cp.rowid > 0"; $sql .= " AND cp.statut = ".Holiday::STATUS_APPROVED; $sql .= " AND ("; @@ -244,7 +243,7 @@ if (!empty($arrayfields['cp.fk_user']['checked'])) { } // Filter: Type -if (!empty($arrayfields['ct.label']['checked'])) { +if (!empty($arrayfields['cp.fk_type']['checked'])) { $typeleaves = $holidaystatic->getTypes(1, -1); $arraytypeleaves = array(); foreach ($typeleaves as $key => $val) { @@ -297,6 +296,9 @@ if (!empty($arrayfields['cp.ref']['checked'])) { if (!empty($arrayfields['cp.fk_user']['checked'])) { print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder); } +if (!empty($arrayfields['cp.fk_type']['checked'])) { + print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], 'cp.fk_type', '', '', '', $sortfield, $sortorder); +} if (!empty($arrayfields['ct.label']['checked'])) { print_liste_field_titre($arrayfields['ct.label']['label'], $_SERVER["PHP_SELF"], 'ct.label', '', '', '', $sortfield, $sortorder); } @@ -382,8 +384,8 @@ if ($num == 0) { if (!empty($arrayfields['cp.fk_user']['checked'])) { print ''; } - if (!empty($arrayfields['ct.label']['checked'])) { - print ''; + if (!empty($arrayfields['cp.fk_type']['checked'])) { + print ''; } if (!empty($arrayfields['cp.date_debut']['checked'])) { @@ -418,7 +420,7 @@ if ($num == 0) { print ''; } if (!empty($arrayfields['cp.description']['checked'])) { - print ''; + print ''; } print ''; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index e8a3880ff40..0b6d36d6743 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -84,8 +84,8 @@ UPDATE llx_const set value = __ENCRYPT('eldy')__ WHERE __DECRYPT('value')__ = 'a UPDATE llx_const set value = __ENCRYPT('eldy')__ WHERE __DECRYPT('value')__ = 'cameleo'; DELETE FROM llx_user_param where param = 'MAIN_THEME' and value in ('auguria', 'amarok', 'cameleo'); -ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging varchar(64) DEFAULT NULL; -ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN packaging varchar(64) DEFAULT NULL; +ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging real DEFAULT NULL; +ALTER TABLE llx_product_fournisseur_price MODIFY COLUMN packaging real DEFAULT NULL; -- For v14 diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 4aad3393137..809ef5fbd65 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -40,8 +40,8 @@ create table llx_product customcode varchar(32), -- Optionnal custom code fk_country integer DEFAULT NULL, -- Optionnal id of original country fk_state integer DEFAULT NULL, -- Optionnal id of original state/province - price double(24,8) DEFAULT 0, - price_ttc double(24,8) DEFAULT 0, + price double(24,8) DEFAULT 0, -- price without tax + price_ttc double(24,8) DEFAULT 0, -- price inc vat (but not localtax1 nor localtax2) price_min double(24,8) DEFAULT 0, price_min_ttc double(24,8) DEFAULT 0, price_base_type varchar(3) DEFAULT 'HT', diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql index 2e9c88bd5ca..e5a0865ef68 100644 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql @@ -50,7 +50,7 @@ create table llx_product_fournisseur_price import_key varchar(14), -- Import key delivery_time_days integer, supplier_reputation varchar(10), - packaging varchar(64) DEFAULT NULL, + packaging real DEFAULT NULL, fk_multicurrency integer, multicurrency_code varchar(255), multicurrency_tx double(24,8) DEFAULT 1, diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql index ff862e427e0..690476e17b7 100644 --- a/htdocs/install/mysql/tables/llx_product_price.sql +++ b/htdocs/install/mysql/tables/llx_product_price.sql @@ -29,8 +29,8 @@ create table llx_product_price fk_product integer NOT NULL, date_price datetime NOT NULL, price_level smallint NULL DEFAULT 1, - price double(24,8) DEFAULT NULL, - price_ttc double(24,8) DEFAULT NULL, + price double(24,8) DEFAULT NULL, -- price without tax + price_ttc double(24,8) DEFAULT NULL, -- price inc vat (but not localtax1 nor localtax2) price_min double(24,8) default NULL, price_min_ttc double(24,8) default NULL, price_base_type varchar(3) DEFAULT 'HT', diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2e8d847ad11..bd4b4d8f7a6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2158,3 +2158,5 @@ YouShouldSetThisToOff=You should set this to 0 or off InstallAndUpgradeLockedBy=Install and upgrades are locked by the file %s IfYouUseASecondTaxYouMustSetYouUseTheMainTax=If you want to use a second tax, you must enable also the first sales tax IfYouUseAThirdTaxYouMustSetYouUseTheMainTax=If you want to use a third tax, you must enable also the first sales tax +DEBUGBAR_USE_LOG_FILE=Use the dolibarr.log file to trap Logs +UsingLogFileShowAllRecordOfSubrequestButIsSlower=Use the dolibarr.log file to trap Logs instead of live memory catching. It allows to catch all logs instead of only log of current process (so including the one of ajax subrequests pages) but will make your instance very very slow. Not recommended. diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index c5e1a58d243..efe1e51482b 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -146,9 +146,11 @@ ConfirmPaySalary=Are you sure you want to classify this salary card as paid? DeleteSocialContribution=Delete a social or fiscal tax payment DeleteVAT=Delete a VAT declaration DeleteSalary=Delete a salary card +DeleteVariousPayment=Delete a various payment ConfirmDeleteSocialContribution=Are you sure you want to delete this social/fiscal tax payment ? ConfirmDeleteVAT=Are you sure you want to delete this VAT declaration ? -ConfirmDeleteSalary=Are you sure you want to delete this salary? +ConfirmDeleteSalary=Are you sure you want to delete this salary ? +ConfirmDeleteVariousPayment=Are you sure you want to delete this various payment ? ExportDataset_tax_1=Social and fiscal taxes and payments CalcModeVATDebt=Mode %sVAT on commitment accounting%s. CalcModeVATEngagement=Mode %sVAT on incomes-expenses%s. diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 15043ce047e..66c5d0e240d 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -272,6 +272,9 @@ ErrorWrongFileName=Name of the file cannot have __SOMETHING__ in it ErrorNotInDictionaryPaymentConditions=Not in Payment Terms Dictionary, please modify. ErrorExecIdFailed=Can't execute command "id" ErrorBadCharIntoLoginName=Unauthorized character in the login name +ErrorInvoiceLoadThirdParty=Can't load third-party object for invoice "%s" +ErrorInvoiceLoadThirdPartyKey=Third-party key "%s" no set for invoice "%s" +ErrorDeleteLineNotAllowedByObjectStatus=Delete line is not allowed by actual object status # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 9018db40a5b..cbe9cca4d7a 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -102,6 +102,9 @@ ConfirmCancelOrder=Are you sure you want to cancel this order? ConfirmMakeOrder=Are you sure you want to confirm you made this order on %s? GenerateBill=Generate invoice ClassifyShipped=Classify delivered +PassedInShippedStatus=classified delivered +YouCantShipThis=I can't classify this. Please check user permissions +MustBeValidatedBefore=must be Validated or In process in order to be classified as shipped DraftOrders=Draft orders DraftSuppliersOrders=Draft purchase orders OnProcessOrders=In process orders diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index fecbe7450c2..7173d465ff2 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -345,7 +345,7 @@ UseProductFournDesc=Add a feature to define the descriptions of products defined ProductSupplierDescription=Vendor description for the product UseProductSupplierPackaging=Use packaging on supplier prices (recalculate quantities according to packaging set on supplier price when adding/updating line in supplier documents) PackagingForThisProduct=Packaging -PackagingForThisProductDesc=On supplier order, you will automaticly order this quantity (or a multiple of this quantity). Cannot be less than minimum buying quantity +PackagingForThisProductDesc=You will automaticaly purchase a multiple of this quantity. QtyRecalculatedWithPackaging=The quantity of the line were recalculated according to supplier packaging #Attributes diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 2fda7e1df0e..1b3211e252c 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -274,4 +274,5 @@ AddPersonToTask=Add also to tasks UsageOrganizeEvent=Usage: Event Organization PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE=Classify project as closed when all its tasks are completed (100%% progress) PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Note: existing projects with all tasks at 100 %% progress won't be affected: you will have to close them manually. This option only affects open projects. -SelectLinesOfTimeSpentToInvoice=Select lines of time spent that are unbilled, then bulk action "Generate Invoice" to bill them \ No newline at end of file +SelectLinesOfTimeSpentToInvoice=Select lines of time spent that are unbilled, then bulk action "Generate Invoice" to bill them +ErrorPROJECTLEADERRoleMissingRestoreIt=The "PROJECTLEADER" role is missing or has been de-activited, please restore in the dictionary of contact types diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index edbc08236d3..6acb50fe7bc 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -85,6 +85,22 @@ ProposalCustomerSignature=Written acceptance, company stamp, date and signature ProposalsStatisticsSuppliers=Vendor proposals statistics CaseFollowedBy=Case followed by SignedOnly=Signed only +NoSign=Set not signed +NoSigned=set not signed +CantBeNoSign=cannot be set not signed +ConfirmMassNoSignature=Bulk Not signed confirmation +ConfirmMassNoSignatureQuestion=Are you sure you want to set not signed the selected records ? +IsNotADraft=is not a draft +PassedInOpenStatus=has been validated +CantBeSign=cannot be signed +Sign=Sign +Signed=signed +CantBeSign=cannot be signed +CantBeValidated=cannot be validated +ConfirmMassValidation=Bulk Validate confirmation +ConfirmMassSignature=Bulk Signature confirmation +ConfirmMassValidationQuestion=Are you sure you want to validate the selected records ? +ConfirmMassSignatureQuestion=Are you sure you want to sign the selected records ? IdProposal=Proposal ID IdProduct=Product ID PrParentLine=Proposal Parent Line diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 16917384460..17ccbc35f83 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -176,7 +176,7 @@ ProductStockWarehouseCreated=Stock limit for alert and desired optimal stock cor ProductStockWarehouseUpdated=Stock limit for alert and desired optimal stock correctly updated ProductStockWarehouseDeleted=Stock limit for alert and desired optimal stock correctly deleted AddNewProductStockWarehouse=Set new limit for alert and desired optimal stock -AddStockLocationLine=Decrease quantity then click to add another warehouse for this product +AddStockLocationLine=Decrease quantity then click to split the line InventoryDate=Inventory date Inventories=Inventories NewInventory=New inventory diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index 280069f5cf9..be7a5f464ff 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -146,9 +146,11 @@ ConfirmPaySalary=Voulez-vous vraiment classer ce salaire comme payé ? DeleteSocialContribution=Effacer une charge fiscale ou sociale DeleteVAT=Supprimer une déclaration de TVA DeleteSalary=Supprimer un salaire +DeleteVariousPayment=Supprimer un paiement divers ConfirmDeleteSocialContribution=Voulez-vous vraiment supprimer ce paiement de taxe sociale / fiscale? ConfirmDeleteVAT=Voulez-vous vraiment supprimer cette déclaration de TVA ? ConfirmDeleteSalary=Êtes-vous sûr de vouloir supprimer ce salaire ? +ConfirmDeleteVariousPayment=Voulez-vous vraiment supprimer ce paiement divers ? ExportDataset_tax_1=Taxes sociales et fiscales et paiements CalcModeVATDebt=Mode %sTVA sur débit%s. CalcModeVATEngagement=Mode %sTVA sur encaissement%s. diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 448cc597a48..3b427a05341 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -415,7 +415,7 @@ TotalLT2IN=Total SGST HT=HT TTC=TTC INCVATONLY=TVA incluse -INCT=TTC +INCT=TVA+Taxes locales incluses VAT=TVA VATIN=IGST VATs=TVA diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang index 16d1ecc2b27..3b0a3e38a7d 100644 --- a/htdocs/langs/fr_FR/orders.lang +++ b/htdocs/langs/fr_FR/orders.lang @@ -102,6 +102,9 @@ ConfirmCancelOrder=Êtes-vous sûr de vouloir annuler cette commande ? ConfirmMakeOrder=Êtes-vous sûr de vouloir confirmer cette commande en date du %s ? GenerateBill=Facturer ClassifyShipped=Classer livrée +PassedInShippedStatus=classée livrée +YouCantShipThis=Classement impossible : veuillez vérifier les droits utilisateur +MustBeValidatedBefore=doit être Validée ou En cours de livraison pour pouvoir être classée livrée DraftOrders=Commandes brouillons DraftSuppliersOrders=Commandes fournisseurs brouillons OnProcessOrders=Commandes en cours de traitement diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index cec5c583ac9..54540b14109 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -346,7 +346,7 @@ UseProductFournDesc=Ajouter une fonctionnalité pour définir la description pro ProductSupplierDescription=Description du fournisseur du produit UseProductSupplierPackaging=Utiliser le conditionnement/emballage sur les prix fournisseur (recalculer les quantités en fonction de l'emballage défini sur le prix fournisseur lors de l'ajout / mise à jour de la ligne dans les documents fournisseurs) PackagingForThisProduct=Emballage -PackagingForThisProductDesc=Sur une commande fournisseur, vous commanderez automatiquement cette quantité ou un multiple. Vous ne pourrez pas saisir un montant inférieur +PackagingForThisProductDesc=Sur une commande fournisseur, vous commanderez automatiquement cette quantité ou un multiple. QtyRecalculatedWithPackaging=La quantité de la ligne a été recalculée en fonction de l'emballage du fournisseur #Attributes diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 82567e05fac..25034194119 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3187,7 +3187,7 @@ if ($module == 'initmodule') { print ''; print ''; print '
'.$langs->trans('BankAccount').''; print img_picto('', 'bank_account', 'class="pictofixedwidth"'); - print $form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); + print $form->select_comptes(($fk_account < 0 ? '' : $fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); print '
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($sign * $object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
'.price($sign * $object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'
'.$i.''.dol_print_date($db->jdate($objp->date), 'day').''.price($objp->amount).''; - $paymentstatic->id = $objp->pid; - $paymentstatic->ref = $objp->pref; if ($paymentstatic->id) { print $paymentstatic->getNomUrl(1); } else { @@ -652,8 +664,6 @@ if ($action == 'new') { print ''; - $accountlinestatic->id = $objp->rowid; - $accountlinestatic->ref = $objp->ref; if ($accountlinestatic->id > 0) { print $accountlinestatic->getNomUrl(1); } else { @@ -663,10 +673,10 @@ if ($action == 'new') { // Action button print ''; if ($object->statut == 0) { - print 'rowid.'">'.img_delete().''; + print 'rowid.'">'.img_delete().''; } if ($object->statut == 1 && $objp->statut != 2) { - print 'rowid.'">'.img_picto($langs->trans("RejectCheck"), 'disable').''; + print 'rowid.'">'.img_picto($langs->trans("RejectCheck"), 'disable').''; } if ($objp->statut == 2) { print '   '.img_picto($langs->trans('CheckRejected'), 'statut8').''; @@ -722,11 +732,13 @@ print ''; if ($action != 'new') { if ($object->statut == 1) { - $filename = dol_sanitizeFileName($object->ref); - $filedir = $dir.get_exdir($object->ref, 0, 1, 0, $object, 'checkdeposits'); + // Documents + $objref = dol_sanitizeFileName($object->ref); + $filedir = $upload_dir.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - - print $formfile->showdocuments('remisecheque', $filename, $filedir, $urlsource, 1, 1); + $genallowed = $usercancreate; + $delallowed = $usercandelete; + print $formfile->showdocuments('remisecheque', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); print '
'; } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 683b2fd0423..559697bf495 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -615,6 +615,7 @@ class RemiseCheque extends CommonObject // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charseSupprimert_output = $outputlangs->charset_output; + $result = $docmodel->write_file($this, $conf->bank->dir_output.'/checkdeposits', $this->ref, $outputlangs); if ($result > 0) { //$outputlangs->charset_output=$sav_charset_output; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 3d38f97b687..59d5e701f8c 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -517,8 +517,12 @@ while ($i < min($num, $limit)) { // Bank transaction if (!empty($arrayfields['transaction']['checked'])) { - $bankline->fetch($objp->fk_bank); - print '
'.$bankline->getNomUrl(1, 0).''; + if ($objp->fk_bank > 0) { + $bankline->fetch($objp->fk_bank); + print $bankline->getNomUrl(1, 0); + } + print '
'.$langs->trans('Ref').''.$langs->trans('Description').''.$langs->trans('VATRate').''.$langs->trans('PriceUHT').''.$langs->trans('Ref').''.$langs->trans('Description').''.$langs->trans('VATRate').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUHTCurrency').''.$langs->trans('PriceUHTCurrency').''.$langs->trans('Qty').''.$langs->trans('Qty').''.$langs->trans('Unit').''.$langs->trans('Unit').''.$langs->trans('ReductionShort').''.$langs->trans('ReductionShort').''.$form->showCheckAddButtons('checkforselect', 1).'
'; } elseif ($display_type == 'line') { - $out .= '
'; + $out .= '
'; } switch ($mode) { diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index eaf4bc511c8..b4613d87fc8 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -54,12 +54,21 @@ class DiscountAbsolute public $fk_soc; public $discount_type; // 0 => customer discount, 1 => supplier discount - public $amount_ht; // - public $amount_tva; // - public $amount_ttc; // - public $multicurrency_amount_ht; - public $multicurrency_amount_tva; - public $multicurrency_amount_ttc; + + public $total_ht; + public $total_tva; + public $total_ttc; + public $amount_ht; // deprecated + public $amount_tva; // deprecated + public $amount_ttc; // deprecated + + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; + public $multicurrency_amount_ht; // deprecated + public $multicurrency_amount_tva; // deprecated + public $multicurrency_amount_ttc; // deprecated + // Vat rate public $tva_tx; public $vat_src_code; @@ -163,13 +172,21 @@ class DiscountAbsolute $this->fk_soc = $obj->fk_soc; $this->discount_type = $obj->discount_type; - $this->amount_ht = $obj->amount_ht; - $this->amount_tva = $obj->amount_tva; - $this->amount_ttc = $obj->amount_ttc; + $this->total_ht = $obj->amount_ht; + $this->total_tva = $obj->amount_tva; + $this->total_ttc = $obj->amount_ttc; + // For backward compatibility + $this->amount_ht = $this->total_ht; + $this->amount_tva = $this->total_tva; + $this->amount_ttc = $this->total_ttc; - $this->multicurrency_amount_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht; - $this->multicurrency_amount_tva = $obj->multicurrency_amount_tva; - $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; + $this->multicurrency_total_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht; + $this->multicurrency_total_tva = $obj->multicurrency_amount_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_amount_ttc; + // For backward compatibility + $this->multicurrency_amount_ht = $this->multicurrency_total_ht; + $this->multicurrency_amount_tva = $this->multicurrency_total_tva; + $this->multicurrency_amount_ttc = $this->multicurrency_total_ttc; $this->tva_tx = $obj->tva_tx; $this->vat_src_code = $obj->vat_src_code; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 7a449f3e7ea..6e4f6892e05 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1766,15 +1766,18 @@ class ExtraFields } } } else { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $toprint = array(); $obj = $this->db->fetch_object($resql); - $c = new Categorie($this->db); - $c->fetch($obj->rowid); - $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text - foreach ($ways as $way) { - $toprint[] = '
  • color ? ' style="background: #'.$c->color.';"' : ' style="background: #bbb"').'>'.img_object('', 'category').' '.$way.'
  • '; + if ($obj->rowid) { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $c = new Categorie($this->db); + $result = $c->fetch($obj->rowid); + if ($result > 0) { + $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text + foreach ($ways as $way) { + $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . img_object('', 'category') . ' ' . $way . '
  • '; + } + } } $value = '
      '.implode(' ', $toprint).'
    '; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 39d53e9dbc7..9c14bfeb866 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3400,7 +3400,7 @@ class Form 'value'=>$outref, 'label'=>$outval, 'qty'=>$outqty, - 'price_ht'=>price2num($objp->unitprice, 'MT'), + 'price_ht'=>price2num($objp->unitprice, 'MU'), 'discount'=>$outdiscount, 'type'=>$outtype, 'duration_value'=>$outdurationvalue, diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index fcca60dad78..349b05416aa 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -359,9 +359,9 @@ class FormFile * Return a string to show the box with list of available documents for object. * This also set the property $this->numoffiles * - * @param string $modulepart Module the files are related to ('propal', 'facture', 'facture_fourn', 'mymodule', 'mymodule:myobject', 'mymodule_temp', ...) - * @param string $modulesubdir Existing (so sanitized) sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module. - * @param string $filedir Directory to scan + * @param string $modulepart Module the files are related to ('propal', 'facture', 'facture_fourn', 'mymodule', 'mymodule:MyObject', 'mymodule_temp', ...) + * @param string $modulesubdir Existing (so sanitized) sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into a subdir of module. + * @param string $filedir Directory to scan (must not end with a /). Example: '/mydolibarrdocuments/facture/FAYYMM-1234' * @param string $urlsource Url of origin page (for return) * @param int|string[] $genallowed Generation is allowed (1/0 or array list of templates) * @param int $delallowed Remove is allowed (1/0) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 17afecde14a..9907ae29834 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -356,10 +356,19 @@ class Utils dol_syslog("Utils::dumpDatabase execmethod=".$execmethod." command:".$fullcommandcrypted, LOG_INFO); + + /* If value has been forced with a php_admin_value, this has no effect. Example of value: '512M' */ + $MemoryLimit = getDolGlobalString('MAIN_MEMORY_LIMIT_DUMP'); + if (!empty($MemoryLimit)) { + @ini_set('memory_limit', $MemoryLimit); + } + + // TODO Replace with executeCLI function if ($execmethod == 1) { $output_arr = array(); $retval = null; + exec($fullcommandclear, $output_arr, $retval); if ($retval != 0) { diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 175c2fa1981..f75018fbdaf 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -963,6 +963,7 @@ function document_preview(file, type, title) img.src = file; } + function show_preview(mode) { /* console.log("mode="+mode+" file="+file+" type="+type+" width="+width+" height="+height); */ var newElem = ''; @@ -977,6 +978,7 @@ function document_preview(file, type, title) } $("#dialogforpopup").html(newElem); + $("#dialogforpopup").dialog({ closeOnEscape: true, resizable: true, @@ -1162,7 +1164,7 @@ $(document).ready(function() { // Force to hide menus when page is inside an iFrame $(document).ready(function() { - if (window.location !== window.parent.location ) { + if (window.location && window.location.pathname.indexOf("externalsite/frametop.php") == -1 && window.location !== window.parent.location ) { console.log("Page is detected to be into an iframe, we hide by CSS the menus"); // The page is in an iframe jQuery(".side-nav-vert, .side-nav, .websitebar").hide(); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e891904e39e..2f9cb532708 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -290,7 +290,7 @@ function dol_shutdown() $depth = $db->transaction_opened; $disconnectdone = $db->close(); } - dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was '.$depth.')' : ''), (($disconnectdone && $depth) ?LOG_WARNING:LOG_INFO)); + dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was '.$depth.')' : ''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO)); } /** @@ -2154,7 +2154,7 @@ function dol_bc($var, $moreclass = '') */ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = '', $mode = 0, $extralangcode = '') { - global $conf, $langs; + global $conf, $langs, $hookmanager; $ret = ''; $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS @@ -2220,6 +2220,14 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs $langs->load("dict"); $ret .= (empty($object->country_code) ? '' : ($ret ? $sep : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code))); } + if ($hookmanager) { + $parameters = array('withcountry' => $withcountry, 'sep' => $sep, 'outputlangs' => $outputlangs,'mode' => $mode, 'extralangcode' => $extralangcode); + $reshook = $hookmanager->executeHooks('formatAddress', $parameters, $object); + if ($reshook > 0) { + $ret = ''; + } + $ret .= $hookmanager->resPrint; + } return $ret; } diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 3ea554a4a8f..a3330d0562e 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -196,7 +196,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); //print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; - //print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; + //print ", dbtablename=".$tableandshare.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."
    "; $parentfortableentity = ''; @@ -494,8 +494,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (!$user->rights->fournisseur->facture->creer) { $deleteok = 0; } - } elseif ($feature == 'payment') { // Permission to delete a payment of an invoice is permission to edit an invoice. - if (!$user->rights->facture->creer) { + } elseif ($feature == 'payment') { + if (!$user->rights->facture->paiement) { $deleteok = 0; } } elseif ($feature == 'banque') { @@ -616,7 +616,7 @@ function checkUserAccessToObject($user, array $featuresarray, $objectid = 0, $ta $feature = 'projet_task'; } - $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website'); // Test on entity only (Objects with no link to company) + $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 3b7cc0d1184..09ba25ce911 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -819,7 +819,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } /** - * Tells if module is core or external + * Tells if module is core or external. + * 'dolibarr' and 'dolibarr_deprecated' is core + * 'experimental' and 'development' is core * * @return string 'core', 'external' or 'unknown' */ diff --git a/htdocs/core/modules/cheque/modules_chequereceipts.php b/htdocs/core/modules/cheque/modules_chequereceipts.php index dfdf0fbe363..e50a6877848 100644 --- a/htdocs/core/modules/cheque/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/modules_chequereceipts.php @@ -126,8 +126,7 @@ abstract class ModeleNumRefChequeReceipts } /** - * \class ModeleChequeReceipts - * \brief Classe mere des modeles de + * Class parent for templates of document generation */ abstract class ModeleChequeReceipts extends CommonDocGenerator { diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 6486306d9ed..96966606e1c 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1504,7 +1504,7 @@ class pdf_eratosthene extends ModelePDFCommandes $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index e26b03cdc46..ee45641c57e 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -290,11 +290,11 @@ class pdf_crabe extends ModelePDFFactures // Definition of $dir and $file if ($object->specimen) { - $dir = $conf->facture->dir_output; + $dir = empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$conf->entity]; $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->facture->dir_output."/".$objectref; + $dir = (empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$conf->entity])."/".$objectref; $file = $dir."/".$objectref.".pdf"; } if (!file_exists($dir)) { @@ -837,7 +837,7 @@ class pdf_crabe extends ModelePDFFactures $tab3_width = 80; $tab3_height = 4; if ($this->page_largeur < 210) { // To work with US executive format - $tab3_posx -= 20; + $tab3_posx -= 15; } $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1211,7 +1211,8 @@ class pdf_crabe extends ModelePDFFactures $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format - $col2x -= 20; + $col1x -= 15; + $col2x -= 10; } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index ef63ad14a94..1bbbb2c9f3f 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -498,7 +498,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis); } // $this->_pagefoot($pdf,$object,$outputlangs,1); $pdf->setTopMargin($tab_top_newpage); @@ -556,7 +556,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis); } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); @@ -578,7 +578,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->useTemplate($tplidx); } if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis); } $posyafter = $tab_top_newpage; @@ -873,7 +873,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis); } } @@ -891,7 +891,7 @@ class pdf_sponge extends ModelePDFFactures } $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis); } } } @@ -977,7 +977,7 @@ class pdf_sponge extends ModelePDFFactures $tab3_width = 80; $tab3_height = 4; if ($this->page_largeur < 210) { // To work with US executive format - $tab3_posx -= 20; + $tab3_posx -= 15; } $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1292,7 +1292,8 @@ class pdf_sponge extends ModelePDFFactures $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format - $col2x -= 20; + $col1x -= 15; + $col2x -= 10; } $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); @@ -1960,7 +1961,7 @@ class pdf_sponge extends ModelePDFFactures $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index a128b92ee29..0128a51c0b8 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -51,7 +51,7 @@ class modCashDesk extends DolibarrModules $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "CashDesk module"; - $this->version = 'deprecated'; + $this->version = 'dolibarr_deprecated'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto = 'cash-register'; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 5e51dd0344d..e5b0473597b 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -855,7 +855,7 @@ class modProduct extends DolibarrModules } if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( - 'sp.packagning'=>'1', + 'sp.packaging'=>'10', )); } diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index c4124ee7c24..08ef6d4b741 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -222,7 +222,7 @@ class modProjet extends DolibarrModules 's.phone'=>'Text', 's.email'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 'p.rowid'=>"List:projet:ref::project", 'p.ref'=>"Text", 'p.title'=>"Text", 'p.usage_opportunity'=>'Boolean', 'p.usage_task'=>'Boolean', 'p.usage_bill_time'=>'Boolean', - 'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric', + 'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric', 'p.budget_amount'=>'Numeric', 'pt.rowid'=>'Numeric', 'pt.ref'=>'Text', 'pt.label'=>'Text', 'pt.dateo'=>"Date", 'pt.datee'=>"Date", 'pt.duration_effective'=>"Duree", 'pt.planned_workload'=>"Numeric", 'pt.progress'=>"Numeric", 'pt.description'=>"Text", 'ptt.rowid'=>'Numeric', 'ptt.task_date'=>'Date', 'ptt.task_duration'=>"Duree", 'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)", 'ptt.note'=>"Text" ); @@ -235,7 +235,7 @@ class modProjet extends DolibarrModules 's.phone'=>'Phone', 's.email'=>'Email', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 'p.rowid'=>"ProjectId", 'p.ref'=>"RefProject", 'p.title'=>'ProjectLabel', 'p.usage_opportunity'=>'ProjectFollowOpportunity', 'p.usage_task'=>'ProjectFollowTasks', 'p.usage_bill_time'=>'BillTime', - 'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.description'=>"Description" + 'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.budget_amount'=>'Budget', 'p.description'=>"Description" ); // Add multicompany field if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) { diff --git a/htdocs/core/modules/modRecruitment.class.php b/htdocs/core/modules/modRecruitment.class.php index 3d4e88872ef..41679c19a1c 100644 --- a/htdocs/core/modules/modRecruitment.class.php +++ b/htdocs/core/modules/modRecruitment.class.php @@ -423,7 +423,7 @@ class modRecruitment extends DolibarrModules $sql = array(); // Document template - $moduledir = 'mymodule'; + $moduledir = 'recruitment'; $myTmpObjects = array(); $myTmpObjects['RecruitmentJobPosition'] = array('includerefgeneration'=>1, 'includedocgeneration'=>1); @@ -431,10 +431,10 @@ class modRecruitment extends DolibarrModules if ($myTmpObjectKey == 'MyObject') { continue; } - if ($myTmpObjectArray['includerefgeneration']) { - $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/mymodule'; - $dest = $dirodt.'/template_myobjects.odt'; + if ($myTmpObjectArray['includedocgeneration']) { + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_recruitmentjobposition.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir; + $dest = $dirodt.'/template_recruitmentjobposition.odt'; if (file_exists($src) && !file_exists($dest)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -450,8 +450,6 @@ class modRecruitment extends DolibarrModules $sql = array_merge($sql, array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity, "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".strtolower($myTmpObjectKey)."',".$conf->entity.")", - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".strtolower($myTmpObjectKey)."', ".$conf->entity.")" )); } } diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 377d5aadbc4..c620bebebc2 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -252,7 +252,7 @@ class modResource extends DolibarrModules $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'resource as r'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = r.rowid'; - $this->export_sql_end[$r] .= ' AND r.entity IN ('.getEntity('resource').')'; + $this->export_sql_end[$r] .= ' WHERE r.entity IN ('.getEntity('resource').')'; // Imports diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 0390a23cc83..bdc3388da5c 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -786,7 +786,7 @@ class modService extends DolibarrModules } if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( - 'sp.packagning'=>'1', + 'sp.packagning'=>'10', )); } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 5fb9949acd3..cb2df1a5ed9 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1595,7 +1595,7 @@ class pdf_cyan extends ModelePDFPropales $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 38344a5f486..d81a01bea92 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -523,9 +523,9 @@ class pdf_squille extends ModelePdfReception while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object); } $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; @@ -534,9 +534,9 @@ class pdf_squille extends ModelePdfReception } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object); } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object); } $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page @@ -550,10 +550,10 @@ class pdf_squille extends ModelePdfReception // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } @@ -719,9 +719,10 @@ class pdf_squille extends ModelePdfReception * @param Translate $outputlangs Langs object * @param int $hidetop Hide top bar of array * @param int $hidebottom Hide bottom bar of array + * @param Object|NULL $object Object reception to generate * @return void */ - protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object = null) { global $conf; @@ -767,7 +768,18 @@ class pdf_squille extends ModelePdfReception $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxqtytoship, $tab_top + 1); - $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"), '', 'C'); + $statusreceived = Reception::STATUS_CLOSED; + if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) { + $statusreceived = Reception::STATUS_VALIDATED; + } + if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) { + $statusreceived = Reception::STATUS_CLOSED; + } + if ($object && $object->statut < $statusreceived) { + $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyToReceive'), '', 'C'); + } else { + $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyReceived'), '', 'C'); + } } if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) { diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index b6da2d4c294..1f32f645116 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2015 Marcos García + * Copyright (C) 2022 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 @@ -132,7 +133,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $this->db = $db; $this->name = "standard"; $this->description = $langs->trans('DocumentModelStandardPDF'); - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + $this->update_main_doc_field = 0; // Save the name of generated file as the main doc when generating a doc with this template // Page size for A4 format $this->type = 'pdf'; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 7e1b1105452..aba01f51742 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -1336,7 +1336,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } /* PHFAVRE $posy+=4; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index f50276821b1..cc0ee2b0f93 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -156,6 +156,7 @@ if (empty($reshook) && isset($extrafields->attributes[$object->table_element]['l //var_dump($user->rights); $permok = false; $keyforperm = $object->element; + if ($object->element == 'fichinter') { $keyforperm = 'ficheinter'; } diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index d4943ac454d..6929b23fcad 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -26,21 +26,21 @@ if (empty($conf) || !is_object($conf)) { tpl['strike']) ? '' : ' strikefordisabled').'">'; -print '
    '.$this->tpl['label'].''.$this->tpl['description'].''.$this->tpl['vat_rate'].''.$this->tpl['price'].'
    '.$this->tpl['label'].''.$this->tpl['description'].''.$this->tpl['vat_rate'].''.$this->tpl['price'].''.$this->tpl['multicurrency_price'].''.$this->tpl['multicurrency_price'].''.$this->tpl['qty'].''.$this->tpl['qty'].''.$langs->trans($this->tpl['unit']).''.$langs->trans($this->tpl['unit']).''.$this->tpl['remise_percent'].''.$this->tpl['remise_percent'].''; - print dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label'); + $exp_tax_cat_label = dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label'); + print $langs->trans($exp_tax_cat_label); print ''.$user->getFullName($langs).''.$obj->label.''.$arraytypeleaves[$obj->fk_type].''.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).''.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).''.dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)).''; - print $perm[1]; + print $langs->trans($perm[1]); print ''; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index dd67a65238b..a5f86ee7e8a 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -972,8 +972,8 @@ class MyObject extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f72642c249a..b6e512d25c2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2020,7 +2020,7 @@ class Product extends CommonObject /** - * Modify customer price of a product/Service + * Modify customer price of a product/Service for a given level * * @param double $newprice New price * @param string $newpricebase HT or TTC @@ -2192,7 +2192,8 @@ class Product extends CommonObject $this->db->commit(); } else { $this->db->rollback(); - dol_print_error($this->db); + $this->error = $this->db->lasterror(); + return -1; } } diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index f7f604b5399..7c463eb35e6 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -528,7 +528,7 @@ class Productbatch extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."product_lot as pl"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pl.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch AS pb ON pl.batch = pb.batch"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock AS ps ON ps.rowid = pb.fk_product_stock"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock AS ps ON ps.rowid = pb.fk_product_stock AND ps.fk_product = ".((int) $fk_product); $sql .= " WHERE p.entity IN (".getEntity('product').")"; $sql .= " AND pl.fk_product = ".((int) $fk_product); if ($fk_warehouse > 0) { diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 92eb4f23140..c309570cc52 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -294,9 +294,10 @@ if (empty($reshook)) { if (empty($packaging)) { $packaging = 1; } + /* We can have a puchase ref that need to buy 100 min for a given price and with a packaging of 50. if ($packaging < $quantity) { $packaging = $quantity; - } + }*/ $object->packaging = $packaging; if (!empty($conf->multicurrency->enabled)) { diff --git a/htdocs/product/price.php b/htdocs/product/price.php index cef401bcc45..458f2ce7a02 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -171,10 +171,52 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } - if ($error) { - //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); - $localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them. - $object->updatePrice(0, $object->price_base_type, $user, $tva_tx, '', 0, $npr, 0, 0, $localtaxarray, $vatratecode); + if (!$error) { + if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { + // Force the update of the price of the product using the new VAT + if ($object->multiprices_base_type[$i] == 'HT') { + $oldprice = $object->multiprices[$i]; + $oldminprice = $object->multiprices_min[$i]; + } else { + $oldprice = $object->multiprices_ttc[$i]; + $oldminprice = $object->multiprices_min_ttc[$i]; + } + $oldpricebasetype = $object->multiprices_base_type[$i]; + $oldnpr = $object->multiprices_recuperableonly[$i]; + + //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); + $localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them. + $level = $i; + $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode); + + if ($ret < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } else { + // Force the update of the price of the product using the new VAT + if ($object->price_base_type == 'HT') { + $oldprice = $object->price; + $oldminprice = $object->price_min; + } else { + $oldprice = $object->price_ttc; + $oldminprice = $object->price_min_ttc; + } + $oldpricebasetype = $object->price_base_type; + $oldnpr = $object->tva_npr; + + //$localtaxarray=array('0'=>$localtax1_type,'1'=>$localtax1,'2'=>$localtax2_type,'3'=>$localtax2); + $localtaxarray = array(); // We do not store localtaxes into product, we will use instead the "vat code" to retrieve them. + $level = 0; + $ret = $object->updatePrice($oldprice, $oldpricebasetype, $user, $tva_tx, $oldminprice, $level, $oldnpr, 0, 0, $localtaxarray, $vatratecode); + + if ($ret < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } } if (!$error) { @@ -394,13 +436,21 @@ if (empty($reshook)) { if ($action == 'activate_price_by_qty') { // Activating product price by quantity add a new price line with price_by_qty set to 1 $level = GETPOST('level', 'int'); - $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1); + $ret = $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 1); + + if ($ret < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } // Unset Price by quantity if ($action == 'disable_price_by_qty') { // Disabling product price by quantity add a new price line with price_by_qty set to 0 $level = GETPOST('level', 'int'); - $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 0); + $ret = $object->updatePrice(0, $object->price_base_type, $user, $object->tva_tx, 0, $level, $object->tva_npr, 0); + + if ($ret < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } if ($action == 'edit_price_by_qty') { // Edition d'un prix par quantité @@ -1469,6 +1519,7 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul } $sql .= " ORDER BY p.date_price DESC, p.rowid DESC, p.price_level ASC"; // $sql .= $db->plimit(); + //print $sql; $result = $db->query($sql); if ($result) { @@ -1483,13 +1534,17 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul // On l'ajoute donc pour remettre a niveau (pb vieilles versions) // We emulate the change of the price from interface with the same value than the one into table llx_product if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - $object->updatePrice(($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_ttc[1] : $object->multiprices[1]), $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1]) ? 0 : $object->multiprices_tva_tx[1]), ($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_min_ttc[1] : $object->multiprices_min[1]), 1); + $ret = $object->updatePrice(($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_ttc[1] : $object->multiprices[1]), $object->multiprices_base_type[1], $user, (empty($object->multiprices_tva_tx[1]) ? 0 : $object->multiprices_tva_tx[1]), ($object->multiprices_base_type[1] == 'TTC' ? $object->multiprices_min_ttc[1] : $object->multiprices_min[1]), 1); } else { - $object->updatePrice(($object->price_base_type == 'TTC' ? $object->price_ttc : $object->price), $object->price_base_type, $user, $object->tva_tx, ($object->price_base_type == 'TTC' ? $object->price_min_ttc : $object->price_min)); + $ret = $object->updatePrice(($object->price_base_type == 'TTC' ? $object->price_ttc : $object->price), $object->price_base_type, $user, $object->tva_tx, ($object->price_base_type == 'TTC' ? $object->price_min_ttc : $object->price_min)); } - $result = $db->query($sql); - $num = $db->num_rows($result); + if ($ret < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + $result = $db->query($sql); + $num = $db->num_rows($result); + } } if ($num > 0) { @@ -1503,8 +1558,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul print_barre_liste($langs->trans("PriceByCustomerLog"), 0, $_SERVER["PHP_SELF"], '', '', '', '', 0, $num, 'title_accountancy.png'); } - print '
    '; - print ''; + print ''."\n"; + print '
    '."\n"; + print '
    '."\n"; print ''; print ''; @@ -1522,6 +1578,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul } print ''; print ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { + print ''; + } if (!empty($conf->dynamicprices->enabled)) { print ''; } @@ -1588,6 +1647,24 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul print ""; } + // Line for default price + if ($objp->price_base_type == 'HT') { + $pu = $objp->price; + } else { + $pu = $objp->price_ttc; + } + + // Local tax was not saved into table llx_product on old version. So we will use value linked to VAT code. + $localtaxarray = getLocalTaxesFromRate($objp->tva_tx.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), 0, $mysoc, $mysoc); + // Define part of HT, VAT, TTC + $resultarray = calcul_price_total(1, $pu, 0, $objp->tva_tx, 1, 1, 0, $objp->price_base_type, $objp->recuperableonly, $object->type, $mysoc, $localtaxarray); + // Calcul du total ht sans remise + $total_ht = $resultarray[0]; + $total_vat = $resultarray[1]; + $total_localtax1 = $resultarray[9]; + $total_localtax2 = $resultarray[10]; + $total_ttc = $resultarray[2]; + // Price if (!empty($objp->fk_price_expression) && !empty($conf->dynamicprices->enabled)) { $price_expression = new PriceExpression($db); @@ -1595,32 +1672,46 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action == 'showlog_defaul $title = $price_expression->title; print ''; print ''; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { + print ''; + } print '"; } else { + // Price HT print '"; + // Price TTC print '"; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { + print ''; + } if (!empty($conf->dynamicprices->enabled)) { //Only if module is enabled print ''; } } + // Price min print ''; + // Price min inc tax print ''; @@ -1911,11 +2002,9 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; print ''; + print ''; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { - //print ''; print ''; - } else { - print ''; } print ''; print ''; @@ -1976,11 +2065,9 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ""; print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { - //print '"; print ''; - } else { - print '"; } print ''; @@ -2023,12 +2110,15 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; - print '
    '; - print '
    '.$langs->trans("AppliedPricesFrom").''.$langs->trans("HT").''.$langs->trans("TTC").''.$langs->trans("INCT").''.$langs->trans("PriceExpressionSelected").''.$title."'; if (empty($objp->price_by_qty)) { print price($objp->price); } print "'; if (empty($objp->price_by_qty)) { - print price($objp->price_ttc); + $price_ttc = $objp->price_ttc; + print price($price_ttc); } print "'; + print $resultarray[2]; + print ''; if (empty($objp->price_by_qty)) { print price($objp->price_min); } print ''; if (empty($objp->price_by_qty)) { - print price($objp->price_min_ttc); + $price_min_ttc = $objp->price_min_ttc; + print price($price_min_ttc); } print ''.$langs->trans("PriceBase").''.$langs->trans("DefaultTaxRate").''.$langs->trans("HT").''.$langs->trans("TTC").'' . $langs->trans("INCVATONLY") . ''.$langs->trans("INCT").''.$langs->trans("TTC").''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.price($line->price)."'.price($line->price_ttc)."' . price($line->price_ttc) . "'.price($resultarray[2]).''.price($line->price_ttc)."'.price($line->price_min).'
    '; + print ''."\n"; + print '
    '."\n"; + print '
    '."\n"; if (count($prodcustprice->lines) > 0 || $search_soc) { $colspan = 9; - //if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++; + if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { + $colspan++; + } print ''; print ''; @@ -2048,13 +2138,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ''; print ''; print ''; + print ''; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { - //print ''; print ''; - } else { - print ''; } - print ''; print ''; print ''; @@ -2068,7 +2155,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $pu = $object->price_ttc; } - // Local tax is not saved into table of product. We use value linked to VAT code. + // Local tax was not saved into table llx_product on old version. So we will use value linked to VAT code. $localtaxarray = getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), 0, $mysoc, $mysoc); // Define part of HT, VAT, TTC $resultarray = calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray); @@ -2106,14 +2193,12 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '"; print ''; - } else { - print '"; } - print ''; print ''; print '"; print '"; + print '"; if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") { //print '"; print ''; - } else { - print '"; } print ''; diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php index 52eec409185..5ab7a8f40a8 100644 --- a/htdocs/product/stats/bom.php +++ b/htdocs/product/stats/bom.php @@ -247,6 +247,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index fd64a1c0572..c7283399a43 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -198,6 +198,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index cb7c84fc863..4c958a20370 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -183,7 +183,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; - + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index b3e5571ac5a..da81f915b45 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -214,6 +214,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 212674582f9..e85801c8642 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -197,6 +197,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 5a5c33312ca..adfe989289e 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -176,6 +176,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index b83d0368b75..096848d6205 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -199,6 +199,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index d583d58bff8..a60261af115 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -198,6 +198,7 @@ if ($id > 0 || !empty($ref)) { } print ''."\n"; + print ''; if (!empty($sortfield)) { print ''; } diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 0f13770d3b3..a4ce5577361 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -904,10 +904,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } // Desired stock - print ''; + print ''; // Limit stock for alert - print ''; + print ''; // Current stock (all warehouses) print ''; // To order - print ''; + print ''; // Supplier print ''; + print ''; + } else { + print ''; + } } // Batch number managment diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 5fb8e3b8af0..0be0ea7ba37 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -236,7 +236,6 @@ class Reception extends CommonObject $this->user = $user; - $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."reception ("; @@ -273,12 +272,12 @@ class Reception extends CommonObject $sql .= ", ".$this->fk_project; $sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : "null"); $sql .= ", '".$this->db->escape($this->tracking_number)."'"; - $sql .= ", ".$this->weight; - $sql .= ", ".$this->sizeS; // TODO Should use this->trueDepth - $sql .= ", ".$this->sizeW; // TODO Should use this->trueWidth - $sql .= ", ".$this->sizeH; // TODO Should use this->trueHeight - $sql .= ", ".$this->weight_units; - $sql .= ", ".$this->size_units; + $sql .= ", ".(is_null($this->weight) ? "NULL" : ((double) $this->weight)); + $sql .= ", ".(is_null($this->sizeS) ? "NULL" : ((double) $this->sizeS)); // TODO Should use this->trueDepth + $sql .= ", ".(is_null($this->sizeW) ? "NULL" : ((double) $this->sizeW)); // TODO Should use this->trueWidth + $sql .= ", ".(is_null($this->sizeH) ? "NULL" : ((double) $this->sizeH)); // TODO Should use this->trueHeight + $sql .= ", ".(is_null($this->weight_units) ? "NULL" : ((double) $this->weight_units)); + $sql .= ", ".(is_null($this->size_units) ? "NULL" : ((double) $this->size_units)); $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); $sql .= ", ".(!empty($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); $sql .= ", ".(!empty($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null"); @@ -566,7 +565,7 @@ class Reception extends CommonObject // Loop on each product line to add a stock movement // TODO in future, reception lines may not be linked to order line - $sql = "SELECT cd.fk_product, cd.subprice,"; + $sql = "SELECT cd.fk_product, cd.subprice, cd.remise_percent,"; $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; $sql .= " ed.eatby, ed.sellby, ed.batch"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; @@ -592,12 +591,19 @@ class Reception extends CommonObject $mouvS = new MouvementStock($this->db); $mouvS->origin = &$this; + // get unit price with discount + $up_ht_disc = $obj->subprice; + if (!empty($obj->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) { + $up_ht_disc = price2num($up_ht_disc * (100 - $obj->remise_percent) / 100, 'MU'); + } + if (empty($obj->batch)) { // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. $inventorycode = ''; - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), '', '', '', '', 0, $inventorycode); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $up_ht_disc, $langs->trans("ReceptionValidatedInDolibarr", $numref), '', '', '', '', 0, $inventorycode); + if ($result < 0) { $error++; $this->errors[] = $mouvS->error; @@ -610,7 +616,8 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) $inventorycode = ''; - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $up_ht_disc, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); + if ($result < 0) { $error++; $this->errors[] = $mouvS->error; @@ -727,8 +734,14 @@ class Reception extends CommonObject $line->qty = $qty; $supplierorderline = new CommandeFournisseurLigne($this->db); - $supplierorderline->fetch($id); + $result = $supplierorderline->fetch($id); + if ($result <= 0) { + $this->error = $supplierorderline->error; + $this->errors = $supplierorderline->errors; + return -1; + } + $fk_product = 0; if (!empty($conf->stock->enabled) && !empty($supplierorderline->fk_product)) { $fk_product = $supplierorderline->fk_product; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 50e978aceab..cc215a855ff 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -919,7 +919,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { diff --git a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php index 84bfd30401c..089aa720fa7 100644 --- a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php +++ b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php @@ -51,7 +51,7 @@ abstract class ModelePDFRecruitmentCandidature extends CommonDocGenerator // phpcs:enable global $conf; - $type = 'recruitmentjobposition'; + $type = 'recruitmentjobcandidature'; $list = array(); include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 76236bb88aa..08e850c259a 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -164,9 +164,9 @@ class PaymentSalary extends CommonObject $this->db->begin(); if ($totalamount != 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_salary, datec, datep, amount,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (entity, fk_salary, datec, datep, amount,"; $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)"; - $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql .= " VALUES (".((int) $conf->entity).", ".((int) $this->chid).", '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datepaye)."',"; $sql .= " ".price2num($totalamount).","; $sql .= " ".((int) $this->paiementtype).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).","; diff --git a/htdocs/salaries/class/salariesstats.class.php b/htdocs/salaries/class/salariesstats.class.php index b3e6c20a0ca..41898bb7341 100644 --- a/htdocs/salaries/class/salariesstats.class.php +++ b/htdocs/salaries/class/salariesstats.class.php @@ -23,7 +23,7 @@ * \brief Fichier de la classe de gestion des stats des salaires */ include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +include_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; /** * Classe permettant la gestion des stats des salaires @@ -58,7 +58,7 @@ class SalariesStats extends Stats $this->socid = $socid; $this->userid = $userid; - $object = new PaymentSalary($this->db); + $object = new Salary($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element; $this->field = 'amount'; @@ -81,7 +81,7 @@ class SalariesStats extends Stats */ public function getNbByYear() { - $sql = "SELECT YEAR(datep) as dm, count(*)"; + $sql = "SELECT YEAR(dateep) as dm, count(*)"; $sql .= " FROM ".$this->from; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY dm DESC"; @@ -99,9 +99,9 @@ class SalariesStats extends Stats */ public function getNbByMonth($year, $format = 0) { - $sql = "SELECT MONTH(datep) as dm, count(*)"; + $sql = "SELECT MONTH(dateep) as dm, count(*)"; $sql .= " FROM ".$this->from; - $sql .= " WHERE YEAR(datep) = ".((int) $year); + $sql .= " WHERE YEAR(dateep) = ".((int) $year); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -121,9 +121,9 @@ class SalariesStats extends Stats */ public function getAmountByMonth($year, $format = 0) { - $sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")"; + $sql = "SELECT date_format(dateep,'%m') as dm, sum(".$this->field.")"; $sql .= " FROM ".$this->from; - $sql .= " WHERE date_format(datep,'%Y') = '".$this->db->escape($year)."'"; + $sql .= " WHERE date_format(dateep,'%Y') = '".$this->db->escape($year)."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -141,9 +141,9 @@ class SalariesStats extends Stats */ public function getAverageByMonth($year) { - $sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")"; + $sql = "SELECT date_format(dateep,'%m') as dm, avg(".$this->field.")"; $sql .= " FROM ".$this->from; - $sql .= " WHERE date_format(datep,'%Y') = '".$this->db->escape($year)."'"; + $sql .= " WHERE date_format(dateep,'%Y') = '".$this->db->escape($year)."'"; $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; $sql .= $this->db->order('dm', 'DESC'); @@ -158,7 +158,7 @@ class SalariesStats extends Stats */ public function getAllByYear() { - $sql = "SELECT date_format(datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql = "SELECT date_format(dateep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql .= " FROM ".$this->from; $sql .= " WHERE ".$this->where; $sql .= " GROUP BY year"; diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index f129e6304ab..964c2521f3c 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -234,7 +234,7 @@ $sql .= " ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = sal.fk_user"; $sql .= " AND s.entity IN (".getEntity('payment_salaries').")"; if (empty($user->rights->salaries->readall)) { - $sql .= " AND s.fk_user IN (".$db->sanitize(join(',', $childids)).")"; + $sql .= " AND sal.fk_user IN (".$db->sanitize(join(',', $childids)).")"; } // Search criteria diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index ecc62c2a237..bfacd908c12 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -74,6 +74,10 @@ dol_mkdir($dir); $useridtofilter = $userid; // Filter from parameters +if (empty($user->rights->salaries->readall) && empty($useridtofilter)) { + $useridtofilter = $user->getAllChildIds(1); +} + $stats = new SalariesStats($db, $socid, $useridtofilter); @@ -204,7 +208,7 @@ print ''; // Year print ''; // Timing (Duration sum of linked fichinter) - if ($conf->ficheinter->enabled) { + if (!empty($conf->ficheinter->enabled)) { $object->fetchObjectLinked(); $num = count($object->linkedObjects); $timing = 0; diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index c77d9bd1232..597372fc17c 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -455,9 +455,12 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac $holiday->id = $objp->rowid; $holiday->ref = $objp->rowid; + $holiday->fk_type = $objp->fk_type; $holiday->statut = $objp->status; - $nbopenedday = num_open_day($db->jdate($objp->date_debut), $db->jdate($objp->date_fin), 0, 1, $objp->halfday); + $holiday->status = $objp->status; + + $nbopenedday = num_open_day($db->jdate($objp->date_debut, 'gmt'), $db->jdate($objp->date_fin, 'gmt'), 0, 1, $objp->halfday); print ''; print ''; print ''; print "\n"; @@ -1565,7 +1565,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Date of birth print ''; print ''; print "\n"; @@ -1834,14 +1834,14 @@ if ($action == 'create' || $action == 'adduserldap') { } } - if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { print ''; } else { print ''; } } elseif ($caneditpassword && !$object->ldap_sid && - (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print ''; } @@ -1850,16 +1850,16 @@ if ($action == 'create' || $action == 'adduserldap') { if ($object->statut == 0) { print ''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { - print ''; + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { + print ''; } if ($object->statut == 0) { print ''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { if ($object->email) { - print ''; + print ''; } else { print ''; } @@ -1868,12 +1868,12 @@ if ($action == 'create' || $action == 'adduserldap') { // Enable user if ($user->id <> $id && $candisableuser && $object->statut == 0 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print ''; } // Disable user if ($user->id <> $id && $candisableuser && $object->statut == 1 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { print ''; } else { if ($user->id == $id) { @@ -1882,7 +1882,7 @@ if ($action == 'create' || $action == 'adduserldap') { } // Delete if ($user->id <> $id && $candisableuser && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $object->entity == 1))) { if ($user->admin || !$object->admin) { // If user edited is admin, delete is possible on for an admin print ''; } else { @@ -2712,9 +2712,9 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; print "\n"; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 2b284f6878e..04eebd6b6c9 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1731,7 +1731,7 @@ class User extends CommonObject $sql .= ", login = '".$this->db->escape($this->login)."'"; $sql .= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null"); $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' - $sql .= ", birth=".(strval($this->birth) != '' ? "'".$this->db->idate($this->birth)."'" : 'null'); + $sql .= ", birth=".(strval($this->birth) != '' ? "'".$this->db->idate($this->birth, 'tzserver')."'" : 'null'); if (!empty($user->admin)) { $sql .= ", admin = ".(int) $this->admin; // admin flag can be set/unset only by an admin user } diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 6eb17a9bffb..ac9d5403671 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -536,7 +536,14 @@ class ProductCombination $new_price += $variation_price; } - $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq, 0, array(), $parent->default_vat_code); + $ret = $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, $i, $new_npr, $new_psq, 0, array(), $parent->default_vat_code); + + if ($ret < 0) { + $this->db->rollback(); + $this->error = $child->error; + $this->errors = $child->errors; + return $ret; + } } } } else { @@ -558,7 +565,14 @@ class ProductCombination $new_price += $this->variation_price; } - $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, 1, $new_npr, $new_psq); + $ret = $child->updatePrice($new_price, $new_type, $user, $new_vat, $new_min_price, 1, $new_npr, $new_psq); + + if ($ret < 0) { + $this->db->rollback(); + $this->error = $child->error; + $this->errors = $child->errors; + return $ret; + } } $this->db->commit(); @@ -567,6 +581,8 @@ class ProductCombination } $this->db->rollback(); + $this->error = $child->error; + $this->errors = $child->errors; return -1; } diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 881f741650d..feec8acf254 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -234,6 +234,13 @@ if (empty($modulepart)) { accessforbidden('Bad value for parameter modulepart', 0, 0, 1); } +// When logged in a different entity, medias cannot be accessed because $conf->$module->multidir_output +// is not set on the requested entity, but they are public documents, so reset entity +if ($modulepart === 'medias' && $entity != $conf->entity) { + $conf->entity = $entity; + $conf->setValues($db); +} + $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $user, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 0e192ff0212..b7062b4f599 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2741,6 +2741,7 @@ if (!GETPOST('hide_websitemenu')) { $htmltext .= '
    '.$langs->trans("GoTo").' '.$virtualurl.'

    '; } if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) { + $htmltext .= ''; $htmltext .= '
    '.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER); } else { $htmltext .= $langs->trans("SetHereVirtualHost", $dataroot);
    '.$langs->trans("PriceBase").''.$langs->trans("DefaultTaxRate").''.$langs->trans("HT").''.$langs->trans("TTC").'' . $langs->trans("INCVATONLY") . ''.$langs->trans("INCT").''.$langs->trans("TTC").''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.$langs->trans("ChangedBy").''.price($object->price)."'.price($object->price_ttc)."' . price($object->price_ttc) . "'.price($resultarray[2]).''.price($object->price_ttc)."'.price($object->price_min).''.price($object->price_min_ttc).''; @@ -2184,11 +2269,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print "'.price($line->price)."'.price($line->price_ttc)."' . price($line->price_ttc) . "'.price($resultarray[2]).''.price($line->price_ttc)."'.price($line->price_min).'
    '.($fk_entrepot > 0 ? $desiredstockwarehouse : $desiredstock).''.((!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $desiredstockwarehouse : $desiredstock).''.($fk_entrepot > 0 ? $alertstockwarehouse : $alertstock).''.((!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) > 0 ? $alertstockwarehouse : $alertstock).''.$warning.$stock; @@ -923,7 +923,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print ''.$ordered.' '.$picto.''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 8897f9550a3..7e309ee2bf7 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -92,6 +92,10 @@ if ($year && $month && $day) { $daytoparse = dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday); // xxxofday is value of day after submit action 'addtime' } +$daytoparsegmt = dol_now('gmt'); +if ($yearofday && $monthofday && $dayofday) $daytoparsegmt = dol_mktime(0, 0, 0, $monthofday, $dayofday, $yearofday, 'gmt'); // xxxofday is value of day after submit action 'addtime' +elseif ($year && $month && $day) $daytoparsegmt = dol_mktime(0, 0, 0, $month, $day, $year, 'gmt'); // this are value submited after submit of action 'submitdateselect' + if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess = $user; $search_usertoprocessid = $usertoprocess->id; @@ -614,6 +618,11 @@ $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSI // Get if user is available or not for each day $isavailable = array(); + +// Assume from Monday to Friday if conf empty or badly formed +$numstartworkingday = 1; +$numendworkingday = 5; + if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); if (count($tmparray) >= 2) { @@ -626,7 +635,7 @@ $statusofholidaytocheck = Holiday::STATUS_APPROVED; $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholidaytocheck); // $daytoparse is a date with hours = 0 $isavailable[$daytoparse] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day -$test = num_public_holiday($daytoparse, $daytoparse + 86400, $mysoc->country_code); +$test = num_public_holiday($daytoparsegmt, $daytoparsegmt + 86400, $mysoc->country_code); if ($test) { $isavailable[$daytoparse] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); } diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 2a27294bfed..d4ab6108b7e 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -95,7 +95,7 @@ $next_day = $next['day']; // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year); -$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); +$firstdaytoshowgmt = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess = $user; @@ -503,6 +503,11 @@ $startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray[' // Get if user is available or not for each day $isavailable = array(); + +// Assume from Monday to Friday if conf empty or badly formed +$numstartworkingday = 1; +$numendworkingday = 5; + if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { $tmparray = explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); if (count($tmparray) >= 2) { @@ -513,25 +518,18 @@ if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 - - // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow - //$tmparray = dol_getdate($dayinloop); - //$dayinloopwithouthours=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); - //print dol_print_date($dayinloop, 'dayhour').' '; - //print dol_print_date($dayinloopwithouthours, 'dayhour').' '; - //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'
    '; + $dayinloopfromfirstdaytoshowgmt = dol_time_plus_duree($firstdaytoshowgmt, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $statusofholidaytocheck = Holiday::STATUS_APPROVED; $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck); $isavailable[$dayinloopfromfirstdaytoshow] = $isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day - $test = num_public_holiday($dayinloopfromfirstdaytoshow, $dayinloopfromfirstdaytoshow + 86400, $mysoc->country_code); + $test = num_public_holiday($dayinloopfromfirstdaytoshowgmt, $dayinloopfromfirstdaytoshowgmt + 86400, $mysoc->country_code); if ($test) { $isavailable[$dayinloopfromfirstdaytoshow] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); } } -//var_dump($isavailable); @@ -663,13 +661,7 @@ if (!empty($arrayfields['timeconsumed']['checked'])) { } for ($idw = 0; $idw < 7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 - $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); - /*print $dayinloopfromfirstdaytoshow; - print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour', 'gmt'); - print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour'); - print dol_print_date($dayinloopfromfirstdaytoshow, '%a', 'gmt'); - print dol_print_date($dayinloopfromfirstdaytoshow, '%a'); - print '
    ';*/ + $cssweekend = ''; if ((($idw + 1) < $numstartworkingday) || (($idw + 1) > $numendworkingday)) { // This is a day is not inside the setup of working days, so we use a week-end css. $cssweekend = 'weekend'; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 89bdb013a32..93344b39cd0 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -180,9 +180,14 @@ if (empty($reshook)) { $result = $object->create($user); if (!$error && $result > 0) { // Add myself as project leader - $typeofcontact = 'PROJECTLEADER'; // TODO If use rename this code in dictionary, the add_contact will generate an error. + $typeofcontact = 'PROJECTLEADER'; $result = $object->add_contact($user->id, $typeofcontact, 'internal'); - if ($result < 0) { + + // -3 means type not found (PROJECTLEADER renamed, de-activated or deleted), so don't prevent creation if it has been the case + if ($result == -3) { + setEventMessage('ErrorPROJECTLEADERRoleMissingRestoreIt', 'errors'); + $error++; + } elseif ($result < 0) { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $error++; @@ -615,11 +620,11 @@ if ($action == 'create' && $user->rights->projet->creer) { } if (count($array) > 0) { - print $form->selectarray('public', $array, GETPOSTISSET('public') ? GETPOST('public') : $object->public, 0, 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray('public', $array, GETPOST('public'), 0, 0, 0, '', 0, 0, 0, '', '', 1); } else { - print ''; + print ''; - if ( (GETPOSTISSET('public') ? GETPOST('public') : $object->public)==0) { + if (GETPOST('public') == 0) { print $langs->trans("PrivateProject"); } else { print $langs->trans("SharedProject"); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 87ef51daefd..cda8494682b 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1144,6 +1144,7 @@ class Task extends CommonObject dol_syslog(get_class($this)."::addTimeSpent", LOG_DEBUG); $ret = 0; + $now = dol_now(); // Check parameters if (!is_object($user)) { @@ -1169,6 +1170,7 @@ class Task extends CommonObject $sql .= ", task_duration"; $sql .= ", fk_user"; $sql .= ", note"; + $sql .= ", datec"; $sql .= ") VALUES ("; $sql .= $this->id; $sql .= ", '".$this->db->idate($this->timespent_date)."'"; @@ -1177,6 +1179,7 @@ class Task extends CommonObject $sql .= ", ".$this->timespent_duration; $sql .= ", ".$this->timespent_fk_user; $sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); + $sql .= ", '".$this->db->idate($now)."'"; $sql .= ")"; $resql = $this->db->query($sql); @@ -1604,23 +1607,23 @@ class Task extends CommonObject $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time"; - $sql .= " WHERE rowid = ".$this->timespent_id; - - dol_syslog(get_class($this)."::delTimeSpent", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('TASK_TIMESPENT_DELETE', $user); + if ($result < 0) { + $error++; + } + // End call triggers } if (!$error) { - if (!$notrigger) { - // Call trigger - $result = $this->call_trigger('TASK_TIMESPENT_DELETE', $user); - if ($result < 0) { - $error++; - } - // End call triggers + $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time"; + $sql .= " WHERE rowid = ".$this->timespent_id; + + dol_syslog(get_class($this)."::delTimeSpent", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index bec61ec0f48..86ac5b3caab 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -116,7 +116,10 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) { $result = $object->update($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); + $action='edit'; } + } else { + $action = 'edit'; } } else { $action = 'edit'; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index e5f5fccffad..9a679c067f8 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -197,6 +197,8 @@ if (empty($reshook)) { $ret = $object->fetch($id); // Reload to get new records $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); } + } else { + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -254,10 +256,10 @@ if (empty($reshook)) { $object->origin = $origin; $object->origin_id = $origin_id; $object->fk_project = GETPOST('projectid', 'int'); - $object->weight = GETPOST('weight', 'int') == '' ? "NULL" : GETPOST('weight', 'int'); - $object->sizeH = GETPOST('sizeH', 'int') == '' ? "NULL" : GETPOST('sizeH', 'int'); - $object->sizeW = GETPOST('sizeW', 'int') == '' ? "NULL" : GETPOST('sizeW', 'int'); - $object->sizeS = GETPOST('sizeS', 'int') == '' ? "NULL" : GETPOST('sizeS', 'int'); + $object->weight = GETPOST('weight', 'int') == '' ? null : GETPOST('weight', 'int'); + $object->sizeH = GETPOST('sizeH', 'int') == '' ? null : GETPOST('sizeH', 'int'); + $object->sizeW = GETPOST('sizeW', 'int') == '' ? null : GETPOST('sizeW', 'int'); + $object->sizeS = GETPOST('sizeS', 'int') == '' ? null : GETPOST('sizeS', 'int'); $object->size_units = GETPOST('size_units', 'int'); $object->weight_units = GETPOST('weight_units', 'int'); @@ -679,7 +681,7 @@ if (empty($reshook)) { $triggersendname = 'RECEPTION_SENTBYMAIL'; $paramname = 'id'; $mode = 'emailfromreception'; - $trackid = 'shi'.$object->id; + $trackid = 'rec'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -1921,15 +1923,16 @@ if ($action == 'create') { // Warehouse source if (!empty($conf->stock->enabled)) { - print '
    '; - if ($lines[$i]->fk_entrepot > 0) { $entrepot = new Entrepot($db); $entrepot->fetch($lines[$i]->fk_entrepot); - print $entrepot->getNomUrl(1); - } - print ''; + print $entrepot->getNomUrl(1); + print '
    '.$langs->tra // User print '
    '.$langs->trans("Employee").''; print img_picto('', 'user', 'class="pictofixedwidth"'); -print $form->select_dolusers(($userid ? $userid : -1), 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); +print $form->select_dolusers(($userid ? $userid : -1), 'userid', 1, '', 0, empty($user->rights->salaries->readall) ? 'hierarchyme' : '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); print '
    '.$langs->trans("Year").''; diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index c87289da390..ab6c6bd063d 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2011 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011-2012 Juanjo Menent +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2011 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -225,7 +225,7 @@ if ($action == "setaskforshippingmet") { } } -//Activate "Disable prospect/customer type" +// Activate "Disable prospect/customer type" if ($action == "setdisableprospectcustomer") { $setdisableprospectcustomer = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 668d8199b16..a88aec05618 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2020 Juanjo Menent - * Copyright (C) 2011-2013 Alexandre Spangaro + * Copyright (C) 2011-2022 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud @@ -986,21 +986,24 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $modCodeFournisseur = new $module; // Define if customer/prospect or supplier status is set or not - if (GETPOST("type") != 'f') { + if (GETPOST("type", 'aZ') != 'f') { $object->client = -1; if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client = 3; } } // Prospect / Customer - if (GETPOST("type") == 'c') { + if (GETPOST("type", 'aZ') == 'c') { if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) { $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; } else { $object->client = 3; } } - if (GETPOST("type") == 'p') { + if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS) && $object->client == 3) { + $object->client = 1; + } + if (GETPOST("type", 'aZ') == 'p') { $object->client = 2; } if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { @@ -1757,21 +1760,21 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (GETPOSTISSET('name')) { // We overwrite with values if posted - $object->name = GETPOST('name', 'alphanohtml'); - $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); - $object->client = GETPOST('client', 'int'); - $object->code_client = GETPOST('customer_code', 'alpha'); - $object->fournisseur = GETPOST('fournisseur', 'int'); - $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); - $object->address = GETPOST('address', 'alphanohtml'); - $object->zip = GETPOST('zipcode', 'alphanohtml'); - $object->town = GETPOST('town', 'alphanohtml'); - $object->country_id = GETPOST('country_id') ?GETPOST('country_id', 'int') : $mysoc->country_id; - $object->state_id = GETPOST('state_id', 'int'); - //$object->skype = GETPOST('skype', 'alpha'); - //$object->twitter = GETPOST('twitter', 'alpha'); - //$object->facebook = GETPOST('facebook', 'alpha'); - //$object->linkedin = GETPOST('linkedin', 'alpha'); + $object->name = GETPOST('name', 'alphanohtml'); + $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); + $object->client = GETPOST('client', 'int'); + $object->code_client = GETPOST('customer_code', 'alpha'); + $object->fournisseur = GETPOST('fournisseur', 'int'); + $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); + $object->address = GETPOST('address', 'alphanohtml'); + $object->zip = GETPOST('zipcode', 'alphanohtml'); + $object->town = GETPOST('town', 'alphanohtml'); + $object->country_id = GETPOST('country_id') ?GETPOST('country_id', 'int') : $mysoc->country_id; + $object->state_id = GETPOST('state_id', 'int'); + //$object->skype = GETPOST('skype', 'alpha'); + //$object->twitter = GETPOST('twitter', 'alpha'); + //$object->facebook = GETPOST('facebook', 'alpha'); + //$object->linkedin = GETPOST('linkedin', 'alpha'); $object->socialnetworks = array(); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3d1637019e9..7c5773363c4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -890,7 +890,7 @@ class Societe extends CommonObject $sql .= ", accountancy_code_buy"; $sql .= ", accountancy_code_sell"; } - $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; + $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".((int) $this->entity).", '".$this->db->idate($now)."'"; $sql .= ", ".(!empty($user->id) ? ((int) $user->id) : "null"); $sql .= ", ".(!empty($this->typent_id) ? ((int) $this->typent_id) : "null"); $sql .= ", ".(!empty($this->canvas) ? "'".$this->db->escape($this->canvas)."'" : "null"); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 1500f00ba91..4ad5fa9ff56 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -303,8 +303,20 @@ if (empty($reshook)) { if (!$error) { if ($origin && $originid) { - $element = 'supplier_proposal'; - $subelement = 'supplier_proposal'; + $element = $subelement = $origin; + if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { + $element = $regs[1]; + $subelement = $regs[2]; + } + + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; + $subelement = 'propal'; + } $object->origin = $origin; $object->origin_id = $originid; @@ -1063,8 +1075,20 @@ if ($action == 'create') { // Load objectsrc if (!empty($origin) && !empty($originid)) { - $element = 'supplier_proposal'; - $subelement = 'supplier_proposal'; + $element = $subelement = GETPOST('origin'); + if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin'), $regs)) { + $element = $regs[1]; + $subelement = $regs[2]; + } + + // For compatibility + if ($element == 'order' || $element == 'commande') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; + $subelement = 'propal'; + } dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 9eb479d93ad..61b60a00644 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -7104,6 +7104,11 @@ if (!empty($conf->global->THEME_CUSTOM_CSS)) { ?> + div.extra_inline_chkbxlst, + div.extra_inline_checkbox { + min-width:150px; + } + /* Must be at end */ div.flot-text .flot-tick-label .tickLabel { color: unset; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index ab2c2794e38..9c1a7c709b7 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1047,7 +1047,7 @@ if ($action == 'create' || $action == 'presend') { print '
    '; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 23437a7564c..af65e5e0bce 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1255,7 +1255,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Date birth print '
    '.$langs->trans("DateOfBirth").''; - print $form->selectDate($dateofbirth, 'dateofbirth', 0, 0, 1, 'createuser', 1, 0); + print $form->selectDate($dateofbirth, 'dateofbirth', 0, 0, 1, 'createuser', 1, 0, 0, '', 0, '', '', 1, '', '', 'tzserver'); print '
    '.$langs->trans("DateOfBirth").''; - print dol_print_date($object->birth, 'day'); + print dol_print_date($object->birth, 'day', 'tzserver'); print '
    '.$langs->trans("DateOfBirth").''; if ($caneditfield) { - echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth, 'dateofbirth', 0, 0, 1, 'updateuser', 1, 0); + echo $form->selectDate($dateofbirth ? $dateofbirth : $object->birth, 'dateofbirth', 0, 0, 1, 'updateuser', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); } else { - print dol_print_date($object->birth, 'day'); + print dol_print_date($object->birth, 'day', 'tzserver'); } print '