Merge branch 'develop' into NEW_Employee_management_improvement
This commit is contained in:
commit
4fa656be96
10
.travis.yml
10
.travis.yml
@ -50,7 +50,7 @@ jobs:
|
|||||||
env: DB=postgresql
|
env: DB=postgresql
|
||||||
- stage: PHP 5.6-7.4
|
- stage: PHP 5.6-7.4
|
||||||
if: type = pull_request OR type = push
|
if: type = pull_request OR type = push
|
||||||
php: '7.4'
|
php: '7.4.22'
|
||||||
env: DB=mysql
|
env: DB=mysql
|
||||||
- stage: PHP Dev
|
- stage: PHP Dev
|
||||||
if: type = push AND branch = develop
|
if: type = push AND branch = develop
|
||||||
@ -106,7 +106,7 @@ install:
|
|||||||
php-parallel-lint/php-console-highlighter ^0 \
|
php-parallel-lint/php-console-highlighter ^0 \
|
||||||
squizlabs/php_codesniffer ^3
|
squizlabs/php_codesniffer ^3
|
||||||
fi
|
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 \
|
composer -n require phpunit/phpunit ^7 \
|
||||||
php-parallel-lint/php-parallel-lint ^1.2 \
|
php-parallel-lint/php-parallel-lint ^1.2 \
|
||||||
php-parallel-lint/php-console-highlighter ^0 \
|
php-parallel-lint/php-console-highlighter ^0 \
|
||||||
@ -241,7 +241,7 @@ before_script:
|
|||||||
# enable php-fpm
|
# enable php-fpm
|
||||||
- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
|
- 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
|
# 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
|
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
|
fi
|
||||||
@ -276,7 +276,7 @@ script:
|
|||||||
set -e
|
set -e
|
||||||
#parallel-lint --exclude htdocs/includes --blame .
|
#parallel-lint --exclude htdocs/includes --blame .
|
||||||
# Exclusions are defined in the ruleset.xml file
|
# 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 \
|
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/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 \
|
--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
|
# Ensure we catch errors
|
||||||
set -e
|
set -e
|
||||||
# Exclusions are defined in the ruleset.xml file
|
# 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 .;
|
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
|
fi
|
||||||
set +e
|
set +e
|
||||||
|
|||||||
@ -17,7 +17,7 @@ Alternatively send an email to security@dolibarr.org (for everybody)
|
|||||||
|
|
||||||
## Hunting vulnerabilities on Dolibarr
|
## Hunting vulnerabilities on Dolibarr
|
||||||
|
|
||||||
We believe that future of software is online SaaS. This means software are more and more critical and no technology is perfect. Working with skilled security researchers is crucial in identifying weaknesses in our technology.
|
We believe that the future of software is online SaaS. This means software are more and more critical and no technology is perfect. Working with skilled security researchers is crucial in identifying weaknesses in our technology.
|
||||||
|
|
||||||
If you believe you've found a security bug in our service, we are happy to work with you to resolve the issue promptly and ensure you are fairly rewarded for your discovery.
|
If you believe you've found a security bug in our service, we are happy to work with you to resolve the issue promptly and ensure you are fairly rewarded for your discovery.
|
||||||
|
|
||||||
@ -35,13 +35,13 @@ You can install the web application yourself on your own platform/server so you
|
|||||||
|
|
||||||
## Eligibility and Responsible Disclosure
|
## Eligibility and Responsible Disclosure
|
||||||
|
|
||||||
We are happy to thank everyone who submits valid reports which help us improve the security of Dolibarr however, only those that meet the following eligibility requirements will be "validated reports" (if not, we may close the report without any answer):
|
We are happy to thank everyone who submits valid reports which help us improve the security of Dolibarr, however only those that meet the following eligibility requirements will be "validated reports" (if not, we may close the report without any answer):
|
||||||
|
|
||||||
You must be the first reporter of the vulnerability (duplicate reports are closed).
|
You must be the first reporter of the vulnerability (duplicate reports are closed).
|
||||||
|
|
||||||
You must send a clear textual description of the report along with steps to reproduce the issue, include attachments such as screenshots or proof of concept code as necessary.
|
You must send a clear textual description of the report along with steps to reproduce the issue, include attachments such as screenshots or proof of concept code as necessary.
|
||||||
|
|
||||||
You must avoid tests that could cause degradation or interruption of our service (refrain from using automated tools, and limit yourself about requests per second), that's why we recommand to install softwate on your own platform.
|
You must avoid tests that could cause degradation or interruption of our service (refrain from using automated tools, and limit yourself about requests per second), that's why we recommand to install software on your own platform.
|
||||||
|
|
||||||
You must not leak, manipulate, or destroy any user data of third parties to find your vulnerability.
|
You must not leak, manipulate, or destroy any user data of third parties to find your vulnerability.
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us
|
|||||||
* The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools)
|
* The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools)
|
||||||
* ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities).
|
* ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities).
|
||||||
* The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer).
|
* The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer).
|
||||||
* The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly.
|
* The web server setup must be done so that only the documents directory is in write mode. The root directory called htdocs must be read-only.
|
||||||
* CSRF attacks are accepted but double check that you have set MAIN_SECURITY_CSRF_WITH_TOKEN to value 3.
|
* CSRF attacks are accepted but double check that you have set MAIN_SECURITY_CSRF_WITH_TOKEN to value 3.
|
||||||
* Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user.
|
* Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user.
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,10 @@ https://en.wikipedia.org/wiki/EPC_QR_code#Generators
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
* For ZATCA QR Code format (Saudi Arabia)
|
* For ZATCA QR Code format (Saudi Arabia). Used when INVOICE_ADD_ZATCA_QR_CODE is set
|
||||||
-----------------------------------------
|
-------------------------------------------------------------------------------------
|
||||||
https://www.pwc.com/m1/en/services/tax/me-tax-legal-news/2021/saudi-arabia-guide-to-develop-compliant-qr-code-for-simplified-einvoices.html
|
https://www.pwc.com/m1/en/services/tax/me-tax-legal-news/2021/saudi-arabia-guide-to-develop-compliant-qr-code-for-simplified-einvoices.html
|
||||||
|
|
||||||
|
https://www.tecklenborgh.com/post/ksa-zatca-publishes-guide-on-how-to-develop-a-fatoora-compliant-qr-code
|
||||||
|
|
||||||
|
Method to encode/decode ZATCA string is available in test/phpunit/BarcodeTest.php
|
||||||
|
|||||||
@ -1,325 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
|
||||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
|
||||||
* Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
|
||||||
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php
|
|
||||||
* \ingroup accountancy
|
|
||||||
* \brief Tab to manage customer lettering
|
|
||||||
*/
|
|
||||||
require '../../main.inc.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
|
||||||
|
|
||||||
// Load translation files required by the page
|
|
||||||
$langs->loadLangs(array("compta", "accountancy"));
|
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
|
||||||
$massaction = GETPOST('massaction', 'alpha');
|
|
||||||
$show_files = GETPOST('show_files', 'int');
|
|
||||||
$confirm = GETPOST('confirm', 'alpha');
|
|
||||||
$toselect = GETPOST('toselect', 'array');
|
|
||||||
// $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
|
|
||||||
// Security check
|
|
||||||
$socid = GETPOSTINT("socid");
|
|
||||||
// if ($user->socid) $socid=$user->socid;
|
|
||||||
|
|
||||||
$limit = GETPOSTISSET('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|
||||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
|
||||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
|
||||||
if (empty($page) || $page == - 1) {
|
|
||||||
$page = 0;
|
|
||||||
} // If $page is not defined, or '' or -1
|
|
||||||
$offset = $limit * $page;
|
|
||||||
$pageprev = $page - 1;
|
|
||||||
$pagenext = $page + 1;
|
|
||||||
if ($sortorder == "") {
|
|
||||||
$sortorder = "ASC";
|
|
||||||
}
|
|
||||||
if ($sortfield == "") {
|
|
||||||
$sortfield = "bk.doc_date";
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
|
|
||||||
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
|
|
||||||
//$search_doc_type = GETPOST("search_doc_type", 'alpha');
|
|
||||||
$search_doc_ref = GETPOST("search_doc_ref", 'alpha');
|
|
||||||
*/
|
|
||||||
|
|
||||||
$lettering = GETPOST('lettering', 'alpha');
|
|
||||||
if (!empty($lettering)) {
|
|
||||||
$action = $lettering;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
|
|
||||||
{
|
|
||||||
$search_date_start = '';
|
|
||||||
$search_date_end = '';
|
|
||||||
//$search_doc_type = '';
|
|
||||||
$search_doc_ref = '';
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$lettering = new Lettering($db);
|
|
||||||
$object = new Societe($db);
|
|
||||||
$object->id = $socid;
|
|
||||||
$result = $object->fetch($socid);
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($conf->accounting->enabled)) {
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
if ($user->socid > 0) {
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
if (empty($user->rights->accounting->mouvements->lire)) {
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Action
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($action == 'lettering') {
|
|
||||||
$result = $lettering->updateLettering($toselect);
|
|
||||||
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages('', $lettering->errors, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
if ($action == 'autolettrage') {
|
|
||||||
|
|
||||||
$result = $lettering->letteringThirdparty($socid);
|
|
||||||
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages('', $lettering->errors, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* View
|
|
||||||
*/
|
|
||||||
|
|
||||||
$form = new Form($db);
|
|
||||||
$formaccounting = new FormAccounting($db);
|
|
||||||
|
|
||||||
$title = $object->name." - ".$langs->trans('TabLetteringCustomer');
|
|
||||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
|
|
||||||
llxHeader('', $title, $help_url);
|
|
||||||
|
|
||||||
$head = societe_prepare_head($object);
|
|
||||||
|
|
||||||
dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
|
|
||||||
|
|
||||||
print dol_get_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'company');
|
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
|
||||||
|
|
||||||
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
|
|
||||||
|
|
||||||
print dol_get_fiche_end();
|
|
||||||
|
|
||||||
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
|
|
||||||
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
|
|
||||||
$sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
|
|
||||||
$sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)."' )";
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
|
|
||||||
$sql .= " AND ( bk.doc_date BETWEEN '" . $db->idate($search_date_start) . "' AND '" . $db->idate($search_date_end) . "' )";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$sql .= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')';
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
|
||||||
|
|
||||||
$debit = 0;
|
|
||||||
$credit = 0;
|
|
||||||
$solde = 0;
|
|
||||||
// Count total nb of records and calc total sum
|
|
||||||
$nbtotalofrecords = '';
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if (!$resql) {
|
|
||||||
dol_print_error($db);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
$nbtotalofrecords = $db->num_rows($resql);
|
|
||||||
|
|
||||||
while ($obj = $db->fetch_object($resql)) {
|
|
||||||
$debit += $obj->debit;
|
|
||||||
$credit += $obj->credit;
|
|
||||||
|
|
||||||
$solde += ($obj->credit - $obj->debit);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql .= $db->plimit($limit + 1, $offset);
|
|
||||||
|
|
||||||
dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEBUG);
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if (!$resql) {
|
|
||||||
dol_print_error($db);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$param = '';
|
|
||||||
$param .= "&socid=".urlencode($socid);
|
|
||||||
|
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
|
|
||||||
dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEBUG);
|
|
||||||
if ($resql) {
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
$param = "&socid=".$socid;
|
|
||||||
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
|
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
||||||
print '<input type="hidden" name="socid" value="'.$object->id.'">';
|
|
||||||
|
|
||||||
$letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>';
|
|
||||||
|
|
||||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit);
|
|
||||||
|
|
||||||
print '<div class="div-table-responsive-no-min">';
|
|
||||||
print '<table class="liste centpercent">'."\n";
|
|
||||||
|
|
||||||
/*
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
//print '<td><input type="text" name="search_doc_type" value="' . $search_doc_type . '"></td>';
|
|
||||||
|
|
||||||
// Date
|
|
||||||
print '<td class="liste_titre center">';
|
|
||||||
print '<div class="nowrap">';
|
|
||||||
print $langs->trans('From') . ' ';
|
|
||||||
print $form->selectDate($search_date_start, 'date_creation_start', 0, 0, 1);
|
|
||||||
print '</div>';
|
|
||||||
print '<div class="nowrap">';
|
|
||||||
print $langs->trans('to') . ' ';
|
|
||||||
print $form->selectDate($search_date_end, 'date_creation_end', 0, 0, 1);
|
|
||||||
print '</div>';
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
// Piece
|
|
||||||
print '<td><input type="text" name="search_doc_ref" value="' . $search_doc_ref . '"></td>';
|
|
||||||
print '<td colspan="6"> </td>';
|
|
||||||
print '<td class="right">';
|
|
||||||
$searchpicto = $form->showFilterButtons();
|
|
||||||
print $searchpicto;
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
*/
|
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
//print_liste_field_titre("Doctype", $_SERVER["PHP_SELF"], "bk.doc_type", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Docdate", $_SERVER["PHP_SELF"], "bk.doc_date", "", $param, "", $sortfield, $sortorder, 'center ');
|
|
||||||
print_liste_field_titre("Piece", $_SERVER["PHP_SELF"], "bk.doc_ref", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("LabelAccount", $_SERVER["PHP_SELF"], "bk.label_compte", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Debit", $_SERVER["PHP_SELF"], "bk.debit", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Credit", $_SERVER["PHP_SELF"], "bk.credit", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center ');
|
|
||||||
print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center ');
|
|
||||||
print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center ');
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
$solde = 0;
|
|
||||||
$tmp = '';
|
|
||||||
|
|
||||||
while ($obj = $db->fetch_object($resql)) {
|
|
||||||
if ($tmp != $obj->lettering_code || empty($tmp)) {
|
|
||||||
$tmp = $obj->lettering_code;
|
|
||||||
}
|
|
||||||
/*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit);
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
|
|
||||||
//print '<td>' . $obj->doc_type . '</td>' . "\n";
|
|
||||||
print '<td class="center">'.dol_print_date($db->jdate($obj->doc_date), 'day').'</td>';
|
|
||||||
print '<td>'.$obj->doc_ref.'</td>';
|
|
||||||
print '<td>'.$obj->label_compte.'</td>';
|
|
||||||
print '<td class="nowrap right">'.price($obj->debit).'</td>';
|
|
||||||
print '<td class="nowrap right">'.price($obj->credit).'</td>';
|
|
||||||
print '<td class="nowrap right">'.price(round($solde, 2)).'</td>';
|
|
||||||
|
|
||||||
// Journal
|
|
||||||
$accountingjournal = new AccountingJournal($db);
|
|
||||||
$result = $accountingjournal->fetch('', $obj->code_journal);
|
|
||||||
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
|
|
||||||
print '<td class="center">'.$journaltoshow.'</td>';
|
|
||||||
|
|
||||||
if (empty($obj->lettering_code) && empty($obj->date_validated)) {
|
|
||||||
print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="'.$obj->rowid.'" /></td>';
|
|
||||||
print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
|
|
||||||
print img_edit();
|
|
||||||
print '</a></td>'."\n";
|
|
||||||
} else {
|
|
||||||
print '<td class="center">'.$obj->lettering_code.'</td>';
|
|
||||||
print '<td></td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</tr>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>'."\n";
|
|
||||||
print '<td class="right nowraponall amount"><strong>'.price($debit).'</strong></td>';
|
|
||||||
print '<td class="right nowraponall amount"><strong>'.price($credit).'</strong></td>';
|
|
||||||
print '<td colspan="4"></td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>'."\n";
|
|
||||||
print '<td colspan="2"> </td>';
|
|
||||||
print '<td class="right nowraponall amount"><strong>'.price($credit - $debit).'</strong></td>';
|
|
||||||
print '<td colspan="6"></td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
print "</table>";
|
|
||||||
|
|
||||||
print '<div class="tabsAction tabsActionNoBottom">'."\n";
|
|
||||||
print $letteringbutton;
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
print "</form>";
|
|
||||||
$db->free($resql);
|
|
||||||
} else {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
// End of page
|
|
||||||
llxFooter();
|
|
||||||
$db->close();
|
|
||||||
@ -1,322 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
|
||||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
|
||||||
* Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
|
||||||
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php
|
|
||||||
* \ingroup Accountancy (Double entries)
|
|
||||||
* \brief Tab to setup lettering
|
|
||||||
*/
|
|
||||||
require '../../main.inc.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
|
||||||
|
|
||||||
// Load translation files required by the page
|
|
||||||
$langs->loadLangs(array("compta", "accountancy"));
|
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
|
||||||
$massaction = GETPOST('massaction', 'alpha');
|
|
||||||
$show_files = GETPOST('show_files', 'int');
|
|
||||||
$confirm = GETPOST('confirm', 'alpha');
|
|
||||||
$toselect = GETPOST('toselect', 'array');
|
|
||||||
// $socid = GETPOST('socid', 'int') ? ((int) GETPOST('socid', 'int')) : ((int) GETPOST('id', 'int'));
|
|
||||||
// Security check
|
|
||||||
$socid = GETPOSTINT("socid");
|
|
||||||
// if ($user->socid) $socid=$user->socid;
|
|
||||||
|
|
||||||
|
|
||||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|
||||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
|
||||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
|
||||||
if (empty($page) || $page == - 1) {
|
|
||||||
$page = 0;
|
|
||||||
} // If $page is not defined, or '' or -1
|
|
||||||
$offset = $limit * $page;
|
|
||||||
$pageprev = $page - 1;
|
|
||||||
$pagenext = $page + 1;
|
|
||||||
if ($sortorder == "") {
|
|
||||||
$sortorder = "ASC";
|
|
||||||
}
|
|
||||||
if ($sortfield == "") {
|
|
||||||
$sortfield = "bk.doc_date";
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
|
|
||||||
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
|
|
||||||
//$search_doc_type = GETPOST("search_doc_type",'alpha');
|
|
||||||
$search_doc_ref = GETPOST("search_doc_ref",'alpha');
|
|
||||||
*/
|
|
||||||
|
|
||||||
$lettering = GETPOST('lettering', 'alpha');
|
|
||||||
if (!empty($lettering)) {
|
|
||||||
$action = $lettering;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
|
|
||||||
{
|
|
||||||
$search_date_start = '';
|
|
||||||
$search_date_end = '';
|
|
||||||
//$search_doc_type='';
|
|
||||||
$search_doc_ref='';
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$lettering = new Lettering($db);
|
|
||||||
$object = new Societe($db);
|
|
||||||
$object->id = $socid;
|
|
||||||
$result = $object->fetch($socid);
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($conf->accounting->enabled)) {
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
if ($user->socid > 0) {
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
if (empty($user->rights->accounting->mouvements->lire)) {
|
|
||||||
accessforbidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Action
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($action == 'lettering') {
|
|
||||||
$result = $lettering->updateLettering($toselect);
|
|
||||||
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages('', $lettering->errors, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
if ($action == 'autolettrage') {
|
|
||||||
|
|
||||||
$result = $lettering->letteringThirdparty($socid);
|
|
||||||
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages('', $lettering->errors, 'errors');
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* View
|
|
||||||
*/
|
|
||||||
|
|
||||||
$form = new Form($db);
|
|
||||||
$formaccounting = new FormAccounting($db);
|
|
||||||
|
|
||||||
$title = $object->name." - ".$langs->trans('TabLetteringSupplier');
|
|
||||||
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
|
|
||||||
llxHeader('', $title, $help_url);
|
|
||||||
|
|
||||||
$head = societe_prepare_head($object);
|
|
||||||
|
|
||||||
dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
|
|
||||||
|
|
||||||
print dol_get_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'company');
|
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
|
||||||
|
|
||||||
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
|
|
||||||
|
|
||||||
print dol_get_fiche_end();
|
|
||||||
|
|
||||||
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
|
|
||||||
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
|
|
||||||
$sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code, bk.date_validated ";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
|
|
||||||
$sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta_fournisseur)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)."' )";
|
|
||||||
if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
|
|
||||||
$sql .= " AND (bk.doc_date BETWEEN '".$db->idate($search_date_start)."' AND '".$db->idate($search_date_end)."' )";
|
|
||||||
}
|
|
||||||
$sql .= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')';
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
|
||||||
|
|
||||||
$debit = 0;
|
|
||||||
$credit = 0;
|
|
||||||
$solde = 0;
|
|
||||||
// Count total nb of records and calc total sum
|
|
||||||
$nbtotalofrecords = '';
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if (!$resql) {
|
|
||||||
dol_print_error($db);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$nbtotalofrecords = $db->num_rows($resql);
|
|
||||||
|
|
||||||
while ($obj = $db->fetch_object($resql)) {
|
|
||||||
$debit += $obj->debit;
|
|
||||||
$credit += $obj->credit;
|
|
||||||
|
|
||||||
$solde += ($obj->credit - $obj->debit);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql .= $db->plimit($limit + 1, $offset);
|
|
||||||
|
|
||||||
dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_supplier.php", LOG_DEBUG);
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if (!$resql) {
|
|
||||||
dol_print_error($db);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$param = '';
|
|
||||||
$param .= "&socid=".urlencode($socid);
|
|
||||||
|
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
|
|
||||||
dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_supplier.php", LOG_DEBUG);
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ($resql) {
|
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
$param = "&socid=".$socid;
|
|
||||||
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
|
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
||||||
print '<input type="hidden" name="socid" value="'.$object->id.'">';
|
|
||||||
|
|
||||||
$letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>';
|
|
||||||
|
|
||||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit);
|
|
||||||
|
|
||||||
print '<div class="div-table-responsive-no-min">';
|
|
||||||
print '<table class="liste centpercent">'."\n";
|
|
||||||
|
|
||||||
/*
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
//print '<td><input type="text" name="search_doc_type" value="' . $search_doc_type . '"></td>';
|
|
||||||
|
|
||||||
// Date
|
|
||||||
print '<td class="liste_titre center">';
|
|
||||||
print '<div class="nowrap">';
|
|
||||||
print $langs->trans('From') . ' ';
|
|
||||||
print $form->selectDate($search_date_start, 'date_creation_start', 0, 0, 1);
|
|
||||||
print '</div>';
|
|
||||||
print '<div class="nowrap">';
|
|
||||||
print $langs->trans('to') . ' ';
|
|
||||||
print $form->selectDate($search_date_end, 'date_creation_end', 0, 0, 1);
|
|
||||||
print '</div>';
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
// Piece
|
|
||||||
print '<td><input type="text" name="search_doc_ref" value="' . $search_doc_ref . '"></td>';
|
|
||||||
print '<td colspan="6"> </td>';
|
|
||||||
print '<td class="right">';
|
|
||||||
$searchpicto = $form->showFilterButtons();
|
|
||||||
print $searchpicto;
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
*/
|
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
//print_liste_field_titre("Doctype", $_SERVER["PHP_SELF"], "bk.doc_type", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Docdate", $_SERVER["PHP_SELF"], "bk.doc_date", "", $param, "", $sortfield, $sortorder, 'center ');
|
|
||||||
print_liste_field_titre("Piece", $_SERVER["PHP_SELF"], "bk.doc_ref", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("LabelAccount", $_SERVER["PHP_SELF"], "bk.label_compte", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Debit", $_SERVER["PHP_SELF"], "bk.debit", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Credit", $_SERVER["PHP_SELF"], "bk.credit", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center ');
|
|
||||||
print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center ');
|
|
||||||
print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center ');
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
$solde = 0;
|
|
||||||
$tmp = '';
|
|
||||||
while ($obj = $db->fetch_object($resql)) {
|
|
||||||
if ($tmp != $obj->lettering_code || empty($tmp)) {
|
|
||||||
$tmp = $obj->lettering_code;
|
|
||||||
}
|
|
||||||
/*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit);
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
|
|
||||||
//print '<td>' . $obj->doc_type . '</td>' . "\n";
|
|
||||||
print '<td class="center">'.dol_print_date($db->jdate($obj->doc_date), 'day').'</td>';
|
|
||||||
print '<td>'.$obj->doc_ref.'</td>';
|
|
||||||
print '<td>'.$obj->label_compte.'</td>';
|
|
||||||
print '<td class="nowrap right">'.price($obj->debit).'</td>';
|
|
||||||
print '<td class="nowrap right">'.price($obj->credit).'</td>';
|
|
||||||
print '<td class="nowrap right">'.price(round($solde, 2)).'</td>';
|
|
||||||
|
|
||||||
// Journal
|
|
||||||
$accountingjournal = new AccountingJournal($db);
|
|
||||||
$result = $accountingjournal->fetch('', $obj->code_journal);
|
|
||||||
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
|
|
||||||
print '<td class="center">'.$journaltoshow.'</td>';
|
|
||||||
|
|
||||||
if (empty($obj->lettering_code) && empty($obj->date_validated)) {
|
|
||||||
print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="'.$obj->rowid.'" /></td>';
|
|
||||||
print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
|
|
||||||
print img_edit();
|
|
||||||
print '</a></td>'."\n";
|
|
||||||
} else {
|
|
||||||
print '<td class="center">'.$obj->lettering_code.'</td>';
|
|
||||||
print '<td></td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</tr>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>'."\n";
|
|
||||||
print '<td class="right nowraponall amount"><strong>'.price($debit).'</strong></td>';
|
|
||||||
print '<td class="right nowraponall amount"><strong>'.price($credit).'</strong></td>';
|
|
||||||
print '<td colspan="6"></td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>'."\n";
|
|
||||||
print '<td colspan="2"> </td>';
|
|
||||||
print '<td class="right nowraponall amount"><strong>'.price($credit - $debit).'</strong></td>';
|
|
||||||
print '<td colspan="4"></td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
print "</table>";
|
|
||||||
|
|
||||||
print '<div class="tabsAction tabsActionNoBottom">'."\n";
|
|
||||||
print $letteringbutton;
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
print "</form>";
|
|
||||||
$db->free($resql);
|
|
||||||
} else {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
// End of page
|
|
||||||
llxFooter();
|
|
||||||
$db->close();
|
|
||||||
@ -64,6 +64,10 @@ class AccountancyExport
|
|||||||
public static $EXPORT_TYPE_FEC = 1000;
|
public static $EXPORT_TYPE_FEC = 1000;
|
||||||
public static $EXPORT_TYPE_FEC2 = 1010;
|
public static $EXPORT_TYPE_FEC2 = 1010;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var DoliDB Database handler
|
||||||
|
*/
|
||||||
|
public $db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[] Error codes (or messages)
|
* @var string[] Error codes (or messages)
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file htdocs/accountancy/class/accountancyimport.class.php
|
* \file htdocs/accountancy/class/accountancyimport.class.php
|
||||||
* \ingroup Accountancy (Double entries)
|
* \ingroup Accountancy (Double entries)
|
||||||
* \brief Class accountancy import
|
* \brief Class with methods for accountancy import
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -39,63 +39,104 @@
|
|||||||
*/
|
*/
|
||||||
class AccountancyImport
|
class AccountancyImport
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var DoliDB Database handler
|
||||||
|
*/
|
||||||
|
public $db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDb $db Database handler
|
||||||
|
*/
|
||||||
|
public function __construct(DoliDB $db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean amount
|
||||||
|
*
|
||||||
|
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
|
||||||
|
* @param array $listfields Fields list to add
|
||||||
|
* @param int $record_key Record key
|
||||||
|
* @return mixed Value
|
||||||
|
*/
|
||||||
|
public function cleanAmount(&$arrayrecord, $listfields, $record_key)
|
||||||
|
{
|
||||||
|
$value_trim = trim($arrayrecord[$record_key]['val']);
|
||||||
|
return floatval($value_trim);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean value with trim
|
||||||
|
*
|
||||||
|
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
|
||||||
|
* @param array $listfields Fields list to add
|
||||||
|
* @param int $record_key Record key
|
||||||
|
* @return mixed Value
|
||||||
|
*/
|
||||||
|
public function cleanValue(&$arrayrecord, $listfields, $record_key)
|
||||||
|
{
|
||||||
|
return trim($arrayrecord[$record_key]['val']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute amount
|
* Compute amount
|
||||||
*
|
*
|
||||||
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
|
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
|
||||||
* @param string $fieldname Field name with alias
|
|
||||||
* @param array $listfields Fields list to add
|
* @param array $listfields Fields list to add
|
||||||
* @param array $listvalues Values list to add
|
* @param int $record_key Record key
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return mixed Value
|
||||||
*/
|
*/
|
||||||
public function computeAmount(&$arrayrecord, $fieldname, &$listfields, &$listvalues)
|
public function computeAmount(&$arrayrecord, $listfields, $record_key)
|
||||||
{
|
{
|
||||||
$fieldArr = explode('.', $fieldname);
|
// get fields indexes
|
||||||
if (count($fieldArr) > 0) {
|
$field_index_list = array_flip($listfields);
|
||||||
$fieldname = $fieldArr[1];
|
if (isset($field_index_list['debit']) && isset($field_index_list['credit'])) {
|
||||||
|
$debit_index = $field_index_list['debit'];
|
||||||
|
$credit_index = $field_index_list['credit'];
|
||||||
|
|
||||||
|
$debit = floatval($arrayrecord[$debit_index]['val']);
|
||||||
|
$credit = floatval($arrayrecord[$credit_index]['val']);
|
||||||
|
if (!empty($debit)) {
|
||||||
|
$amount = $debit;
|
||||||
|
} else {
|
||||||
|
$amount = $credit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "'" . $this->db->escape(abs($amount)) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$debit = floatval(trim($arrayrecord[11]['val']));
|
return "''";
|
||||||
$credit = floatval(trim($arrayrecord[12]['val']));
|
|
||||||
if (!empty($debit)) {
|
|
||||||
$amount = $debit;
|
|
||||||
} else {
|
|
||||||
$amount = $credit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$listfields[] = $fieldname;
|
|
||||||
$listvalues[] = "'" . abs($amount) . "'";
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute sens
|
* Compute direction
|
||||||
*
|
*
|
||||||
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
|
* @param array $arrayrecord Array of read values: [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=string), [fieldpos+1]...
|
||||||
* @param string $fieldname Field name with alias
|
|
||||||
* @param array $listfields Fields list to add
|
* @param array $listfields Fields list to add
|
||||||
* @param array $listvalues Values list to add
|
* @param int $record_key Record key
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return mixed Value
|
||||||
*/
|
*/
|
||||||
public function computeDirection(&$arrayrecord, $fieldname, &$listfields, &$listvalues)
|
public function computeDirection(&$arrayrecord, $listfields, $record_key)
|
||||||
{
|
{
|
||||||
$fieldArr = explode('.', $fieldname);
|
$field_index_list = array_flip($listfields);
|
||||||
if (count($fieldArr) > 0) {
|
if (isset($field_index_list['debit'])) {
|
||||||
$fieldname = $fieldArr[1];
|
$debit_index = $field_index_list['debit'];
|
||||||
|
|
||||||
|
$debit = floatval($arrayrecord[$debit_index]['val']);
|
||||||
|
if (!empty($debit)) {
|
||||||
|
$sens = 'D';
|
||||||
|
} else {
|
||||||
|
$sens = 'C';
|
||||||
|
}
|
||||||
|
|
||||||
|
return "'" . $this->db->escape($sens) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$debit = floatval(trim($arrayrecord[11]['val']));
|
return "''";
|
||||||
if (!empty($debit)) {
|
|
||||||
$sens = 'D';
|
|
||||||
} else {
|
|
||||||
$sens = 'C';
|
|
||||||
}
|
|
||||||
|
|
||||||
$listfields[] = $fieldname;
|
|
||||||
$listvalues[] = "'" . $sens . "'";
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -137,9 +137,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->acco
|
|||||||
if (!$error) {
|
if (!$error) {
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l";
|
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet";
|
||||||
$sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
|
$sql1 .= " SET fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
|
||||||
$sql1 .= ' WHERE l.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
|
$sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
|
||||||
|
|
||||||
dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1);
|
dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1);
|
||||||
$resql1 = $db->query($sql1);
|
$resql1 = $db->query($sql1);
|
||||||
@ -497,7 +497,7 @@ if ($result) {
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td class="tdoverflowonsmartphone">';
|
print '<td class="tdoverflowonsmartphone">';
|
||||||
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
|
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1));
|
||||||
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
||||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
|
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -637,7 +637,7 @@ if ($result) {
|
|||||||
|
|
||||||
// Description
|
// Description
|
||||||
print '<td class="tdoverflowonsmartphone small">';
|
print '<td class="tdoverflowonsmartphone small">';
|
||||||
$text = dolGetFirstLineOfText(dol_string_nohtmltag($facture_static_det->desc));
|
$text = dolGetFirstLineOfText(dol_string_nohtmltag($facture_static_det->desc, 1));
|
||||||
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
||||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $facture_static_det->desc);
|
print $form->textwithtooltip(dol_trunc($text, $trunclength), $facture_static_det->desc);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -405,7 +405,7 @@ if ($result) {
|
|||||||
|
|
||||||
// Fees description -- Can be null
|
// Fees description -- Can be null
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments));
|
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments, 1));
|
||||||
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
||||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
|
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -481,7 +481,7 @@ if ($result) {
|
|||||||
|
|
||||||
// Fees description -- Can be null
|
// Fees description -- Can be null
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments));
|
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments, 1));
|
||||||
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
||||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
|
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -117,77 +117,79 @@ if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_S
|
|||||||
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
|
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
|
print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
|
||||||
print "<br>\n"; print "<br>\n";
|
if (!empty($user->rights->accounting->chartofaccount)) {
|
||||||
|
print "<br>\n"; print "<br>\n";
|
||||||
|
|
||||||
print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
|
print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
|
||||||
print '<hr>';
|
print '<hr>';
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
// STEPS
|
// STEPS
|
||||||
$step++;
|
|
||||||
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}');
|
|
||||||
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").'</strong></a>', $s);
|
|
||||||
print $s;
|
|
||||||
print "<br>\n";
|
|
||||||
$step++;
|
|
||||||
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}');
|
|
||||||
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/accountmodel.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'</strong></a>', $s);
|
|
||||||
print $s;
|
|
||||||
print "<br>\n";
|
|
||||||
$step++;
|
|
||||||
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}');
|
|
||||||
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'</strong></a>', $s);
|
|
||||||
print $s;
|
|
||||||
print "<br>\n";
|
|
||||||
|
|
||||||
print "<br>\n";
|
|
||||||
print $langs->trans("AccountancyAreaDescActionOnceBis");
|
|
||||||
print "<br>\n";
|
|
||||||
print "<br>\n";
|
|
||||||
|
|
||||||
$step++;
|
|
||||||
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}');
|
|
||||||
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/defaultaccounts.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong></a>', $s);
|
|
||||||
print $s;
|
|
||||||
print "<br>\n";
|
|
||||||
|
|
||||||
$step++;
|
|
||||||
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n";
|
|
||||||
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'</strong></a>', $s);
|
|
||||||
print $s;
|
|
||||||
print "<br>\n";
|
|
||||||
|
|
||||||
$step++;
|
|
||||||
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=10&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong></a>';
|
|
||||||
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}');
|
|
||||||
$s = str_replace('{s}', $textlink, $s);
|
|
||||||
print $s;
|
|
||||||
print "<br>\n";
|
|
||||||
if (!empty($conf->tax->enabled)) {
|
|
||||||
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
|
|
||||||
$step++;
|
$step++;
|
||||||
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
|
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}');
|
||||||
|
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").'</strong></a>', $s);
|
||||||
|
print $s;
|
||||||
|
print "<br>\n";
|
||||||
|
$step++;
|
||||||
|
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}');
|
||||||
|
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/accountmodel.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'</strong></a>', $s);
|
||||||
|
print $s;
|
||||||
|
print "<br>\n";
|
||||||
|
$step++;
|
||||||
|
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}');
|
||||||
|
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'</strong></a>', $s);
|
||||||
|
print $s;
|
||||||
|
print "<br>\n";
|
||||||
|
|
||||||
|
print "<br>\n";
|
||||||
|
print $langs->trans("AccountancyAreaDescActionOnceBis");
|
||||||
|
print "<br>\n";
|
||||||
|
print "<br>\n";
|
||||||
|
|
||||||
|
$step++;
|
||||||
|
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}');
|
||||||
|
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/defaultaccounts.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong></a>', $s);
|
||||||
|
print $s;
|
||||||
|
print "<br>\n";
|
||||||
|
|
||||||
|
$step++;
|
||||||
|
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n";
|
||||||
|
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'</strong></a>', $s);
|
||||||
|
print $s;
|
||||||
|
print "<br>\n";
|
||||||
|
|
||||||
|
$step++;
|
||||||
|
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=10&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong></a>';
|
||||||
|
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}');
|
||||||
$s = str_replace('{s}', $textlink, $s);
|
$s = str_replace('{s}', $textlink, $s);
|
||||||
print $s;
|
print $s;
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
}
|
|
||||||
if (!empty($conf->expensereport->enabled)) {
|
if (!empty($conf->tax->enabled)) {
|
||||||
|
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
|
||||||
|
$step++;
|
||||||
|
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
|
||||||
|
$s = str_replace('{s}', $textlink, $s);
|
||||||
|
print $s;
|
||||||
|
print "<br>\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}', '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>', $s);
|
||||||
|
print $s;
|
||||||
|
print "<br>\n";
|
||||||
|
}
|
||||||
|
|
||||||
$step++;
|
$step++;
|
||||||
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
|
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}');
|
||||||
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>', $s);
|
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/productaccount.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'</strong></a>', $s);
|
||||||
print $s;
|
print $s;
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$step++;
|
|
||||||
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}');
|
|
||||||
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/productaccount.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'</strong></a>', $s);
|
|
||||||
print $s;
|
|
||||||
print "<br>\n";
|
|
||||||
|
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
// Step A - E
|
// Step A - E
|
||||||
|
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|||||||
@ -412,8 +412,13 @@ if ($action == 'writebookkeeping') {
|
|||||||
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
|
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
|
||||||
$bookkeeping->thirdparty_code = $companystatic->code_client;
|
$bookkeeping->thirdparty_code = $companystatic->code_client;
|
||||||
|
|
||||||
$bookkeeping->subledger_account = '';
|
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
|
||||||
$bookkeeping->subledger_label = '';
|
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
||||||
|
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||||
|
} else {
|
||||||
|
$bookkeeping->subledger_account = '';
|
||||||
|
$bookkeeping->subledger_label = '';
|
||||||
|
}
|
||||||
|
|
||||||
$bookkeeping->numero_compte = $k;
|
$bookkeeping->numero_compte = $k;
|
||||||
$bookkeeping->label_compte = $label_account;
|
$bookkeeping->label_compte = $label_account;
|
||||||
@ -886,6 +891,13 @@ if (empty($action) || $action == 'view') {
|
|||||||
print "</td>";
|
print "</td>";
|
||||||
// Subledger account
|
// Subledger account
|
||||||
print "<td>";
|
print "<td>";
|
||||||
|
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
|
||||||
|
if (($accountoshow == "") || $accountoshow == 'NotDefined') {
|
||||||
|
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
|
||||||
|
} else {
|
||||||
|
print length_accounta($tabcompany[$key]['code_compta']);
|
||||||
|
}
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
$companystatic->id = $tabcompany[$key]['id'];
|
$companystatic->id = $tabcompany[$key]['id'];
|
||||||
$companystatic->name = $tabcompany[$key]['name'];
|
$companystatic->name = $tabcompany[$key]['name'];
|
||||||
|
|||||||
@ -140,9 +140,9 @@ if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->acco
|
|||||||
if (!$error) {
|
if (!$error) {
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as l";
|
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
|
||||||
$sql1 .= " SET l.fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
|
$sql1 .= " SET fk_code_ventilation=".(GETPOST('account_parent', 'int') > 0 ? GETPOST('account_parent', 'int') : '0');
|
||||||
$sql1 .= ' WHERE l.rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
|
$sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
|
||||||
|
|
||||||
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
|
dol_syslog('accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
|
||||||
$resql1 = $db->query($sql1);
|
$resql1 = $db->query($sql1);
|
||||||
@ -502,7 +502,7 @@ if ($result) {
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
print '<td class="tdoverflowonsmartphone">';
|
print '<td class="tdoverflowonsmartphone">';
|
||||||
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
|
$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1));
|
||||||
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
||||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
|
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -644,7 +644,7 @@ if ($result) {
|
|||||||
|
|
||||||
// Description
|
// Description
|
||||||
print '<td class="tdoverflowonsmartphone small">';
|
print '<td class="tdoverflowonsmartphone small">';
|
||||||
$text = dolGetFirstLineOfText(dol_string_nohtmltag($facturefourn_static_det->desc));
|
$text = dolGetFirstLineOfText(dol_string_nohtmltag($facturefourn_static_det->desc, 1));
|
||||||
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
|
||||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $facturefourn_static_det->desc);
|
print $form->textwithtooltip(dol_trunc($text, $trunclength), $facturefourn_static_det->desc);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|||||||
@ -358,7 +358,7 @@ class Members extends DolibarrApi
|
|||||||
if ($member->update(DolibarrApiAccess::$user) >= 0) {
|
if ($member->update(DolibarrApiAccess::$user) >= 0) {
|
||||||
return $this->get($id);
|
return $this->get($id);
|
||||||
} else {
|
} else {
|
||||||
throw new RestException(500, $member->error);
|
throw new RestException(500, 'Error when updating member: '.$member->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -204,7 +204,7 @@ class MembersTypes extends DolibarrApi
|
|||||||
if ($membertype->update(DolibarrApiAccess::$user) >= 0) {
|
if ($membertype->update(DolibarrApiAccess::$user) >= 0) {
|
||||||
return $this->get($id);
|
return $this->get($id);
|
||||||
} else {
|
} else {
|
||||||
throw new RestException(500, $membertype->error);
|
throw new RestException(500, 'Error when updating member type: '.$membertype->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -159,7 +159,7 @@ class Subscriptions extends DolibarrApi
|
|||||||
$subscription->$field = $value;
|
$subscription->$field = $value;
|
||||||
}
|
}
|
||||||
if ($subscription->create(DolibarrApiAccess::$user) < 0) {
|
if ($subscription->create(DolibarrApiAccess::$user) < 0) {
|
||||||
throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors));
|
throw new RestException(500, 'Error when creating contribution', array_merge(array($subscription->error), $subscription->errors));
|
||||||
}
|
}
|
||||||
return $subscription->id;
|
return $subscription->id;
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ class Subscriptions extends DolibarrApi
|
|||||||
if ($subscription->update(DolibarrApiAccess::$user) > 0) {
|
if ($subscription->update(DolibarrApiAccess::$user) > 0) {
|
||||||
return $this->get($id);
|
return $this->get($id);
|
||||||
} else {
|
} else {
|
||||||
throw new RestException(500, $subscription->error);
|
throw new RestException(500, 'Error when updating contribution: '.$subscription->error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -358,7 +358,7 @@ class Subscription extends CommonObject
|
|||||||
$result = $member->update_end_date($user);
|
$result = $member->update_end_date($user);
|
||||||
|
|
||||||
if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) { // If we found bank account line (this means this->fk_bank defined)
|
if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) { // If we found bank account line (this means this->fk_bank defined)
|
||||||
$result = $accountline->delete($user); // Return false if refused because line is conciliated
|
$result = $accountline->delete($user); // Return false if refused because line is reconciled
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@ -177,8 +177,8 @@ if ($conf->use_javascript_ajax) {
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($AdherentType as $key => $adhtype) {
|
foreach ($AdherentType as $key => $adhtype) {
|
||||||
$dataval['draft'][] = array($i, isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0);
|
$dataval['draft'][] = array($i, isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0);
|
||||||
$dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0);
|
|
||||||
$dataval['uptodate'][] = array($i, isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0);
|
$dataval['uptodate'][] = array($i, isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0);
|
||||||
|
$dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0);
|
||||||
$dataval['excluded'][] = array($i, isset($MembersExcluded[$key]) ? $MembersExcluded[$key] : 0);
|
$dataval['excluded'][] = array($i, isset($MembersExcluded[$key]) ? $MembersExcluded[$key] : 0);
|
||||||
$dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0);
|
$dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0);
|
||||||
|
|
||||||
@ -191,18 +191,18 @@ if ($conf->use_javascript_ajax) {
|
|||||||
}
|
}
|
||||||
$total = $SumToValidate + $SumValidated + $SumUpToDate + $SumExcluded + $SumResiliated;
|
$total = $SumToValidate + $SumValidated + $SumUpToDate + $SumExcluded + $SumResiliated;
|
||||||
$dataseries = array();
|
$dataseries = array();
|
||||||
$dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), round($SumValidated));
|
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SumToValidate)); // Draft, not yet validated
|
||||||
$dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), round($SumUpToDate));
|
$dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), round($SumUpToDate));
|
||||||
|
$dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), round($SumValidated));
|
||||||
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusExcluded"), round($SumExcluded));
|
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusExcluded"), round($SumExcluded));
|
||||||
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SumResiliated));
|
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SumResiliated));
|
||||||
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SumToValidate));
|
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||||
$dolgraph = new DolGraph();
|
$dolgraph = new DolGraph();
|
||||||
$dolgraph->SetData($dataseries);
|
$dolgraph->SetData($dataseries);
|
||||||
$dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, '-'.$badgeStatus8, $badgeStatus6, '-'.$badgeStatus0));
|
$dolgraph->SetDataColor(array('-'.$badgeStatus0, $badgeStatus4, '-'.$badgeStatus1, '-'.$badgeStatus8, $badgeStatus6));
|
||||||
$dolgraph->setShowLegend(2);
|
$dolgraph->setShowLegend(2);
|
||||||
$dolgraph->setShowPercent(1);
|
$dolgraph->setShowPercent(1);
|
||||||
$dolgraph->SetType(array('pie'));
|
$dolgraph->SetType(array('pie'));
|
||||||
|
|||||||
@ -94,7 +94,7 @@ if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2
|
|||||||
$search_code = GETPOST('search_code', 'alpha');
|
$search_code = GETPOST('search_code', 'alpha');
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||||
$hookmanager->initHooks(array('admin'));
|
$hookmanager->initHooks(array('admin', 'dictionaryadmin'));
|
||||||
|
|
||||||
// This page is a generic page to edit dictionaries
|
// This page is a generic page to edit dictionaries
|
||||||
// Put here declaration of dictionaries properties
|
// Put here declaration of dictionaries properties
|
||||||
@ -218,7 +218,7 @@ $tabsql[17] = "SELECT id as rowid, code, label, accountancy_code, active FR
|
|||||||
$tabsql[18] = "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
|
$tabsql[18] = "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
|
||||||
$tabsql[19] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
|
$tabsql[19] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
|
||||||
$tabsql[20] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
|
$tabsql[20] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
|
||||||
$tabsql[21] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.position FROM ".MAIN_DB_PREFIX."c_availability AS c";
|
$tabsql[21] = "SELECT c.rowid as rowid, c.code, c.label, c.type_duration, c.qty, c.active, c.position FROM ".MAIN_DB_PREFIX."c_availability AS c";
|
||||||
$tabsql[22] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
|
$tabsql[22] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
|
||||||
$tabsql[23] = "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
|
$tabsql[23] = "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
|
||||||
$tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
|
$tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
|
||||||
@ -265,7 +265,7 @@ $tabsqlsort[17] = "code ASC";
|
|||||||
$tabsqlsort[18] = "code ASC, libelle ASC";
|
$tabsqlsort[18] = "code ASC, libelle ASC";
|
||||||
$tabsqlsort[19] = "id ASC";
|
$tabsqlsort[19] = "id ASC";
|
||||||
$tabsqlsort[20] = "code ASC, libelle ASC";
|
$tabsqlsort[20] = "code ASC, libelle ASC";
|
||||||
$tabsqlsort[21] = "code ASC, label ASC, position ASC";
|
$tabsqlsort[21] = "code ASC, label ASC, position ASC, type_duration ASC, qty ASC";
|
||||||
$tabsqlsort[22] = "code ASC, label ASC";
|
$tabsqlsort[22] = "code ASC, label ASC";
|
||||||
$tabsqlsort[23] = "country ASC, taux ASC";
|
$tabsqlsort[23] = "country ASC, taux ASC";
|
||||||
$tabsqlsort[24] = "code ASC, label ASC";
|
$tabsqlsort[24] = "code ASC, label ASC";
|
||||||
@ -312,7 +312,7 @@ $tabfield[17] = "code,label,accountancy_code";
|
|||||||
$tabfield[18] = "code,libelle,tracking";
|
$tabfield[18] = "code,libelle,tracking";
|
||||||
$tabfield[19] = "code,libelle";
|
$tabfield[19] = "code,libelle";
|
||||||
$tabfield[20] = "code,libelle";
|
$tabfield[20] = "code,libelle";
|
||||||
$tabfield[21] = "code,label,position";
|
$tabfield[21] = "code,label,qty,type_duration,position";
|
||||||
$tabfield[22] = "code,label";
|
$tabfield[22] = "code,label";
|
||||||
$tabfield[23] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
|
$tabfield[23] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
|
||||||
$tabfield[24] = "code,label";
|
$tabfield[24] = "code,label";
|
||||||
@ -359,7 +359,7 @@ $tabfieldvalue[17] = "code,label,accountancy_code";
|
|||||||
$tabfieldvalue[18] = "code,libelle,tracking";
|
$tabfieldvalue[18] = "code,libelle,tracking";
|
||||||
$tabfieldvalue[19] = "code,libelle";
|
$tabfieldvalue[19] = "code,libelle";
|
||||||
$tabfieldvalue[20] = "code,libelle";
|
$tabfieldvalue[20] = "code,libelle";
|
||||||
$tabfieldvalue[21] = "code,label,position";
|
$tabfieldvalue[21] = "code,label,qty,type_duration,position";
|
||||||
$tabfieldvalue[22] = "code,label";
|
$tabfieldvalue[22] = "code,label";
|
||||||
$tabfieldvalue[23] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
|
$tabfieldvalue[23] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
|
||||||
$tabfieldvalue[24] = "code,label";
|
$tabfieldvalue[24] = "code,label";
|
||||||
@ -406,7 +406,7 @@ $tabfieldinsert[17] = "code,label,accountancy_code";
|
|||||||
$tabfieldinsert[18] = "code,libelle,tracking";
|
$tabfieldinsert[18] = "code,libelle,tracking";
|
||||||
$tabfieldinsert[19] = "code,libelle";
|
$tabfieldinsert[19] = "code,libelle";
|
||||||
$tabfieldinsert[20] = "code,libelle";
|
$tabfieldinsert[20] = "code,libelle";
|
||||||
$tabfieldinsert[21] = "code,label,position";
|
$tabfieldinsert[21] = "code,label,qty,type_duration,position";
|
||||||
$tabfieldinsert[22] = "code,label";
|
$tabfieldinsert[22] = "code,label";
|
||||||
$tabfieldinsert[23] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
|
$tabfieldinsert[23] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
|
||||||
$tabfieldinsert[24] = "code,label";
|
$tabfieldinsert[24] = "code,label";
|
||||||
@ -566,7 +566,7 @@ $tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode"));
|
|||||||
$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
|
$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||||
$tabhelp[35] = array();
|
$tabhelp[35] = array();
|
||||||
$tabhelp[36] = array('range_ik'=>$langs->trans('PrevRangeToThisRange'));
|
$tabhelp[36] = array('range_ik'=>$langs->trans('PrevRangeToThisRange'));
|
||||||
$tabhelp[37] = array('code'=>$langs->trans("EnterAnyCode"), 'unit_type' => $langs->trans('MeasuringUnitTypeDesc'), 'scale' => $langs->trans('MeasuringScaleDesc'));
|
$tabhelp[37] = array('code'=>$langs->trans("EnterAnyCode"), 'unit_type' => $langs->trans('Measuringtype_durationDesc'), 'scale' => $langs->trans('MeasuringScaleDesc'));
|
||||||
$tabhelp[38] = array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc'));
|
$tabhelp[38] = array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc'));
|
||||||
$tabhelp[39] = array('code'=>$langs->trans("EnterAnyCode"));
|
$tabhelp[39] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||||
$tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"));
|
$tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"));
|
||||||
@ -669,8 +669,8 @@ if ($id == 11) {
|
|||||||
|
|
||||||
asort($elementList);
|
asort($elementList);
|
||||||
$sourceList = array(
|
$sourceList = array(
|
||||||
'internal' => $langs->trans('Internal'),
|
'internal' => $langs->trans('Internal'),
|
||||||
'external' => $langs->trans('External')
|
'external' => $langs->trans('External')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,445 +694,470 @@ if ($id == 10) {
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$parameters = array(
|
||||||
|
'id' =>$id,
|
||||||
|
'rowid' =>$rowid,
|
||||||
|
'code' =>$code,
|
||||||
|
'confirm' =>$confirm,
|
||||||
|
'entity' =>$entity,
|
||||||
|
'taborder' =>$taborder,
|
||||||
|
'tabname' =>$tabname,
|
||||||
|
'tablib' =>$tablib,
|
||||||
|
'tabsql' =>$tabsql,
|
||||||
|
'tabsqlsort' =>$tabsqlsort,
|
||||||
|
'tabfield' =>$tabfield,
|
||||||
|
'tabfieldvalue' =>$tabfieldvalue,
|
||||||
|
'tabfieldinsert'=>$tabfieldinsert,
|
||||||
|
'tabrowid' =>$tabrowid,
|
||||||
|
'tabcond' =>$tabcond,
|
||||||
|
'tabhelp' =>$tabhelp,
|
||||||
|
'tabcomplete' =>$tabcomplete
|
||||||
|
);
|
||||||
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
|
if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
|
||||||
$search_country_id = '';
|
$search_country_id = '';
|
||||||
$search_code = '';
|
$search_code = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions add or modify an entry into a dictionary
|
if (empty($reshook)) {
|
||||||
if (GETPOST('actionadd') || GETPOST('actionmodify')) {
|
// Actions add or modify an entry into a dictionary
|
||||||
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
|
if (GETPOST('actionadd') || GETPOST('actionmodify')) {
|
||||||
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
|
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
|
||||||
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
|
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
|
||||||
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
|
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
|
||||||
|
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
|
||||||
|
|
||||||
// Check that all mandatory fields are filled
|
// Check that all mandatory fields are filled
|
||||||
$ok = 1;
|
$ok = 1;
|
||||||
foreach ($listfield as $f => $value) {
|
foreach ($listfield as $f => $value) {
|
||||||
// Discard check of mandatory fields for country for some tables
|
// Discard check of mandatory fields for country for some tables
|
||||||
if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) {
|
if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) {
|
||||||
continue; // For some pages, country is not mandatory
|
continue; // For some pages, country is not mandatory
|
||||||
|
}
|
||||||
|
if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp'))) {
|
||||||
|
continue; // For some pages, country is not mandatory
|
||||||
|
}
|
||||||
|
// Discard check of mandatory fiedls for other fields
|
||||||
|
if ($value == 'localtax1' && !GETPOST('localtax1_type')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($value == 'localtax2' && !GETPOST('localtax2_type')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($value == 'color' && !GETPOST('color')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($value == 'formula' && !GETPOST('formula')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($value == 'dayrule' && !GETPOST('dayrule')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($value == 'sortorder') {
|
||||||
|
continue; // For a column name 'sortorder', we use the field name 'position'
|
||||||
|
}
|
||||||
|
if ((!GETPOSTISSET($value) || GETPOST($value) == '')
|
||||||
|
&& (!in_array($value, array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking', 'picto')) // Fields that are not mandatory
|
||||||
|
&& ($id != 10 || ($value != 'code' && $value != 'note')) // Field code and note is not mandatory for dictionary table 10
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
$ok = 0;
|
||||||
|
$fieldnamekey = $value;
|
||||||
|
// We take translate key of field
|
||||||
|
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
|
||||||
|
$fieldnamekey = 'Label';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'libelle_facture') {
|
||||||
|
$fieldnamekey = 'LabelOnDocuments';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'nbjour') {
|
||||||
|
$fieldnamekey = 'NbOfDays';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'decalage') {
|
||||||
|
$fieldnamekey = 'Offset';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'module') {
|
||||||
|
$fieldnamekey = 'Module';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'code') {
|
||||||
|
$fieldnamekey = 'Code';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'note') {
|
||||||
|
$fieldnamekey = 'Note';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'taux') {
|
||||||
|
$fieldnamekey = 'Rate';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'type') {
|
||||||
|
$fieldnamekey = 'Type';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'position') {
|
||||||
|
$fieldnamekey = 'Position';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'unicode') {
|
||||||
|
$fieldnamekey = 'Unicode';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'deductible') {
|
||||||
|
$fieldnamekey = 'Deductible';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'sortorder') {
|
||||||
|
$fieldnamekey = 'SortOrder';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'category_type') {
|
||||||
|
$fieldnamekey = 'Calculated';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'revenuestamp_type') {
|
||||||
|
$fieldnamekey = 'TypeOfRevenueStamp';
|
||||||
|
}
|
||||||
|
if ($fieldnamekey == 'use_default') {
|
||||||
|
$fieldnamekey = 'UseByDefault';
|
||||||
|
}
|
||||||
|
|
||||||
|
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp'))) {
|
// Other checks
|
||||||
continue; // For some pages, country is not mandatory
|
if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) {
|
||||||
}
|
|
||||||
// Discard check of mandatory fiedls for other fields
|
|
||||||
if ($value == 'localtax1' && !GETPOST('localtax1_type')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($value == 'localtax2' && !GETPOST('localtax2_type')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($value == 'color' && !GETPOST('color')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($value == 'formula' && !GETPOST('formula')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($value == 'dayrule' && !GETPOST('dayrule')) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($value == 'sortorder') {
|
|
||||||
continue; // For a column name 'sortorder', we use the field name 'position'
|
|
||||||
}
|
|
||||||
if ((!GETPOSTISSET($value) || GETPOST($value) == '')
|
|
||||||
&& (!in_array($value, array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking', 'picto')) // Fields that are not mandatory
|
|
||||||
&& ($id != 10 || ($value != 'code' && $value != 'note')) // Field code and note is not mandatory for dictionary table 10
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$ok = 0;
|
$ok = 0;
|
||||||
$fieldnamekey = $value;
|
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
|
||||||
// We take translate key of field
|
|
||||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
|
|
||||||
$fieldnamekey = 'Label';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'libelle_facture') {
|
|
||||||
$fieldnamekey = 'LabelOnDocuments';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'nbjour') {
|
|
||||||
$fieldnamekey = 'NbOfDays';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'decalage') {
|
|
||||||
$fieldnamekey = 'Offset';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'module') {
|
|
||||||
$fieldnamekey = 'Module';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'code') {
|
|
||||||
$fieldnamekey = 'Code';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'note') {
|
|
||||||
$fieldnamekey = 'Note';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'taux') {
|
|
||||||
$fieldnamekey = 'Rate';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'type') {
|
|
||||||
$fieldnamekey = 'Type';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'position') {
|
|
||||||
$fieldnamekey = 'Position';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'unicode') {
|
|
||||||
$fieldnamekey = 'Unicode';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'deductible') {
|
|
||||||
$fieldnamekey = 'Deductible';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'sortorder') {
|
|
||||||
$fieldnamekey = 'SortOrder';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'category_type') {
|
|
||||||
$fieldnamekey = 'Calculated';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'revenuestamp_type') {
|
|
||||||
$fieldnamekey = 'TypeOfRevenueStamp';
|
|
||||||
}
|
|
||||||
if ($fieldnamekey == 'use_default') {
|
|
||||||
$fieldnamekey = 'UseByDefault';
|
|
||||||
}
|
|
||||||
|
|
||||||
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
|
|
||||||
}
|
}
|
||||||
}
|
if (GETPOSTISSET("code")) {
|
||||||
// Other checks
|
if (GETPOST("code") == '0') {
|
||||||
if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) {
|
$ok = 0;
|
||||||
$ok = 0;
|
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
|
||||||
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
|
}
|
||||||
}
|
}
|
||||||
if (GETPOSTISSET("code")) {
|
if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) {
|
||||||
if (GETPOST("code") == '0') {
|
if (in_array($tablib[$id], array('DictionaryCompanyType', 'DictionaryHolidayTypes'))) { // Field country is no mandatory for such dictionaries
|
||||||
|
$_POST["country"] = '';
|
||||||
|
} else {
|
||||||
|
$ok = 0;
|
||||||
|
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (($id == 3 || $id == 42) && !is_numeric(GETPOST("code"))) {
|
||||||
$ok = 0;
|
$ok = 0;
|
||||||
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
|
setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) {
|
// Clean some parameters
|
||||||
if (in_array($tablib[$id], array('DictionaryCompanyType', 'DictionaryHolidayTypes'))) { // Field country is no mandatory for such dictionaries
|
if ((GETPOST("localtax1_type") || (GETPOST('localtax1_type') == '0')) && !GETPOST("localtax1")) {
|
||||||
$_POST["country"] = '';
|
$_POST["localtax1"] = '0'; // If empty, we force to 0
|
||||||
} else {
|
}
|
||||||
$ok = 0;
|
if ((GETPOST("localtax2_type") || (GETPOST('localtax2_type') == '0')) && !GETPOST("localtax2")) {
|
||||||
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
|
$_POST["localtax2"] = '0'; // If empty, we force to 0
|
||||||
|
}
|
||||||
|
if (GETPOST("accountancy_code") <= 0) {
|
||||||
|
$_POST["accountancy_code"] = ''; // If empty, we force to null
|
||||||
|
}
|
||||||
|
if (GETPOST("accountancy_code_sell") <= 0) {
|
||||||
|
$_POST["accountancy_code_sell"] = ''; // If empty, we force to null
|
||||||
|
}
|
||||||
|
if (GETPOST("accountancy_code_buy") <= 0) {
|
||||||
|
$_POST["accountancy_code_buy"] = ''; // If empty, we force to null
|
||||||
|
}
|
||||||
|
if ($id == 10 && GETPOSTISSET("code")) { // Spaces are not allowed into code for tax dictionary
|
||||||
|
$_POST["code"] = preg_replace('/[^a-zA-Z0-9\-\+]/', '', GETPOST("code"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (($id == 3 || $id == 42) && !is_numeric(GETPOST("code"))) {
|
|
||||||
$ok = 0;
|
|
||||||
setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clean some parameters
|
// If check ok and action add, add the line
|
||||||
if ((GETPOST("localtax1_type") || (GETPOST('localtax1_type') == '0')) && !GETPOST("localtax1")) {
|
if ($ok && GETPOST('actionadd')) {
|
||||||
$_POST["localtax1"] = '0'; // If empty, we force to 0
|
if ($tabrowid[$id]) {
|
||||||
}
|
// Get free id for insert
|
||||||
if ((GETPOST("localtax2_type") || (GETPOST('localtax2_type') == '0')) && !GETPOST("localtax2")) {
|
$newid = 0;
|
||||||
$_POST["localtax2"] = '0'; // If empty, we force to 0
|
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
|
||||||
}
|
$result = $db->query($sql);
|
||||||
if (GETPOST("accountancy_code") <= 0) {
|
if ($result) {
|
||||||
$_POST["accountancy_code"] = ''; // If empty, we force to null
|
$obj = $db->fetch_object($result);
|
||||||
}
|
$newid = ($obj->newid + 1);
|
||||||
if (GETPOST("accountancy_code_sell") <= 0) {
|
} else {
|
||||||
$_POST["accountancy_code_sell"] = ''; // If empty, we force to null
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
if (GETPOST("accountancy_code_buy") <= 0) {
|
}
|
||||||
$_POST["accountancy_code_buy"] = ''; // If empty, we force to null
|
|
||||||
}
|
|
||||||
if ($id == 10 && GETPOSTISSET("code")) { // Spaces are not allowed into code for tax dictionary
|
|
||||||
$_POST["code"] = preg_replace('/[^a-zA-Z0-9\-\+]/', '', GETPOST("code"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// If check ok and action add, add the line
|
// Add new entry
|
||||||
if ($ok && GETPOST('actionadd')) {
|
$sql = "INSERT INTO ".$tabname[$id]." (";
|
||||||
if ($tabrowid[$id]) {
|
// List of fields
|
||||||
// Get free id for insert
|
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
|
||||||
$newid = 0;
|
$sql .= $tabrowid[$id].",";
|
||||||
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
|
}
|
||||||
$result = $db->query($sql);
|
$sql .= $tabfieldinsert[$id];
|
||||||
if ($result) {
|
$sql .= ",active)";
|
||||||
$obj = $db->fetch_object($result);
|
$sql .= " VALUES(";
|
||||||
$newid = ($obj->newid + 1);
|
|
||||||
|
// List of values
|
||||||
|
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
|
||||||
|
$sql .= $newid.",";
|
||||||
|
}
|
||||||
|
$i = 0;
|
||||||
|
foreach ($listfieldinsert as $f => $value) {
|
||||||
|
$keycode = $listfieldvalue[$i];
|
||||||
|
if (empty($keycode)) {
|
||||||
|
$keycode = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($value == 'price' || preg_match('/^amount/i', $value)) {
|
||||||
|
$_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
|
||||||
|
} elseif ($value == 'taux' || $value == 'localtax1') {
|
||||||
|
$_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z
|
||||||
|
} elseif ($value == 'entity') {
|
||||||
|
$_POST[$keycode] = getEntity($tabname[$id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($i) {
|
||||||
|
$sql .= ",";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($keycode == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
|
||||||
|
$sql .= (int) GETPOST('position', 'int');
|
||||||
|
} elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == 10)) {
|
||||||
|
$sql .= "null"; // For vat, we want/accept code = ''
|
||||||
|
} elseif ($keycode == 'content') {
|
||||||
|
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
|
||||||
|
} elseif (in_array($keycode, array('joinfile', 'private', 'pos', 'position', 'scale', 'use_default'))) {
|
||||||
|
$sql .= (int) GETPOST($keycode, 'int');
|
||||||
|
} else {
|
||||||
|
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$sql .= ",1)";
|
||||||
|
|
||||||
|
dol_syslog("actionadd", LOG_DEBUG);
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) { // Add is ok
|
||||||
|
setEventMessages($langs->transnoentities("RecordCreatedSuccessfully"), null, 'mesgs');
|
||||||
|
|
||||||
|
// Clean $_POST array, we keep only id of dictionary
|
||||||
|
if ($id == 10 && GETPOST('country', 'int') > 0) {
|
||||||
|
$search_country_id = GETPOST('country', 'int');
|
||||||
|
}
|
||||||
|
$_POST = array('id'=>$id);
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||||
|
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new entry
|
// If verif ok and action modify, modify the line
|
||||||
$sql = "INSERT INTO ".$tabname[$id]." (";
|
if ($ok && GETPOST('actionmodify')) {
|
||||||
// List of fields
|
if ($tabrowid[$id]) {
|
||||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
|
$rowidcol = $tabrowid[$id];
|
||||||
$sql .= $tabrowid[$id].",";
|
|
||||||
}
|
|
||||||
$sql .= $tabfieldinsert[$id];
|
|
||||||
$sql .= ",active)";
|
|
||||||
$sql .= " VALUES(";
|
|
||||||
|
|
||||||
// List of values
|
|
||||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
|
|
||||||
$sql .= $newid.",";
|
|
||||||
}
|
|
||||||
$i = 0;
|
|
||||||
foreach ($listfieldinsert as $f => $value) {
|
|
||||||
$keycode = $listfieldvalue[$i];
|
|
||||||
if (empty($keycode)) {
|
|
||||||
$keycode = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($value == 'price' || preg_match('/^amount/i', $value)) {
|
|
||||||
$_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
|
|
||||||
} elseif ($value == 'taux' || $value == 'localtax1') {
|
|
||||||
$_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z
|
|
||||||
} elseif ($value == 'entity') {
|
|
||||||
$_POST[$keycode] = getEntity($tabname[$id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($i) {
|
|
||||||
$sql .= ",";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($keycode == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
|
|
||||||
$sql .= (int) GETPOST('position', 'int');
|
|
||||||
} elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == 10)) {
|
|
||||||
$sql .= "null"; // For vat, we want/accept code = ''
|
|
||||||
} elseif ($keycode == 'content') {
|
|
||||||
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
|
|
||||||
} elseif (in_array($keycode, array('joinfile', 'private', 'pos', 'position', 'scale', 'use_default'))) {
|
|
||||||
$sql .= (int) GETPOST($keycode, 'int');
|
|
||||||
} else {
|
} else {
|
||||||
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
|
$rowidcol = "rowid";
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
// Modify entry
|
||||||
}
|
$sql = "UPDATE ".$tabname[$id]." SET ";
|
||||||
$sql .= ",1)";
|
// Modifie valeur des champs
|
||||||
|
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
|
||||||
dol_syslog("actionadd", LOG_DEBUG);
|
$sql .= $tabrowid[$id]."=";
|
||||||
$resql = $db->query($sql);
|
$sql .= "'".$db->escape($rowid)."', ";
|
||||||
if ($resql) { // Add is ok
|
|
||||||
setEventMessages($langs->transnoentities("RecordCreatedSuccessfully"), null, 'mesgs');
|
|
||||||
|
|
||||||
// Clean $_POST array, we keep only id of dictionary
|
|
||||||
if ($id == 10 && GETPOST('country', 'int') > 0) {
|
|
||||||
$search_country_id = GETPOST('country', 'int');
|
|
||||||
}
|
}
|
||||||
$_POST = array('id'=>$id);
|
$i = 0;
|
||||||
} else {
|
foreach ($listfieldmodify as $field) {
|
||||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
$keycode = $listfieldvalue[$i];
|
||||||
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
|
if (empty($keycode)) {
|
||||||
|
$keycode = $field;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($field == 'price' || preg_match('/^amount/i', $field)) {
|
||||||
|
$_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
|
||||||
|
} elseif ($field == 'taux' || $field == 'localtax1') {
|
||||||
|
$_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z
|
||||||
|
} elseif ($field == 'entity') {
|
||||||
|
$_POST[$keycode] = getEntity($tabname[$id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($i) {
|
||||||
|
$sql .= ",";
|
||||||
|
}
|
||||||
|
$sql .= $field."=";
|
||||||
|
if ($listfieldvalue[$i] == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
|
||||||
|
$sql .= (int) GETPOST('position', 'int');
|
||||||
|
} elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == 10)) {
|
||||||
|
$sql .= "null"; // For vat, we want/accept code = ''
|
||||||
|
} elseif ($keycode == 'content') {
|
||||||
|
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
|
||||||
|
} elseif (in_array($keycode, array('joinfile', 'private', 'pos', 'position', 'scale', 'use_default'))) {
|
||||||
|
$sql .= (int) GETPOST($keycode, 'int');
|
||||||
|
} else {
|
||||||
|
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
if (in_array($rowidcol, array('code', 'code_iso'))) {
|
||||||
|
$sql .= " WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
$sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
|
||||||
|
}
|
||||||
|
if (in_array('entity', $listfieldmodify)) {
|
||||||
|
$sql .= " AND entity = ".((int) getEntity($tabname[$id], 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
dol_syslog("actionmodify", LOG_DEBUG);
|
||||||
|
//print $sql;
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if (!$resql) {
|
||||||
|
setEventMessages($db->error(), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||||
}
|
}
|
||||||
|
|
||||||
// If verif ok and action modify, modify the line
|
if (GETPOST('actioncancel')) {
|
||||||
if ($ok && GETPOST('actionmodify')) {
|
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
|
||||||
if ($tabrowid[$id]) {
|
if ($tabrowid[$id]) {
|
||||||
$rowidcol = $tabrowid[$id];
|
$rowidcol = $tabrowid[$id];
|
||||||
} else {
|
} else {
|
||||||
$rowidcol = "rowid";
|
$rowidcol = "rowid";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modify entry
|
$sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET ";
|
|
||||||
// Modifie valeur des champs
|
|
||||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
|
|
||||||
$sql .= $tabrowid[$id]."=";
|
|
||||||
$sql .= "'".$db->escape($rowid)."', ";
|
|
||||||
}
|
|
||||||
$i = 0;
|
|
||||||
foreach ($listfieldmodify as $field) {
|
|
||||||
$keycode = $listfieldvalue[$i];
|
|
||||||
if (empty($keycode)) {
|
|
||||||
$keycode = $field;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($field == 'price' || preg_match('/^amount/i', $field)) {
|
dol_syslog("delete", LOG_DEBUG);
|
||||||
$_POST[$keycode] = price2num(GETPOST($keycode), 'MU');
|
$result = $db->query($sql);
|
||||||
} elseif ($field == 'taux' || $field == 'localtax1') {
|
if (!$result) {
|
||||||
$_POST[$keycode] = price2num(GETPOST($keycode), 8); // Note that localtax2 can be a list of rates separated by coma like X:Y:Z
|
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
|
||||||
} elseif ($field == 'entity') {
|
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
|
||||||
$_POST[$keycode] = getEntity($tabname[$id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($i) {
|
|
||||||
$sql .= ",";
|
|
||||||
}
|
|
||||||
$sql .= $field."=";
|
|
||||||
if ($listfieldvalue[$i] == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
|
|
||||||
$sql .= (int) GETPOST('position', 'int');
|
|
||||||
} elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == 10)) {
|
|
||||||
$sql .= "null"; // For vat, we want/accept code = ''
|
|
||||||
} elseif ($keycode == 'content') {
|
|
||||||
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
|
|
||||||
} elseif (in_array($keycode, array('joinfile', 'private', 'pos', 'position', 'scale', 'use_default'))) {
|
|
||||||
$sql .= (int) GETPOST($keycode, 'int');
|
|
||||||
} else {
|
} else {
|
||||||
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
if (in_array($rowidcol, array('code', 'code_iso'))) {
|
|
||||||
$sql .= " WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
|
|
||||||
} else {
|
|
||||||
$sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
|
|
||||||
}
|
|
||||||
if (in_array('entity', $listfieldmodify)) {
|
|
||||||
$sql .= " AND entity = ".((int) getEntity($tabname[$id], 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
dol_syslog("actionmodify", LOG_DEBUG);
|
|
||||||
//print $sql;
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if (!$resql) {
|
|
||||||
setEventMessages($db->error(), null, 'errors');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GETPOST('actioncancel')) {
|
// activate
|
||||||
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
if ($action == $acts[0]) {
|
||||||
}
|
if ($tabrowid[$id]) {
|
||||||
|
$rowidcol = $tabrowid[$id];
|
||||||
|
} else {
|
||||||
|
$rowidcol = "rowid";
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
|
if ($rowid) {
|
||||||
if ($tabrowid[$id]) {
|
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
$rowidcol = $tabrowid[$id];
|
} elseif ($code) {
|
||||||
} else {
|
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
$rowidcol = "rowid";
|
}
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
// disable
|
||||||
|
if ($action == $acts[1]) {
|
||||||
dol_syslog("delete", LOG_DEBUG);
|
if ($tabrowid[$id]) {
|
||||||
$result = $db->query($sql);
|
$rowidcol = $tabrowid[$id];
|
||||||
if (!$result) {
|
|
||||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
|
|
||||||
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
|
|
||||||
} else {
|
} else {
|
||||||
|
$rowidcol = "rowid";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rowid) {
|
||||||
|
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
|
} elseif ($code) {
|
||||||
|
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// favorite
|
||||||
|
if ($action == 'activate_favorite') {
|
||||||
|
if ($tabrowid[$id]) {
|
||||||
|
$rowidcol = $tabrowid[$id];
|
||||||
|
} else {
|
||||||
|
$rowidcol = "rowid";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rowid) {
|
||||||
|
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
|
} elseif ($code) {
|
||||||
|
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable favorite
|
||||||
|
if ($action == 'disable_favorite') {
|
||||||
|
if ($tabrowid[$id]) {
|
||||||
|
$rowidcol = $tabrowid[$id];
|
||||||
|
} else {
|
||||||
|
$rowidcol = "rowid";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rowid) {
|
||||||
|
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
|
} elseif ($code) {
|
||||||
|
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is in EEC - Activate
|
||||||
|
if ($action == 'activate_eec') {
|
||||||
|
if ($tabrowid[$id]) {
|
||||||
|
$rowidcol = $tabrowid[$id];
|
||||||
|
} else {
|
||||||
|
$rowidcol = "rowid";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rowid) {
|
||||||
|
$sql = "UPDATE ".$tabname[$id]." SET eec = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
|
} elseif ($code) {
|
||||||
|
$sql = "UPDATE ".$tabname[$id]." SET eec = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is in EEC - Disable
|
||||||
|
if ($action == 'disable_eec') {
|
||||||
|
if ($tabrowid[$id]) {
|
||||||
|
$rowidcol = $tabrowid[$id];
|
||||||
|
} else {
|
||||||
|
$rowidcol = "rowid";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rowid) {
|
||||||
|
$sql = "UPDATE ".$tabname[$id]." SET eec = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
|
} elseif ($code) {
|
||||||
|
$sql = "UPDATE ".$tabname[$id]." SET eec = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if (!$result) {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// activate
|
|
||||||
if ($action == $acts[0]) {
|
|
||||||
if ($tabrowid[$id]) {
|
|
||||||
$rowidcol = $tabrowid[$id];
|
|
||||||
} else {
|
|
||||||
$rowidcol = "rowid";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($rowid) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
} elseif ($code) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if (!$result) {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// disable
|
|
||||||
if ($action == $acts[1]) {
|
|
||||||
if ($tabrowid[$id]) {
|
|
||||||
$rowidcol = $tabrowid[$id];
|
|
||||||
} else {
|
|
||||||
$rowidcol = "rowid";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($rowid) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
} elseif ($code) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if (!$result) {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// favorite
|
|
||||||
if ($action == 'activate_favorite') {
|
|
||||||
if ($tabrowid[$id]) {
|
|
||||||
$rowidcol = $tabrowid[$id];
|
|
||||||
} else {
|
|
||||||
$rowidcol = "rowid";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($rowid) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
} elseif ($code) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if (!$result) {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// disable favorite
|
|
||||||
if ($action == 'disable_favorite') {
|
|
||||||
if ($tabrowid[$id]) {
|
|
||||||
$rowidcol = $tabrowid[$id];
|
|
||||||
} else {
|
|
||||||
$rowidcol = "rowid";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($rowid) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
} elseif ($code) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if (!$result) {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is in EEC - Activate
|
|
||||||
if ($action == 'activate_eec') {
|
|
||||||
if ($tabrowid[$id]) {
|
|
||||||
$rowidcol = $tabrowid[$id];
|
|
||||||
} else {
|
|
||||||
$rowidcol = "rowid";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($rowid) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET eec = 1 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
} elseif ($code) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET eec = 1 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if (!$result) {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is in EEC - Disable
|
|
||||||
if ($action == 'disable_eec') {
|
|
||||||
if ($tabrowid[$id]) {
|
|
||||||
$rowidcol = $tabrowid[$id];
|
|
||||||
} else {
|
|
||||||
$rowidcol = "rowid";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($rowid) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET eec = 0 WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
} elseif ($code) {
|
|
||||||
$sql = "UPDATE ".$tabname[$id]." SET eec = 0 WHERE code='".dol_escape_htmltag($code)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if (!$result) {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -1466,6 +1491,9 @@ if ($id) {
|
|||||||
if ($value == 'block_if_negative') {
|
if ($value == 'block_if_negative') {
|
||||||
$valuetoshow = $langs->trans('BlockHolidayIfNegative');
|
$valuetoshow = $langs->trans('BlockHolidayIfNegative');
|
||||||
}
|
}
|
||||||
|
if ($value == 'type_duration') {
|
||||||
|
$valuetoshow = $langs->trans('Unit');
|
||||||
|
}
|
||||||
|
|
||||||
if ($id == 2) { // Special case for state page
|
if ($id == 2) { // Special case for state page
|
||||||
if ($value == 'region_id') {
|
if ($value == 'region_id') {
|
||||||
@ -1818,6 +1846,9 @@ if ($id) {
|
|||||||
if ($value == 'block_if_negative') {
|
if ($value == 'block_if_negative') {
|
||||||
$valuetoshow = $langs->trans('BlockHolidayIfNegative');
|
$valuetoshow = $langs->trans('BlockHolidayIfNegative');
|
||||||
}
|
}
|
||||||
|
if ($value == 'type_duration') {
|
||||||
|
$valuetoshow = $langs->trans('Unit');
|
||||||
|
}
|
||||||
|
|
||||||
if ($value == 'region_id' || $value == 'country_id') {
|
if ($value == 'region_id' || $value == 'country_id') {
|
||||||
$showfield = 0;
|
$showfield = 0;
|
||||||
@ -2055,6 +2086,9 @@ if ($id) {
|
|||||||
$valuetoshow = $langs->trans($obj->{$value});
|
$valuetoshow = $langs->trans($obj->{$value});
|
||||||
} elseif ($value == 'block_if_negative') {
|
} elseif ($value == 'block_if_negative') {
|
||||||
$valuetoshow = yn($obj->{$value});
|
$valuetoshow = yn($obj->{$value});
|
||||||
|
} elseif ($value == 'type_duration') {
|
||||||
|
$TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes'));
|
||||||
|
$valuetoshow =$TDurationTypes[$obj->{$value}];
|
||||||
}
|
}
|
||||||
$class .= ($class ? ' ' : '').'tddict';
|
$class .= ($class ? ' ' : '').'tddict';
|
||||||
if ($value == 'note' && $id == 10) {
|
if ($value == 'note' && $id == 10) {
|
||||||
@ -2411,10 +2445,10 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
|
|||||||
} elseif ($value == 'unit') {
|
} elseif ($value == 'unit') {
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$units = array(
|
$units = array(
|
||||||
'mm' => $langs->trans('SizeUnitmm'),
|
'mm' => $langs->trans('SizeUnitmm'),
|
||||||
'cm' => $langs->trans('SizeUnitcm'),
|
'cm' => $langs->trans('SizeUnitcm'),
|
||||||
'point' => $langs->trans('SizeUnitpoint'),
|
'point' => $langs->trans('SizeUnitpoint'),
|
||||||
'inch' => $langs->trans('SizeUnitinch')
|
'inch' => $langs->trans('SizeUnitinch')
|
||||||
);
|
);
|
||||||
print $form->selectarray('unit', $units, (!empty($obj->{$value}) ? $obj->{$value}:''), 0, 0, 0);
|
print $form->selectarray('unit', $units, (!empty($obj->{$value}) ? $obj->{$value}:''), 0, 0, 0);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -2450,6 +2484,10 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
|
|||||||
print '<td>';
|
print '<td>';
|
||||||
print $form->selectyesno("block_if_negative", (!empty($obj->{$value}) ? $obj->{$value}:''), 1);
|
print $form->selectyesno("block_if_negative", (!empty($obj->{$value}) ? $obj->{$value}:''), 1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
} elseif ($value == 'type_duration') {
|
||||||
|
print '<td>';
|
||||||
|
print $form->selectTypeDuration('', $obj->{$value}, array('i','h'));
|
||||||
|
print '</td>';
|
||||||
} else {
|
} else {
|
||||||
$fieldValue = isset($obj->{$value}) ? $obj->{$value}: '';
|
$fieldValue = isset($obj->{$value}) ? $obj->{$value}: '';
|
||||||
|
|
||||||
|
|||||||
@ -220,8 +220,9 @@ if ($action == 'edit') {
|
|||||||
foreach ($arrayofparameters as $constname => $val) {
|
foreach ($arrayofparameters as $constname => $val) {
|
||||||
if ($val['enabled']==1) {
|
if ($val['enabled']==1) {
|
||||||
$setupnotempty++;
|
$setupnotempty++;
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>aa';
|
||||||
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
|
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
|
||||||
|
$tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
|
||||||
print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
|
print '<span id="helplink'.$constname.'" class="spanforparamtooltip">'.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).'</span>';
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
|
|
||||||
@ -314,6 +315,7 @@ if ($action == 'edit') {
|
|||||||
$setupnotempty++;
|
$setupnotempty++;
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
|
$tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
|
||||||
|
$tooltiphelp .= (($langs->trans($constname . 'Tooltip2') && $langs->trans($constname . 'Tooltip2') != $constname . 'Tooltip2') ? '<br><br>'."\n".$langs->trans($constname . 'Tooltip2') : '');
|
||||||
print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
|
print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
|
|
||||||
|
|||||||
@ -225,6 +225,12 @@ if ($action == 'updateMask') {
|
|||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} elseif ($action == 'set_INVOICE_CHECK_POSTERIOR_DATE') {
|
||||||
|
$check_posterior_date = GETPOST('INVOICE_CHECK_POSTERIOR_DATE', 'int');
|
||||||
|
$res = dolibarr_set_const($db, 'INVOICE_CHECK_POSTERIOR_DATE', $check_posterior_date, 'chaine', 0, '', $conf->entity);
|
||||||
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -761,6 +767,25 @@ print '<input type="submit" class="button button-edit" value="'.$langs->trans("M
|
|||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
|
|
||||||
|
print '<tr class="oddeven"><td>'.$langs->trans("InvoiceCheckPosteriorDate"). ' ' ;
|
||||||
|
print $form->textwithpicto('', $langs->trans("InvoiceCheckPosteriorDateHelp"), 1, 'help') . '</td>';
|
||||||
|
print '<td class="left">';
|
||||||
|
if ($conf->use_javascript_ajax) {
|
||||||
|
print ajax_constantonoff('INVOICE_CHECK_POSTERIOR_DATE');
|
||||||
|
} else {
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
print '<input type="hidden" name="token" value="'.newToken().'" />';
|
||||||
|
print '<input type="hidden" name="action" value="set_INVOICE_CHECK_POSTERIOR_DATE" />';
|
||||||
|
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||||
|
print $form->selectarray("INVOICE_CHECK_POSTERIOR_DATE", $arrval, $conf->global->INVOICE_CHECK_POSTERIOR_DATE);
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="center">';
|
||||||
|
print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'" />';
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|||||||
@ -46,11 +46,12 @@ if ($action == 'test' || $action == 'send') {
|
|||||||
|
|
||||||
$substitutionarrayfortest = array(
|
$substitutionarrayfortest = array(
|
||||||
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
|
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
|
||||||
|
'__CHECK_READ__' => (!empty($object) && is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '',
|
||||||
|
'__USER_LOGIN__' => $user->login,
|
||||||
|
'__USER_EMAIL__' => $user->email,
|
||||||
|
'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
|
||||||
'__ID__' => 'RecipientIdRecord',
|
'__ID__' => 'RecipientIdRecord',
|
||||||
//'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
|
//'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails
|
||||||
'__CHECK_READ__' => (!empty($object) && is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '',
|
|
||||||
'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
|
|
||||||
'__LOGIN__' => $user->login,
|
|
||||||
'__LASTNAME__' => 'RecipientLastname',
|
'__LASTNAME__' => 'RecipientLastname',
|
||||||
'__FIRSTNAME__' => 'RecipientFirstname',
|
'__FIRSTNAME__' => 'RecipientFirstname',
|
||||||
'__ADDRESS__'=> 'RecipientAddress',
|
'__ADDRESS__'=> 'RecipientAddress',
|
||||||
@ -762,9 +763,18 @@ if ($action == 'edit') {
|
|||||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
|
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
|
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
|
||||||
print $conf->global->MAIN_MAIL_AUTOCOPY_TO;
|
$listofemail = explode(',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
|
||||||
if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
|
$i = 0;
|
||||||
print img_warning($langs->trans("ErrorBadEMail"));
|
foreach ($listofemail as $key => $val) {
|
||||||
|
if ($i) {
|
||||||
|
print ', ';
|
||||||
|
}
|
||||||
|
$val = trim($val);
|
||||||
|
print $val;
|
||||||
|
if (!isValidEmail($val, 0, 1)) {
|
||||||
|
print img_warning($langs->trans("ErrorBadEMail", $val));
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print ' ';
|
print ' ';
|
||||||
|
|||||||
@ -205,7 +205,7 @@ if (!empty($conf->expedition->enabled)) {
|
|||||||
$elementList['shipping_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendShipment'));
|
$elementList['shipping_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendShipment'));
|
||||||
}
|
}
|
||||||
if (!empty($conf->reception->enabled)) {
|
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)) {
|
if (!empty($conf->ficheinter->enabled)) {
|
||||||
$elementList['fichinter_send'] = img_picto('', 'intervention', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendIntervention'));
|
$elementList['fichinter_send'] = img_picto('', 'intervention', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendIntervention'));
|
||||||
|
|||||||
@ -267,6 +267,7 @@ $constantes = array();
|
|||||||
foreach ($listofnotifiedevents as $notifiedevent) {
|
foreach ($listofnotifiedevents as $notifiedevent) {
|
||||||
$label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
|
$label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
|
||||||
$elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype']));
|
$elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype']));
|
||||||
|
$model = $notifiedevent['elementtype'].'_send';
|
||||||
|
|
||||||
if ($notifiedevent['elementtype'] == 'order_supplier') {
|
if ($notifiedevent['elementtype'] == 'order_supplier') {
|
||||||
$elementLabel = $langs->trans('SupplierOrder');
|
$elementLabel = $langs->trans('SupplierOrder');
|
||||||
|
|||||||
@ -198,6 +198,37 @@ if ($action == 'updateMask') {
|
|||||||
// par appel methode canBeActivated
|
// par appel methode canBeActivated
|
||||||
|
|
||||||
dolibarr_set_const($db, "PROPALE_ADDON", $value, 'chaine', 0, '', $conf->entity);
|
dolibarr_set_const($db, "PROPALE_ADDON", $value, 'chaine', 0, '', $conf->entity);
|
||||||
|
} elseif (preg_match('/set_(.*)/', $action, $reg)) {
|
||||||
|
$code = $reg[1];
|
||||||
|
$value = (GETPOST($code) ? GETPOST($code) : 1);
|
||||||
|
|
||||||
|
$res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
|
||||||
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error) {
|
||||||
|
setEventMessages($langs->trans('Error'), null, 'errors');
|
||||||
|
} else {
|
||||||
|
setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
|
||||||
|
header("Location: " . $_SERVER["PHP_SELF"]);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
} elseif (preg_match('/del_(.*)/', $action, $reg)) {
|
||||||
|
$code = $reg[1];
|
||||||
|
$res = dolibarr_del_const($db, $code, $conf->entity);
|
||||||
|
|
||||||
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error) {
|
||||||
|
setEventMessages($langs->trans('Error'), null, 'errors');
|
||||||
|
} else {
|
||||||
|
setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
|
||||||
|
header("Location: " . $_SERVER["PHP_SELF"]);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -593,6 +624,28 @@ print '<td class="right"><input type="submit" class="button button-edit" value="
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
|
// default update prices on cloning a proposal
|
||||||
|
/*
|
||||||
|
print '<form method="post" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||||
|
print '<input type="hidden" name="token" value="' . newToken() .'">';
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
print '<td>' . $langs->trans('DefaultPuttingPricesUpToDate').'</td>';
|
||||||
|
print '<td></td>';
|
||||||
|
print '<td class="right">';
|
||||||
|
if (!empty($conf->use_javascript_ajax)) {
|
||||||
|
print ajax_constantonoff('PROPOSAL_CLONE_UPDATE_PRICES', array(), $conf->entity, 0, 0, 1, 0);
|
||||||
|
} else {
|
||||||
|
if (empty($conf->global->PROPOSAL_CLONE_UPDATE_PRICES)) {
|
||||||
|
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=set_PROPOSAL_CLONE_UPDATE_PRICES">' . img_picto($langs->trans('Disabled'), 'switch_off') . '</a>';
|
||||||
|
} else {
|
||||||
|
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=del_PROPOSAL_CLONE_UPDATE_PRICES">' . img_picto($langs->trans('Enabled'), 'switch_on') . '</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
print '</form>';
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
|||||||
@ -36,6 +36,14 @@ if (!$user->admin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
|
$sortfield = GETPOST('sortfield', 'aZ09');
|
||||||
|
$sortorder = GETPOST('sortorder', 'aZ09');
|
||||||
|
if (empty($sortfield)) {
|
||||||
|
$sortfield = 'date';
|
||||||
|
}
|
||||||
|
if (empty($sortorder)) {
|
||||||
|
$sortorder = 'desc';
|
||||||
|
}
|
||||||
|
|
||||||
$upload_dir = $conf->admin->dir_temp;
|
$upload_dir = $conf->admin->dir_temp;
|
||||||
|
|
||||||
@ -73,8 +81,6 @@ if ($action == 'updateform') {
|
|||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile', 'alpha')), null, 'errors');
|
setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile', 'alpha')), null, 'errors');
|
||||||
}
|
}
|
||||||
Header('Location: '.$_SERVER["PHP_SELF"]);
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,7 +196,7 @@ $formfile = new FormFile($db);
|
|||||||
$formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestFileUploadForm"), 0, 0, 1, 50, '', '', 1, '', 0);
|
$formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestFileUploadForm"), 0, 0, 1, 50, '', '', 1, '', 0);
|
||||||
|
|
||||||
// List of document
|
// List of document
|
||||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1);
|
$filearray = dol_dir_list($upload_dir, "files", 0, '', '', $sortfield, $sortorder == 'desc' ? SORT_DESC : SORT_ASC, 1);
|
||||||
$formfile->list_of_documents($filearray, null, 'admin_temp', '');
|
$formfile->list_of_documents($filearray, null, 'admin_temp', '');
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
|
|||||||
@ -214,10 +214,6 @@ if (in_array($type, array('mysql', 'mysqli'))) {
|
|||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<fieldset><legend>'.$langs->trans("ExportOptions").'</legend>';
|
print '<fieldset><legend>'.$langs->trans("ExportOptions").'</legend>';
|
||||||
print '<div class="formelementrow">';
|
|
||||||
print '<input type="checkbox" name="use_transaction" value="yes" id="checkbox_use_transaction" />';
|
|
||||||
print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) {
|
if (!empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) {
|
||||||
print '<div class="formelementrow">';
|
print '<div class="formelementrow">';
|
||||||
@ -239,14 +235,35 @@ if (in_array($type, array('mysql', 'mysqli'))) {
|
|||||||
print '<option value="ORACLE">ORACLE</option>';
|
print '<option value="ORACLE">ORACLE</option>';
|
||||||
print '<option value="POSTGRESQL">POSTGRESQL</option>';
|
print '<option value="POSTGRESQL">POSTGRESQL</option>';
|
||||||
print '</select>';
|
print '</select>';
|
||||||
print '<br>';
|
print '<br><br>';
|
||||||
|
|
||||||
print '<input type="checkbox" name="use_mysql_quick_param" value="yes" id="checkbox_use_quick" />';
|
print '<div class="formelementrow">';
|
||||||
|
print '<input type="checkbox" name="use_transaction" value="yes" id="checkbox_use_transaction" checked="checked" />';
|
||||||
|
print '<label for="checkbox_use_transaction">'.$langs->trans("UseTransactionnalMode").'</label>';
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print '<input type="checkbox" name="use_mysql_quick_param" value="yes" id="checkbox_use_quick" checked="checked" />';
|
||||||
print '<label for="checkbox_use_quick">';
|
print '<label for="checkbox_use_quick">';
|
||||||
print $form->textwithpicto($langs->trans('ExportUseMySQLQuickParameter'), $langs->trans('ExportUseMySQLQuickParameterHelp'));
|
print $form->textwithpicto($langs->trans('ExportUseMySQLQuickParameter'), $langs->trans('ExportUseMySQLQuickParameterHelp'));
|
||||||
print '</label>';
|
print '</label>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
$execmethod = 0;
|
||||||
|
if (!empty($conf->global->MAIN_EXEC_USE_POPEN)) {
|
||||||
|
$execmethod = $conf->global->MAIN_EXEC_USE_POPEN;
|
||||||
|
}
|
||||||
|
if (empty($execmethod)) {
|
||||||
|
$execmethod = 1;
|
||||||
|
}
|
||||||
|
if ($execmethod == 1) {
|
||||||
|
// If we use the "exec" method for shell, we ask if we need to use the alternative low memory exec mode.
|
||||||
|
print '<input type="checkbox" name="lowmemorydump" value="yes" id="lowmemorydump"'.(GETPOSTISSET('lowmemorydump') ? GETPOST('lowmemorydump', 'alpha') : getDolGlobalString('MAIN_LOW_MEMORY_DUMP') ? ' checked="checked"' : '').'" />';
|
||||||
|
print '<label for="lowmemorydump">';
|
||||||
|
print $form->textwithpicto($langs->trans('ExportUseLowMemoryMode'), $langs->trans('ExportUseLowMemoryModeHelp'));
|
||||||
|
print '</label>';
|
||||||
|
print '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
|
print '<!-- <input type="checkbox" name="drop_database" value="yes" id="checkbox_drop_database" />';
|
||||||
print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
|
print '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
|
||||||
print '-->';
|
print '-->';
|
||||||
|
|||||||
@ -126,7 +126,7 @@ class Documents extends DolibarrApi
|
|||||||
* @param string $langcode Language code like 'en_US', 'fr_FR', 'es_ES', ... (If not set, use the default language).
|
* @param string $langcode Language code like 'en_US', 'fr_FR', 'es_ES', ... (If not set, use the default language).
|
||||||
* @return array List of documents
|
* @return array List of documents
|
||||||
*
|
*
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
* @throws RestException 501
|
* @throws RestException 501
|
||||||
* @throws RestException 400
|
* @throws RestException 400
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
@ -249,7 +249,7 @@ class Documents extends DolibarrApi
|
|||||||
* @throws RestException 400
|
* @throws RestException 400
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*
|
*
|
||||||
* @url GET /
|
* @url GET /
|
||||||
*/
|
*/
|
||||||
@ -546,7 +546,7 @@ class Documents extends DolibarrApi
|
|||||||
* @throws RestException 400
|
* @throws RestException 400
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*
|
*
|
||||||
* @url POST /upload
|
* @url POST /upload
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -158,6 +158,25 @@ if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $
|
|||||||
$api = new DolibarrApi($db, '', $refreshcache);
|
$api = new DolibarrApi($db, '', $refreshcache);
|
||||||
//var_dump($api->r->apiVersionMap);
|
//var_dump($api->r->apiVersionMap);
|
||||||
|
|
||||||
|
// If MAIN_API_DEBUG is set to 1, we save logs into file "dolibarr_api.log"
|
||||||
|
if (!empty($conf->global->MAIN_API_DEBUG)) {
|
||||||
|
$r = $api->r;
|
||||||
|
$r->onCall(function () use ($r) {
|
||||||
|
// Don't log Luracast Restler Explorer recources calls
|
||||||
|
//if (!preg_match('/^explorer/', $r->url)) {
|
||||||
|
// 'method' => $api->r->requestMethod,
|
||||||
|
// 'url' => $api->r->url,
|
||||||
|
// 'route' => $api->r->apiMethodInfo->className.'::'.$api->r->apiMethodInfo->methodName,
|
||||||
|
// 'version' => $api->r->getRequestedApiVersion(),
|
||||||
|
// 'data' => $api->r->getRequestData(),
|
||||||
|
//dol_syslog("Debug API input ".var_export($r, true), LOG_DEBUG, 0, '_api');
|
||||||
|
dol_syslog("Debug API url ".var_export($r->url, true), LOG_DEBUG, 0, '_api');
|
||||||
|
dol_syslog("Debug API input ".var_export($r->getRequestData(), true), LOG_DEBUG, 0, '_api');
|
||||||
|
//}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Enable the Restler API Explorer.
|
// Enable the Restler API Explorer.
|
||||||
// See https://github.com/Luracast/Restler-API-Explorer for more info.
|
// See https://github.com/Luracast/Restler-API-Explorer for more info.
|
||||||
$api->r->addAPIClass('Luracast\\Restler\\Explorer');
|
$api->r->addAPIClass('Luracast\\Restler\\Explorer');
|
||||||
|
|||||||
@ -519,7 +519,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
$keyforbreak = 'duration';
|
$keyforbreak = 'duration';
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
|
||||||
$object->calculateCosts();
|
$object->calculateCosts();
|
||||||
print '<tr><td>'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td><td>'.price($object->total_cost).'</td></tr>';
|
print '<tr><td>'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td><td><span class="amount">'.price($object->total_cost).'</span></td></tr>';
|
||||||
print '<tr><td>'.$langs->trans("UnitCost").'</td><td>'.price($object->unit_cost).'</td></tr>';
|
print '<tr><td>'.$langs->trans("UnitCost").'</td><td>'.price($object->unit_cost).'</td></tr>';
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
|
|||||||
@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("mrp", "other"));
|
$langs->loadLangs(array("mrp", "other", "stocks"));
|
||||||
|
|
||||||
// Get parameters
|
// Get parameters
|
||||||
$id = GETPOST('id', 'int');
|
$id = GETPOST('id', 'int');
|
||||||
@ -170,7 +170,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
$keyforbreak = 'duration';
|
$keyforbreak = 'duration';
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
|
||||||
|
|
||||||
print '<tr><td>'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td><td>'.price($object->total_cost).'</td></tr>';
|
print '<tr><td>'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td><td><span class="amount">'.price($object->total_cost).'</span></td></tr>';
|
||||||
print '<tr><td>'.$langs->trans("UnitCost").'</td><td>'.price($object->unit_cost).'</td></tr>';
|
print '<tr><td>'.$langs->trans("UnitCost").'</td><td>'.price($object->unit_cost).'</td></tr>';
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
@ -211,9 +211,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '<a id="hide_all" href="#">'.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").'</a> ';
|
print '<a id="hide_all" href="#">'.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").'</a> ';
|
||||||
}
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="linecolqty">'.$langs->trans('Quantity').'</td>';
|
print '<td class="linecolqty right">'.$langs->trans('Quantity').'</td>';
|
||||||
print '<td class="linecolstock">'.$form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1).'</td>';
|
print '<td class="linecolstock right">'.$form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1).'</td>';
|
||||||
print '<td class="linecoltheoricalstock">'.$form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")).'</td>';
|
print '<td class="linecoltheoricalstock right">'.$form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
if (! empty($TChildBom)) {
|
if (! empty($TChildBom)) {
|
||||||
if ($action == 'treeview') {
|
if ($action == 'treeview') {
|
||||||
@ -227,9 +227,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print img_picto('', 'folder-open');
|
print img_picto('', 'folder-open');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="linecolqty">'.$TProduct['qty'].'</td>';
|
print '<td class="linecolqty right">'.$TProduct['qty'].'</td>';
|
||||||
print '<td class="linecolstock"></td>';
|
print '<td class="linecolstock right"></td>';
|
||||||
print '<td class="linecoltheoricalstock"></td>';
|
print '<td class="linecoltheoricalstock right"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
if (! empty($TProduct['product'])) {
|
if (! empty($TProduct['product'])) {
|
||||||
@ -241,9 +241,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
if ($fk_bom != $object->id) print '<tr class="sub_bom_lines oddeven" parentid="'.$fk_bom.'">';
|
if ($fk_bom != $object->id) print '<tr class="sub_bom_lines oddeven" parentid="'.$fk_bom.'">';
|
||||||
else print '<tr class="oddeven">';
|
else print '<tr class="oddeven">';
|
||||||
print '<td class="linecoldescription">'.str_repeat($repeatChar, $TInfos['level']).$prod->getNomUrl(1).'</td>';
|
print '<td class="linecoldescription">'.str_repeat($repeatChar, $TInfos['level']).$prod->getNomUrl(1).'</td>';
|
||||||
print '<td class="linecolqty">'.$TInfos['qty'].'</td>';
|
print '<td class="linecolqty right">'.$TInfos['qty'].'</td>';
|
||||||
print '<td class="linecolstock">'.$prod->stock_reel.'</td>';
|
print '<td class="linecolstock right">'.price2num($prod->stock_reel, 'MS').'</td>';
|
||||||
print '<td class="linecoltheoricalstock">'.$prod->stock_theorique.'</td>';
|
print '<td class="linecoltheoricalstock right">'.$prod->stock_theorique.'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,9 +256,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
if (empty($prod->stock_reel)) $prod->stock_reel = 0;
|
if (empty($prod->stock_reel)) $prod->stock_reel = 0;
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td class="linecoldescription">'.$prod->getNomUrl(1).'</td>';
|
print '<td class="linecoldescription">'.$prod->getNomUrl(1).'</td>';
|
||||||
print '<td class="linecolqty">'.$qty.'</td>';
|
print '<td class="linecolqty right">'.$qty.'</td>';
|
||||||
print '<td class="linecolstock">'.$prod->stock_reel.'</td>';
|
print '<td class="linecolstock right">'.price2num($prod->stock_reel, 'MS').'</td>';
|
||||||
print '<td class="linecoltheoricalstock">'.$prod->stock_theorique.'</td>';
|
print '<td class="linecoltheoricalstock right">'.$prod->stock_theorique.'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,7 +78,7 @@ class BOM extends CommonObject
|
|||||||
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
|
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
|
||||||
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
|
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
|
||||||
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
|
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
|
||||||
* 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200'
|
* 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
|
||||||
* 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
|
* 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
|
||||||
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
|
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
|
||||||
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
|
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
|
||||||
@ -97,7 +97,7 @@ class BOM extends CommonObject
|
|||||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
|
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
|
||||||
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5),
|
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5),
|
||||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',),
|
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',),
|
||||||
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'2', 'autofocusoncreate'=>1, 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax200'),
|
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'2', 'autofocusoncreate'=>1, 'css'=>'minwidth300 maxwidth400', 'csslist'=>'tdoverflowmax200'),
|
||||||
'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth175', 'csslist'=>'minwidth175 center'),
|
'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth175', 'csslist'=>'minwidth175 center'),
|
||||||
//'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'position'=>32, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing')),
|
//'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'position'=>32, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing')),
|
||||||
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'picto'=>'product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax100'),
|
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'picto'=>'product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax100'),
|
||||||
|
|||||||
@ -126,7 +126,7 @@ print '</td>';
|
|||||||
$total_cost = 0;
|
$total_cost = 0;
|
||||||
print '<td id="costline_'.$line->id.'" class="linecolcost nowrap right">';
|
print '<td id="costline_'.$line->id.'" class="linecolcost nowrap right">';
|
||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
echo price($line->total_cost);
|
echo '<span class="amount">'.price($line->total_cost).'</span>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') {
|
if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') {
|
||||||
@ -152,12 +152,12 @@ if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') {
|
|||||||
print '<td class="linecolmove tdlineupdown center">';
|
print '<td class="linecolmove tdlineupdown center">';
|
||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
if ($i > 0) {
|
if ($i > 0) {
|
||||||
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&rowid='.$line->id.'">';
|
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&token='.newToken().'&rowid='.$line->id.'">';
|
||||||
echo img_up('default', 0, 'imgupforline');
|
echo img_up('default', 0, 'imgupforline');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
}
|
}
|
||||||
if ($i < $num - 1) {
|
if ($i < $num - 1) {
|
||||||
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&rowid='.$line->id.'">';
|
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&token='.newToken().'&rowid='.$line->id.'">';
|
||||||
echo img_down('default', 0, 'imgdownforline');
|
echo img_down('default', 0, 'imgdownforline');
|
||||||
print '</a>';
|
print '</a>';
|
||||||
}
|
}
|
||||||
@ -236,15 +236,16 @@ if ($resql) {
|
|||||||
// Efficiency
|
// Efficiency
|
||||||
print '<td class="linecolefficiency nowrap right" id="sub_bom_efficiency_'.$sub_bom_line->id.'">'.$sub_bom_line->efficiency.'</td>';
|
print '<td class="linecolefficiency nowrap right" id="sub_bom_efficiency_'.$sub_bom_line->id.'">'.$sub_bom_line->efficiency.'</td>';
|
||||||
|
|
||||||
|
// Cost
|
||||||
if (!empty($sub_bom->id)) {
|
if (!empty($sub_bom->id)) {
|
||||||
$sub_bom->calculateCosts();
|
$sub_bom->calculateCosts();
|
||||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($sub_bom->total_cost * $sub_bom_line->qty * $line->qty).'</td>';
|
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price($sub_bom->total_cost * $sub_bom_line->qty * $line->qty).'</span></td>';
|
||||||
$total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty;
|
$total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty;
|
||||||
} elseif ($sub_bom_product->cost_price > 0) {
|
} elseif ($sub_bom_product->cost_price > 0) {
|
||||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty).'</td>';
|
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty).'</span></td>';
|
||||||
$total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty;
|
$total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty;
|
||||||
} elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined
|
} elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined
|
||||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty).'</td>';
|
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty).'</span></td>';
|
||||||
$total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty;
|
$total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty;
|
||||||
} else { // Minimum purchase price if cost price and PMP aren't defined
|
} else { // Minimum purchase price if cost price and PMP aren't defined
|
||||||
$sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
|
$sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
|
||||||
@ -254,7 +255,7 @@ if ($resql) {
|
|||||||
$obj = $object->db->fetch_object($resql_supplier_price);
|
$obj = $object->db->fetch_object($resql_supplier_price);
|
||||||
$line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty;
|
$line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty;
|
||||||
|
|
||||||
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">'.price($line_cost).'</td>';
|
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price($line_cost).'</span></td>';
|
||||||
$total_cost+= $line_cost;
|
$total_cost+= $line_cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,11 +267,12 @@ if ($resql) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Replace of the total_cost value by the sum of all sub-BOM lines total_cost
|
// Replace of the total_cost value by the sum of all sub-BOM lines total_cost
|
||||||
|
// TODO Remove this bad practice. We should not replace content of ouput using javascript but value should be good during generation of output.
|
||||||
if ($total_cost > 0) {
|
if ($total_cost > 0) {
|
||||||
$line->total_cost = price($total_cost);
|
$line->total_cost = price($total_cost);
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
$('#costline_<?php echo $line->id?>').html("<?php echo "".price($total_cost)?>");
|
$('#costline_<?php echo $line->id?>').html('<?php echo "<span class=\"amount\">".price($total_cost)."</span>"; ?>');
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
CACHE MANIFEST
|
|
||||||
# version 2013-05-21 13:30:21
|
|
||||||
# Note: If this file is dynamic, it must return MIME text/cache-manifest
|
|
||||||
# Note: Order of CACHE, NETWORK and FALLBACK section does not change behaviour
|
|
||||||
" Note:
|
|
||||||
|
|
||||||
|
|
||||||
# Files listed under CACHE will be ALWAYS cached after they are loaded.
|
|
||||||
# And they will be always used from Cache after (even after refresh).
|
|
||||||
CACHE:
|
|
||||||
theme/dolibarr_logo.svg
|
|
||||||
support/
|
|
||||||
support/index.php
|
|
||||||
|
|
||||||
support/default.css
|
|
||||||
support/helpcenter.png
|
|
||||||
support/internet.png
|
|
||||||
support/mail.png
|
|
||||||
support/pagemaster.png
|
|
||||||
support/redstar.png
|
|
||||||
support/star.png
|
|
||||||
support/who.png
|
|
||||||
|
|
||||||
|
|
||||||
# The NETWORK section contains the path to a folder to ensure that requests
|
|
||||||
# to load resources will use internet.
|
|
||||||
# CACHE has priority on NETWORK, so usage is useless
|
|
||||||
NETWORK:
|
|
||||||
/
|
|
||||||
|
|
||||||
# The FALLBACK section contains entries that provide a backup strategy.
|
|
||||||
# If the browser is unable to retrieve the original content, the fallback resource will be used.
|
|
||||||
# In the example above, we display a static image in case the dynamic one is unavailable.
|
|
||||||
FALLBACK:
|
|
||||||
#/ public/notice.php
|
|
||||||
#theme/eldy/img/* theme/md/img/*
|
|
||||||
@ -133,7 +133,9 @@ if (empty($nosearch)) {
|
|||||||
print '</span>';
|
print '</span>';
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
print "\t\t<td>";
|
print "\t\t<td>";
|
||||||
print dolGetFirstLineOfText($cat->description);
|
$text = dolGetFirstLineOfText(dol_string_nohtmltag($cat->description, 1));
|
||||||
|
$trunclength = 48;
|
||||||
|
print $form->textwithtooltip(dol_trunc($text, $trunclength), $cat->description);
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
print "\t</tr>\n";
|
print "\t</tr>\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1491,6 +1491,10 @@ if ($id > 0) {
|
|||||||
$("#fullday").change(function() {
|
$("#fullday").change(function() {
|
||||||
setdatefields();
|
setdatefields();
|
||||||
});
|
});
|
||||||
|
$("#actioncode").change(function() {
|
||||||
|
if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
|
||||||
|
else $("#dateend").removeClass("fieldrequired");
|
||||||
|
});
|
||||||
})';
|
})';
|
||||||
print '</script>'."\n";
|
print '</script>'."\n";
|
||||||
}
|
}
|
||||||
@ -1535,22 +1539,26 @@ if ($id > 0) {
|
|||||||
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent ? ' checked' : '').'></td></tr>';
|
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent ? ' checked' : '').'></td></tr>';
|
||||||
|
|
||||||
// Date start - end
|
// Date start - end
|
||||||
print '<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").'</span></td><td colspan="3">';
|
print '<tr><td class="nowrap">';
|
||||||
|
print '<span class="fieldrequired">'.$langs->trans("DateActionStart").'</span>';
|
||||||
|
print ' - ';
|
||||||
|
print '<span id="dateend"'.($object->type_code == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").'</span>';
|
||||||
|
print '</td><td td colspan="3">';
|
||||||
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
|
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
|
||||||
if (GETPOST("afaire") == 1) {
|
if (GETPOST("afaire") == 1) {
|
||||||
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
|
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
|
||||||
} elseif (GETPOST("afaire") == 2) {
|
} elseif (GETPOST("afaire") == 2) {
|
||||||
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
|
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
|
||||||
} else {
|
} else {
|
||||||
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
|
print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
|
||||||
}
|
}
|
||||||
print ' - ';
|
print ' - ';
|
||||||
if (GETPOST("afaire") == 1) {
|
if (GETPOST("afaire") == 1) {
|
||||||
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
|
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
|
||||||
} elseif (GETPOST("afaire") == 2) {
|
} elseif (GETPOST("afaire") == 2) {
|
||||||
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
|
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
|
||||||
} else {
|
} else {
|
||||||
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuser') : 'tzuser');
|
print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
@ -1988,11 +1996,15 @@ if ($id > 0) {
|
|||||||
|
|
||||||
// Date start
|
// Date start
|
||||||
print '<tr><td>'.$langs->trans("DateActionStart").'</td><td>';
|
print '<tr><td>'.$langs->trans("DateActionStart").'</td><td>';
|
||||||
|
// Test a date before the 27 march and one after
|
||||||
|
//print dol_print_date($object->datep, 'dayhour', 'gmt');
|
||||||
|
//print dol_print_date($object->datep, 'dayhour', 'tzuser');
|
||||||
|
//print dol_print_date($object->datep, 'dayhour', 'tzuserrel');
|
||||||
if (empty($object->fulldayevent)) {
|
if (empty($object->fulldayevent)) {
|
||||||
print dol_print_date($object->datep, 'dayhour', 'tzuser');
|
print dol_print_date($object->datep, 'dayhour', 'tzuserrel');
|
||||||
} else {
|
} else {
|
||||||
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
|
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
|
||||||
print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
|
print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuserrel'));
|
||||||
}
|
}
|
||||||
if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
|
if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
|
||||||
print img_warning($langs->trans("Late"));
|
print img_warning($langs->trans("Late"));
|
||||||
@ -2003,10 +2015,10 @@ if ($id > 0) {
|
|||||||
// Date end
|
// Date end
|
||||||
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td>';
|
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td>';
|
||||||
if (empty($object->fulldayevent)) {
|
if (empty($object->fulldayevent)) {
|
||||||
print dol_print_date($object->datef, 'dayhour', 'tzuser');
|
print dol_print_date($object->datef, 'dayhour', 'tzuserrel');
|
||||||
} else {
|
} else {
|
||||||
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
|
$tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
|
||||||
print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
|
print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuserrel'));
|
||||||
}
|
}
|
||||||
if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
|
if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
|
||||||
print img_warning($langs->trans("Late"));
|
print img_warning($langs->trans("Late"));
|
||||||
|
|||||||
@ -931,7 +931,7 @@ if ($showbirthday) {
|
|||||||
$sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
|
$sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
|
||||||
$sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).'))';
|
$sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.((int) $user->id).'))';
|
||||||
$sql .= " AND sp.entity IN (".getEntity('socpeople').")";
|
$sql .= " AND sp.entity IN (".getEntity('contact').")";
|
||||||
if ($mode == 'show_day') {
|
if ($mode == 'show_day') {
|
||||||
$sql .= ' AND MONTH(birthday) = '.((int) $month);
|
$sql .= ' AND MONTH(birthday) = '.((int) $month);
|
||||||
$sql .= ' AND DAY(birthday) = '.((int) $day);
|
$sql .= ' AND DAY(birthday) = '.((int) $day);
|
||||||
|
|||||||
@ -943,8 +943,8 @@ while ($i < min($num, $limit)) {
|
|||||||
// Description
|
// Description
|
||||||
if (!empty($arrayfields['a.note']['checked'])) {
|
if (!empty($arrayfields['a.note']['checked'])) {
|
||||||
print '<td class="tdoverflowonsmartphone">';
|
print '<td class="tdoverflowonsmartphone">';
|
||||||
$text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 0));
|
$text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 1));
|
||||||
print $form->textwithtooltip(dol_trunc($text, 40), $actionstatic->note_private);
|
print $form->textwithtooltip(dol_trunc($text, 48), $actionstatic->note_private);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
* Copyright (C) 2015-2021 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2015-2021 Frédéric France <frederic.france@netlogic.fr>
|
||||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
|
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
|
||||||
|
* Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -38,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||||
if (!empty($conf->facture->enabled)) {
|
if (!empty($conf->facture->enabled)) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
}
|
}
|
||||||
@ -112,6 +114,7 @@ $cancel = GETPOST('cancel', 'alpha');
|
|||||||
|
|
||||||
$object = new Client($db);
|
$object = new Client($db);
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
|
$formfile = new FormFile($db);
|
||||||
|
|
||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
@ -859,6 +862,36 @@ if ($object->id > 0) {
|
|||||||
$propal_static->total_tva = $objp->total_tva;
|
$propal_static->total_tva = $objp->total_tva;
|
||||||
$propal_static->total_ttc = $objp->total_ttc;
|
$propal_static->total_ttc = $objp->total_ttc;
|
||||||
print $propal_static->getNomUrl(1);
|
print $propal_static->getNomUrl(1);
|
||||||
|
|
||||||
|
// Preview
|
||||||
|
$filedir = $conf->propal->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
$file_list = null;
|
||||||
|
if (!empty($filedir)) {
|
||||||
|
$file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
|
||||||
|
}
|
||||||
|
if (is_array($file_list)) {
|
||||||
|
// Defined relative dir to DOL_DATA_ROOT
|
||||||
|
$relativedir = '';
|
||||||
|
if ($filedir) {
|
||||||
|
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
|
||||||
|
$relativedir = preg_replace('/^[\\/]/', '', $relativedir);
|
||||||
|
}
|
||||||
|
// Get list of files stored into database for same relative directory
|
||||||
|
if ($relativedir) {
|
||||||
|
completeFileArrayWithDatabaseInfo($file_list, $relativedir);
|
||||||
|
|
||||||
|
//var_dump($sortfield.' - '.$sortorder);
|
||||||
|
if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
|
||||||
|
$file_list = dol_sort_array($file_list, $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
|
||||||
|
print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0, $param);
|
||||||
|
}
|
||||||
|
// $filename = dol_sanitizeFileName($objp->ref);
|
||||||
|
// $filedir = $conf->propal->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
// $urlsource = '/comm/propal/card.php?id='.$objp->cid;
|
||||||
|
// print $formfile->getDocumentsLink($propal_static->element, $filename, $filedir);
|
||||||
if (($db->jdate($objp->date_limit) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
|
if (($db->jdate($objp->date_limit) < ($now - $conf->propal->cloture->warning_delay)) && $objp->fk_statut == $propal_static::STATUS_VALIDATED) {
|
||||||
print " ".img_warning();
|
print " ".img_warning();
|
||||||
}
|
}
|
||||||
@ -940,7 +973,38 @@ if ($object->id > 0) {
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td class="nowraponall">';
|
print '<td class="nowraponall">';
|
||||||
print $commande_static->getNomUrl(1);
|
print $commande_static->getNomUrl(1);
|
||||||
print '</td><td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day')."</td>\n";
|
// Preview
|
||||||
|
$filedir = $conf->commande->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
$file_list = null;
|
||||||
|
if (!empty($filedir)) {
|
||||||
|
$file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
|
||||||
|
}
|
||||||
|
if (is_array($file_list)) {
|
||||||
|
// Defined relative dir to DOL_DATA_ROOT
|
||||||
|
$relativedir = '';
|
||||||
|
if ($filedir) {
|
||||||
|
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
|
||||||
|
$relativedir = preg_replace('/^[\\/]/', '', $relativedir);
|
||||||
|
}
|
||||||
|
// Get list of files stored into database for same relative directory
|
||||||
|
if ($relativedir) {
|
||||||
|
completeFileArrayWithDatabaseInfo($file_list, $relativedir);
|
||||||
|
|
||||||
|
//var_dump($sortfield.' - '.$sortorder);
|
||||||
|
if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
|
||||||
|
$file_list = dol_sort_array($file_list, $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
|
||||||
|
print $formfile->showPreview($file_list, $commande_static->element, $relativepath, 0, $param);
|
||||||
|
}
|
||||||
|
// $filename = dol_sanitizeFileName($objp->ref);
|
||||||
|
// $filedir = $conf->order->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
// $urlsource = '/commande/card.php?id='.$objp->cid;
|
||||||
|
// print $formfile->getDocumentsLink($commande_static->element, $filename, $filedir);
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->dc), 'day')."</td>\n";
|
||||||
print '<td class="right" style="min-width: 60px">'.price($objp->total_ht).'</td>';
|
print '<td class="right" style="min-width: 60px">'.price($objp->total_ht).'</td>';
|
||||||
print '<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).'</td></tr>';
|
print '<td class="right" style="min-width: 60px" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).'</td></tr>';
|
||||||
$i++;
|
$i++;
|
||||||
@ -1003,6 +1067,35 @@ if ($object->id > 0) {
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td class="nowraponall">';
|
print '<td class="nowraponall">';
|
||||||
print $sendingstatic->getNomUrl(1);
|
print $sendingstatic->getNomUrl(1);
|
||||||
|
// Preview
|
||||||
|
$filedir = $conf->expedition->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
$file_list = null;
|
||||||
|
if (!empty($filedir)) {
|
||||||
|
$file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
|
||||||
|
}
|
||||||
|
if (is_array($file_list)) {
|
||||||
|
// Defined relative dir to DOL_DATA_ROOT
|
||||||
|
$relativedir = '';
|
||||||
|
if ($filedir) {
|
||||||
|
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
|
||||||
|
$relativedir = preg_replace('/^[\\/]/', '', $relativedir);
|
||||||
|
}
|
||||||
|
// Get list of files stored into database for same relative directory
|
||||||
|
if ($relativedir) {
|
||||||
|
completeFileArrayWithDatabaseInfo($file_list, $relativedir);
|
||||||
|
|
||||||
|
//var_dump($sortfield.' - '.$sortorder);
|
||||||
|
if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
|
||||||
|
$file_list = dol_sort_array($file_list, $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
|
||||||
|
print $formfile->showPreview($file_list, $sendingstatic->element, $relativepath, 0, $param);
|
||||||
|
}
|
||||||
|
// $filename = dol_sanitizeFileName($objp->ref);
|
||||||
|
// $filedir = $conf->expedition->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
// $urlsource = '/expedition/card.php?id='.$objp->cid;
|
||||||
|
// print $formfile->getDocumentsLink($sendingstatic->element, $filename, $filedir);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if ($objp->date_creation > 0) {
|
if ($objp->date_creation > 0) {
|
||||||
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation), 'day').'</td>';
|
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_creation), 'day').'</td>';
|
||||||
@ -1076,6 +1169,35 @@ if ($object->id > 0) {
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td class="nowraponall">';
|
print '<td class="nowraponall">';
|
||||||
print $contrat->getNomUrl(1, 12);
|
print $contrat->getNomUrl(1, 12);
|
||||||
|
// Preview
|
||||||
|
$filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
$file_list = null;
|
||||||
|
if (!empty($filedir)) {
|
||||||
|
$file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
|
||||||
|
}
|
||||||
|
if (is_array($file_list)) {
|
||||||
|
// Defined relative dir to DOL_DATA_ROOT
|
||||||
|
$relativedir = '';
|
||||||
|
if ($filedir) {
|
||||||
|
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
|
||||||
|
$relativedir = preg_replace('/^[\\/]/', '', $relativedir);
|
||||||
|
}
|
||||||
|
// Get list of files stored into database for same relative directory
|
||||||
|
if ($relativedir) {
|
||||||
|
completeFileArrayWithDatabaseInfo($file_list, $relativedir);
|
||||||
|
|
||||||
|
//var_dump($sortfield.' - '.$sortorder);
|
||||||
|
if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
|
||||||
|
$file_list = dol_sort_array($file_list, $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
|
||||||
|
print $formfile->showPreview($file_list, $contrat->element, $relativepath, 0, $param);
|
||||||
|
}
|
||||||
|
// $filename = dol_sanitizeFileName($objp->ref);
|
||||||
|
// $filedir = $conf->contrat->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
// $urlsource = '/contrat/card.php?id='.$objp->cid;
|
||||||
|
// print $formfile->getDocumentsLink($contrat->element, $filename, $filedir);
|
||||||
print $late;
|
print $late;
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
print '<td class="nowrap">'.dol_trunc($objp->refsup, 12)."</td>\n";
|
print '<td class="nowrap">'.dol_trunc($objp->refsup, 12)."</td>\n";
|
||||||
@ -1137,6 +1259,35 @@ if ($object->id > 0) {
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td class="nowraponall">';
|
print '<td class="nowraponall">';
|
||||||
print $fichinter_static->getNomUrl(1);
|
print $fichinter_static->getNomUrl(1);
|
||||||
|
// Preview
|
||||||
|
$filedir = $conf->fichinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
$file_list = null;
|
||||||
|
if (!empty($filedir)) {
|
||||||
|
$file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
|
||||||
|
}
|
||||||
|
if (is_array($file_list)) {
|
||||||
|
// Defined relative dir to DOL_DATA_ROOT
|
||||||
|
$relativedir = '';
|
||||||
|
if ($filedir) {
|
||||||
|
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
|
||||||
|
$relativedir = preg_replace('/^[\\/]/', '', $relativedir);
|
||||||
|
}
|
||||||
|
// Get list of files stored into database for same relative directory
|
||||||
|
if ($relativedir) {
|
||||||
|
completeFileArrayWithDatabaseInfo($file_list, $relativedir);
|
||||||
|
|
||||||
|
//var_dump($sortfield.' - '.$sortorder);
|
||||||
|
if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
|
||||||
|
$file_list = dol_sort_array($file_list, $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
|
||||||
|
print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0, $param);
|
||||||
|
}
|
||||||
|
// $filename = dol_sanitizeFileName($objp->ref);
|
||||||
|
// $filedir = $conf->fichinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
// $urlsource = '/fichinter/card.php?id='.$objp->cid;
|
||||||
|
// print $formfile->getDocumentsLink($fichinter_static->element, $filename, $filedir);
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
//print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n";
|
//print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->startdate)).'</td>'."\n";
|
||||||
print '<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).'</td>'."\n";
|
print '<td class="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).'</td>'."\n";
|
||||||
@ -1213,6 +1364,7 @@ if ($object->id > 0) {
|
|||||||
print '<td class="nowrap">';
|
print '<td class="nowrap">';
|
||||||
print $invoicetemplate->getNomUrl(1);
|
print $invoicetemplate->getNomUrl(1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
if ($objp->frequency && $objp->date_last_gen > 0) {
|
if ($objp->frequency && $objp->date_last_gen > 0) {
|
||||||
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen), 'day').'</td>';
|
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->date_last_gen), 'day').'</td>';
|
||||||
} else {
|
} else {
|
||||||
@ -1301,6 +1453,35 @@ if ($object->id > 0) {
|
|||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td class="nowraponall">';
|
print '<td class="nowraponall">';
|
||||||
print $facturestatic->getNomUrl(1);
|
print $facturestatic->getNomUrl(1);
|
||||||
|
// Preview
|
||||||
|
$filedir = $conf->facture->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
$file_list = null;
|
||||||
|
if (!empty($filedir)) {
|
||||||
|
$file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC);
|
||||||
|
}
|
||||||
|
if (is_array($file_list)) {
|
||||||
|
// Defined relative dir to DOL_DATA_ROOT
|
||||||
|
$relativedir = '';
|
||||||
|
if ($filedir) {
|
||||||
|
$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $filedir);
|
||||||
|
$relativedir = preg_replace('/^[\\/]/', '', $relativedir);
|
||||||
|
}
|
||||||
|
// Get list of files stored into database for same relative directory
|
||||||
|
if ($relativedir) {
|
||||||
|
completeFileArrayWithDatabaseInfo($file_list, $relativedir);
|
||||||
|
|
||||||
|
//var_dump($sortfield.' - '.$sortorder);
|
||||||
|
if (!empty($sortfield) && !empty($sortorder)) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
|
||||||
|
$file_list = dol_sort_array($file_list, $sortfield, $sortorder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf';
|
||||||
|
print $formfile->showPreview($file_list, $facturestatic->element, $relativepath, 0, $param);
|
||||||
|
}
|
||||||
|
// $filename = dol_sanitizeFileName($objp->ref);
|
||||||
|
// $filedir = $conf->facture->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref);
|
||||||
|
// $urlsource = '/compta/facture/card.php?id='.$objp->cid;
|
||||||
|
//print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if ($objp->df > 0) {
|
if ($objp->df > 0) {
|
||||||
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->df), 'day').'</td>';
|
print '<td class="right" width="80px">'.dol_print_date($db->jdate($objp->df), 'day').'</td>';
|
||||||
|
|||||||
@ -88,7 +88,7 @@ if (empty($user->rights->societe->client->voir) && !$socid) {
|
|||||||
$sql .= " ".MAIN_DB_PREFIX."socpeople as p";
|
$sql .= " ".MAIN_DB_PREFIX."socpeople as p";
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
|
||||||
$sql .= " WHERE s.fk_stcomm = st.id";
|
$sql .= " WHERE s.fk_stcomm = st.id";
|
||||||
$sql .= " AND p.entity IN (".getEntity('socpeople').")";
|
$sql .= " AND p.entity IN (".getEntity('contact').")";
|
||||||
if (empty($user->rights->societe->client->voir) && !$socid) {
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
||||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -568,9 +568,15 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
|
|||||||
if (empty($user->rights->societe->client->voir) && !$socid) {
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
||||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||||
}
|
}
|
||||||
if ($socid) {
|
// Add where from hooks
|
||||||
$sql .= " AND s.rowid = $socid";
|
$parameters = array('socid' => $socid);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $companystatic); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) {
|
||||||
|
if ($socid > 0) {
|
||||||
|
$sql .= " AND s.rowid = ".((int) $socid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
$sql .= " ORDER BY s.tms DESC";
|
$sql .= " ORDER BY s.tms DESC";
|
||||||
$sql .= $db->plimit($max, 0);
|
$sql .= $db->plimit($max, 0);
|
||||||
|
|
||||||
@ -664,9 +670,15 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S
|
|||||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||||
}
|
}
|
||||||
if ($socid) {
|
// Add where from hooks
|
||||||
$sql .= " AND s.rowid = ".((int) $socid);
|
$parameters = array('socid' => $socid);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $companystatic); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) {
|
||||||
|
if ($socid > 0) {
|
||||||
|
$sql .= " AND s.rowid = ".((int) $socid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
$sql .= " ORDER BY s.datec DESC";
|
$sql .= " ORDER BY s.datec DESC";
|
||||||
$sql .= $db->plimit($max, 0);
|
$sql .= $db->plimit($max, 0);
|
||||||
|
|
||||||
|
|||||||
@ -686,7 +686,7 @@ class AdvanceTargetingMailing extends CommonObject
|
|||||||
|
|
||||||
$sqlwhere = array();
|
$sqlwhere = array();
|
||||||
|
|
||||||
$sqlwhere[] = 't.entity IN ('.getEntity('socpeople').')';
|
$sqlwhere[] = 't.entity IN ('.getEntity('contact').')';
|
||||||
|
|
||||||
if (count($arrayquery) > 0) {
|
if (count($arrayquery) > 0) {
|
||||||
if (array_key_exists('contact_categ', $arrayquery)) {
|
if (array_key_exists('contact_categ', $arrayquery)) {
|
||||||
|
|||||||
@ -116,7 +116,7 @@ $usercandelete = $user->rights->propal->supprimer;
|
|||||||
|
|
||||||
$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->close)));
|
$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->close)));
|
||||||
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate)));
|
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate)));
|
||||||
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send);
|
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send)));
|
||||||
|
|
||||||
$usercancreateorder = $user->rights->commande->creer;
|
$usercancreateorder = $user->rights->commande->creer;
|
||||||
$usercancreateinvoice = $user->rights->facture->creer;
|
$usercancreateinvoice = $user->rights->facture->creer;
|
||||||
@ -220,7 +220,7 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $object->createFromClone($user, $socid, (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : null));
|
$result = $object->createFromClone($user, $socid, (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : null), (GETPOST('update_prices', 'aZ') ? true : false));
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
|
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
|
||||||
exit();
|
exit();
|
||||||
@ -246,8 +246,11 @@ if (empty($reshook)) {
|
|||||||
// Remove line
|
// Remove line
|
||||||
$result = $object->deleteline($lineid);
|
$result = $object->deleteline($lineid);
|
||||||
// reorder lines
|
// reorder lines
|
||||||
if ($result) {
|
if ($result > 0) {
|
||||||
$object->line_order(true);
|
$object->line_order(true);
|
||||||
|
} else {
|
||||||
|
$langs->load("errors");
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||||
@ -1914,8 +1917,8 @@ if ($action == 'create') {
|
|||||||
$formquestion = array(
|
$formquestion = array(
|
||||||
// 'text' => $langs->trans("ConfirmClone"),
|
// 'text' => $langs->trans("ConfirmClone"),
|
||||||
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
|
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
|
||||||
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
|
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')),
|
||||||
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))
|
array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans('PuttingPricesUpToDate'), 'value' => (!empty($conf->global->PROPOSAL_CLONE_UPDATE_PRICES) ? 1 : 0)),
|
||||||
);
|
);
|
||||||
if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->delivery_date)) {
|
if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->delivery_date)) {
|
||||||
$formquestion[] = array('type' => 'date', 'name' => 'date_delivery', 'label' => $langs->trans("DeliveryDate"), 'value' => $object->delivery_date);
|
$formquestion[] = array('type' => 'date', 'name' => 'date_delivery', 'label' => $langs->trans("DeliveryDate"), 'value' => $object->delivery_date);
|
||||||
|
|||||||
@ -625,7 +625,7 @@ class Proposals extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*/
|
*/
|
||||||
public function deleteContact($id, $contactid, $type)
|
public function deleteContact($id, $contactid, $type)
|
||||||
{
|
{
|
||||||
@ -799,7 +799,7 @@ class Proposals extends DolibarrApi
|
|||||||
* @throws RestException 304
|
* @throws RestException 304
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -992,6 +992,8 @@ class Propal extends CommonObject
|
|||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
$this->error = $line->error;
|
||||||
|
$this->errors = $line->errors;
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1324,11 +1326,12 @@ class Propal extends CommonObject
|
|||||||
* @param User $user User making the clone
|
* @param User $user User making the clone
|
||||||
* @param int $socid Id of thirdparty
|
* @param int $socid Id of thirdparty
|
||||||
* @param int $forceentity Entity id to force
|
* @param int $forceentity Entity id to force
|
||||||
|
* @param bool $update_prices [=false] Update prices if true
|
||||||
* @return int New id of clone
|
* @return int New id of clone
|
||||||
*/
|
*/
|
||||||
public function createFromClone(User $user, $socid = 0, $forceentity = null)
|
public function createFromClone(User $user, $socid = 0, $forceentity = null, $update_prices = false)
|
||||||
{
|
{
|
||||||
global $conf, $hookmanager;
|
global $conf, $hookmanager, $mysoc;
|
||||||
|
|
||||||
dol_include_once('/projet/class/project.class.php');
|
dol_include_once('/projet/class/project.class.php');
|
||||||
|
|
||||||
@ -1375,6 +1378,55 @@ class Propal extends CommonObject
|
|||||||
$objsoc->fetch($object->socid);
|
$objsoc->fetch($object->socid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update prices
|
||||||
|
if ($update_prices === true) {
|
||||||
|
if ($objsoc->id > 0 && !empty($object->lines)) {
|
||||||
|
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||||
|
// If price per customer
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($object->lines as $line) {
|
||||||
|
if ($line->fk_product > 0) {
|
||||||
|
$prod = new Product($this->db);
|
||||||
|
$res = $prod->fetch($line->fk_product);
|
||||||
|
if ($res > 0) {
|
||||||
|
$pu_ht = $prod->price;
|
||||||
|
$tva_tx = get_default_tva($mysoc, $objsoc, $prod->id);
|
||||||
|
$remise_percent = $objsoc->remise_percent;
|
||||||
|
|
||||||
|
if (!empty($conf->global->PRODUIT_MULTIPRICES) && $objsoc->price_level > 0) {
|
||||||
|
$pu_ht = $prod->multiprices[$objsoc->price_level];
|
||||||
|
if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility
|
||||||
|
if (isset($prod->multiprices_tva_tx[$objsoc->price_level])) {
|
||||||
|
$tva_tx = $prod->multiprices_tva_tx[$objsoc->price_level];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
|
||||||
|
$prodcustprice = new Productcustomerprice($this->db);
|
||||||
|
$filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $objsoc->id);
|
||||||
|
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
||||||
|
if ($result) {
|
||||||
|
// If there is some prices specific to the customer
|
||||||
|
if (count($prodcustprice->lines) > 0) {
|
||||||
|
$pu_ht = price($prodcustprice->lines[0]->price);
|
||||||
|
$tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx);
|
||||||
|
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||||
|
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$line->subprice = $pu_ht;
|
||||||
|
$line->tva_tx = $tva_tx;
|
||||||
|
$line->remise_percent = $remise_percent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$object->id = 0;
|
$object->id = 0;
|
||||||
$object->ref = '';
|
$object->ref = '';
|
||||||
$object->entity = (!empty($forceentity) ? $forceentity : $object->entity);
|
$object->entity = (!empty($forceentity) ? $forceentity : $object->entity);
|
||||||
@ -1730,8 +1782,9 @@ class Propal extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function fetch_lines($only_product = 0, $loadalsotranslation = 0, $filters = '')
|
public function fetch_lines($only_product = 0, $loadalsotranslation = 0, $filters = '')
|
||||||
{
|
{
|
||||||
global $langs, $conf;
|
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
|
global $langs, $conf;
|
||||||
|
|
||||||
$this->lines = array();
|
$this->lines = array();
|
||||||
|
|
||||||
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
|
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
|
||||||
@ -4194,36 +4247,40 @@ class PropaleLigne extends CommonObjectLine
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".((int) $this->rowid);
|
if (!$notrigger) {
|
||||||
dol_syslog("PropaleLigne::delete", LOG_DEBUG);
|
// Call trigger
|
||||||
if ($this->db->query($sql)) {
|
$result = $this->call_trigger('LINEPROPAL_DELETE', $user);
|
||||||
// Remove extrafields
|
if ($result < 0) {
|
||||||
if (!$error) {
|
$error++;
|
||||||
$this->id = $this->rowid;
|
|
||||||
$result = $this->deleteExtraFields();
|
|
||||||
if ($result < 0) {
|
|
||||||
$error++;
|
|
||||||
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// End call triggers
|
||||||
|
|
||||||
if (!$error && !$notrigger) {
|
if (!$error) {
|
||||||
// Call trigger
|
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "propaldet WHERE rowid = " . ((int) $this->rowid);
|
||||||
$result = $this->call_trigger('LINEPROPAL_DELETE', $user);
|
dol_syslog("PropaleLigne::delete", LOG_DEBUG);
|
||||||
if ($result < 0) {
|
if ($this->db->query($sql)) {
|
||||||
$this->db->rollback();
|
// Remove extrafields
|
||||||
return -1;
|
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();
|
if ($error) {
|
||||||
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
$this->error = $this->db->error()." sql=".$sql;
|
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
|
} else {
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -356,9 +356,9 @@ if ($action == 'validate' && $permissiontovalidate) {
|
|||||||
$db->begin();
|
$db->begin();
|
||||||
$error = 0;
|
$error = 0;
|
||||||
foreach ($toselect as $checked) {
|
foreach ($toselect as $checked) {
|
||||||
if ($tmpproposal->fetch($checked)) {
|
if ($tmpproposal->fetch($checked) > 0) {
|
||||||
if ($tmpproposal->statut == 0) {
|
if ($tmpproposal->statut == $tmpproposal::STATUS_DRAFT) {
|
||||||
if ($tmpproposal->valid($user)) {
|
if ($tmpproposal->valid($user) > 0) {
|
||||||
setEventMessage($langs->trans('hasBeenValidated', $tmpproposal->ref), 'mesgs');
|
setEventMessage($langs->trans('hasBeenValidated', $tmpproposal->ref), 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessage($langs->trans('CantBeValidated'), 'errors');
|
setEventMessage($langs->trans('CantBeValidated'), 'errors');
|
||||||
@ -370,7 +370,7 @@ if ($action == 'validate' && $permissiontovalidate) {
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -388,13 +388,13 @@ if ($action == "sign" && $permissiontoclose) {
|
|||||||
$db->begin();
|
$db->begin();
|
||||||
$error = 0;
|
$error = 0;
|
||||||
foreach ($toselect as $checked) {
|
foreach ($toselect as $checked) {
|
||||||
if ($tmpproposal->fetch($checked)) {
|
if ($tmpproposal->fetch($checked) > 0) {
|
||||||
if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) {
|
if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) {
|
||||||
$tmpproposal->statut = $tmpproposal::STATUS_SIGNED;
|
$tmpproposal->statut = $tmpproposal::STATUS_SIGNED;
|
||||||
if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_SIGNED)) {
|
if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_SIGNED) >= 0) {
|
||||||
setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs');
|
setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -402,7 +402,7 @@ if ($action == "sign" && $permissiontoclose) {
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,27 +413,28 @@ if ($action == "sign" && $permissiontoclose) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == "nosign" && $permissiontoclose) {
|
if ($action == "nosign" && $permissiontoclose) {
|
||||||
if (GETPOST('confirm') == 'yes') {
|
if (GETPOST('confirm') == 'yes') {
|
||||||
$tmpproposal = new Propal($db);
|
$tmpproposal = new Propal($db);
|
||||||
$db->begin();
|
$db->begin();
|
||||||
$error = 0;
|
$error = 0;
|
||||||
foreach ($toselect as $checked) {
|
foreach ($toselect as $checked) {
|
||||||
if ($tmpproposal->fetch($checked)) {
|
if ($tmpproposal->fetch($checked) > 0) {
|
||||||
if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) {
|
if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) {
|
||||||
$tmpproposal->statut = $tmpproposal::STATUS_NOTSIGNED;
|
$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');
|
setEventMessage($tmpproposal->ref." ".$langs->trans('NoSigned'), 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeClosed'), 'errors');
|
setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeNoSign'), 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -574,7 +574,7 @@ class Orders extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*/
|
*/
|
||||||
public function deleteContact($id, $contactid, $type)
|
public function deleteContact($id, $contactid, $type)
|
||||||
{
|
{
|
||||||
@ -704,7 +704,7 @@ class Orders extends DolibarrApi
|
|||||||
* @throws RestException 304
|
* @throws RestException 304
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -974,7 +974,7 @@ class Orders extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*/
|
*/
|
||||||
public function getOrderShipments($id)
|
public function getOrderShipments($id)
|
||||||
{
|
{
|
||||||
@ -1030,7 +1030,7 @@ class Orders extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*/
|
*/
|
||||||
public function createOrderShipment($id, $warehouse_id)
|
public function createOrderShipment($id, $warehouse_id)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,9 +9,9 @@
|
|||||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||||
* Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2016-2022 Ferran Marcet <fmarcet@2byte.es>
|
||||||
* Copyright (C) 2021-2022 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2021-2022 Frédéric France <frederic.france@netlogic.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -519,6 +519,7 @@ class Commande extends CommonOrder
|
|||||||
if ($this->lines[$i]->fk_product > 0) {
|
if ($this->lines[$i]->fk_product > 0) {
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
$mouvP->origin = &$this;
|
$mouvP->origin = &$this;
|
||||||
|
$mouvP->setOrigin($this->element, $this->id);
|
||||||
// We decrement stock of product (and sub-products)
|
// We decrement stock of product (and sub-products)
|
||||||
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num));
|
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num));
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
@ -647,6 +648,7 @@ class Commande extends CommonOrder
|
|||||||
if ($this->lines[$i]->fk_product > 0) {
|
if ($this->lines[$i]->fk_product > 0) {
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
$mouvP->origin = &$this;
|
$mouvP->origin = &$this;
|
||||||
|
$mouvP->setOrigin($this->element, $this->id);
|
||||||
// We increment stock of product (and sub-products)
|
// We increment stock of product (and sub-products)
|
||||||
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr", $this->ref));
|
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr", $this->ref));
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
@ -828,6 +830,7 @@ class Commande extends CommonOrder
|
|||||||
for ($i = 0; $i < $num; $i++) {
|
for ($i = 0; $i < $num; $i++) {
|
||||||
if ($this->lines[$i]->fk_product > 0) {
|
if ($this->lines[$i]->fk_product > 0) {
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
|
$mouvP->setOrigin($this->element, $this->id);
|
||||||
// We increment stock of product (and sub-products)
|
// We increment stock of product (and sub-products)
|
||||||
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr", $this->ref)); // price is 0, we don't want WAP to be changed
|
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderCanceledInDolibarr", $this->ref)); // price is 0, we don't want WAP to be changed
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
@ -2028,8 +2031,9 @@ class Commande extends CommonOrder
|
|||||||
*/
|
*/
|
||||||
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
|
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
|
||||||
{
|
{
|
||||||
global $langs, $conf;
|
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
|
global $langs, $conf;
|
||||||
|
|
||||||
$this->lines = array();
|
$this->lines = array();
|
||||||
|
|
||||||
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,';
|
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,';
|
||||||
@ -3723,7 +3727,7 @@ class Commande extends CommonOrder
|
|||||||
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
|
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
|
||||||
}
|
}
|
||||||
if (!empty($this->date)) {
|
if (!empty($this->date)) {
|
||||||
$label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'dayhour');
|
$label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day');
|
||||||
}
|
}
|
||||||
if (!empty($this->delivery_date)) {
|
if (!empty($this->delivery_date)) {
|
||||||
$label .= '<br><b>'.$langs->trans('DeliveryDate').':</b> '.dol_print_date($this->delivery_date, 'dayhour');
|
$label .= '<br><b>'.$langs->trans('DeliveryDate').':</b> '.dol_print_date($this->delivery_date, 'dayhour');
|
||||||
|
|||||||
@ -345,7 +345,7 @@ if ($action == 'shipped' && $permissiontoadd) {
|
|||||||
$error = 0;
|
$error = 0;
|
||||||
foreach ($toselect as $checked) {
|
foreach ($toselect as $checked) {
|
||||||
if ($objecttmp->fetch($checked)) {
|
if ($objecttmp->fetch($checked)) {
|
||||||
if ($objecttmp->statut == 1) {
|
if ($objecttmp->statut == 1 || $objecttmp->statut == 2) {
|
||||||
if ($objecttmp->cloture($user)) {
|
if ($objecttmp->cloture($user)) {
|
||||||
setEventMessage($langs->trans('PassedInClosedStatus', $objecttmp->ref), 'mesgs');
|
setEventMessage($langs->trans('PassedInClosedStatus', $objecttmp->ref), 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -170,7 +170,7 @@ $arrayfields = array(
|
|||||||
'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>1000),
|
'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>1000),
|
||||||
'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1001),
|
'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1001),
|
||||||
'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>1010),
|
'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>1010),
|
||||||
'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>1020),
|
'b.conciliated'=>array('label'=>$langs->trans("BankLineReconciled"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>1020),
|
||||||
);
|
);
|
||||||
// Extra fields
|
// Extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||||
|
|||||||
@ -179,7 +179,7 @@ if (empty($reshook)) {
|
|||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'delete') {
|
if ($action == 'confirm_delete' && $confirm == 'yes') {
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
|
|
||||||
if ($object->rappro == 0) {
|
if ($object->rappro == 0) {
|
||||||
@ -543,6 +543,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);
|
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);
|
print dol_get_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto);
|
||||||
|
|
||||||
$morehtmlref = '<div class="refidno">';
|
$morehtmlref = '<div class="refidno">';
|
||||||
|
|||||||
@ -208,6 +208,9 @@ if (empty($reshook)) {
|
|||||||
$object->model_pdf = GETPOST('modelpdf', 'alpha');
|
$object->model_pdf = GETPOST('modelpdf', 'alpha');
|
||||||
$object->usenewprice = GETPOST('usenewprice', 'alpha');
|
$object->usenewprice = GETPOST('usenewprice', 'alpha');
|
||||||
|
|
||||||
|
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
|
||||||
|
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
|
||||||
|
|
||||||
$object->frequency = $frequency;
|
$object->frequency = $frequency;
|
||||||
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
|
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
|
||||||
$object->nb_gen_max = $nb_gen_max;
|
$object->nb_gen_max = $nb_gen_max;
|
||||||
@ -261,8 +264,6 @@ if (empty($reshook)) {
|
|||||||
} else {
|
} else {
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
|
|
||||||
$error++;
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
|
||||||
$action = "create";
|
$action = "create";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1027,12 +1028,14 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
// Payment term
|
// Payment term
|
||||||
print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>";
|
print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>";
|
||||||
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none');
|
print $form->getSelectConditionsPaiements(GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $object->cond_reglement_id, 'cond_reglement_id', -1, 0, 0, '');
|
||||||
|
//$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id');
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
// Payment mode
|
// Payment mode
|
||||||
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
|
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
|
||||||
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none', '', 1);
|
print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 0, 0, 1, '', 1);
|
||||||
|
//$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', '', 1);
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
// Project
|
// Project
|
||||||
@ -1040,8 +1043,9 @@ if ($action == 'create') {
|
|||||||
$projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
|
$projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
|
||||||
$langs->load('projects');
|
$langs->load('projects');
|
||||||
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
||||||
|
print img_picto('', 'project');
|
||||||
$numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
|
$numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
|
||||||
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->thirdparty->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.$langs->trans("AddProject").'</a>';
|
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->thirdparty->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').'</a>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1074,7 +1078,8 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
// Frequency + unit
|
// Frequency + unit
|
||||||
print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>";
|
print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>";
|
||||||
print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency') ?GETPOST('unit_frequency') : 'm'));
|
print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' /> ";
|
||||||
|
print $form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency') ?GETPOST('unit_frequency') : 'm'));
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
// Date next run
|
// Date next run
|
||||||
@ -1474,15 +1479,16 @@ if ($action == 'create') {
|
|||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<table class="nobordernopadding">';
|
print '<table class="nobordernopadding">';
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print "<input type='text' name='frequency' value='".$object->frequency."' size='5' /> ".$form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency ? $object->unit_frequency : 'm'));
|
print "<input type='text' name='frequency' value='".$object->frequency."' size='5' /> ";
|
||||||
|
print $form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency ? $object->unit_frequency : 'm'));
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"></td>';
|
print '<td class="left"><input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans("Modify").'"></td>';
|
||||||
print '</tr></table></form>';
|
print '</tr></table></form>';
|
||||||
} else {
|
} else {
|
||||||
if ($object->frequency > 0) {
|
if ($object->frequency > 0) {
|
||||||
print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
|
print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
|
||||||
} else {
|
} else {
|
||||||
print $langs->trans("NotARecurringInvoiceTemplate");
|
print '<span class="opacitymedium">'.$langs->trans("NotARecurringInvoiceTemplate").'</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|||||||
@ -302,6 +302,14 @@ if (empty($reshook)) {
|
|||||||
// Validation
|
// Validation
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
|
if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) {
|
||||||
|
$last_of_type = $object->willBeLastOfSameType();
|
||||||
|
if (empty($object->date_validation) && !$last_of_type[0]) {
|
||||||
|
setEventMessages($langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $object->ref, dol_print_date($object->date, 'day'), dol_print_date($last_of_type[1], 'day')), null, 'errors');
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// On verifie signe facture
|
// On verifie signe facture
|
||||||
if ($object->type == Facture::TYPE_CREDIT_NOTE) {
|
if ($object->type == Facture::TYPE_CREDIT_NOTE) {
|
||||||
// Si avoir, le signe doit etre negatif
|
// Si avoir, le signe doit etre negatif
|
||||||
@ -607,63 +615,6 @@ if (empty($reshook)) {
|
|||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$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', 'ACCOUNTANCY_CODE_CUSTOMER');
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($key == 'ACCOUNTANCY_CODE_CUSTOMER') {
|
|
||||||
// Check for mandatory
|
|
||||||
if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_INVOICE_MANDATORY) && empty($object->thirdparty->code_compta)) {
|
|
||||||
$langs->load("errors");
|
|
||||||
$error++;
|
|
||||||
setEventMessages($langs->trans("ErrorAccountancyCodeCustomerIsMandatory", $object->thirdparty->name).' ('.$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) {
|
|
||||||
$keymin = strtolower($key);
|
|
||||||
$vallabel = $object->$keymin;
|
|
||||||
|
|
||||||
// Check for mandatory
|
|
||||||
$keymandatory = 'INVOICE_'.$key.'_MANDATORY_FOR_VALIDATION';
|
|
||||||
if (!$vallabel && !empty($conf->global->$keymandatory)) {
|
|
||||||
$langs->load("errors");
|
|
||||||
$error++;
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for warehouse
|
// Check for warehouse
|
||||||
if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
|
if ($object->type != Facture::TYPE_DEPOSIT && !empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
|
||||||
$qualified_for_stock_change = 0;
|
$qualified_for_stock_change = 0;
|
||||||
@ -3058,7 +3009,7 @@ if ($action == 'create') {
|
|||||||
if (empty($conf->global->INVOICE_DISABLE_AUTOMATIC_RECURRING_INVOICE)) {
|
if (empty($conf->global->INVOICE_DISABLE_AUTOMATIC_RECURRING_INVOICE)) {
|
||||||
$text .= ' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name'));
|
$text .= ' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name'));
|
||||||
}
|
}
|
||||||
print info_admin($text, 0, 0, 0).'<br>';
|
print info_admin($text, 0, 0, 0, 'opacitymedium').'<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST" id="formtocreate" name="formtocreate">';
|
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST" id="formtocreate" name="formtocreate">';
|
||||||
@ -3857,7 +3808,6 @@ if ($action == 'create') {
|
|||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
} elseif ($id > 0 || !empty($ref)) {
|
} elseif ($id > 0 || !empty($ref)) {
|
||||||
if (empty($object->id)) {
|
if (empty($object->id)) {
|
||||||
llxHeader();
|
|
||||||
$langs->load('errors');
|
$langs->load('errors');
|
||||||
echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
|
echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
|
||||||
llxFooter();
|
llxFooter();
|
||||||
@ -4818,6 +4768,7 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
// List of previous situation invoices
|
// List of previous situation invoices
|
||||||
if (($object->situation_cycle_ref > 0) && !empty($conf->global->INVOICE_USE_SITUATION)) {
|
if (($object->situation_cycle_ref > 0) && !empty($conf->global->INVOICE_USE_SITUATION)) {
|
||||||
|
print '<!-- List of situation invoices -->';
|
||||||
print '<table class="noborder situationstable" width="100%">';
|
print '<table class="noborder situationstable" width="100%">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
@ -4956,15 +4907,16 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
// List of payments already done
|
// List of payments already done
|
||||||
|
|
||||||
|
print '<!-- List of payments already done -->';
|
||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
print '<table class="noborder paymenttable centpercent">';
|
print '<table class="noborder paymenttable centpercent">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td class="liste_titre">'.($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).'</td>';
|
print '<td class="liste_titre">'.($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).'</td>';
|
||||||
print '<td class="liste_titre">'.$langs->trans('Date').'</td>';
|
print '<td class="liste_titre"><span class="hideonsmartphone">'.$langs->trans('Date').'</span></td>';
|
||||||
print '<td class="liste_titre">'.$langs->trans('Type').'</td>';
|
print '<td class="liste_titre"><span class="hideonsmartphone">'.$langs->trans('Type').'</span></td>';
|
||||||
if (!empty($conf->banque->enabled)) {
|
if (!empty($conf->banque->enabled)) {
|
||||||
print '<td class="liste_titre">'.$langs->trans('BankAccount').'</td>';
|
print '<td class="liste_titre"><span class="hideonsmartphone">'.$langs->trans('BankAccount').'</span></td>';
|
||||||
}
|
}
|
||||||
print '<td class="liste_titre right">'.$langs->trans('Amount').'</td>';
|
print '<td class="liste_titre right">'.$langs->trans('Amount').'</td>';
|
||||||
print '<td class="liste_titre" width="18"> </td>';
|
print '<td class="liste_titre" width="18"> </td>';
|
||||||
@ -5359,6 +5311,12 @@ if ($action == 'create') {
|
|||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
|
$params = array(
|
||||||
|
'attr' => array(
|
||||||
|
'title' => '',
|
||||||
|
'class' => 'classfortooltip'
|
||||||
|
)
|
||||||
|
);
|
||||||
// Editer une facture deja validee, sans paiement effectue et pas exporte en compta
|
// Editer une facture deja validee, sans paiement effectue et pas exporte en compta
|
||||||
if ($object->statut == Facture::STATUS_VALIDATED) {
|
if ($object->statut == Facture::STATUS_VALIDATED) {
|
||||||
// We check if lines of invoice are not already transfered into accountancy
|
// We check if lines of invoice are not already transfered into accountancy
|
||||||
@ -5368,18 +5326,22 @@ if ($action == 'create') {
|
|||||||
if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == price2num($object->total_ttc, 'MT', 1) && empty($object->paye))) {
|
if (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_EDITED) || ($resteapayer == price2num($object->total_ttc, 'MT', 1) && empty($object->paye))) {
|
||||||
if (!$objectidnext && $object->is_last_in_cycle()) {
|
if (!$objectidnext && $object->is_last_in_cycle()) {
|
||||||
if ($usercanunvalidate) {
|
if ($usercanunvalidate) {
|
||||||
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif">'.$langs->trans('Modify').'</a>';
|
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<span class="butActionRefused classfortooltip" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Modify').'</span>';
|
$params['attr']['title'] = $langs->trans('NotEnoughPermissions');
|
||||||
|
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=modif', '', false, $params);
|
||||||
}
|
}
|
||||||
} elseif (!$object->is_last_in_cycle()) {
|
} elseif (!$object->is_last_in_cycle()) {
|
||||||
print '<span class="butActionRefused classfortooltip" title="'.$langs->trans("NotLastInCycle").'">'.$langs->trans('Modify').'</span>';
|
$params['attr']['title'] = $langs->trans('NotLastInCycle');
|
||||||
|
print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseReplacedInvoice").'">'.$langs->trans('Modify').'</span>';
|
$params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice');
|
||||||
|
print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print '<span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseDispatchedInBookkeeping").'">'.$langs->trans('Modify').'</span>';
|
$params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping');
|
||||||
|
print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5394,9 +5356,10 @@ if ($action == 'create') {
|
|||||||
&& ($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data
|
&& ($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data
|
||||||
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) { // A paid invoice (partially or completely)
|
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) { // A paid invoice (partially or completely)
|
||||||
if ($object->close_code != 'replaced' || (!$objectidnext)) { // Not replaced by another invoice or replaced but the replacement invoice has been deleted
|
if ($object->close_code != 'replaced' || (!$objectidnext)) { // Not replaced by another invoice or replaced but the replacement invoice has been deleted
|
||||||
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans('ReOpen').'</a>';
|
print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=reopen&token='.newToken(), '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseReplacedInvoice").'">'.$langs->trans('ReOpen').'</span>';
|
$params['attr']['title'] = $langs->trans("DisabledBecauseReplacedInvoice");
|
||||||
|
print dolGetButtonAction($langs->trans('ReOpen'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5414,7 +5377,7 @@ if ($action == 'create') {
|
|||||||
// Validate
|
// Validate
|
||||||
if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (!empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) {
|
if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (!empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) {
|
||||||
if ($usercanvalidate) {
|
if ($usercanvalidate) {
|
||||||
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=valid&token='.newToken().'">'.$langs->trans('Validate').'</a>';
|
print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=valid&token='.newToken(), '', true, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5425,9 +5388,9 @@ if ($action == 'create') {
|
|||||||
print '<span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseReplacedInvoice").'">'.$langs->trans('SendMail').'</span>';
|
print '<span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseReplacedInvoice").'">'.$langs->trans('SendMail').'</span>';
|
||||||
} else {
|
} else {
|
||||||
if ($usercansend) {
|
if ($usercansend) {
|
||||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>';
|
print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a>';
|
print dolGetButtonAction($langs->trans('SendMail'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5464,10 +5427,12 @@ if ($action == 'create') {
|
|||||||
} else {
|
} else {
|
||||||
if ($object->type == Facture::TYPE_DEPOSIT && $resteapayer == 0) {
|
if ($object->type == Facture::TYPE_DEPOSIT && $resteapayer == 0) {
|
||||||
// For down payment, we refuse to receive more than amount to pay.
|
// For down payment, we refuse to receive more than amount to pay.
|
||||||
print '<span class="butActionRefused" title="'.$langs->trans("DisabledBecauseRemainderToPayIsZero").'">'.$langs->trans('DoPayment').'</span>';
|
$params['attr']['title'] = $langs->trans('DisabledBecauseRemainderToPayIsZero');
|
||||||
|
print dolGetButtonAction($langs->trans('DoPayment'), '', 'default', '#', '', false, $params);
|
||||||
} else {
|
} else {
|
||||||
// Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done)
|
// Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done)
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/paiement.php?facid='.$object->id.'&action=create&accountid='.$object->fk_account.'">'.$langs->trans('DoPayment').'</a>';
|
//print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/paiement.php?facid='.$object->id.'&action=create&accountid='.$object->fk_account.'">'.$langs->trans('DoPayment').'</a>';
|
||||||
|
print dolGetButtonAction($langs->trans('DoPayment'), '', 'default', DOL_URL_ROOT.'/compta/paiement.php?facid='.$object->id.'&action=create&accountid='.$object->fk_account, '', true, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5516,9 +5481,10 @@ if ($action == 'create') {
|
|||||||
) {
|
) {
|
||||||
if ($object->type == Facture::TYPE_DEPOSIT && price2num($object->total_ttc, 'MT') != price2num($sumofpaymentall, 'MT')) {
|
if ($object->type == Facture::TYPE_DEPOSIT && price2num($object->total_ttc, 'MT') != price2num($sumofpaymentall, 'MT')) {
|
||||||
// We can close a down payment only if paid amount is same than amount of down payment (by definition)
|
// We can close a down payment only if paid amount is same than amount of down payment (by definition)
|
||||||
print '<span class="butActionRefused" title="'.$langs->trans("AmountPaidMustMatchAmountOfDownPayment").'">'.$langs->trans('ClassifyPaid').'</span>';
|
$params['attr']['title'] = $langs->trans('AmountPaidMustMatchAmountOfDownPayment');
|
||||||
|
print dolGetButtonAction($langs->trans('ClassifyPaid'), '', 'default', '#', '', false, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=paid">'.$langs->trans('ClassifyPaid').'</a>';
|
print dolGetButtonAction($langs->trans('ClassifyPaid'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=paid', '', true, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5563,13 +5529,13 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
// Clone
|
// Clone
|
||||||
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate) {
|
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate) {
|
||||||
print '<a class="butAction'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=clone&object=invoice">'.$langs->trans("ToClone").'</a>';
|
print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?facid='.$object->id.'&action=clone&object=invoice', '', true, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone as predefined / Create template
|
// Clone as predefined / Create template
|
||||||
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $usercancreate) {
|
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $usercancreate) {
|
||||||
if (!$objectidnext && count($object->lines) > 0) {
|
if (!$objectidnext && count($object->lines) > 0) {
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$object->id.'&action=create">'.$langs->trans("ChangeIntoRepeatableInvoice").'</a>';
|
print dolGetButtonAction($langs->trans('ChangeIntoRepeatableInvoice'), '', 'default', DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$object->id.'&action=create', '', true, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5602,25 +5568,35 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
$isErasable = $object->is_erasable();
|
$isErasable = $object->is_erasable();
|
||||||
|
$params = array(
|
||||||
|
'attr' => array(
|
||||||
|
'title' => '',
|
||||||
|
'class' => 'classfortooltip'
|
||||||
|
)
|
||||||
|
);
|
||||||
if ($usercandelete || ($usercancreate && $isErasable == 1)) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
|
if ($usercandelete || ($usercancreate && $isErasable == 1)) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
|
||||||
//var_dump($isErasable);
|
$enableDelete = false;
|
||||||
|
$deleteHref = '#';
|
||||||
if ($isErasable == -4) {
|
if ($isErasable == -4) {
|
||||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecausePayments").'">'.$langs->trans('Delete').'</a>';
|
$params['attr']['title'] = $langs->trans('DisabledBecausePayments');
|
||||||
} elseif ($isErasable == -3) {
|
} elseif ($isErasable == -3) {
|
||||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotLastSituationInvoice").'">'.$langs->trans('Delete').'</a>';
|
$params['attr']['title'] = $langs->trans('DisabledBecauseNotLastSituationInvoice');
|
||||||
} elseif ($isErasable == -2) {
|
} elseif ($isErasable == -2) {
|
||||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotLastInvoice").'">'.$langs->trans('Delete').'</a>';
|
$params['attr']['title'] = $langs->trans('DisabledBecauseNotLastInvoice');
|
||||||
} elseif ($isErasable == -1) {
|
} elseif ($isErasable == -1) {
|
||||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseDispatchedInBookkeeping").'">'.$langs->trans('Delete').'</a>';
|
$params['attr']['title'] = $langs->trans('DisabledBecauseDispatchedInBookkeeping');
|
||||||
} elseif ($isErasable <= 0) { // Any other cases
|
} elseif ($isErasable <= 0) { // Any other cases
|
||||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseNotErasable").'">'.$langs->trans('Delete').'</a>';
|
$params['attr']['title'] = $langs->trans('DisabledBecauseNotErasable');
|
||||||
} elseif ($objectidnext) {
|
} elseif ($objectidnext) {
|
||||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("DisabledBecauseReplacedInvoice").'">'.$langs->trans('Delete').'</a>';
|
$params['attr']['title'] = $langs->trans('DisabledBecauseReplacedInvoice');
|
||||||
} else {
|
} else {
|
||||||
print '<a class="butActionDelete'.($conf->use_javascript_ajax ? ' reposition' : '').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>';
|
$deleteHref = $_SERVER["PHP_SELF"].'?facid='.$object->id.'&action=delete&token='.newToken();
|
||||||
|
$enableDelete = true;
|
||||||
}
|
}
|
||||||
|
print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $deleteHref, '', $enableDelete, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
|
$params['attr']['title'] = $langs->trans('NotAllowed');
|
||||||
|
print dolGetButtonAction($langs->trans('Delete'), '', 'delete', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
@ -519,7 +519,7 @@ class Invoices extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*/
|
*/
|
||||||
public function deleteContact($id, $contactid, $type)
|
public function deleteContact($id, $contactid, $type)
|
||||||
{
|
{
|
||||||
@ -661,7 +661,7 @@ class Invoices extends DolibarrApi
|
|||||||
|
|
||||||
$result = $this->invoice->delete(DolibarrApiAccess::$user);
|
$result = $this->invoice->delete(DolibarrApiAccess::$user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
throw new RestException(500);
|
throw new RestException(500, 'Error when deleting invoice');
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
@ -780,7 +780,7 @@ class Invoices extends DolibarrApi
|
|||||||
* @throws RestException 304
|
* @throws RestException 304
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0)
|
public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0)
|
||||||
@ -829,7 +829,7 @@ class Invoices extends DolibarrApi
|
|||||||
* @throws RestException 304
|
* @throws RestException 304
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function settodraft($id, $idwarehouse = -1)
|
public function settodraft($id, $idwarehouse = -1)
|
||||||
@ -932,7 +932,7 @@ class Invoices extends DolibarrApi
|
|||||||
* @throws RestException 304
|
* @throws RestException 304
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*/
|
*/
|
||||||
public function settopaid($id, $close_code = '', $close_note = '')
|
public function settopaid($id, $close_code = '', $close_note = '')
|
||||||
{
|
{
|
||||||
@ -982,7 +982,7 @@ class Invoices extends DolibarrApi
|
|||||||
* @throws RestException 304
|
* @throws RestException 304
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*/
|
*/
|
||||||
public function settounpaid($id)
|
public function settounpaid($id)
|
||||||
{
|
{
|
||||||
@ -1069,7 +1069,7 @@ class Invoices extends DolibarrApi
|
|||||||
* @throws RestException 304
|
* @throws RestException 304
|
||||||
* @throws RestException 401
|
* @throws RestException 401
|
||||||
* @throws RestException 404
|
* @throws RestException 404
|
||||||
* @throws RestException 500
|
* @throws RestException 500 System error
|
||||||
*/
|
*/
|
||||||
public function markAsCreditAvailable($id)
|
public function markAsCreditAvailable($id)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -309,10 +309,10 @@ class FactureRec extends CommonInvoice
|
|||||||
$sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "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");
|
$sql .= ", ".(!empty($this->model_pdf) ? ("'".$this->db->escape($this->model_pdf)."'") : "NULL");
|
||||||
$sql .= ", ".((int) $user->id);
|
$sql .= ", ".((int) $user->id);
|
||||||
$sql .= ", ".(!empty($facsrc->fk_project) ? ((int) $facsrc->fk_project) : "null");
|
$sql .= ", ".(!empty($this->fk_project) ? ((int) $this->fk_project) : "null");
|
||||||
$sql .= ", ".(!empty($facsrc->fk_account) ? ((int) $facsrc->fk_account) : "null");
|
$sql .= ", ".(!empty($facsrc->fk_account) ? ((int) $facsrc->fk_account) : "null");
|
||||||
$sql .= ", ".($facsrc->cond_reglement_id > 0 ? ((int) $facsrc->cond_reglement_id) : "null");
|
$sql .= ", ".($this->cond_reglement_id > 0 ? ((int) $this->cond_reglement_id) : "null");
|
||||||
$sql .= ", ".($facsrc->mode_reglement_id > 0 ? ((int) $facsrc->mode_reglement_id) : "null");
|
$sql .= ", ".($this->mode_reglement_id > 0 ? ((int) $this->mode_reglement_id) : "null");
|
||||||
$sql .= ", ".((int) $this->usenewprice);
|
$sql .= ", ".((int) $this->usenewprice);
|
||||||
$sql .= ", ".((int) $this->frequency);
|
$sql .= ", ".((int) $this->frequency);
|
||||||
$sql .= ", '".$this->db->escape($this->unit_frequency)."'";
|
$sql .= ", '".$this->db->escape($this->unit_frequency)."'";
|
||||||
@ -344,6 +344,9 @@ class FactureRec extends CommonInvoice
|
|||||||
$tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')';
|
$tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$default_start_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_START');
|
||||||
|
$default_end_fill = getDolGlobalInt('INVOICEREC_SET_AUTOFILL_DATE_END');
|
||||||
|
|
||||||
$result_insert = $this->addline(
|
$result_insert = $this->addline(
|
||||||
$facsrc->lines[$i]->desc,
|
$facsrc->lines[$i]->desc,
|
||||||
$facsrc->lines[$i]->subprice,
|
$facsrc->lines[$i]->subprice,
|
||||||
@ -363,8 +366,8 @@ class FactureRec extends CommonInvoice
|
|||||||
$facsrc->lines[$i]->label,
|
$facsrc->lines[$i]->label,
|
||||||
$facsrc->lines[$i]->fk_unit,
|
$facsrc->lines[$i]->fk_unit,
|
||||||
$facsrc->lines[$i]->multicurrency_subprice,
|
$facsrc->lines[$i]->multicurrency_subprice,
|
||||||
0,
|
$default_start_fill,
|
||||||
0,
|
$default_end_fill,
|
||||||
null,
|
null,
|
||||||
$facsrc->lines[$i]->pa_ht
|
$facsrc->lines[$i]->pa_ht
|
||||||
);
|
);
|
||||||
@ -524,6 +527,8 @@ class FactureRec extends CommonInvoice
|
|||||||
*/
|
*/
|
||||||
public function fetch($rowid, $ref = '', $ref_ext = '')
|
public function fetch($rowid, $ref = '', $ref_ext = '')
|
||||||
{
|
{
|
||||||
|
dol_syslog('FactureRec::fetch', LOG_DEBUG);
|
||||||
|
|
||||||
$sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.total_tva, f.localtax1, f.localtax2, f.total_ht, f.total_ttc';
|
$sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.total_tva, f.localtax1, f.localtax2, f.total_ht, f.total_ttc';
|
||||||
$sql .= ', f.remise_percent, f.remise_absolue, f.remise';
|
$sql .= ', f.remise_percent, f.remise_absolue, f.remise';
|
||||||
$sql .= ', f.date_lim_reglement as dlr';
|
$sql .= ', f.date_lim_reglement as dlr';
|
||||||
@ -655,18 +660,20 @@ class FactureRec extends CommonInvoice
|
|||||||
*/
|
*/
|
||||||
public function fetch_lines()
|
public function fetch_lines()
|
||||||
{
|
{
|
||||||
global $extrafields;
|
|
||||||
|
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
|
|
||||||
$this->lines = array();
|
$this->lines = array();
|
||||||
|
|
||||||
// Retrieve all extrafield for line
|
// Retrieve all extrafield for line
|
||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
if (!is_object($extrafields)) {
|
/*if (!is_object($extrafields)) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
$extrafields = new ExtraFields($this->db);
|
$extrafields = new ExtraFields($this->db);
|
||||||
}
|
}
|
||||||
$extrafields->fetch_name_optionals_label($this->table_element_line, true);
|
$extrafields->fetch_name_optionals_label($this->table_element_line, true);
|
||||||
|
*/
|
||||||
|
|
||||||
|
dol_syslog('FactureRec::fetch_lines', LOG_DEBUG);
|
||||||
|
|
||||||
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, ';
|
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, ';
|
||||||
$sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,';
|
$sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,';
|
||||||
@ -680,7 +687,6 @@ class FactureRec extends CommonInvoice
|
|||||||
$sql .= ' WHERE l.fk_facture = '.((int) $this->id);
|
$sql .= ' WHERE l.fk_facture = '.((int) $this->id);
|
||||||
$sql .= ' ORDER BY l.rang';
|
$sql .= ' ORDER BY l.rang';
|
||||||
|
|
||||||
dol_syslog('FactureRec::fetch_lines', LOG_DEBUG);
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
* Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
|
* Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
|
||||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2016-2022 Ferran Marcet <fmarcet@2byte.es>
|
||||||
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||||
* Copyright (C) 2022 Sylvain Legrand <contact@infras.fr>
|
* Copyright (C) 2022 Sylvain Legrand <contact@infras.fr>
|
||||||
@ -1775,8 +1775,9 @@ class Facture extends CommonInvoice
|
|||||||
*/
|
*/
|
||||||
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
|
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
|
||||||
{
|
{
|
||||||
global $langs, $conf;
|
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
|
global $langs, $conf;
|
||||||
|
|
||||||
$this->lines = array();
|
$this->lines = array();
|
||||||
|
|
||||||
$sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
|
$sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
|
||||||
@ -2326,6 +2327,7 @@ class Facture extends CommonInvoice
|
|||||||
if ($this->lines[$i]->fk_product > 0) {
|
if ($this->lines[$i]->fk_product > 0) {
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
$mouvP->origin = &$this;
|
$mouvP->origin = &$this;
|
||||||
|
$mouvP->setOrigin($this->element, $this->id);
|
||||||
// We decrease stock for product
|
// We decrease stock for product
|
||||||
if ($this->type == self::TYPE_CREDIT_NOTE) {
|
if ($this->type == self::TYPE_CREDIT_NOTE) {
|
||||||
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref));
|
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceDeleteDolibarr", $this->ref));
|
||||||
@ -2632,7 +2634,7 @@ class Facture extends CommonInvoice
|
|||||||
*/
|
*/
|
||||||
public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0, $batch_rule = 0)
|
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';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
|
||||||
$productStatic = null;
|
$productStatic = null;
|
||||||
@ -2671,6 +2673,66 @@ class Facture extends CommonInvoice
|
|||||||
dol_syslog(get_class($this)."::validate ".$this->error.' MAIN_USE_ADVANCED_PERMS='.$conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR);
|
dol_syslog(get_class($this)."::validate ".$this->error.' MAIN_USE_ADVANCED_PERMS='.$conf->global->MAIN_USE_ADVANCED_PERMS, LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (!empty($conf->global-> INVOICE_CHECK_POSTERIOR_DATE)) {
|
||||||
|
$last_of_type = $this->willBeLastOfSameType();
|
||||||
|
if (!$last_of_type[0]) {
|
||||||
|
$this->error = $langs->transnoentities("ErrorInvoiceIsNotLastOfSameType", $this->ref, dol_print_date($this->date, 'day'), dol_print_date($last_of_type[1], 'day'));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for mandatory fields in thirdparty (defined into setup)
|
||||||
|
if (!empty($this->thirdparty) && is_object($this->thirdparty)) {
|
||||||
|
$array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL');
|
||||||
|
foreach ($array_to_check as $key) {
|
||||||
|
$keymin = strtolower($key);
|
||||||
|
if (!property_exists($this->thirdparty, $keymin)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$vallabel = $this->thirdparty->$keymin;
|
||||||
|
|
||||||
|
$i = (int) preg_replace('/[^0-9]/', '', $key);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for mandatory fields in $this
|
||||||
|
$array_to_check = array('REF_CLIENT'=>'RefCustomer');
|
||||||
|
foreach ($array_to_check as $key => $val) {
|
||||||
|
$keymin = strtolower($key);
|
||||||
|
$vallabel = $this->$keymin;
|
||||||
|
|
||||||
|
// Check for mandatory
|
||||||
|
$keymandatory = 'INVOICE_'.$key.'_MANDATORY_FOR_VALIDATION';
|
||||||
|
if (!$vallabel && !empty($conf->global->$keymandatory)) {
|
||||||
|
$langs->load("errors");
|
||||||
|
$error++;
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
@ -2763,6 +2825,7 @@ class Facture extends CommonInvoice
|
|||||||
if ($this->lines[$i]->fk_product > 0) {
|
if ($this->lines[$i]->fk_product > 0) {
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
$mouvP->origin = &$this;
|
$mouvP->origin = &$this;
|
||||||
|
$mouvP->setOrigin($this->element, $this->id);
|
||||||
// We decrease stock for product
|
// We decrease stock for product
|
||||||
if ($this->type == self::TYPE_CREDIT_NOTE) {
|
if ($this->type == self::TYPE_CREDIT_NOTE) {
|
||||||
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num));
|
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num));
|
||||||
@ -3055,6 +3118,7 @@ class Facture extends CommonInvoice
|
|||||||
if ($this->lines[$i]->fk_product > 0) {
|
if ($this->lines[$i]->fk_product > 0) {
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
$mouvP->origin = &$this;
|
$mouvP->origin = &$this;
|
||||||
|
$mouvP->setOrigin($this->element, $this->id);
|
||||||
// We decrease stock for product
|
// We decrease stock for product
|
||||||
if ($this->type == self::TYPE_CREDIT_NOTE) {
|
if ($this->type == self::TYPE_CREDIT_NOTE) {
|
||||||
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref));
|
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref));
|
||||||
@ -5123,6 +5187,37 @@ class Facture extends CommonInvoice
|
|||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See if current invoice date is posterior to the last invoice date among validated invoices of same type.
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function willBeLastOfSameType()
|
||||||
|
{
|
||||||
|
// get date of last validated invoices of same type
|
||||||
|
$sql = "SELECT datef";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
|
||||||
|
$sql .= " WHERE type = " . (int) $this->type ;
|
||||||
|
$sql .= " AND date_valid IS NOT NULL";
|
||||||
|
$sql .= " ORDER BY datef DESC LIMIT 1";
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ($result) {
|
||||||
|
// compare with current validation date
|
||||||
|
if ($this->db->num_rows($result)) {
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
$last_date = $this->db->jdate($obj->datef);
|
||||||
|
$invoice_date = $this->date;
|
||||||
|
|
||||||
|
return [$invoice_date >= $last_date, $last_date];
|
||||||
|
} else {
|
||||||
|
// element is first of type to be validated
|
||||||
|
return [true];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -721,7 +721,6 @@ if ($resql) {
|
|||||||
if (!empty($arrayfields['f.titre']['checked'])) {
|
if (!empty($arrayfields['f.titre']['checked'])) {
|
||||||
print '<td class="nowrap tdoverflowmax200">';
|
print '<td class="nowrap tdoverflowmax200">';
|
||||||
print $invoicerectmp->getNomUrl(1);
|
print $invoicerectmp->getNomUrl(1);
|
||||||
print "</a>";
|
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
if (!$i) {
|
if (!$i) {
|
||||||
$totalarray['nbfield']++;
|
$totalarray['nbfield']++;
|
||||||
@ -765,7 +764,7 @@ if ($resql) {
|
|||||||
}
|
}
|
||||||
// Payment term
|
// Payment term
|
||||||
if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
|
if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) {
|
||||||
print '<td class="right">';
|
print '<td class="tdoverflowmax150">';
|
||||||
$form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
|
$form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none');
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
if (!$i) {
|
if (!$i) {
|
||||||
@ -774,7 +773,7 @@ if ($resql) {
|
|||||||
}
|
}
|
||||||
// Payment mode
|
// Payment mode
|
||||||
if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
|
if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) {
|
||||||
print '<td class="right">';
|
print '<td class="tdoverflowmax150">';
|
||||||
$form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
|
$form->form_modes_reglement('', $objp->fk_mode_reglement, 'none');
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
if (!$i) {
|
if (!$i) {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
|
|||||||
$trclass .= ' liste_sub_total';
|
$trclass .= ' liste_sub_total';
|
||||||
}
|
}
|
||||||
print '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
|
print '<tr class="'.$trclass.'" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" >';
|
||||||
print '<td class="linkedcol-element">';
|
print '<td class="linkedcol-element tdoverflowmax100">';
|
||||||
switch ($objectlink->type) {
|
switch ($objectlink->type) {
|
||||||
case Facture::TYPE_REPLACEMENT:
|
case Facture::TYPE_REPLACEMENT:
|
||||||
echo $langs->trans("InvoiceReplacement");
|
echo $langs->trans("InvoiceReplacement");
|
||||||
|
|||||||
@ -46,7 +46,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tr class="<?php echo $trclass; ?>" >
|
<tr class="<?php echo $trclass; ?>" >
|
||||||
<td class="linkedcol-element"><?php echo $langs->trans("RepeatableInvoice"); ?></td>
|
<td class="linkedcol-element tdoverflowmax100"><?php echo $langs->trans("RepeatableInvoice"); ?></td>
|
||||||
<td class="linkedcol-name"><!-- nowraponall because ref is a label --><?php echo $objectlink->getNomUrl(1); ?></td>
|
<td class="linkedcol-name"><!-- nowraponall because ref is a label --><?php echo $objectlink->getNomUrl(1); ?></td>
|
||||||
<td class="linkedcol-ref" align="center"></td>
|
<td class="linkedcol-ref" align="center"></td>
|
||||||
<td class="linkedcol-date" align="center"><?php echo dol_print_date($objectlink->date_when, 'day'); ?></td>
|
<td class="linkedcol-date" align="center"><?php echo dol_print_date($objectlink->date_when, 'day'); ?></td>
|
||||||
|
|||||||
@ -491,8 +491,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
if ($facture->type == 2) {
|
if ($facture->type == 2) {
|
||||||
print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>';
|
print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', 0, '', 1);
|
print img_picto('', 'bank_account');
|
||||||
|
print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', 0, 'widthcentpercentminusx maxwidth500', 1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
} else {
|
} else {
|
||||||
print '<td> </td>';
|
print '<td> </td>';
|
||||||
@ -501,26 +503,27 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
|||||||
|
|
||||||
// Bank check number
|
// Bank check number
|
||||||
print '<tr><td>'.$langs->trans('Numero');
|
print '<tr><td>'.$langs->trans('Numero');
|
||||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
print ' <em class="opacitymedium">('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.'"></td></tr>';
|
print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.'"></td></tr>';
|
||||||
|
|
||||||
// Check transmitter
|
// Check transmitter
|
||||||
print '<tr><td class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter');
|
print '<tr><td class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter');
|
||||||
print ' <em>('.$langs->trans("ChequeMaker").')</em>';
|
print ' <em class="opacitymedium">('.$langs->trans("ChequeMaker").')</em>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
|
print '<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
|
||||||
|
|
||||||
// Bank name
|
// Bank name
|
||||||
print '<tr><td>'.$langs->trans('Bank');
|
print '<tr><td>'.$langs->trans('Bank');
|
||||||
print ' <em>('.$langs->trans("ChequeBank").')</em>';
|
print ' <em class="opacitymedium">('.$langs->trans("ChequeBank").')</em>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
|
print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
print '<tr><td>'.$langs->trans('Comments').'</td>';
|
print '<tr><td>'.$langs->trans('Comments').'</td>';
|
||||||
print '<td class="tdtop">';
|
print '<td class="tdtop">';
|
||||||
print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment', 'restricthtml').'</textarea></td></tr>';
|
print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment', 'restricthtml').'</textarea>';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -730,7 +730,7 @@ class RemiseCheque extends CommonObject
|
|||||||
$bankline = new AccountLine($db);
|
$bankline = new AccountLine($db);
|
||||||
$bankline->fetch($bank_id);
|
$bankline->fetch($bank_id);
|
||||||
|
|
||||||
/* Conciliation is allowed because when check is returned, a new line is created onto bank transaction log.
|
/* Reconciliation is allowed because when check is returned, a new line is created onto bank transaction log.
|
||||||
if ($bankline->rappro)
|
if ($bankline->rappro)
|
||||||
{
|
{
|
||||||
$this->error='ActionRefusedLineAlreadyConciliated';
|
$this->error='ActionRefusedLineAlreadyConciliated';
|
||||||
@ -739,7 +739,7 @@ class RemiseCheque extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Not conciliated, we can delete it
|
// Not reconciled, we can delete it
|
||||||
//$bankline->delete($user); // We delete
|
//$bankline->delete($user); // We delete
|
||||||
|
|
||||||
$bankaccount = $payment->fk_account;
|
$bankaccount = $payment->fk_account;
|
||||||
|
|||||||
@ -309,20 +309,22 @@ if ($id > 0 || $ref) {
|
|||||||
// Actions
|
// Actions
|
||||||
if ($action != 'settransmitted' && $action != 'setcredited') {
|
if ($action != 'settransmitted' && $action != 'setcredited') {
|
||||||
print "\n".'<div class="tabsAction">'."\n";
|
print "\n".'<div class="tabsAction">'."\n";
|
||||||
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) {
|
||||||
|
if (empty($object->date_trans)) {
|
||||||
|
if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->send);
|
||||||
|
else print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->send);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($object->date_trans)) {
|
if (!empty($object->date_trans) && $object->date_credit == 0) {
|
||||||
if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->send);
|
if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("ClassDebited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->debit);
|
||||||
else print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->send);
|
else print dolGetButtonAction($langs->trans("ClassCredited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->credit);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->create);
|
||||||
|
else print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->creer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($object->date_trans) && $object->date_credit == 0) {
|
|
||||||
if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("ClassDebited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->debit);
|
|
||||||
else print dolGetButtonAction($langs->trans("ClassCredited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->credit);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->create);
|
|
||||||
else print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->creer);
|
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1831,7 +1831,7 @@ class BonPrelevement extends CommonObject
|
|||||||
$DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d');
|
$DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d');
|
||||||
|
|
||||||
if ($type != 'bank-transfer') {
|
if ($type != 'bank-transfer') {
|
||||||
// SEPA Paiement Information of buyer for Direct debit
|
// SEPA Paiement Information of buyer for Direct Debit
|
||||||
$XML_DEBITOR = '';
|
$XML_DEBITOR = '';
|
||||||
$XML_DEBITOR .= ' <DrctDbtTxInf>'.$CrLf;
|
$XML_DEBITOR .= ' <DrctDbtTxInf>'.$CrLf;
|
||||||
$XML_DEBITOR .= ' <PmtId>'.$CrLf;
|
$XML_DEBITOR .= ' <PmtId>'.$CrLf;
|
||||||
@ -1884,7 +1884,7 @@ class BonPrelevement extends CommonObject
|
|||||||
// Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum)
|
// Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum)
|
||||||
$XML_CREDITOR .= ' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('CT-'.dol_trunc($row_idfac.'-'.$row_ref, 20, 'right', 'UTF-8', 1)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
|
$XML_CREDITOR .= ' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('CT-'.dol_trunc($row_idfac.'-'.$row_ref, 20, 'right', 'UTF-8', 1)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters
|
||||||
$XML_CREDITOR .= ' </PmtId>'.$CrLf;
|
$XML_CREDITOR .= ' </PmtId>'.$CrLf;
|
||||||
if ($this->sepa_xml_pti_in_ctti) {
|
if (!empty($this->sepa_xml_pti_in_ctti)) {
|
||||||
$XML_CREDITOR .= ' <PmtTpInf>' . $CrLf;
|
$XML_CREDITOR .= ' <PmtTpInf>' . $CrLf;
|
||||||
|
|
||||||
// Can be 'NORM' for normal or 'HIGH' for high priority level
|
// Can be 'NORM' for normal or 'HIGH' for high priority level
|
||||||
@ -2076,7 +2076,7 @@ class BonPrelevement extends CommonObject
|
|||||||
$RefBon = $obj->ref;
|
$RefBon = $obj->ref;
|
||||||
|
|
||||||
if ($type != 'bank-transfer') {
|
if ($type != 'bank-transfer') {
|
||||||
// SEPA Paiement Information of my company for Direct debit
|
// SEPA Paiement Information of my company for Direct Debit
|
||||||
$XML_SEPA_INFO = '';
|
$XML_SEPA_INFO = '';
|
||||||
$XML_SEPA_INFO .= ' <PmtInf>'.$CrLf;
|
$XML_SEPA_INFO .= ' <PmtInf>'.$CrLf;
|
||||||
$XML_SEPA_INFO .= ' <PmtInfId>'.('DD/'.$dateTime_YMD.'/ID'.$IdBon.'-'.$RefBon).'</PmtInfId>'.$CrLf;
|
$XML_SEPA_INFO .= ' <PmtInfId>'.('DD/'.$dateTime_YMD.'/ID'.$IdBon.'-'.$RefBon).'</PmtInfId>'.$CrLf;
|
||||||
@ -2147,7 +2147,7 @@ class BonPrelevement extends CommonObject
|
|||||||
//$XML_SEPA_INFO .= ' <BtchBookg>False</BtchBookg>'.$CrLf;
|
//$XML_SEPA_INFO .= ' <BtchBookg>False</BtchBookg>'.$CrLf;
|
||||||
$XML_SEPA_INFO .= ' <NbOfTxs>'.$nombre.'</NbOfTxs>'.$CrLf;
|
$XML_SEPA_INFO .= ' <NbOfTxs>'.$nombre.'</NbOfTxs>'.$CrLf;
|
||||||
$XML_SEPA_INFO .= ' <CtrlSum>'.$total.'</CtrlSum>'.$CrLf;
|
$XML_SEPA_INFO .= ' <CtrlSum>'.$total.'</CtrlSum>'.$CrLf;
|
||||||
if (!$this->sepa_xml_pti_in_ctti) {
|
if (!empty($this->sepa_xml_pti_in_ctti) && !empty($format)) { // @TODO Using $format (FRST ou RCUR) in a section for a Credit Transfer looks strange.
|
||||||
$XML_SEPA_INFO .= ' <PmtTpInf>' . $CrLf;
|
$XML_SEPA_INFO .= ' <PmtTpInf>' . $CrLf;
|
||||||
$XML_SEPA_INFO .= ' <SvcLvl>' . $CrLf;
|
$XML_SEPA_INFO .= ' <SvcLvl>' . $CrLf;
|
||||||
$XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf;
|
$XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf;
|
||||||
|
|||||||
@ -520,6 +520,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
|
// Actions to send emails
|
||||||
$triggersendname = 'CONTACT_SENTBYMAIL';
|
$triggersendname = 'CONTACT_SENTBYMAIL';
|
||||||
$paramname = 'id';
|
$paramname = 'id';
|
||||||
|
|||||||
@ -376,7 +376,7 @@ class Contact extends CommonObject
|
|||||||
public function load_state_board()
|
public function load_state_board()
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $user;
|
global $user, $hookmanager;
|
||||||
|
|
||||||
$this->nb = array();
|
$this->nb = array();
|
||||||
$clause = "WHERE";
|
$clause = "WHERE";
|
||||||
@ -394,6 +394,12 @@ class Contact extends CommonObject
|
|||||||
if ($user->socid > 0) {
|
if ($user->socid > 0) {
|
||||||
$sql .= " AND sp.fk_soc = ".((int) $user->socid);
|
$sql .= " AND sp.fk_soc = ".((int) $user->socid);
|
||||||
}
|
}
|
||||||
|
// Add where from hooks
|
||||||
|
if (is_object($hookmanager)) {
|
||||||
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $this); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
|
}
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
@ -1820,7 +1826,7 @@ class Contact extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople=".((int) $this->id)." AND entity IN (".getEntity("societe_contact").")";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_socpeople=".((int) $this->id)." AND entity IN (".getEntity("contact").")";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
|||||||
@ -384,7 +384,7 @@ if (!empty($conf->mailing->enabled)) {
|
|||||||
}
|
}
|
||||||
// Add fields from hooks
|
// Add fields from hooks
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
$sql .= $hookmanager->resPrint;
|
$sql .= $hookmanager->resPrint;
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
|
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
|
||||||
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
||||||
@ -405,7 +405,7 @@ if (!empty($search_categ_supplier) && $search_categ_supplier != '-1') {
|
|||||||
if (empty($user->rights->societe->client->voir) && !$socid) {
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
||||||
}
|
}
|
||||||
$sql .= ' WHERE p.entity IN ('.getEntity('socpeople').')';
|
$sql .= ' WHERE p.entity IN ('.getEntity('contact').')';
|
||||||
if (empty($user->rights->societe->client->voir) && !$socid) { //restriction
|
if (empty($user->rights->societe->client->voir) && !$socid) { //restriction
|
||||||
$sql .= " AND (sc.fk_user = ".((int) $user->id)." OR p.fk_soc IS NULL)";
|
$sql .= " AND (sc.fk_user = ".((int) $user->id)." OR p.fk_soc IS NULL)";
|
||||||
}
|
}
|
||||||
@ -543,7 +543,7 @@ if (!empty($socid)) {
|
|||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||||
// Add where from hooks
|
// Add where from hooks
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
$sql .= $hookmanager->resPrint;
|
$sql .= $hookmanager->resPrint;
|
||||||
// Add order
|
// Add order
|
||||||
if ($view == "recent") {
|
if ($view == "recent") {
|
||||||
@ -767,7 +767,7 @@ $moreforfilter .= '</div>';
|
|||||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||||
print $moreforfilter;
|
print $moreforfilter;
|
||||||
$parameters = array('type'=>$type);
|
$parameters = array('type'=>$type);
|
||||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
@ -910,7 +910,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
|||||||
|
|
||||||
// Fields from hook
|
// Fields from hook
|
||||||
$parameters = array('arrayfields'=>$arrayfields);
|
$parameters = array('arrayfields'=>$arrayfields);
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
// Date creation
|
// Date creation
|
||||||
if (!empty($arrayfields['p.datec']['checked'])) {
|
if (!empty($arrayfields['p.datec']['checked'])) {
|
||||||
@ -1018,7 +1018,7 @@ $parameters = array(
|
|||||||
'sortfield'=>$sortfield,
|
'sortfield'=>$sortfield,
|
||||||
'sortorder'=>$sortorder,
|
'sortorder'=>$sortorder,
|
||||||
);
|
);
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
if (!empty($arrayfields['p.datec']['checked'])) {
|
if (!empty($arrayfields['p.datec']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||||
@ -1255,7 +1255,7 @@ while ($i < min($num, $limit)) {
|
|||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
||||||
// Fields from hook
|
// Fields from hook
|
||||||
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
|
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
// Date creation
|
// Date creation
|
||||||
if (!empty($arrayfields['p.datec']['checked'])) {
|
if (!empty($arrayfields['p.datec']['checked'])) {
|
||||||
@ -1312,7 +1312,7 @@ while ($i < min($num, $limit)) {
|
|||||||
$db->free($resql);
|
$db->free($resql);
|
||||||
|
|
||||||
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|||||||
@ -2027,62 +2027,73 @@ if ($action == 'create') {
|
|||||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
|
$params = array(
|
||||||
|
'attr' => array(
|
||||||
|
'title' => '',
|
||||||
|
'class' => 'classfortooltip'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
if (empty($user->socid)) {
|
if (empty($user->socid)) {
|
||||||
if ($object->statut == 1) {
|
if ($object->statut == 1) {
|
||||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->contrat->creer)) {
|
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->contrat->creer)) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
|
print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle', '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>';
|
print dolGetButtonAction($langs->trans('SendMail'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($object->statut == 0 && $nbofservices) {
|
if ($object->statut == 0 && $nbofservices) {
|
||||||
if ($user->rights->contrat->creer) {
|
if ($user->rights->contrat->creer) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid&token='.newToken().'">'.$langs->trans("Validate").'</a></div>';
|
print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid&token='.newToken(), '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Validate").'</a></div>';
|
$params['attr']['title'] = $langs->trans("NotEnoughPermissions");
|
||||||
|
print dolGetButtonAction($langs->trans('Validate'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($object->statut == 1) {
|
if ($object->statut == 1) {
|
||||||
if ($user->rights->contrat->creer) {
|
if ($user->rights->contrat->creer) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans("Modify").'</a></div>';
|
print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken(), '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Modify").'</a></div>';
|
$params['attr']['title'] = $langs->trans("NotEnoughPermissions");
|
||||||
|
print dolGetButtonAction($langs->trans('Modify'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) {
|
if (!empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) {
|
||||||
$langs->load("orders");
|
$langs->load("orders");
|
||||||
if ($user->rights->commande->creer) {
|
if ($user->rights->commande->creer) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&token='.newToken().'&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id.'">'.$langs->trans("CreateOrder").'</a></div>';
|
print dolGetButtonAction($langs->trans('CreateOrder'), '', 'default', DOL_URL_ROOT.'/commande/card.php?action=create&token='.newToken().'&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateOrder").'</a></div>';
|
$params['attr']['title'] = $langs->trans("NotEnoughPermissions");
|
||||||
|
print dolGetButtonAction($langs->trans('CreateOrder'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->facture->enabled) && $object->statut > 0) {
|
if (!empty($conf->facture->enabled) && $object->statut > 0) {
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
if ($user->rights->facture->creer) {
|
if ($user->rights->facture->creer) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id.'">'.$langs->trans("CreateBill").'</a></div>';
|
print dolGetButtonAction($langs->trans('CreateBill'), '', 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateBill").'</a></div>';
|
$params['attr']['title'] = $langs->trans("NotEnoughPermissions");
|
||||||
|
print dolGetButtonAction($langs->trans('CreateBill'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) {
|
if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) {
|
||||||
if ($user->rights->contrat->activer) {
|
if ($user->rights->contrat->activer) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" id="btnactivateall" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=activate&token='.newToken().'">'.$langs->trans("ActivateAllContracts").'</a></div>';
|
print dolGetButtonAction($langs->trans('ActivateAllContracts'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=activate&token='.newToken(), '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" id="btnactivateall" href="#">'.$langs->trans("ActivateAllContracts").'</a></div>';
|
print dolGetButtonAction($langs->trans('ActivateAllContracts'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($object->nbofservicesclosed < $nbofservices) {
|
if ($object->nbofservicesclosed < $nbofservices) {
|
||||||
if ($user->rights->contrat->desactiver) {
|
if ($user->rights->contrat->desactiver) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" id="btncloseall" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken().'">'.$langs->trans("CloseAllContracts").'</a></div>';
|
print dolGetButtonAction($langs->trans('CloseAllContracts'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" id="btncloseall" href="#">'.$langs->trans("CloseAllContracts").'</a></div>';
|
print dolGetButtonAction($langs->trans('CloseAllContracts'), '', 'default', '#', '', false, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (! $numactive)
|
//if (! $numactive)
|
||||||
@ -2104,16 +2115,17 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
// Clone
|
// Clone
|
||||||
if ($user->rights->contrat->creer) {
|
if ($user->rights->contrat->creer) {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&token='.newToken().'&object='.$object->element.'">'.$langs->trans("ToClone").'</a></div>';
|
print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&token='.newToken(), '', true, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// On peut supprimer entite si
|
// On peut supprimer entite si
|
||||||
// - Droit de creer + mode brouillon (erreur creation)
|
// - Droit de creer + mode brouillon (erreur creation)
|
||||||
// - Droit de supprimer
|
// - Droit de supprimer
|
||||||
if (($user->rights->contrat->creer && $object->statut == $object::STATUS_DRAFT) || $user->rights->contrat->supprimer) {
|
if (($user->rights->contrat->creer && $object->statut == $object::STATUS_DRAFT) || $user->rights->contrat->supprimer) {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
|
print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), '', true, $params);
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("Delete").'</a></div>';
|
$params['attr']['title'] = $langs->trans("NotAllowed");
|
||||||
|
print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), '', false, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -233,10 +233,10 @@ class Contrat extends CommonObject
|
|||||||
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
|
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
|
||||||
'date_contrat' =>array('type'=>'datetime', 'label'=>'Date contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
|
'date_contrat' =>array('type'=>'datetime', 'label'=>'Date contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
|
||||||
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70),
|
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70),
|
||||||
'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>75),
|
'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>75),
|
||||||
'fk_commercial_signature' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk commercial signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80),
|
'fk_commercial_signature' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative Signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80),
|
||||||
'fk_commercial_suivi' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk commercial suivi', 'enabled'=>1, 'visible'=>-1, 'position'=>85),
|
'fk_commercial_suivi' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative follower', 'enabled'=>1, 'visible'=>-1, 'position'=>85),
|
||||||
'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90),
|
'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90),
|
||||||
'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105),
|
'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105),
|
||||||
'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110),
|
'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110),
|
||||||
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115),
|
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115),
|
||||||
@ -245,7 +245,7 @@ class Contrat extends CommonObject
|
|||||||
'ref_customer' =>array('type'=>'varchar(50)', 'label'=>'Ref customer', 'enabled'=>1, 'visible'=>-1, 'position'=>130),
|
'ref_customer' =>array('type'=>'varchar(50)', 'label'=>'Ref customer', 'enabled'=>1, 'visible'=>-1, 'position'=>130),
|
||||||
'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135),
|
'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135),
|
||||||
'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>140),
|
'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>140),
|
||||||
'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Closed'))
|
'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'notnull'=>1, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Closed'))
|
||||||
);
|
);
|
||||||
// END MODULEBUILDER PROPERTIES
|
// END MODULEBUILDER PROPERTIES
|
||||||
|
|
||||||
@ -751,15 +751,14 @@ class Contrat extends CommonObject
|
|||||||
* Load lines array into this->lines.
|
* Load lines array into this->lines.
|
||||||
* This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed
|
* This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed
|
||||||
*
|
*
|
||||||
* @param int $only_product Return only physical products
|
* @param int $only_services 0=Default, 1=Force only services (depending on setup, we may also have physical products in a contract)
|
||||||
* @param int $loadalsotranslation Return translation for products
|
* @param int $loadalsotranslation 0=Default, 1=Load also translations of product descriptions
|
||||||
*
|
* @return ContratLigne[] Return array of contract lines
|
||||||
* @return ContratLigne[] Return array of contract lines
|
|
||||||
*/
|
*/
|
||||||
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
|
public function fetch_lines($only_services = 0, $loadalsotranslation = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs, $conf, $extrafields;
|
global $langs, $conf;
|
||||||
|
|
||||||
$this->nbofservices = 0;
|
$this->nbofservices = 0;
|
||||||
$this->nbofserviceswait = 0;
|
$this->nbofserviceswait = 0;
|
||||||
@ -773,13 +772,15 @@ class Contrat extends CommonObject
|
|||||||
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
|
/*
|
||||||
if (!is_object($extrafields)) {
|
if (!is_object($extrafields)) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
$extrafields = new ExtraFields($this->db);
|
$extrafields = new ExtraFields($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
$line = new ContratLigne($this->db);
|
$line = new ContratLigne($this->db);
|
||||||
$extrafields->fetch_name_optionals_label($line->table_element, true);
|
$extrafields->fetch_name_optionals_label(ContratLigne::$table_element, true);
|
||||||
|
*/
|
||||||
|
|
||||||
$this->lines = array();
|
$this->lines = array();
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
@ -802,6 +803,9 @@ class Contrat extends CommonObject
|
|||||||
$sql .= " d.product_type as type";
|
$sql .= " d.product_type as type";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
|
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
|
||||||
$sql .= " WHERE d.fk_contrat = ".((int) $this->id);
|
$sql .= " WHERE d.fk_contrat = ".((int) $this->id);
|
||||||
|
if ($only_services == 1) {
|
||||||
|
$sql .= " AND d.product_type = 1";
|
||||||
|
}
|
||||||
$sql .= " ORDER by d.rowid ASC";
|
$sql .= " ORDER by d.rowid ASC";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
|
||||||
@ -814,6 +818,7 @@ class Contrat extends CommonObject
|
|||||||
$objp = $this->db->fetch_object($result);
|
$objp = $this->db->fetch_object($result);
|
||||||
|
|
||||||
$line = new ContratLigne($this->db);
|
$line = new ContratLigne($this->db);
|
||||||
|
|
||||||
$line->id = $objp->rowid;
|
$line->id = $objp->rowid;
|
||||||
$line->ref = $objp->rowid;
|
$line->ref = $objp->rowid;
|
||||||
$line->fk_contrat = $objp->fk_contrat;
|
$line->fk_contrat = $objp->fk_contrat;
|
||||||
@ -840,7 +845,7 @@ class Contrat extends CommonObject
|
|||||||
$line->type = $objp->type;
|
$line->type = $objp->type;
|
||||||
|
|
||||||
$line->fk_fournprice = $objp->fk_fournprice;
|
$line->fk_fournprice = $objp->fk_fournprice;
|
||||||
$marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
|
$marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $objp->fk_fournprice, $objp->pa_ht);
|
||||||
$line->pa_ht = $marginInfos[0];
|
$line->pa_ht = $marginInfos[0];
|
||||||
|
|
||||||
$line->fk_user_author = $objp->fk_user_author;
|
$line->fk_user_author = $objp->fk_user_author;
|
||||||
@ -882,6 +887,7 @@ class Contrat extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->lines[$pos] = $line;
|
$this->lines[$pos] = $line;
|
||||||
|
|
||||||
$this->lines_id_index_mapper[$line->id] = $pos;
|
$this->lines_id_index_mapper[$line->id] = $pos;
|
||||||
|
|
||||||
//dol_syslog("1 ".$line->desc);
|
//dol_syslog("1 ".$line->desc);
|
||||||
@ -2750,8 +2756,8 @@ class ContratLigne extends CommonObjectLine
|
|||||||
//'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115),
|
//'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115),
|
||||||
//'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>120),
|
//'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>120),
|
||||||
//'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>125),
|
//'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>125),
|
||||||
'fk_user_ouverture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserOpen', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135),
|
'fk_user_ouverture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserStartingService', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135),
|
||||||
'fk_user_cloture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserCloture', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135),
|
'fk_user_cloture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserClosingService', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135),
|
||||||
'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 4=>'Open', 5=>'Closed'))
|
'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 4=>'Open', 5=>'Closed'))
|
||||||
);
|
);
|
||||||
// END MODULEBUILDER PROPERTIES
|
// END MODULEBUILDER PROPERTIES
|
||||||
|
|||||||
@ -350,25 +350,43 @@ if ($search_dfyear > 0 && $search_op2df) {
|
|||||||
$sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'";
|
$sql .= " HAVING MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") <= '".$db->idate(dol_get_last_day($search_dfyear, $search_dfmonth, false))."' AND MIN(".$db->ifsql("cd.statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(dol_get_first_day($search_dfyear, $search_dfmonth, false))."'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
|
||||||
|
|
||||||
$totalnboflines = 0;
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if ($result) {
|
|
||||||
$totalnboflines = $db->num_rows($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
$nbtotalofrecords = '';
|
$nbtotalofrecords = '';
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
$result = $db->query($sql);
|
//$result = $db->query($sql);
|
||||||
$nbtotalofrecords = $db->num_rows($result);
|
//$nbtotalofrecords = $db->num_rows($result);
|
||||||
|
|
||||||
|
if ($search_dfyear > 0 && $search_op2df) {
|
||||||
|
$resql = $db->query($sql, 0, 'auto', 1);
|
||||||
|
while ($db->fetch_object($resql)) {
|
||||||
|
if (empty($nbtotalofrecords)) {
|
||||||
|
$nbtotalofrecords = 1; // We can't make +1 because init value is ''
|
||||||
|
} else {
|
||||||
|
$nbtotalofrecords++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||||
|
$sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'contratdet as cd ON c.rowid = cd.fk_contrat/', '', $sqlforcount);
|
||||||
|
$sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product/', '', $sqlforcount);
|
||||||
|
$sqlforcount = preg_replace('/AND cp.fk_categorie = '.((int) $search_product_category).'/', '', $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 resultset is smaller then paging size (filtering), goto and load page 0
|
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= $db->plimit($limit + 1, $offset);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
if ($limit) {
|
||||||
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
@ -508,7 +526,7 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
|||||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||||
|
|
||||||
print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'contract', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
||||||
|
|
||||||
$topicmail = "SendContractRef";
|
$topicmail = "SendContractRef";
|
||||||
$modelmail = "contract";
|
$modelmail = "contract";
|
||||||
|
|||||||
@ -49,7 +49,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
|
|||||||
<td class="nowraponall"><?php echo $objectlink->getNomUrl(1); ?></td>
|
<td class="nowraponall"><?php echo $objectlink->getNomUrl(1); ?></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td class="center"><?php echo dol_print_date($objectlink->date_contrat, 'day'); ?></td>
|
<td class="center"><?php echo dol_print_date($objectlink->date_contrat, 'day'); ?></td>
|
||||||
<td class="right"><?php
|
<td class="nowraponall right"><?php
|
||||||
// Price of contract is not shown by default because a contract is a list of service with
|
// Price of contract is not shown by default because a contract is a list of service with
|
||||||
// start and end date that change with time andd that may be different that the period of reference for price.
|
// start and end date that change with time andd that may be different that the period of reference for price.
|
||||||
// So price of a contract does often means nothing. Prices is on the different invoices done on same contract.
|
// So price of a contract does often means nothing. Prices is on the different invoices done on same contract.
|
||||||
|
|||||||
@ -255,6 +255,12 @@ if ($action == 'update' && !empty($permissiontoadd)) {
|
|||||||
$result = $object->update($user);
|
$result = $object->update($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$action = 'view';
|
$action = 'view';
|
||||||
|
$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
|
||||||
|
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
|
||||||
|
if ($urltogo) {
|
||||||
|
header("Location: " . $urltogo);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$error++;
|
$error++;
|
||||||
// Creation KO
|
// Creation KO
|
||||||
|
|||||||
@ -32,7 +32,7 @@ $addlinkid = GETPOST('idtolinkto', 'int');
|
|||||||
$addlinkref = GETPOST('reftolinkto', 'alpha');
|
$addlinkref = GETPOST('reftolinkto', 'alpha');
|
||||||
$cancellink = GETPOST('cancel', 'alpha');
|
$cancellink = GETPOST('cancel', 'alpha');
|
||||||
|
|
||||||
// Link invoice to order
|
// Link object to another object
|
||||||
if ($action == 'addlink' && !empty($permissiondellink) && !$cancellink && $id > 0 && $addlinkid > 0) {
|
if ($action == 'addlink' && !empty($permissiondellink) && !$cancellink && $id > 0 && $addlinkid > 0) {
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
@ -61,7 +61,7 @@ if ($action == 'addlinkbyref' && ! empty($permissiondellink) && !$cancellink &&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete link
|
// Delete link in table llx_element_element
|
||||||
if ($action == 'dellink' && !empty($permissiondellink) && !$cancellink && $dellinkid > 0) {
|
if ($action == 'dellink' && !empty($permissiondellink) && !$cancellink && $dellinkid > 0) {
|
||||||
$result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid);
|
$result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
|
|||||||
@ -635,6 +635,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
|||||||
|
|
||||||
$TFact = array();
|
$TFact = array();
|
||||||
$TFactThird = array();
|
$TFactThird = array();
|
||||||
|
$TFactThirdNbLines = array();
|
||||||
|
|
||||||
$nb_bills_created = 0;
|
$nb_bills_created = 0;
|
||||||
$lastid= 0;
|
$lastid= 0;
|
||||||
@ -685,6 +686,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
|||||||
$lastid = $objecttmp->id;
|
$lastid = $objecttmp->id;
|
||||||
|
|
||||||
$TFactThird[$cmd->socid] = $objecttmp;
|
$TFactThird[$cmd->socid] = $objecttmp;
|
||||||
|
$TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang
|
||||||
} else {
|
} else {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->error);
|
$errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->error);
|
||||||
@ -774,6 +776,11 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
|||||||
|
|
||||||
$objecttmp->context['createfromclone'];
|
$objecttmp->context['createfromclone'];
|
||||||
|
|
||||||
|
$rang = $lines[$i]->rang;
|
||||||
|
//there may already be rows from previous orders
|
||||||
|
if (!empty($createbills_onebythird))
|
||||||
|
$rang = $TFactThirdNbLines[$cmd->socid];
|
||||||
|
|
||||||
$result = $objecttmp->addline(
|
$result = $objecttmp->addline(
|
||||||
$desc,
|
$desc,
|
||||||
$lines[$i]->subprice,
|
$lines[$i]->subprice,
|
||||||
@ -791,7 +798,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
|||||||
'HT',
|
'HT',
|
||||||
0,
|
0,
|
||||||
$product_type,
|
$product_type,
|
||||||
$lines[$i]->rang,
|
$rang,
|
||||||
$lines[$i]->special_code,
|
$lines[$i]->special_code,
|
||||||
$objecttmp->origin,
|
$objecttmp->origin,
|
||||||
$lines[$i]->rowid,
|
$lines[$i]->rowid,
|
||||||
@ -806,6 +813,8 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
|||||||
);
|
);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$lineid = $result;
|
$lineid = $result;
|
||||||
|
if (!empty($createbills_onebythird)) //increment rang to keep order
|
||||||
|
$TFactThirdNbLines[$rcp->socid]++;
|
||||||
} else {
|
} else {
|
||||||
$lineid = 0;
|
$lineid = 0;
|
||||||
$error++;
|
$error++;
|
||||||
@ -1209,6 +1218,26 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) {
|
|||||||
setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors');
|
setEventMessages($langs->trans('ErrorMassValidationNotAllowedWhenStockIncreaseOnAction'), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
if ($objecttmp->element == 'facture') {
|
||||||
|
if (!empty($toselect) && !empty($conf->global->INVOICE_CHECK_POSTERIOR_DATE)) {
|
||||||
|
// order $toselect by date
|
||||||
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture";
|
||||||
|
$sql .= " WHERE rowid IN (".$db->sanitize(implode(",", $toselect)).")";
|
||||||
|
$sql .= " ORDER BY datef";
|
||||||
|
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$toselectnew = [];
|
||||||
|
while ( !empty($arr = $db->fetch_row($resql))) {
|
||||||
|
$toselectnew[] = $arr[0];
|
||||||
|
}
|
||||||
|
$toselect = (empty($toselectnew)) ? $toselect : $toselectnew;
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
|||||||
@ -95,6 +95,8 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
|
|||||||
$perm = 1;
|
$perm = 1;
|
||||||
} elseif ($table_element_line == 'facture_fourn_det_rec' && $user->rights->fournisseur->facture->creer) {
|
} elseif ($table_element_line == 'facture_fourn_det_rec' && $user->rights->fournisseur->facture->creer) {
|
||||||
$perm = 1;
|
$perm = 1;
|
||||||
|
} elseif ($table_element_line == 'product_attribute_value' && $fk_element == 'fk_product_attribute' && ($user->rights->produit->lire || $user->rights->service->lire)) {
|
||||||
|
$perm = 1;
|
||||||
} elseif ($table_element_line == 'ecm_files') { // Used when of page "documents.php"
|
} elseif ($table_element_line == 'ecm_files') { // Used when of page "documents.php"
|
||||||
if (!empty($user->rights->ecm->creer)) {
|
if (!empty($user->rights->ecm->creer)) {
|
||||||
$perm = 1;
|
$perm = 1;
|
||||||
|
|||||||
@ -76,7 +76,7 @@ class box_clients extends ModeleBoxes
|
|||||||
*/
|
*/
|
||||||
public function loadBox($max = 5)
|
public function loadBox($max = 5)
|
||||||
{
|
{
|
||||||
global $user, $langs, $conf;
|
global $user, $langs, $hookmanager;
|
||||||
$langs->load("boxes");
|
$langs->load("boxes");
|
||||||
|
|
||||||
$this->max = $max;
|
$this->max = $max;
|
||||||
@ -100,9 +100,15 @@ class box_clients extends ModeleBoxes
|
|||||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||||
}
|
}
|
||||||
if ($user->socid) {
|
// Add where from hooks
|
||||||
$sql .= " AND s.rowid = ".((int) $user->socid);
|
$parameters = array('socid' => $user->socid, 'boxcode' => $this->boxcode);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $thirdpartystatic); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) {
|
||||||
|
if ($user->socid > 0) {
|
||||||
|
$sql .= " AND s.rowid = ".((int) $user->socid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
$sql .= " ORDER BY s.tms DESC";
|
$sql .= " ORDER BY s.tms DESC";
|
||||||
$sql .= $this->db->plimit($max, 0);
|
$sql .= $this->db->plimit($max, 0);
|
||||||
|
|
||||||
|
|||||||
@ -74,11 +74,15 @@ class box_contacts extends ModeleBoxes
|
|||||||
*/
|
*/
|
||||||
public function loadBox($max = 5)
|
public function loadBox($max = 5)
|
||||||
{
|
{
|
||||||
global $user, $langs, $conf;
|
global $user, $langs, $conf, $hookmanager;
|
||||||
|
|
||||||
$langs->load("boxes");
|
$langs->load("boxes");
|
||||||
|
|
||||||
$this->max = $max;
|
$this->max = $max;
|
||||||
|
|
||||||
|
$contactstatic = new Contact($this->db);
|
||||||
|
$societestatic = new Societe($this->db);
|
||||||
|
|
||||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max));
|
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max));
|
||||||
|
|
||||||
if ($user->rights->societe->lire && $user->rights->societe->contact->lire) {
|
if ($user->rights->societe->lire && $user->rights->societe->contact->lire) {
|
||||||
@ -106,13 +110,19 @@ class box_contacts extends ModeleBoxes
|
|||||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
}
|
}
|
||||||
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
|
$sql .= " WHERE sp.entity IN (".getEntity('contact').")";
|
||||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||||
}
|
}
|
||||||
if ($user->socid) {
|
// Add where from hooks
|
||||||
$sql .= " AND sp.fk_soc = ".((int) $user->socid);
|
$parameters = array('socid' => $user->socid, 'boxcode' => $this->boxcode);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) {
|
||||||
|
if ($user->socid > 0) {
|
||||||
|
$sql .= " AND sp.fk_soc = ".((int) $user->socid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
$sql .= " ORDER BY sp.tms DESC";
|
$sql .= " ORDER BY sp.tms DESC";
|
||||||
$sql .= $this->db->plimit($max, 0);
|
$sql .= $this->db->plimit($max, 0);
|
||||||
|
|
||||||
@ -120,9 +130,6 @@ class box_contacts extends ModeleBoxes
|
|||||||
if ($result) {
|
if ($result) {
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
|
|
||||||
$contactstatic = new Contact($this->db);
|
|
||||||
$societestatic = new Societe($this->db);
|
|
||||||
|
|
||||||
$line = 0;
|
$line = 0;
|
||||||
while ($line < $num) {
|
while ($line < $num) {
|
||||||
$objp = $this->db->fetch_object($result);
|
$objp = $this->db->fetch_object($result);
|
||||||
|
|||||||
@ -71,7 +71,7 @@ class box_fournisseurs extends ModeleBoxes
|
|||||||
*/
|
*/
|
||||||
public function loadBox($max = 5)
|
public function loadBox($max = 5)
|
||||||
{
|
{
|
||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs, $hookmanager;
|
||||||
$langs->load("boxes");
|
$langs->load("boxes");
|
||||||
|
|
||||||
$this->max = $max;
|
$this->max = $max;
|
||||||
@ -95,9 +95,15 @@ class box_fournisseurs extends ModeleBoxes
|
|||||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||||
}
|
}
|
||||||
if ($user->socid) {
|
// Add where from hooks
|
||||||
$sql .= " AND s.rowid = ".((int) $user->socid);
|
$parameters = array('socid' => $user->socid, 'boxcode' => $this->boxcode);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $thirdpartystatic); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) {
|
||||||
|
if ($user->socid > 0) {
|
||||||
|
$sql .= " AND s.rowid = ".((int) $user->socid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
$sql .= " ORDER BY s.tms DESC ";
|
$sql .= " ORDER BY s.tms DESC ";
|
||||||
$sql .= $this->db->plimit($max, 0);
|
$sql .= $this->db->plimit($max, 0);
|
||||||
|
|
||||||
|
|||||||
@ -177,16 +177,16 @@ class box_members_by_type extends ModeleBoxes
|
|||||||
);
|
);
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
'td' => 'class="right"',
|
'td' => 'class="right"',
|
||||||
'text' => $langs->trans("MembersStatusToValid"),
|
'text' => $langs->trans("MembersStatusToValid"), // Draft
|
||||||
);
|
|
||||||
$this->info_box_contents[$line][] = array(
|
|
||||||
'td' => 'class="right"',
|
|
||||||
'text' => $langs->trans("OutOfDate"),
|
|
||||||
);
|
);
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
'td' => 'class="right"',
|
'td' => 'class="right"',
|
||||||
'text' => $langs->trans("UpToDate"),
|
'text' => $langs->trans("UpToDate"),
|
||||||
);
|
);
|
||||||
|
$this->info_box_contents[$line][] = array(
|
||||||
|
'td' => 'class="right"',
|
||||||
|
'text' => $langs->trans("OutOfDate"),
|
||||||
|
);
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
'td' => 'class="right"',
|
'td' => 'class="right"',
|
||||||
'text' => $langs->trans("MembersStatusExcluded"),
|
'text' => $langs->trans("MembersStatusExcluded"),
|
||||||
@ -215,12 +215,12 @@ class box_members_by_type extends ModeleBoxes
|
|||||||
);
|
);
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
'td' => 'class="right"',
|
'td' => 'class="right"',
|
||||||
'text' => (isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3),
|
'text' => (isset($MembersUpToDate[$key]) && $MembersUpToDate[$key] > 0 ? $MembersUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3),
|
||||||
'asis' => 1,
|
'asis' => 1,
|
||||||
);
|
);
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
'td' => 'class="right"',
|
'td' => 'class="right"',
|
||||||
'text' => (isset($MembersUpToDate[$key]) && $MembersUpToDate[$key] > 0 ? $MembersUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3),
|
'text' => (isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3),
|
||||||
'asis' => 1,
|
'asis' => 1,
|
||||||
);
|
);
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
@ -255,12 +255,12 @@ class box_members_by_type extends ModeleBoxes
|
|||||||
);
|
);
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
'td' => 'class="liste_total right"',
|
'td' => 'class="liste_total right"',
|
||||||
'text' => $SumValidated.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3),
|
'text' => $SumUpToDate.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3),
|
||||||
'asis' => 1
|
'asis' => 1
|
||||||
);
|
);
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
'td' => 'class="liste_total right"',
|
'td' => 'class="liste_total right"',
|
||||||
'text' => $SumUpToDate.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3),
|
'text' => $SumValidated.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3),
|
||||||
'asis' => 1
|
'asis' => 1
|
||||||
);
|
);
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
|
|||||||
@ -103,8 +103,8 @@ class box_produits extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
// Add where from hooks
|
// Add where from hooks
|
||||||
if (is_object($hookmanager)) {
|
if (is_object($hookmanager)) {
|
||||||
$parameters = array('boxproductlist'=>1);
|
$parameters = array('boxproductlist' => 1, 'boxcode' => $this->boxcode);
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $productstatic); // Note that $action and $object may have been modified by hook
|
||||||
$sql .= $hookmanager->resPrint;
|
$sql .= $hookmanager->resPrint;
|
||||||
}
|
}
|
||||||
$sql .= $this->db->order('p.datec', 'DESC');
|
$sql .= $this->db->order('p.datec', 'DESC');
|
||||||
|
|||||||
@ -103,8 +103,8 @@ class box_produits_alerte_stock extends ModeleBoxes
|
|||||||
}
|
}
|
||||||
// Add where from hooks
|
// Add where from hooks
|
||||||
if (is_object($hookmanager)) {
|
if (is_object($hookmanager)) {
|
||||||
$parameters = array('boxproductalertstocklist'=>1);
|
$parameters = array('boxproductalertstocklist' => 1, 'boxcode' => $this->boxcode);
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $productstatic); // Note that $action and $object may have been modified by hook
|
||||||
$sql .= $hookmanager->resPrint;
|
$sql .= $hookmanager->resPrint;
|
||||||
}
|
}
|
||||||
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,";
|
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,";
|
||||||
|
|||||||
@ -78,7 +78,7 @@ class box_prospect extends ModeleBoxes
|
|||||||
*/
|
*/
|
||||||
public function loadBox($max = 5)
|
public function loadBox($max = 5)
|
||||||
{
|
{
|
||||||
global $user, $langs, $conf;
|
global $user, $langs, $hookmanager;
|
||||||
|
|
||||||
$this->max = $max;
|
$this->max = $max;
|
||||||
|
|
||||||
@ -101,9 +101,15 @@ class box_prospect extends ModeleBoxes
|
|||||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||||
}
|
}
|
||||||
if ($user->socid) {
|
// Add where from hooks
|
||||||
$sql .= " AND s.rowid = ".((int) $user->socid);
|
$parameters = array('socid' => $user->socid, 'boxcode' => $this->boxcode);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $thirdpartystatic); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook)) {
|
||||||
|
if ($user->socid > 0) {
|
||||||
|
$sql .= " AND s.rowid = ".((int) $user->socid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
$sql .= " ORDER BY s.tms DESC";
|
$sql .= " ORDER BY s.tms DESC";
|
||||||
$sql .= $this->db->plimit($max, 0);
|
$sql .= $this->db->plimit($max, 0);
|
||||||
|
|
||||||
|
|||||||
@ -162,7 +162,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes
|
|||||||
|
|
||||||
$this->info_box_contents[$line][] = array(
|
$this->info_box_contents[$line][] = array(
|
||||||
'td' => 'class="right"',
|
'td' => 'class="right"',
|
||||||
'text' => $delayIcon.'<span class="classfortooltip" title="'.$langs->trans('DateDeliveryPlanned').'"><i class="fa fa-dolly" ></i> '.($delivery_date ? dol_print_date($delivery_date, 'day', 'tzuserrel') : '').'</span>',
|
'text' => $delayIcon.'<span class="classfortooltip" title="'.$langs->trans('DateDeliveryPlanned').'"><i class="fa fa-flip-dolly" ></i> '.($delivery_date ? dol_print_date($delivery_date, 'day', 'tzuserrel') : '').'</span>',
|
||||||
'asis' => 1
|
'asis' => 1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -140,7 +140,7 @@ class CMailFile
|
|||||||
*/
|
*/
|
||||||
public function __construct($subject, $to, $from, $msg, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = 0, $errors_to = '', $css = '', $trackid = '', $moreinheader = '', $sendcontext = 'standard', $replyto = '')
|
public function __construct($subject, $to, $from, $msg, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = 0, $errors_to = '', $css = '', $trackid = '', $moreinheader = '', $sendcontext = 'standard', $replyto = '')
|
||||||
{
|
{
|
||||||
global $conf, $dolibarr_main_data_root;
|
global $conf, $dolibarr_main_data_root, $user;
|
||||||
|
|
||||||
// Clean values of $mimefilename_list
|
// Clean values of $mimefilename_list
|
||||||
if (is_array($mimefilename_list)) {
|
if (is_array($mimefilename_list)) {
|
||||||
@ -251,9 +251,31 @@ class CMailFile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add autocopy to if not already in $to (Note: Adding bcc for specific modules are also done from pages)
|
// Add auto copy to if not already in $to (Note: Adding bcc for specific modules are also done from pages)
|
||||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) && !preg_match('/'.preg_quote($conf->global->MAIN_MAIL_AUTOCOPY_TO, '/').'/i', $to)) {
|
// For example MAIN_MAIL_AUTOCOPY_TO can be 'email@example.com, __USER_EMAIL__, ...'
|
||||||
$addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
|
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
|
||||||
|
$listofemailstoadd = explode(',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
|
||||||
|
foreach ($listofemailstoadd as $key => $val) {
|
||||||
|
$emailtoadd = $listofemailstoadd[$key];
|
||||||
|
if (trim($emailtoadd) == '__USER_EMAIL__') {
|
||||||
|
if (!empty($user) && !empty($user->email)) {
|
||||||
|
$emailtoadd = $user->email;
|
||||||
|
} else {
|
||||||
|
$emailtoadd = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($emailtoadd && preg_match('/'.preg_quote($emailtoadd, '/').'/i', $to)) {
|
||||||
|
$emailtoadd = ''; // Email already in the "To"
|
||||||
|
}
|
||||||
|
if ($emailtoadd) {
|
||||||
|
$listofemailstoadd[$key] = $emailtoadd;
|
||||||
|
} else {
|
||||||
|
unset($listofemailstoadd[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($listofemailstoadd)) {
|
||||||
|
$addr_bcc .= ($addr_bcc ? ', ' : '').join(', ', $listofemailstoadd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->subject = $subject;
|
$this->subject = $subject;
|
||||||
|
|||||||
@ -827,8 +827,10 @@ abstract class CommonInvoice extends CommonObject
|
|||||||
$tmplang->load("main");
|
$tmplang->load("main");
|
||||||
|
|
||||||
$datestring = dol_print_date($this->date, 'dayhourrfc');
|
$datestring = dol_print_date($this->date, 'dayhourrfc');
|
||||||
$pricewithtaxstring = price($this->total_ttc, 0, $tmplang, 0, -1, 2);
|
//$pricewithtaxstring = price($this->total_ttc, 0, $tmplang, 0, -1, 2);
|
||||||
$pricetaxstring = price($this->total_tva, 0, $tmplang, 0, -1, 2);
|
//$pricetaxstring = price($this->total_tva, 0, $tmplang, 0, -1, 2);
|
||||||
|
$pricewithtaxstring = price2num($this->total_ttc, 2, 1);
|
||||||
|
$pricetaxstring = price2num($this->total_tva, 2, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$name = implode(unpack("H*", $this->thirdparty->name));
|
$name = implode(unpack("H*", $this->thirdparty->name));
|
||||||
@ -857,7 +859,7 @@ abstract class CommonInvoice extends CommonObject
|
|||||||
// Using TLV format
|
// Using TLV format
|
||||||
$s = pack('C1', 1).pack('C1', strlen($this->thirdparty->name)).$this->thirdparty->name;
|
$s = pack('C1', 1).pack('C1', strlen($this->thirdparty->name)).$this->thirdparty->name;
|
||||||
$s .= pack('C1', 2).pack('C1', strlen($this->thirdparty->tva_intra)).$this->thirdparty->tva_intra;
|
$s .= pack('C1', 2).pack('C1', strlen($this->thirdparty->tva_intra)).$this->thirdparty->tva_intra;
|
||||||
$s .= pack('C1', 3).pack('C1', strlen($datestring)).$this->date;
|
$s .= pack('C1', 3).pack('C1', strlen($datestring)).$datestring;
|
||||||
$s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring;
|
$s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring;
|
||||||
$s .= pack('C1', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring;
|
$s .= pack('C1', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring;
|
||||||
$s .= ''; // Hash of xml invoice
|
$s .= ''; // Hash of xml invoice
|
||||||
|
|||||||
@ -2931,15 +2931,20 @@ abstract class CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fieldposition = 'rang'; // @todo Rename 'rang' into 'position'
|
||||||
|
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||||
|
$fieldposition = 'position';
|
||||||
|
}
|
||||||
|
|
||||||
// Count number of lines to reorder (according to choice $renum)
|
// Count number of lines to reorder (according to choice $renum)
|
||||||
$nl = 0;
|
$nl = 0;
|
||||||
$sql = "SELECT count(rowid) FROM ".$this->db->prefix().$this->table_element_line;
|
$sql = "SELECT count(rowid) FROM ".$this->db->prefix().$this->table_element_line;
|
||||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||||
if (!$renum) {
|
if (!$renum) {
|
||||||
$sql .= ' AND rang = 0';
|
$sql .= " AND " . $fieldposition . " = 0";
|
||||||
}
|
}
|
||||||
if ($renum) {
|
if ($renum) {
|
||||||
$sql .= ' AND rang <> 0';
|
$sql .= " AND " . $fieldposition . " <> 0";
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::line_order", LOG_DEBUG);
|
dol_syslog(get_class($this)."::line_order", LOG_DEBUG);
|
||||||
@ -2960,7 +2965,7 @@ abstract class CommonObject
|
|||||||
if ($fk_parent_line) {
|
if ($fk_parent_line) {
|
||||||
$sql .= ' AND fk_parent_line IS NULL';
|
$sql .= ' AND fk_parent_line IS NULL';
|
||||||
}
|
}
|
||||||
$sql .= " ORDER BY rang ASC, rowid ".$rowidorder;
|
$sql .= " ORDER BY " . $fieldposition . " ASC, rowid " . $rowidorder;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG);
|
dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -3001,12 +3006,17 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function getChildrenOfLine($id, $includealltree = 0)
|
public function getChildrenOfLine($id, $includealltree = 0)
|
||||||
{
|
{
|
||||||
|
$fieldposition = 'rang'; // @todo Rename 'rang' into 'position'
|
||||||
|
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||||
|
$fieldposition = 'position';
|
||||||
|
}
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
|
|
||||||
$sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;
|
$sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;
|
||||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||||
$sql .= ' AND fk_parent_line = '.((int) $id);
|
$sql .= ' AND fk_parent_line = '.((int) $id);
|
||||||
$sql .= ' ORDER BY rang ASC';
|
$sql .= " ORDER BY " . $fieldposition . " ASC";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id, LOG_DEBUG);
|
dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -3077,7 +3087,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
global $hookmanager;
|
global $hookmanager;
|
||||||
$fieldposition = 'rang'; // @todo Rename 'rang' into 'position'
|
$fieldposition = 'rang'; // @todo Rename 'rang' into 'position'
|
||||||
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction'))) {
|
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||||
$fieldposition = 'position';
|
$fieldposition = 'position';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3123,13 +3133,13 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
if ($rang > 1) {
|
if ($rang > 1) {
|
||||||
$fieldposition = 'rang';
|
$fieldposition = 'rang';
|
||||||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) {
|
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||||
$fieldposition = 'position';
|
$fieldposition = 'position';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
||||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||||
$sql .= ' AND rang = '.((int) ($rang - 1));
|
$sql .= " AND " . $fieldposition . " = " . ((int) ($rang - 1));
|
||||||
if ($this->db->query($sql)) {
|
if ($this->db->query($sql)) {
|
||||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1));
|
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1));
|
||||||
$sql .= ' WHERE rowid = '.((int) $rowid);
|
$sql .= ' WHERE rowid = '.((int) $rowid);
|
||||||
@ -3154,13 +3164,13 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
if ($rang < $max) {
|
if ($rang < $max) {
|
||||||
$fieldposition = 'rang';
|
$fieldposition = 'rang';
|
||||||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) {
|
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||||
$fieldposition = 'position';
|
$fieldposition = 'position';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
||||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||||
$sql .= ' AND rang = '.((int) ($rang + 1));
|
$sql .= " AND " . $fieldposition . " = " . ((int) ($rang + 1));
|
||||||
if ($this->db->query($sql)) {
|
if ($this->db->query($sql)) {
|
||||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1));
|
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1));
|
||||||
$sql .= ' WHERE rowid = '.((int) $rowid);
|
$sql .= ' WHERE rowid = '.((int) $rowid);
|
||||||
@ -3181,7 +3191,12 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function getRangOfLine($rowid)
|
public function getRangOfLine($rowid)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rang FROM ".$this->db->prefix().$this->table_element_line;
|
$fieldposition = 'rang';
|
||||||
|
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||||
|
$fieldposition = 'position';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT " . $fieldposition . " FROM ".$this->db->prefix().$this->table_element_line;
|
||||||
$sql .= " WHERE rowid = ".((int) $rowid);
|
$sql .= " WHERE rowid = ".((int) $rowid);
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG);
|
dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG);
|
||||||
@ -3200,9 +3215,14 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function getIdOfLine($rang)
|
public function getIdOfLine($rang)
|
||||||
{
|
{
|
||||||
|
$fieldposition = 'rang';
|
||||||
|
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) {
|
||||||
|
$fieldposition = 'position';
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;
|
$sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;
|
||||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||||
$sql .= " AND rang = ".((int) $rang);
|
$sql .= " AND " . $fieldposition . " = ".((int) $rang);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$row = $this->db->fetch_row($resql);
|
$row = $this->db->fetch_row($resql);
|
||||||
@ -3221,7 +3241,7 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
$positionfield = 'rang';
|
$positionfield = 'rang';
|
||||||
if ($this->table_element == 'bom_bom') {
|
if (in_array($this->table_element, array('bom_bom', 'product_attribute'))) {
|
||||||
$positionfield = 'position';
|
$positionfield = 'position';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4354,9 +4374,10 @@ abstract class CommonObject
|
|||||||
* Check is done into this->childtables. There is no check into llx_element_element.
|
* Check is done into this->childtables. There is no check into llx_element_element.
|
||||||
*
|
*
|
||||||
* @param int $id Force id of object
|
* @param int $id Force id of object
|
||||||
|
* @param int $entity Force entity to check
|
||||||
* @return int <0 if KO, 0 if not used, >0 if already used
|
* @return int <0 if KO, 0 if not used, >0 if already used
|
||||||
*/
|
*/
|
||||||
public function isObjectUsed($id = 0)
|
public function isObjectUsed($id = 0, $entity = 0)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
@ -4379,11 +4400,25 @@ abstract class CommonObject
|
|||||||
|
|
||||||
// Test if child exists
|
// Test if child exists
|
||||||
$haschild = 0;
|
$haschild = 0;
|
||||||
foreach ($arraytoscan as $table => $elementname) {
|
foreach ($arraytoscan as $table => $element) {
|
||||||
//print $id.'-'.$table.'-'.$elementname.'<br>';
|
//print $id.'-'.$table.'-'.$elementname.'<br>';
|
||||||
// Check if third party can be deleted
|
// Check if element can be deleted
|
||||||
$sql = "SELECT COUNT(*) as nb from ".$this->db->prefix().$table;
|
$sql = "SELECT COUNT(*) as nb";
|
||||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $id);
|
$sql.= " FROM ".$this->db->prefix().$table." as c";
|
||||||
|
if (!empty($element['parent']) && !empty($element['parentkey'])) {
|
||||||
|
$sql.= ", ".$this->db->prefix().$element['parent']." as p";
|
||||||
|
}
|
||||||
|
$sql.= " WHERE c.".$this->fk_element." = ".((int) $id);
|
||||||
|
if (!empty($element['parent']) && !empty($element['parentkey'])) {
|
||||||
|
$sql.= " AND c.".$element['parentkey']." = p.rowid";
|
||||||
|
}
|
||||||
|
if (!empty($entity)) {
|
||||||
|
if (!empty($element['parent']) && !empty($element['parentkey'])) {
|
||||||
|
$sql.= " AND p.entity = ".((int) $entity);
|
||||||
|
} else {
|
||||||
|
$sql.= " AND c.entity = ".((int) $entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
@ -4391,11 +4426,12 @@ abstract class CommonObject
|
|||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
//print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild;
|
//print 'Found into table '.$table.', type '.$langs->transnoentitiesnoconv($elementname).', haschild='.$haschild;
|
||||||
$haschild += $obj->nb;
|
$haschild += $obj->nb;
|
||||||
if (is_numeric($elementname)) { // old usage
|
if (is_numeric($element)) { // very old usage array('table1', 'table2', ...)
|
||||||
$this->errors[] = $langs->transnoentities("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $table);
|
$this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $table);
|
||||||
} else // new usage: $elementname=Translation key
|
} elseif (is_string($element)) { // old usage array('table1' => 'TranslateKey1', 'table2' => 'TranslateKey2', ...)
|
||||||
{
|
$this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($element));
|
||||||
$this->errors[] = $langs->transnoentities("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($elementname));
|
} else { // new usage: $element['name']=Translation key
|
||||||
|
$this->errors[] = $langs->transnoentitiesnoconv("ErrorRecordHasAtLeastOneChildOfType", method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref, $langs->transnoentitiesnoconv($element['name']));
|
||||||
}
|
}
|
||||||
break; // We found at least one, we stop here
|
break; // We found at least one, we stop here
|
||||||
}
|
}
|
||||||
@ -6648,7 +6684,7 @@ abstract class CommonObject
|
|||||||
|
|
||||||
// Add validation state class
|
// Add validation state class
|
||||||
if (!empty($validationClass)) {
|
if (!empty($validationClass)) {
|
||||||
$morecss.= ' '.$validationClass;
|
$morecss.= $validationClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($type, array('date'))) {
|
if (in_array($type, array('date'))) {
|
||||||
@ -7067,6 +7103,8 @@ abstract class CommonObject
|
|||||||
$paramforthenewlink = '';
|
$paramforthenewlink = '';
|
||||||
$paramforthenewlink .= (GETPOSTISSET('action') ? '&action='.GETPOST('action', 'aZ09') : '');
|
$paramforthenewlink .= (GETPOSTISSET('action') ? '&action='.GETPOST('action', 'aZ09') : '');
|
||||||
$paramforthenewlink .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : '');
|
$paramforthenewlink .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : '');
|
||||||
|
$paramforthenewlink .= (GETPOSTISSET('origin') ? '&origin='.GETPOST('origin', 'aZ09') : '');
|
||||||
|
$paramforthenewlink .= (GETPOSTISSET('originid') ? '&originid='.GETPOST('originid', 'int') : '');
|
||||||
$paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--';
|
$paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--';
|
||||||
// TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page
|
// TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page
|
||||||
$out .= '<a class="butActionNew" title="'.$langs->trans("New").'" href="'.$url_path.'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].($paramforthenewlink ? '?'.$paramforthenewlink : '')).'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
|
$out .= '<a class="butActionNew" title="'.$langs->trans("New").'" href="'.$url_path.'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].($paramforthenewlink ? '?'.$paramforthenewlink : '')).'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
|
||||||
|
|||||||
@ -616,15 +616,15 @@ class Conf
|
|||||||
if (!empty($this->productbatch->enabled)) {
|
if (!empty($this->productbatch->enabled)) {
|
||||||
$this->global->STOCK_CALCULATE_ON_BILL = 0;
|
$this->global->STOCK_CALCULATE_ON_BILL = 0;
|
||||||
$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
|
$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
|
||||||
$this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
|
if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
|
||||||
$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 0;
|
if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT)) $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 1;
|
||||||
$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
|
$this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0;
|
||||||
$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
|
$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
|
||||||
if (empty($this->reception->enabled)) {
|
if (empty($this->reception->enabled)) {
|
||||||
$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
|
$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
|
||||||
} else {
|
} else {
|
||||||
$this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
|
if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) $this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
|
||||||
$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0;
|
if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION)) $this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,12 +54,21 @@ class DiscountAbsolute
|
|||||||
public $fk_soc;
|
public $fk_soc;
|
||||||
|
|
||||||
public $discount_type; // 0 => customer discount, 1 => supplier discount
|
public $discount_type; // 0 => customer discount, 1 => supplier discount
|
||||||
public $amount_ht; //
|
|
||||||
public $amount_tva; //
|
public $total_ht;
|
||||||
public $amount_ttc; //
|
public $total_tva;
|
||||||
public $multicurrency_amount_ht;
|
public $total_ttc;
|
||||||
public $multicurrency_amount_tva;
|
public $amount_ht; // deprecated
|
||||||
public $multicurrency_amount_ttc;
|
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
|
// Vat rate
|
||||||
public $tva_tx;
|
public $tva_tx;
|
||||||
public $vat_src_code;
|
public $vat_src_code;
|
||||||
@ -163,13 +172,21 @@ class DiscountAbsolute
|
|||||||
$this->fk_soc = $obj->fk_soc;
|
$this->fk_soc = $obj->fk_soc;
|
||||||
$this->discount_type = $obj->discount_type;
|
$this->discount_type = $obj->discount_type;
|
||||||
|
|
||||||
$this->amount_ht = $obj->amount_ht;
|
$this->total_ht = $obj->amount_ht;
|
||||||
$this->amount_tva = $obj->amount_tva;
|
$this->total_tva = $obj->amount_tva;
|
||||||
$this->amount_ttc = $obj->amount_ttc;
|
$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_total_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht;
|
||||||
$this->multicurrency_amount_tva = $obj->multicurrency_amount_tva;
|
$this->multicurrency_total_tva = $obj->multicurrency_amount_tva;
|
||||||
$this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc;
|
$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->tva_tx = $obj->tva_tx;
|
||||||
$this->vat_src_code = $obj->vat_src_code;
|
$this->vat_src_code = $obj->vat_src_code;
|
||||||
|
|||||||
@ -193,10 +193,10 @@ class DolEditor
|
|||||||
removePlugins : \''.$pluginstodisable.'\',
|
removePlugins : \''.$pluginstodisable.'\',
|
||||||
readOnly : '.($this->readonly ? 'true' : 'false').',
|
readOnly : '.($this->readonly ? 'true' : 'false').',
|
||||||
htmlEncodeOutput :'.$htmlencode_force.',
|
htmlEncodeOutput :'.$htmlencode_force.',
|
||||||
allowedContent :'.($disallowAnyContent ? 'false' : 'true').',
|
allowedContent :'.($disallowAnyContent ? 'false' : 'true').', /* Advanced Content Filter (ACF) is own when allowedContent is false */
|
||||||
extraAllowedContent : \'a[target];div{float,display}\', /* Add the style float and display into div to default other allowed tags */
|
extraAllowedContent : \'a[target];div{float,display}\', /* Add the style float and display into div to default other allowed tags */
|
||||||
disallowedContent : '.($disallowAnyContent ? '\'\'' : '\'\'').',
|
disallowedContent : '.($disallowAnyContent ? '\'\'' : '\'\'').', /* Tags that are not allowed */
|
||||||
fullPage : '.($fullpage ? 'true' : 'false').',
|
fullPage : '.($fullpage ? 'true' : 'false').', /* if true, the html, header and body tags are kept */
|
||||||
toolbar: \''.$this->toolbarname.'\',
|
toolbar: \''.$this->toolbarname.'\',
|
||||||
toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').',
|
toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').',
|
||||||
width: '.($this->width ? '\''.$this->width.'\'' : '\'\'').',
|
width: '.($this->width ? '\''.$this->width.'\'' : '\'\'').',
|
||||||
|
|||||||
@ -1886,7 +1886,7 @@ class ExtraFields
|
|||||||
$out = '<'.$tagtype.' id="trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'" class="trextrafieldseparator trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'">';
|
$out = '<'.$tagtype.' id="trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'" class="trextrafieldseparator trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'">';
|
||||||
$out .= '<'.$tagtype_dyn.' '.(!empty($colspan)?'colspan="' . $colspan . '"':'').'>';
|
$out .= '<'.$tagtype_dyn.' '.(!empty($colspan)?'colspan="' . $colspan . '"':'').'>';
|
||||||
// Some js code will be injected here to manage the collapsing of extrafields
|
// Some js code will be injected here to manage the collapsing of extrafields
|
||||||
$out .= '<span class="cursorpointer '.($extrafield_collapse_display_value == 0 ? 'fas fa-square' : 'far fa-'.(($expand_display ? 'minus' : 'plus').'-square')).'"></span> ';
|
$out .= '<span class="cursorpointer '.($extrafield_collapse_display_value == 0 ? 'fas fa-square opacitymedium' : 'far fa-'.(($expand_display ? 'minus' : 'plus').'-square')).'"></span> ';
|
||||||
$out .= '<strong>';
|
$out .= '<strong>';
|
||||||
$out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]);
|
$out .= $langs->trans($this->attributes[$object->table_element]['label'][$key]);
|
||||||
$out .= '</strong>';
|
$out .= '</strong>';
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||||
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||||
* Copyright (C) 2014-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
* Copyright (C) 2014-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||||
* Copyright (C) 2018-2021 Ferran Marcet <fmarcet@2byte.es>
|
* Copyright (C) 2018-2022 Ferran Marcet <fmarcet@2byte.es>
|
||||||
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
|
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
|
||||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||||
* Copyright (C) 2018 Christophe Battarel <christophe@altairis.fr>
|
* Copyright (C) 2018 Christophe Battarel <christophe@altairis.fr>
|
||||||
@ -1320,6 +1320,7 @@ class Form
|
|||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf, $user, $langs;
|
global $conf, $user, $langs;
|
||||||
|
global $hookmanager;
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
$num = 0;
|
$num = 0;
|
||||||
@ -1367,6 +1368,10 @@ class Form
|
|||||||
if (!empty($excludeids)) {
|
if (!empty($excludeids)) {
|
||||||
$sql .= " AND s.rowid NOT IN (".$this->db->sanitize(join(',', $excludeids)).")";
|
$sql .= " AND s.rowid NOT IN (".$this->db->sanitize(join(',', $excludeids)).")";
|
||||||
}
|
}
|
||||||
|
// Add where from hooks
|
||||||
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('selectThirdpartyListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
// Add criteria
|
// Add criteria
|
||||||
if ($filterkey && $filterkey != '') {
|
if ($filterkey && $filterkey != '') {
|
||||||
$sql .= " AND (";
|
$sql .= " AND (";
|
||||||
@ -1672,13 +1677,17 @@ class Form
|
|||||||
if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
|
if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
|
||||||
$sql .= " LEFT OUTER JOIN ".$this->db->prefix()."societe as s ON s.rowid=sp.fk_soc";
|
$sql .= " LEFT OUTER JOIN ".$this->db->prefix()."societe as s ON s.rowid=sp.fk_soc";
|
||||||
}
|
}
|
||||||
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
|
$sql .= " WHERE sp.entity IN (".getEntity('contact').")";
|
||||||
if ($socid > 0 || $socid == -1) {
|
if ($socid > 0 || $socid == -1) {
|
||||||
$sql .= " AND sp.fk_soc = ".((int) $socid);
|
$sql .= " AND sp.fk_soc = ".((int) $socid);
|
||||||
}
|
}
|
||||||
if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) {
|
if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) {
|
||||||
$sql .= " AND sp.statut <> 0";
|
$sql .= " AND sp.statut <> 0";
|
||||||
}
|
}
|
||||||
|
// Add where from hooks
|
||||||
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('selectContactListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
$sql .= " ORDER BY sp.lastname ASC";
|
$sql .= " ORDER BY sp.lastname ASC";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::selectcontacts", LOG_DEBUG);
|
dol_syslog(get_class($this)."::selectcontacts", LOG_DEBUG);
|
||||||
@ -2462,6 +2471,7 @@ class Form
|
|||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
global $hookmanager;
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
$outarray = array();
|
$outarray = array();
|
||||||
@ -2607,6 +2617,10 @@ class Form
|
|||||||
} elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only
|
} elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only
|
||||||
$sql .= " AND p.fk_product_type = 0";
|
$sql .= " AND p.fk_product_type = 0";
|
||||||
}
|
}
|
||||||
|
// Add where from hooks
|
||||||
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('selectProductsListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
// Add criteria on ref/label
|
// Add criteria on ref/label
|
||||||
if ($filterkey != '') {
|
if ($filterkey != '') {
|
||||||
$sql .= ' AND (';
|
$sql .= ' AND (';
|
||||||
@ -3180,6 +3194,7 @@ class Form
|
|||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs, $conf, $user;
|
global $langs, $conf, $user;
|
||||||
|
global $hookmanager;
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
$outarray = array();
|
$outarray = array();
|
||||||
@ -3229,6 +3244,10 @@ class Form
|
|||||||
if (!empty($filtre)) {
|
if (!empty($filtre)) {
|
||||||
$sql .= " ".$filtre;
|
$sql .= " ".$filtre;
|
||||||
}
|
}
|
||||||
|
// Add where from hooks
|
||||||
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('selectSuppliersProductsListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
// Add criteria on ref/label
|
// Add criteria on ref/label
|
||||||
if ($filterkey != '') {
|
if ($filterkey != '') {
|
||||||
$sql .= ' AND (';
|
$sql .= ' AND (';
|
||||||
@ -8587,6 +8606,7 @@ class Form
|
|||||||
print '<br><form action="' . $_SERVER["PHP_SELF"] . '" method="POST" name="formlinkedbyref' . $key . '">';
|
print '<br><form action="' . $_SERVER["PHP_SELF"] . '" method="POST" name="formlinkedbyref' . $key . '">';
|
||||||
print '<input type="hidden" name="id" value="' . $object->id . '">';
|
print '<input type="hidden" name="id" value="' . $object->id . '">';
|
||||||
print '<input type="hidden" name="action" value="addlinkbyref">';
|
print '<input type="hidden" name="action" value="addlinkbyref">';
|
||||||
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="addlink" value="' . $key . '">';
|
print '<input type="hidden" name="addlink" value="' . $key . '">';
|
||||||
print '<table class="noborder">';
|
print '<table class="noborder">';
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
|
|||||||
@ -618,7 +618,7 @@ class FormCompany extends Form
|
|||||||
*/
|
*/
|
||||||
public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '')
|
public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '')
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $hookmanager;
|
||||||
|
|
||||||
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
|
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
|
||||||
// Use Ajax search
|
// Use Ajax search
|
||||||
@ -718,6 +718,10 @@ class FormCompany extends Form
|
|||||||
if (is_array($limitto) && count($limitto)) {
|
if (is_array($limitto) && count($limitto)) {
|
||||||
$sql .= " AND s.rowid IN (".$this->db->sanitize(join(',', $limitto)).")";
|
$sql .= " AND s.rowid IN (".$this->db->sanitize(join(',', $limitto)).")";
|
||||||
}
|
}
|
||||||
|
// Add where from hooks
|
||||||
|
$parameters = array();
|
||||||
|
$reshook = $hookmanager->executeHooks('selectCompaniesForNewContactListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql .= $hookmanager->resPrint;
|
||||||
$sql .= " ORDER BY s.nom ASC";
|
$sql .= " ORDER BY s.nom ASC";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|||||||
@ -1506,7 +1506,7 @@ class FormFile
|
|||||||
if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) {
|
if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) {
|
||||||
$useajax = 0;
|
$useajax = 0;
|
||||||
}
|
}
|
||||||
print '<a href="'.((($useinecm && $useinecm != 6) && $useajax) ? '#' : ($url.'?action=deletefile&token='.newToken().'&urlfile='.urlencode($filepath).$param)).'" class="'.($useajax ? 'reposition ' : '').'deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>';
|
print '<a href="'.((($useinecm && $useinecm != 6) && $useajax) ? '#' : ($url.'?action=deletefile&token='.newToken().'&urlfile='.urlencode($filepath).$param)).'" class="reposition deletefilelink" rel="'.$filepath.'">'.img_delete().'</a>';
|
||||||
}
|
}
|
||||||
print "</td>";
|
print "</td>";
|
||||||
|
|
||||||
|
|||||||
@ -88,7 +88,7 @@ class FormOther
|
|||||||
$stringaddbarcode = str_replace("tmphtml", $htmltoreplaceby, $stringaddbarcode);
|
$stringaddbarcode = str_replace("tmphtml", $htmltoreplaceby, $stringaddbarcode);
|
||||||
$out .= $stringaddbarcode.' <input type="text" name="barcodeproductqty" class="width50 right" value="1"><br>';
|
$out .= $stringaddbarcode.' <input type="text" name="barcodeproductqty" class="width50 right" value="1"><br>';
|
||||||
$out .= '<br>';
|
$out .= '<br>';
|
||||||
$out .= '<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.'" placeholder="'.dol_escape_htmltag($langs->trans("ScanOrTypeOrCopyPasteYouBarCode")).'"></textarea>';
|
$out .= '<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.'" placeholder="'.dol_escape_htmltag($langs->trans("ScanOrTypeOrCopyPasteYourBarCodes")).'"></textarea>';
|
||||||
|
|
||||||
/*print '<br>'.$langs->trans("or").'<br>';
|
/*print '<br>'.$langs->trans("or").'<br>';
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ class FormOther
|
|||||||
$out .= 'jQuery("#scantoolmessage").text("");';
|
$out .= 'jQuery("#scantoolmessage").text("");';
|
||||||
$out .= '});'."\n";
|
$out .= '});'."\n";
|
||||||
$out .= '$("#exec'.dol_escape_js($jstoexecuteonadd).'").click(function(){
|
$out .= '$("#exec'.dol_escape_js($jstoexecuteonadd).'").click(function(){
|
||||||
console.log("We call js to execute '.dol_escape_js($jstoexecuteonadd).'");
|
console.log("We call js to execute \''.dol_escape_js($jstoexecuteonadd).'\'");
|
||||||
'.dol_escape_js($jstoexecuteonadd).'();
|
'.dol_escape_js($jstoexecuteonadd).'();
|
||||||
return false; /* We want to stay on the scan tool */
|
return false; /* We want to stay on the scan tool */
|
||||||
})';
|
})';
|
||||||
|
|||||||
@ -608,7 +608,7 @@ class Notify
|
|||||||
$mimefilename_list[] = $ref.".pdf";
|
$mimefilename_list[] = $ref.".pdf";
|
||||||
}
|
}
|
||||||
|
|
||||||
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
|
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list, 'outputlangs'=>$outputlangs, 'labeltouse'=>$labeltouse);
|
||||||
if (!isset($action)) {
|
if (!isset($action)) {
|
||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -189,7 +189,7 @@ class Utils
|
|||||||
* @param int $usedefault 1=Use default backup profile (Set this to 1 when used as cron)
|
* @param int $usedefault 1=Use default backup profile (Set this to 1 when used as cron)
|
||||||
* @param string $file 'auto' or filename to build
|
* @param string $file 'auto' or filename to build
|
||||||
* @param int $keeplastnfiles Keep only last n files (not used yet)
|
* @param int $keeplastnfiles Keep only last n files (not used yet)
|
||||||
* @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec', 2=Use the 'popen' method
|
* @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec' - need size of dump in memory, but low memory method is used if GETPOST('lowmemorydump') is set, 2=Use the 'popen' method (low memory method)
|
||||||
* @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
|
* @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
|
||||||
*/
|
*/
|
||||||
public function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0)
|
public function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0)
|
||||||
@ -278,8 +278,8 @@ class Utils
|
|||||||
if (!empty($dolibarr_main_db_port)) {
|
if (!empty($dolibarr_main_db_port)) {
|
||||||
$param .= " -P ".$dolibarr_main_db_port;
|
$param .= " -P ".$dolibarr_main_db_port;
|
||||||
}
|
}
|
||||||
if (!GETPOST("use_transaction", "alpha")) {
|
if (GETPOST("use_transaction", "alpha")) {
|
||||||
$param .= " -l --single-transaction";
|
$param .= " --single-transaction";
|
||||||
}
|
}
|
||||||
if (GETPOST("disable_fk", "alpha") || $usedefault) {
|
if (GETPOST("disable_fk", "alpha") || $usedefault) {
|
||||||
$param .= " -K";
|
$param .= " -K";
|
||||||
@ -342,17 +342,42 @@ class Utils
|
|||||||
|
|
||||||
$handle = '';
|
$handle = '';
|
||||||
|
|
||||||
|
$lowmemorydump = GETPOSTISSET("lowmemorydump", "alpha") ? GETPOST("lowmemorydump") : getDolGlobalString('MAIN_LOW_MEMORY_DUMP');
|
||||||
|
|
||||||
// Start call method to execute dump
|
// Start call method to execute dump
|
||||||
$fullcommandcrypted = $command." ".$paramcrypted." 2>&1";
|
$fullcommandcrypted = $command." ".$paramcrypted." 2>&1";
|
||||||
$fullcommandclear = $command." ".$paramclear." 2>&1";
|
$fullcommandclear = $command." ".$paramclear." 2>&1";
|
||||||
if ($compression == 'none') {
|
if (!$lowmemorydump) {
|
||||||
$handle = fopen($outputfile, 'w');
|
if ($compression == 'none') {
|
||||||
} elseif ($compression == 'gz') {
|
$handle = fopen($outputfile, 'w');
|
||||||
$handle = gzopen($outputfile, 'w');
|
} elseif ($compression == 'gz') {
|
||||||
} elseif ($compression == 'bz') {
|
$handle = gzopen($outputfile, 'w');
|
||||||
$handle = bzopen($outputfile, 'w');
|
} elseif ($compression == 'bz') {
|
||||||
} elseif ($compression == 'zstd') {
|
$handle = bzopen($outputfile, 'w');
|
||||||
$handle = fopen($outputfile, 'w');
|
} elseif ($compression == 'zstd') {
|
||||||
|
$handle = fopen($outputfile, 'w');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($compression == 'none') {
|
||||||
|
$fullcommandclear .= " > ".$outputfile;
|
||||||
|
$fullcommandcrypted .= " > ".$outputfile;
|
||||||
|
$handle = 1;
|
||||||
|
} elseif ($compression == 'gz') {
|
||||||
|
$fullcommandclear .= " | gzip > ".$outputfile;
|
||||||
|
$fullcommandcrypted .= " | gzip > ".$outputfile;
|
||||||
|
$paramcrypted.=" | gzip";
|
||||||
|
$handle = 1;
|
||||||
|
} elseif ($compression == 'bz') {
|
||||||
|
$fullcommandclear .= " | bzip2 > ".$outputfile;
|
||||||
|
$fullcommandcrypted .= " | bzip2 > ".$outputfile;
|
||||||
|
$paramcrypted.=" | bzip2";
|
||||||
|
$handle = 1;
|
||||||
|
} elseif ($compression == 'zstd') {
|
||||||
|
$fullcommandclear .= " | zstd > ".$outputfile;
|
||||||
|
$fullcommandcrypted .= " | zstd > ".$outputfile;
|
||||||
|
$paramcrypted.=" | zstd";
|
||||||
|
$handle = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ok = 0;
|
$ok = 0;
|
||||||
@ -374,7 +399,8 @@ class Utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO Replace with executeCLI function
|
// TODO Replace with executeCLI function but
|
||||||
|
// we must first introduce a low memory mode
|
||||||
if ($execmethod == 1) {
|
if ($execmethod == 1) {
|
||||||
$output_arr = array();
|
$output_arr = array();
|
||||||
$retval = null;
|
$retval = null;
|
||||||
@ -394,16 +420,23 @@ class Utils
|
|||||||
if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) {
|
if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fwrite($handle, $read.($execmethod == 2 ? '' : "\n"));
|
if (!$lowmemorydump) {
|
||||||
if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) {
|
fwrite($handle, $read.($execmethod == 2 ? '' : "\n"));
|
||||||
$ok = 1;
|
if (preg_match('/'.preg_quote('-- Dump completed', '/').'/i', $read)) {
|
||||||
} elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) {
|
$ok = 1;
|
||||||
$ok = 1;
|
} elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES', '/').'/i', $read)) {
|
||||||
|
$ok = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// If we have a result here in lowmemorydump mode, something is strange
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} elseif ($lowmemorydump) {
|
||||||
|
$ok = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($execmethod == 2) { // With this method, there is no way to get the return code, only output
|
if ($execmethod == 2) { // With this method, there is no way to get the return code, only output
|
||||||
$handlein = popen($fullcommandclear, 'r');
|
$handlein = popen($fullcommandclear, 'r');
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|||||||
@ -212,6 +212,29 @@ if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) {
|
|||||||
print dol_get_fiche_head($head, 'customreports', $title, -1, $picto);
|
print dol_get_fiche_head($head, 'customreports', $title, -1, $picto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$newarrayoftype = array();
|
||||||
|
foreach ($arrayoftype as $key => $val) {
|
||||||
|
if (dol_eval($val['enabled'], 1, 1, '1')) {
|
||||||
|
$newarrayoftype[$key] = $arrayoftype[$key];
|
||||||
|
}
|
||||||
|
if ($val['langs']) {
|
||||||
|
$langs->load($val['langs']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
$arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count);
|
||||||
|
$arrayofmesures = dol_sort_array($arrayofmesures, 'position', 'asc', 0, 0, 1);
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
$arrayofxaxis = fillArrayOfXAxis($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofxaxis, 0, $count);
|
||||||
|
$arrayofxaxis = dol_sort_array($arrayofxaxis, 'position', 'asc', 0, 0, 1);
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
$arrayofgroupby = fillArrayOfGroupBy($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofgroupby, 0, $count);
|
||||||
|
$arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1);
|
||||||
|
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if ($action == 'viewgraph') {
|
if ($action == 'viewgraph') {
|
||||||
if (!count($search_measures)) {
|
if (!count($search_measures)) {
|
||||||
@ -253,10 +276,18 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT DISTINCT ".$fieldtocount." as val";
|
$sql = "SELECT DISTINCT ".$fieldtocount." as val";
|
||||||
|
|
||||||
if (strpos($fieldtocount, 'te.') === 0) {
|
if (strpos($fieldtocount, 'te.') === 0) {
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.'_extrafields as te';
|
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te";
|
||||||
} else {
|
} else {
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
|
$tabletouse = $object->table_element;
|
||||||
|
$tablealiastouse = 't';
|
||||||
|
if (!empty($arrayofgroupby[$gval])) {
|
||||||
|
$tmpval = explode('.', $gval);
|
||||||
|
$tabletouse = $arrayofgroupby[$gval]['table'];
|
||||||
|
$tablealiastouse = $tmpval[0];
|
||||||
|
}
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX.$tabletouse." as ".$tablealiastouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the where here
|
// Add the where here
|
||||||
@ -272,7 +303,7 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
$sql .= ' LIMIT '.($MAXUNIQUEVALFORGROUP + 1);
|
$sql .= " LIMIT ".((int) ($MAXUNIQUEVALFORGROUP + 1));
|
||||||
|
|
||||||
//print $sql;
|
//print $sql;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
@ -319,8 +350,17 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
|||||||
|
|
||||||
$arrayofvaluesforgroupby['g_'.$gkey][$keytouse] = $valuetranslated;
|
$arrayofvaluesforgroupby['g_'.$gkey][$keytouse] = $valuetranslated;
|
||||||
}
|
}
|
||||||
|
// Add also the possible NULL value if field is a parent field that is not a strict join
|
||||||
|
$tmpfield = explode('.', $gval);
|
||||||
|
if ($tmpfield[0] != 't' || (is_array($object->fields[$tmpfield[1]]) && empty($object->fields[$tmpfield[1]]['notnull']))) {
|
||||||
|
dol_syslog("The group by field ".$gval." may be null (because field is null or it is a left join), so we add __NULL__ entry in list of possible values");
|
||||||
|
//var_dump($gval); var_dump($object->fields);
|
||||||
|
$arrayofvaluesforgroupby['g_'.$gkey]['__NULL__'] = $langs->transnoentitiesnoconv("NotDefined");
|
||||||
|
}
|
||||||
|
|
||||||
asort($arrayofvaluesforgroupby['g_'.$gkey]);
|
asort($arrayofvaluesforgroupby['g_'.$gkey]);
|
||||||
|
|
||||||
|
// Add a protection/error to refuse the request if number of differentr values for the group by is higher than $MAXUNIQUEVALFORGROUP
|
||||||
if (count($arrayofvaluesforgroupby['g_'.$gkey]) > $MAXUNIQUEVALFORGROUP) {
|
if (count($arrayofvaluesforgroupby['g_'.$gkey]) > $MAXUNIQUEVALFORGROUP) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
if (strpos($fieldtocount, 'te.') === 0) {
|
if (strpos($fieldtocount, 'te.') === 0) {
|
||||||
@ -380,15 +420,6 @@ print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
|||||||
// Select object
|
// Select object
|
||||||
print '<div class="divadvancedsearchfield center floatnone">';
|
print '<div class="divadvancedsearchfield center floatnone">';
|
||||||
print '<div class="inline-block"><span class="opacitymedium">'.$langs->trans("StatisticsOn").'</span></div> ';
|
print '<div class="inline-block"><span class="opacitymedium">'.$langs->trans("StatisticsOn").'</span></div> ';
|
||||||
$newarrayoftype = array();
|
|
||||||
foreach ($arrayoftype as $key => $val) {
|
|
||||||
if (dol_eval($val['enabled'], 1, 1, '1')) {
|
|
||||||
$newarrayoftype[$key] = $arrayoftype[$key];
|
|
||||||
}
|
|
||||||
if ($val['langs']) {
|
|
||||||
$langs->load($val['langs']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', 'minwidth200', 1);
|
print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', 'minwidth200', 1);
|
||||||
if (empty($conf->use_javascript_ajax)) {
|
if (empty($conf->use_javascript_ajax)) {
|
||||||
print '<input type="submit" class="button buttongen button-save nomargintop" name="changeobjecttype" value="'.$langs->trans("Refresh").'">';
|
print '<input type="submit" class="button buttongen button-save nomargintop" name="changeobjecttype" value="'.$langs->trans("Refresh").'">';
|
||||||
@ -412,17 +443,18 @@ print '</div>';
|
|||||||
|
|
||||||
// Add measures into array
|
// Add measures into array
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count);
|
|
||||||
//var_dump($arrayofmesures);
|
//var_dump($arrayofmesures);
|
||||||
print '<div class="divadvancedsearchfield clearboth">';
|
print '<div class="divadvancedsearchfield clearboth">';
|
||||||
print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span><span class="fas fa-caret-left caretleftaxis" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span></div>';
|
print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span><span class="fas fa-caret-left caretleftaxis" title="'.dol_escape_htmltag($langs->trans("Measures")).'"></span></div>';
|
||||||
print $form->multiselectarray('search_measures', $arrayofmesures, $search_measures, 0, 0, 'minwidth400', 1, 0, '', '', $langs->trans("Measures")); // Fill the array $arrayofmeasures with possible fields
|
$simplearrayofmesures = array();
|
||||||
|
foreach ($arrayofmesures as $key => $val) {
|
||||||
|
$simplearrayofmesures[$key] = $arrayofmesures[$key]['label'];
|
||||||
|
}
|
||||||
|
print $form->multiselectarray('search_measures', $simplearrayofmesures, $search_measures, 0, 0, 'minwidth400', 1, 0, '', '', $langs->trans("Measures")); // Fill the array $arrayofmeasures with possible fields
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
// XAxis
|
// XAxis
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$arrayofxaxis = fillArrayOfXAxis($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofxaxis, 0, $count);
|
|
||||||
$arrayofxaxis = dol_sort_array($arrayofxaxis, 'position', 'asc', 0, 0, 1);
|
|
||||||
print '<div class="divadvancedsearchfield">';
|
print '<div class="divadvancedsearchfield">';
|
||||||
print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span><span class="fas fa-caret-down caretdownaxis" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span></div>';
|
print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span><span class="fas fa-caret-down caretdownaxis" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span></div>';
|
||||||
//var_dump($arrayofxaxis);
|
//var_dump($arrayofxaxis);
|
||||||
@ -431,8 +463,6 @@ print '</div>';
|
|||||||
|
|
||||||
// Group by
|
// Group by
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$arrayofgroupby = fillArrayOfGroupBy($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofgroupby, 0, $count);
|
|
||||||
$arrayofgroupby = dol_sort_array($arrayofgroupby, 'position', 'asc', 0, 0, 1);
|
|
||||||
print '<div class="divadvancedsearchfield">';
|
print '<div class="divadvancedsearchfield">';
|
||||||
print '<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("GroupBy")).'"></span></div>';
|
print '<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("GroupBy")).'"></span></div>';
|
||||||
print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth200 maxwidth250', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields
|
print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth200 maxwidth250', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields
|
||||||
@ -454,18 +484,38 @@ if ($mode == 'grid') {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
|
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
|
||||||
$arrayofyaxis['t.'.$key.'-year'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.')', 'position' => $val['position']);
|
$arrayofyaxis['t.'.$key.'-year'] = array(
|
||||||
$arrayofyaxis['t.'.$key.'-month'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => $val['position']);
|
'label' => $langs->trans($val['label']).' ('.$YYYY.')',
|
||||||
$arrayofyaxis['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => $val['position']);
|
'position' => $val['position'],
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofyaxis['t.'.$key.'-month'] = array(
|
||||||
|
'label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')',
|
||||||
|
'position' => $val['position'],
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofyaxis['t.'.$key.'-day'] = array(
|
||||||
|
'label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')',
|
||||||
|
'position' => $val['position'],
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$arrayofyaxis['t.'.$key] = array('label' => $val['label'], 'position' => (int) $val['position']);
|
$arrayofyaxis['t.'.$key] = array(
|
||||||
|
'label' => $val['label'],
|
||||||
|
'position' => (int) $val['position'],
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add measure from extrafields
|
// Add measure from extrafields
|
||||||
if ($object->isextrafieldmanaged) {
|
if ($object->isextrafieldmanaged) {
|
||||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||||
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
|
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
|
||||||
$arrayofyaxis['te.'.$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'position' => (int) $extrafields->attributes[$object->table_element]['pos'][$key]);
|
$arrayofyaxis['te.'.$key] = array(
|
||||||
|
'label' => $extrafields->attributes[$object->table_element]['label'][$key],
|
||||||
|
'position' => (int) $extrafields->attributes[$object->table_element]['pos'][$key],
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -495,7 +545,7 @@ $sql = '';
|
|||||||
if (!empty($search_measures) && !empty($search_xaxis)) {
|
if (!empty($search_measures) && !empty($search_xaxis)) {
|
||||||
$fieldid = 'rowid';
|
$fieldid = 'rowid';
|
||||||
|
|
||||||
$sql = 'SELECT ';
|
$sql = "SELECT ";
|
||||||
foreach ($search_xaxis as $key => $val) {
|
foreach ($search_xaxis as $key => $val) {
|
||||||
if (preg_match('/\-year$/', $val)) {
|
if (preg_match('/\-year$/', $val)) {
|
||||||
$tmpval = preg_replace('/\-year$/', '', $val);
|
$tmpval = preg_replace('/\-year$/', '', $val);
|
||||||
@ -542,23 +592,72 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = preg_replace('/,\s*$/', '', $sql);
|
$sql = preg_replace('/,\s*$/', '', $sql);
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
|
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
|
||||||
// Add measure from extrafields
|
// Add measure from extrafields
|
||||||
if ($object->isextrafieldmanaged) {
|
if ($object->isextrafieldmanaged) {
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te ON te.fk_object = t.".$fieldid;
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as te ON te.fk_object = t.".$fieldid;
|
||||||
}
|
}
|
||||||
if ($object->ismultientitymanaged) {
|
// Add table for link for multientity
|
||||||
|
if ($object->ismultientitymanaged) { // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
|
||||||
if ($object->ismultientitymanaged == 1) {
|
if ($object->ismultientitymanaged == 1) {
|
||||||
// Nothing here
|
// No table to add here
|
||||||
} else {
|
} else {
|
||||||
$tmparray = explode('@', $object->ismultientitymanaged);
|
$tmparray = explode('@', $object->ismultientitymanaged);
|
||||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1]." as parenttable ON t.".$tmparray[0]." = parenttable.rowid";
|
$sql .= " INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1]." as parenttableforentity ON t.".$tmparray[0]." = parenttableforentity.rowid";
|
||||||
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
|
$sql .= " AND parenttableforentity.entity IN (".getEntity($tmparray[1]).")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql .= ' WHERE 1 = 1';
|
|
||||||
if ($object->ismultientitymanaged == 1) {
|
$listoftablesalreadyadded = array($object->table_element => $object->table_element);
|
||||||
$sql .= ' AND entity IN ('.getEntity($object->element).')';
|
|
||||||
|
// Add LEFT JOIN for all parent tables mentionned into the Xaxis
|
||||||
|
//var_dump($arrayofxaxis); var_dump($search_xaxis);
|
||||||
|
foreach ($search_xaxis as $key => $val) {
|
||||||
|
if (!empty($arrayofxaxis[$val])) {
|
||||||
|
$tmpval = explode('.', $val);
|
||||||
|
//var_dump($arrayofxaxis[$val]['table']);
|
||||||
|
if (! in_array($arrayofxaxis[$val]['table'], $listoftablesalreadyadded)) { // We do not add join for main table already added
|
||||||
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$arrayofxaxis[$val]['table']." as ".$db->sanitize($tmpval[0])." ON t.".str_replace('t__', '', $db->sanitize($tmpval[0]))." = ".$db->sanitize($tmpval[0]).".rowid";
|
||||||
|
$listoftablesalreadyadded[$arrayofxaxis[$val]['table']] = $arrayofxaxis[$val]['table'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($db, 'Found a key into search_xaxis not found into arrayofxaxis');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add LEFT JOIN for all parent tables mentionned into the Group by
|
||||||
|
//var_dump($arrayofgroupby); var_dump($search_groupby);
|
||||||
|
foreach ($search_groupby as $key => $val) {
|
||||||
|
if (!empty($arrayofgroupby[$val])) {
|
||||||
|
$tmpval = explode('.', $val);
|
||||||
|
//var_dump($arrayofxaxis[$val]['table']);
|
||||||
|
if (! in_array($arrayofgroupby[$val]['table'], $listoftablesalreadyadded)) { // We do not add join for main table already added
|
||||||
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$arrayofgroupby[$val]['table']." as ".$tmpval[0]." ON t.".str_replace('t__', '', $tmpval[0])." = ".$tmpval[0].".rowid";
|
||||||
|
$listoftablesalreadyadded[$arrayofgroupby[$val]['table']] = $arrayofgroupby[$val]['table'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($db, 'Found a key into search_groupby not found into arrayofgroupby');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add LEFT JOIN for all parent tables mentionned into the Yaxis
|
||||||
|
//var_dump($arrayofgroupby); var_dump($search_groupby);
|
||||||
|
foreach ($search_measures as $key => $val) {
|
||||||
|
if (!empty($arrayofmesures[$val])) {
|
||||||
|
$tmpval = explode('.', $val);
|
||||||
|
//var_dump($arrayofxaxis[$val]['table']);
|
||||||
|
if (! in_array($arrayofmesures[$val]['table'], $listoftablesalreadyadded)) { // We do not add join for main table already added
|
||||||
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$arrayofmesures[$val]['table']." as ".$tmpval[0]." ON t.".str_replace('t__', '', $tmpval[0])." = ".$tmpval[0].".rowid";
|
||||||
|
$listoftablesalreadyadded[$arrayofmesures[$val]['table']] = $arrayofmesures[$val]['table'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($db, 'Found a key into search_measures not found into arrayofmesures');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= " WHERE 1 = 1";
|
||||||
|
if ($object->ismultientitymanaged == 1) { // 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
|
||||||
|
$sql .= " AND t.entity IN (".getEntity($object->element).")";
|
||||||
}
|
}
|
||||||
// Add the where here
|
// Add the where here
|
||||||
$sqlfilters = $search_component_params_hidden;
|
$sqlfilters = $search_component_params_hidden;
|
||||||
@ -571,7 +670,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
|||||||
print $errormessage;
|
print $errormessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql .= ' GROUP BY ';
|
$sql .= " GROUP BY ";
|
||||||
foreach ($search_xaxis as $key => $val) {
|
foreach ($search_xaxis as $key => $val) {
|
||||||
if (preg_match('/\-year$/', $val)) {
|
if (preg_match('/\-year$/', $val)) {
|
||||||
$tmpval = preg_replace('/\-year$/', '', $val);
|
$tmpval = preg_replace('/\-year$/', '', $val);
|
||||||
@ -636,7 +735,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
|||||||
|
|
||||||
$legend = array();
|
$legend = array();
|
||||||
foreach ($search_measures as $key => $val) {
|
foreach ($search_measures as $key => $val) {
|
||||||
$legend[] = $langs->trans($arrayofmesures[$val]);
|
$legend[] = $langs->trans($arrayofmesures[$val]['label']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$useagroupby = (is_array($search_groupby) && count($search_groupby));
|
$useagroupby = (is_array($search_groupby) && count($search_groupby));
|
||||||
@ -667,7 +766,7 @@ if ($sql) {
|
|||||||
if (!empty($object->fields[$xvalwithoutprefix]['arrayofkeyval'])) {
|
if (!empty($object->fields[$xvalwithoutprefix]['arrayofkeyval'])) {
|
||||||
$xlabel = $object->fields[$xvalwithoutprefix]['arrayofkeyval'][$obj->$fieldforxkey];
|
$xlabel = $object->fields[$xvalwithoutprefix]['arrayofkeyval'][$obj->$fieldforxkey];
|
||||||
}
|
}
|
||||||
$labeltouse = (($xlabel || $xlabel == '0') ? dol_trunc($xlabel, 20, 'middle') : ($xlabel === '' ? $langs->trans("Empty") : $langs->trans("NotDefined")));
|
$labeltouse = (($xlabel || $xlabel == '0') ? dol_trunc($xlabel, 20, 'middle') : ($xlabel === '' ? $langs->transnoentitiesnoconv("Empty") : $langs->transnoentitiesnoconv("NotDefined")));
|
||||||
|
|
||||||
if ($oldlabeltouse && ($labeltouse != $oldlabeltouse)) {
|
if ($oldlabeltouse && ($labeltouse != $oldlabeltouse)) {
|
||||||
$xi++; // Increase $xi
|
$xi++; // Increase $xi
|
||||||
@ -861,26 +960,64 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
|
|||||||
|
|
||||||
if ($level == 0) {
|
if ($level == 0) {
|
||||||
// Add the count of record only for the main/first level object. Parents are necessarly unique for each record.
|
// Add the count of record only for the main/first level object. Parents are necessarly unique for each record.
|
||||||
$arrayofmesures[$tablealias.'.count'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': Count';
|
$arrayofmesures[$tablealias.'.count'] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': Count',
|
||||||
|
'position' => 0,
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add main fields of object
|
// Add main fields of object
|
||||||
foreach ($object->fields as $key => $val) {
|
foreach ($object->fields as $key => $val) {
|
||||||
if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) {
|
if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) {
|
||||||
$arrayofmesures[$tablealias.'.'.$key.'-sum'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>';
|
$position = (!empty($val['position']) ? $val['position'] : 0);
|
||||||
$arrayofmesures[$tablealias.'.'.$key.'-average'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>';
|
$arrayofmesures[$tablealias.'.'.$key.'-sum'] = array(
|
||||||
$arrayofmesures[$tablealias.'.'.$key.'-min'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>';
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
|
||||||
$arrayofmesures[$tablealias.'.'.$key.'-max'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>';
|
'position' => ($position+($count * 100000)).'.1',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofmesures[$tablealias.'.'.$key.'-average'] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Average").')</span>',
|
||||||
|
'position' => ($position+($count * 100000)).'.2',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofmesures[$tablealias.'.'.$key.'-min'] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>',
|
||||||
|
'position' => ($position+($count * 100000)).'.3',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofmesures[$tablealias.'.'.$key.'-max'] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>',
|
||||||
|
'position' => ($position+($count * 100000)).'.4',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add extrafields to Measures
|
// Add extrafields to Measures
|
||||||
if ($object->isextrafieldmanaged) {
|
if ($object->isextrafieldmanaged) {
|
||||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||||
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
|
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) {
|
||||||
$arrayofmesures[$tablealias.'e.'.$key.'-sum'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>';
|
$position = (!empty($val['position']) ? $val['position'] : 0);
|
||||||
$arrayofmesures[$tablealias.'e.'.$key.'-average'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Average").')</span>';
|
$arrayofmesures[$tablealias.'e.'.$key.'-sum'] = array(
|
||||||
$arrayofmesures[$tablealias.'e.'.$key.'-min'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>';
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
|
||||||
$arrayofmesures[$tablealias.'e.'.$key.'-max'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>';
|
'position' => ($position+($count * 100000)).'.1',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofmesures[$tablealias.'e.'.$key.'-average'] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Average").')</span>',
|
||||||
|
'position' => ($position+($count * 100000)).'.2',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofmesures[$tablealias.'e.'.$key.'-min'] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>',
|
||||||
|
'position' => ($position+($count * 100000)).'.3',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofmesures[$tablealias.'e.'.$key.'-max'] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>',
|
||||||
|
'position' => ($position+($count * 100000)).'.4',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -888,19 +1025,16 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
|
|||||||
foreach ($object->fields as $key => $val) {
|
foreach ($object->fields as $key => $val) {
|
||||||
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
||||||
$tmptype = explode(':', $val['type'], 4);
|
$tmptype = explode(':', $val['type'], 4);
|
||||||
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
|
if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
|
||||||
$newobject = $tmptype[1];
|
$newobject = $tmptype[1];
|
||||||
dol_include_once($tmptype[2]);
|
dol_include_once($tmptype[2]);
|
||||||
if (class_exists($newobject)) {
|
if (class_exists($newobject)) {
|
||||||
$tmpobject = new $newobject($db);
|
$tmpobject = new $newobject($db);
|
||||||
/*var_dump($val['label']);
|
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
||||||
var_dump($tmptype);
|
|
||||||
var_dump($arrayofmesures);
|
|
||||||
var_dump('t-'.$key);*/
|
|
||||||
$count++;
|
$count++;
|
||||||
$arrayofmesures = fillArrayOfMeasures($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofmesures, $level + 1, $count);
|
$arrayofmesures = fillArrayOfMeasures($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofmesures, $level + 1, $count);
|
||||||
} else {
|
} else {
|
||||||
print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n";
|
print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -914,7 +1048,7 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
|
|||||||
* Fill arrayofmesures for an object
|
* Fill arrayofmesures for an object
|
||||||
*
|
*
|
||||||
* @param mixed $object Any object
|
* @param mixed $object Any object
|
||||||
* @param string $tablealias Alias of table
|
* @param string $tablealias Alias of table ('t' for example)
|
||||||
* @param string $labelofobject Label of object
|
* @param string $labelofobject Label of object
|
||||||
* @param array $arrayofxaxis Array of xaxis already filled
|
* @param array $arrayofxaxis Array of xaxis already filled
|
||||||
* @param int $level Level
|
* @param int $level Level
|
||||||
@ -964,14 +1098,32 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
|
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
|
||||||
$arrayofxaxis[$tablealias.'.'.$key.'-year'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => ($val['position']+($count * 100000)).'.1');
|
$position = (!empty($val['position']) ? $val['position'] : 0);
|
||||||
$arrayofxaxis[$tablealias.'.'.$key.'-month'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => ($val['position']+($count * 100000)).'.2');
|
$arrayofxaxis[$tablealias.'.'.$key.'-year'] = array(
|
||||||
$arrayofxaxis[$tablealias.'.'.$key.'-day'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => ($val['position']+($count * 100000)).'.3');
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>',
|
||||||
|
'position' => ($position+($count * 100000)).'.1',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofxaxis[$tablealias.'.'.$key.'-month'] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>',
|
||||||
|
'position' => ($position+($count * 100000)).'.2',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofxaxis[$tablealias.'.'.$key.'-day'] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>',
|
||||||
|
'position' => ($position+($count * 100000)).'.3',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$arrayofxaxis[$tablealias.'.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000)));
|
$arrayofxaxis[$tablealias.'.'.$key] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']),
|
||||||
|
'position' => ($position+($count * 100000)),
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add extrafields to X-Axis
|
// Add extrafields to X-Axis
|
||||||
if ($object->isextrafieldmanaged) {
|
if ($object->isextrafieldmanaged) {
|
||||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||||
@ -981,26 +1133,28 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
|
|||||||
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
|
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$arrayofxaxis[$tablealias.'e.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000));
|
$arrayofxaxis[$tablealias.'e.'.$key] = array(
|
||||||
|
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]),
|
||||||
|
'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000),
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add fields for parent objects
|
// Add fields for parent objects
|
||||||
foreach ($object->fields as $key => $val) {
|
foreach ($object->fields as $key => $val) {
|
||||||
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
||||||
$tmptype = explode(':', $val['type'], 4);
|
$tmptype = explode(':', $val['type'], 4);
|
||||||
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
|
if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
|
||||||
$newobject = $tmptype[1];
|
$newobject = $tmptype[1];
|
||||||
dol_include_once($tmptype[2]);
|
dol_include_once($tmptype[2]);
|
||||||
if (class_exists($newobject)) {
|
if (class_exists($newobject)) {
|
||||||
$tmpobject = new $newobject($db);
|
$tmpobject = new $newobject($db);
|
||||||
/*var_dump($val['label']);
|
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
||||||
var_dump($tmptype);
|
|
||||||
var_dump($arrayofmesures);
|
|
||||||
var_dump('t-'.$key);*/
|
|
||||||
$count++;
|
$count++;
|
||||||
$arrayofxaxis = fillArrayOfXAxis($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofxaxis, $level + 1, $count);
|
$arrayofxaxis = fillArrayOfXAxis($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofxaxis, $level + 1, $count);
|
||||||
} else {
|
} else {
|
||||||
print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n";
|
print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1064,14 +1218,32 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
|
if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) {
|
||||||
$arrayofgroupby[$tablealias.'.'.$key.'-year'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => ($val['position']+($count * 100000)).'.1');
|
$position = (!empty($val['position']) ? $val['position'] : 0);
|
||||||
$arrayofgroupby[$tablealias.'.'.$key.'-month'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => ($val['position']+($count * 100000)).'.2');
|
$arrayofgroupby[$tablealias.'.'.$key.'-year'] = array(
|
||||||
$arrayofgroupby[$tablealias.'.'.$key.'-day'] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => ($val['position']+($count * 100000)).'.3');
|
'label' => img_picto('', $object->picto,
|
||||||
|
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.')</span>', 'position' => ($position+($count * 100000)).'.1',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofgroupby[$tablealias.'.'.$key.'-month'] = array(
|
||||||
|
'label' => img_picto('', $object->picto,
|
||||||
|
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.')</span>', 'position' => ($position+($count * 100000)).'.2',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
|
$arrayofgroupby[$tablealias.'.'.$key.'-day'] = array(
|
||||||
|
'label' => img_picto('', $object->picto,
|
||||||
|
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$YYYY.'-'.$MM.'-'.$DD.')</span>', 'position' => ($position+($count * 100000)).'.3',
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$arrayofgroupby[$tablealias.'.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($val['position']+($count * 100000)));
|
$arrayofgroupby[$tablealias.'.'.$key] = array(
|
||||||
|
'label' => img_picto('', $object->picto,
|
||||||
|
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($position+($count * 100000)),
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add extrafields to Group by
|
// Add extrafields to Group by
|
||||||
if ($object->isextrafieldmanaged) {
|
if ($object->isextrafieldmanaged) {
|
||||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||||
@ -1081,26 +1253,28 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
|
|||||||
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
|
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$arrayofgroupby[$tablealias.'e.'.$key] = array('label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000));
|
$arrayofgroupby[$tablealias.'e.'.$key] = array(
|
||||||
|
'label' => img_picto('', $object->picto,
|
||||||
|
'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]), 'position' => 1000 + (int) $extrafields->attributes[$object->table_element]['pos'][$key] + ($count * 100000),
|
||||||
|
'table' => $object->table_element
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add fields for parent objects
|
// Add fields for parent objects
|
||||||
foreach ($object->fields as $key => $val) {
|
foreach ($object->fields as $key => $val) {
|
||||||
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
||||||
$tmptype = explode(':', $val['type'], 4);
|
$tmptype = explode(':', $val['type'], 4);
|
||||||
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
|
if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
|
||||||
$newobject = $tmptype[1];
|
$newobject = $tmptype[1];
|
||||||
dol_include_once($tmptype[2]);
|
dol_include_once($tmptype[2]);
|
||||||
if (class_exists($newobject)) {
|
if (class_exists($newobject)) {
|
||||||
$tmpobject = new $newobject($db);
|
$tmpobject = new $newobject($db);
|
||||||
/*var_dump($val['label']);
|
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
||||||
var_dump($tmptype);
|
|
||||||
var_dump($arrayofmesures);
|
|
||||||
var_dump('t-'.$key);*/
|
|
||||||
$count++;
|
$count++;
|
||||||
$arrayofgroupby = fillArrayOfGroupBy($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofgroupby, $level + 1, $count);
|
$arrayofgroupby = fillArrayOfGroupBy($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofgroupby, $level + 1, $count);
|
||||||
} else {
|
} else {
|
||||||
print 'Failed to find '.$newobject.' class for field '.$key.' of object '.$object->element."\n";
|
print 'For property '.$object->element.'->'.$key.', type="'.$val['type'].'": Failed to find class '.$newobject." in file ".$tmptype[2]."<br>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -266,7 +266,7 @@ class DoliDBMysqli extends DoliDB
|
|||||||
* @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollback to savepoint if error (this allow to have some request with errors inside global transactions).
|
* @param int $usesavepoint 0=Default mode, 1=Run a savepoint before and a rollback to savepoint if error (this allow to have some request with errors inside global transactions).
|
||||||
* Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints.
|
* Note that with Mysql, this parameter is not used as Myssql can already commit a transaction even if one request is in error, without using savepoints.
|
||||||
* @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
|
* @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...)
|
||||||
* @param int $result_mode Result mode
|
* @param int $result_mode Result mode (Using 1=MYSQLI_USE_RESULT instead of 0=MYSQLI_STORE_RESULT will not buffer the result and save memory)
|
||||||
* @return bool|mysqli_result Resultset of answer
|
* @return bool|mysqli_result Resultset of answer
|
||||||
*/
|
*/
|
||||||
public function query($query, $usesavepoint = 0, $type = 'auto', $result_mode = 0)
|
public function query($query, $usesavepoint = 0, $type = 'auto', $result_mode = 0)
|
||||||
|
|||||||
@ -1187,9 +1187,9 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
// Force to hide menus when page is inside an iFrame
|
// Force to hide menus when page is inside an iFrame so we can show any page into a dialog popup
|
||||||
$(document).ready(function() {
|
$(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");
|
console.log("Page is detected to be into an iframe, we hide by CSS the menus");
|
||||||
// The page is in an iframe
|
// The page is in an iframe
|
||||||
jQuery(".side-nav-vert, .side-nav, .websitebar").hide();
|
jQuery(".side-nav-vert, .side-nav, .websitebar").hide();
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user