forked from Wavyzz/dolibarr
Merge branch 'develop' of github.com:Dolibarr/dolibarr into NEW_inventory_pmp_hidden_conf
This commit is contained in:
10
.travis.yml
10
.travis.yml
@@ -50,7 +50,7 @@ jobs:
|
||||
env: DB=postgresql
|
||||
- stage: PHP 5.6-7.4
|
||||
if: type = pull_request OR type = push
|
||||
php: '7.4'
|
||||
php: '7.4.22'
|
||||
env: DB=mysql
|
||||
- stage: PHP Dev
|
||||
if: type = push AND branch = develop
|
||||
@@ -106,7 +106,7 @@ install:
|
||||
php-parallel-lint/php-console-highlighter ^0 \
|
||||
squizlabs/php_codesniffer ^3
|
||||
fi
|
||||
if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then
|
||||
if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '7.4.22' ]; then
|
||||
composer -n require phpunit/phpunit ^7 \
|
||||
php-parallel-lint/php-parallel-lint ^1.2 \
|
||||
php-parallel-lint/php-console-highlighter ^0 \
|
||||
@@ -241,7 +241,7 @@ before_script:
|
||||
# enable php-fpm
|
||||
- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
|
||||
- |
|
||||
if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
|
||||
if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ] || [ "$TRAVIS_PHP_VERSION" = '7.4.22' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
|
||||
# Copy the included pool
|
||||
sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf
|
||||
fi
|
||||
@@ -276,7 +276,7 @@ script:
|
||||
set -e
|
||||
#parallel-lint --exclude htdocs/includes --blame .
|
||||
# Exclusions are defined in the ruleset.xml file
|
||||
if [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then
|
||||
if [ "$TRAVIS_PHP_VERSION" = "7.4.22" ]; then
|
||||
parallel-lint -e php --exclude dev/tools/test/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \
|
||||
--exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \
|
||||
--exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \
|
||||
@@ -291,7 +291,7 @@ script:
|
||||
# Ensure we catch errors
|
||||
set -e
|
||||
# Exclusions are defined in the ruleset.xml file
|
||||
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then
|
||||
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4.22" ]; then
|
||||
phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .;
|
||||
fi
|
||||
set +e
|
||||
|
||||
29
ChangeLog
29
ChangeLog
@@ -3,6 +3,7 @@ English Dolibarr ChangeLog
|
||||
--------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
***** ChangeLog for 16.0.0 compared to 15.0.0 *****
|
||||
|
||||
For users:
|
||||
@@ -30,6 +31,34 @@ Following changes may create regressions for some external modules, but were nec
|
||||
|
||||
|
||||
|
||||
***** ChangeLog for 15.0.1 compared to 15.0.0 *****
|
||||
FIX: #19777 #20281
|
||||
FIX: bad position of extrafields for interventions
|
||||
FIX: Blocking situation when a payment was deleted in bank.
|
||||
FIX: creation of the shipment if order contains services
|
||||
FIX: Drag and drop line of files on join files tab
|
||||
FIX: Error management on mass action "Approve holiday"
|
||||
FIX: error with php8
|
||||
FIX: in case of VAT refund, negative amount must be allowed
|
||||
FIX: invoice pdf: lines originating from deposits were not detailed anymore
|
||||
FIX: Invoice - When you create an invoice for a given thirdparty, fk_account is not retrieved from company card
|
||||
FIX: list of visible type of event was not correctly filtered
|
||||
FIX: Missing or bad permissions
|
||||
FIX: Missing the field date start/end in export supplier invoice/order
|
||||
FIX: On large proposal or invoice, fix n(n+1) sql into a n sql.
|
||||
FIX: options should not exists on invoices
|
||||
FIX: payment not completed when using Paypal.
|
||||
FIX: permission to download files of expense report with readall.
|
||||
FIX- Preview icon in documents list PDF in the admin page third-party
|
||||
FIX: shipping list, e.shipping_method_id should be e.fk_shipping_method.
|
||||
FIX: Show product photo on Supplier order Cornas model.
|
||||
FIX: User name in ManufacturingOrder
|
||||
FIX: viewimage.php blocks requests with multicompany from other enties
|
||||
FIX: #yogosha9048
|
||||
FIX: #yogosha9054
|
||||
FIX: #yogosha9095
|
||||
|
||||
|
||||
***** ChangeLog for 15.0.0 compared to 14.0.0 *****
|
||||
|
||||
For users:
|
||||
|
||||
@@ -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.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_FEC2 = 1010;
|
||||
|
||||
/**
|
||||
* @var DoliDB Database handler
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string[] Error codes (or messages)
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
/**
|
||||
* \file htdocs/accountancy/class/accountancyimport.class.php
|
||||
* \ingroup Accountancy (Double entries)
|
||||
* \brief Class accountancy import
|
||||
* \brief Class with methods for accountancy import
|
||||
*/
|
||||
|
||||
|
||||
@@ -39,63 +39,104 @@
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @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 $listvalues Values list to add
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $record_key Record key
|
||||
* @return mixed Value
|
||||
*/
|
||||
public function computeAmount(&$arrayrecord, $fieldname, &$listfields, &$listvalues)
|
||||
public function computeAmount(&$arrayrecord, $listfields, $record_key)
|
||||
{
|
||||
$fieldArr = explode('.', $fieldname);
|
||||
if (count($fieldArr) > 0) {
|
||||
$fieldname = $fieldArr[1];
|
||||
// get fields indexes
|
||||
$field_index_list = array_flip($listfields);
|
||||
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']));
|
||||
$credit = floatval(trim($arrayrecord[12]['val']));
|
||||
if (!empty($debit)) {
|
||||
$amount = $debit;
|
||||
} else {
|
||||
$amount = $credit;
|
||||
}
|
||||
|
||||
$listfields[] = $fieldname;
|
||||
$listvalues[] = "'" . abs($amount) . "'";
|
||||
|
||||
return 1;
|
||||
return "''";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compute sens
|
||||
* Compute direction
|
||||
*
|
||||
* @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 $listvalues Values list to add
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param int $record_key Record key
|
||||
* @return mixed Value
|
||||
*/
|
||||
public function computeDirection(&$arrayrecord, $fieldname, &$listfields, &$listvalues)
|
||||
public function computeDirection(&$arrayrecord, $listfields, $record_key)
|
||||
{
|
||||
$fieldArr = explode('.', $fieldname);
|
||||
if (count($fieldArr) > 0) {
|
||||
$fieldname = $fieldArr[1];
|
||||
$field_index_list = array_flip($listfields);
|
||||
if (isset($field_index_list['debit'])) {
|
||||
$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']));
|
||||
if (!empty($debit)) {
|
||||
$sens = 'D';
|
||||
} else {
|
||||
$sens = 'C';
|
||||
}
|
||||
|
||||
$listfields[] = $fieldname;
|
||||
$listvalues[] = "'" . $sens . "'";
|
||||
|
||||
return 1;
|
||||
return "''";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ if ($result) {
|
||||
print '</td>';
|
||||
|
||||
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;
|
||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
|
||||
print '</td>';
|
||||
|
||||
@@ -637,7 +637,7 @@ if ($result) {
|
||||
|
||||
// Description
|
||||
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;
|
||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $facture_static_det->desc);
|
||||
print '</td>';
|
||||
|
||||
@@ -405,7 +405,7 @@ if ($result) {
|
||||
|
||||
// Fees description -- Can be null
|
||||
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;
|
||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
|
||||
print '</td>';
|
||||
|
||||
@@ -481,7 +481,7 @@ if ($result) {
|
||||
|
||||
// Fees description -- Can be null
|
||||
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;
|
||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
|
||||
print '</td>';
|
||||
|
||||
@@ -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->thirdparty_code = $companystatic->code_client;
|
||||
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT')) {
|
||||
$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->label_compte = $label_account;
|
||||
@@ -886,6 +891,13 @@ if (empty($action) || $action == 'view') {
|
||||
print "</td>";
|
||||
// Subledger account
|
||||
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>';
|
||||
$companystatic->id = $tabcompany[$key]['id'];
|
||||
$companystatic->name = $tabcompany[$key]['name'];
|
||||
|
||||
@@ -502,7 +502,7 @@ if ($result) {
|
||||
print '</td>';
|
||||
|
||||
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;
|
||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
|
||||
print '</td>';
|
||||
|
||||
@@ -644,7 +644,7 @@ if ($result) {
|
||||
|
||||
// Description
|
||||
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;
|
||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $facturefourn_static_det->desc);
|
||||
print '</td>';
|
||||
|
||||
@@ -1719,8 +1719,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>';
|
||||
|
||||
@@ -1737,9 +1735,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
if ($user->admin) {
|
||||
print '<!-- '.$langs->trans("Crypted").': '.$object->pass_indatabase_crypted.' -->';
|
||||
}
|
||||
print '<span class="opacitymedium"'.$langs->trans("Hidden").'</span>';
|
||||
print '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
|
||||
}
|
||||
if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) {
|
||||
if (!empty($object->pass_indatabase) && empty($object->user_id)) { // Show warning only for old password still in clear (does not happen anymore)
|
||||
$langs->load("errors");
|
||||
$htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
|
||||
print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
|
||||
@@ -1778,7 +1776,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border tableforfield tableforfield centpercent">';
|
||||
print '<table class="border tableforfield centpercent">';
|
||||
|
||||
// Tags / Categories
|
||||
if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
|
||||
@@ -1853,18 +1851,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// VCard
|
||||
/*
|
||||
print '<tr><td>';
|
||||
print $langs->trans("VCard").'</td><td colspan="3">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'">';
|
||||
print img_picto($langs->trans("Download").' vcard', 'vcard.png', 'class="paddingrightonly"');
|
||||
print $langs->trans("Download");
|
||||
print img_picto($langs->trans("Download").' vcard', 'download', 'class="paddingleft"');
|
||||
print '</a>';
|
||||
print '</td></tr>';
|
||||
*/
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
print "</div></div>\n";
|
||||
|
||||
@@ -358,7 +358,7 @@ class Members extends DolibarrApi
|
||||
if ($member->update(DolibarrApiAccess::$user) >= 0) {
|
||||
return $this->get($id);
|
||||
} 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) {
|
||||
return $this->get($id);
|
||||
} 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ class Subscriptions extends DolibarrApi
|
||||
if ($subscription->update(DolibarrApiAccess::$user) > 0) {
|
||||
return $this->get($id);
|
||||
} 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);
|
||||
|
||||
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) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
|
||||
@@ -501,7 +501,7 @@ if ($rowid > 0) {
|
||||
|
||||
// Login
|
||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.' </td></tr>';
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.dol_escape_htmltag($object->login).'</td></tr>';
|
||||
}
|
||||
|
||||
// Type
|
||||
@@ -512,25 +512,24 @@ if ($rowid > 0) {
|
||||
print '</tr>';
|
||||
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.dol_escape_htmltag($object->company).'</td></tr>';
|
||||
|
||||
// Civility
|
||||
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().' </td>';
|
||||
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Password
|
||||
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
|
||||
print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass);
|
||||
print '<tr><td>'.$langs->trans("Password").'</td><td>';
|
||||
if ($object->pass) {
|
||||
print preg_replace('/./i', '*', $object->pass);
|
||||
} else {
|
||||
if ($user->admin) {
|
||||
print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
|
||||
} else {
|
||||
print $langs->trans("Hidden");
|
||||
print '<!-- '.$langs->trans("Crypted").': '.$object->pass_indatabase_crypted.' -->';
|
||||
}
|
||||
print '<span class="opacitymedium">'.$langs->trans("Hidden").'</span>';
|
||||
}
|
||||
if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) {
|
||||
if (!empty($object->pass_indatabase) && empty($object->user_id)) { // Show warning only for old password still in clear (does not happen anymore)
|
||||
$langs->load("errors");
|
||||
$htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
|
||||
print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
|
||||
@@ -546,15 +545,17 @@ if ($rowid > 0) {
|
||||
print " ".img_warning($langs->trans("Late"));
|
||||
}
|
||||
} else {
|
||||
if (!$adht->subscription) {
|
||||
if ($object->need_subscription == 0) {
|
||||
print $langs->trans("SubscriptionNotNeeded");
|
||||
} elseif (!$adht->subscription) {
|
||||
print $langs->trans("SubscriptionNotRecorded");
|
||||
if ($object->statut > 0) {
|
||||
print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
|
||||
if (Adherent::STATUS_VALIDATED == $object->statut) {
|
||||
print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated
|
||||
}
|
||||
} else {
|
||||
print $langs->trans("SubscriptionNotReceived");
|
||||
if ($object->statut > 0) {
|
||||
print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
|
||||
if (Adherent::STATUS_VALIDATED == $object->statut) {
|
||||
print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft, not excluded and not resiliated
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -563,18 +564,13 @@ if ($rowid > 0) {
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border tableforfield centpercent">';
|
||||
|
||||
// Birthday
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
|
||||
|
||||
// Public
|
||||
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
|
||||
|
||||
// Categories
|
||||
// Tags / Categories
|
||||
if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
|
||||
print '<tr><td>'.$langs->trans("Categories").'</td>';
|
||||
print '<td colspan="2">';
|
||||
@@ -582,6 +578,12 @@ if ($rowid > 0) {
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Birth Date
|
||||
print '<tr><td class="titlefield">'.$langs->trans("DateOfBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
|
||||
|
||||
// Public
|
||||
print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
|
||||
|
||||
// Other attributes
|
||||
$cols = 2;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
||||
@@ -663,8 +665,6 @@ if ($rowid > 0) {
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print '</form>';
|
||||
|
||||
|
||||
/*
|
||||
* Action bar
|
||||
|
||||
@@ -94,7 +94,7 @@ if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2
|
||||
$search_code = GETPOST('search_code', 'alpha');
|
||||
|
||||
// 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
|
||||
// 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[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[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[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";
|
||||
@@ -265,7 +265,7 @@ $tabsqlsort[17] = "code ASC";
|
||||
$tabsqlsort[18] = "code ASC, libelle ASC";
|
||||
$tabsqlsort[19] = "id 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[23] = "country ASC, taux ASC";
|
||||
$tabsqlsort[24] = "code ASC, label ASC";
|
||||
@@ -312,7 +312,7 @@ $tabfield[17] = "code,label,accountancy_code";
|
||||
$tabfield[18] = "code,libelle,tracking";
|
||||
$tabfield[19] = "code,libelle";
|
||||
$tabfield[20] = "code,libelle";
|
||||
$tabfield[21] = "code,label,position";
|
||||
$tabfield[21] = "code,label,qty,type_duration,position";
|
||||
$tabfield[22] = "code,label";
|
||||
$tabfield[23] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfield[24] = "code,label";
|
||||
@@ -359,7 +359,7 @@ $tabfieldvalue[17] = "code,label,accountancy_code";
|
||||
$tabfieldvalue[18] = "code,libelle,tracking";
|
||||
$tabfieldvalue[19] = "code,libelle";
|
||||
$tabfieldvalue[20] = "code,libelle";
|
||||
$tabfieldvalue[21] = "code,label,position";
|
||||
$tabfieldvalue[21] = "code,label,qty,type_duration,position";
|
||||
$tabfieldvalue[22] = "code,label";
|
||||
$tabfieldvalue[23] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldvalue[24] = "code,label";
|
||||
@@ -406,7 +406,7 @@ $tabfieldinsert[17] = "code,label,accountancy_code";
|
||||
$tabfieldinsert[18] = "code,libelle,tracking";
|
||||
$tabfieldinsert[19] = "code,libelle";
|
||||
$tabfieldinsert[20] = "code,libelle";
|
||||
$tabfieldinsert[21] = "code,label,position";
|
||||
$tabfieldinsert[21] = "code,label,qty,type_duration,position";
|
||||
$tabfieldinsert[22] = "code,label";
|
||||
$tabfieldinsert[23] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note";
|
||||
$tabfieldinsert[24] = "code,label";
|
||||
@@ -566,7 +566,7 @@ $tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
$tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
$tabhelp[35] = array();
|
||||
$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[39] = array('code'=>$langs->trans("EnterAnyCode"));
|
||||
$tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp"));
|
||||
@@ -669,8 +669,8 @@ if ($id == 11) {
|
||||
|
||||
asort($elementList);
|
||||
$sourceList = array(
|
||||
'internal' => $langs->trans('Internal'),
|
||||
'external' => $langs->trans('External')
|
||||
'internal' => $langs->trans('Internal'),
|
||||
'external' => $langs->trans('External')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -694,445 +694,470 @@ if ($id == 10) {
|
||||
* 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')) {
|
||||
$search_country_id = '';
|
||||
$search_code = '';
|
||||
}
|
||||
|
||||
// Actions add or modify an entry into a dictionary
|
||||
if (GETPOST('actionadd') || GETPOST('actionmodify')) {
|
||||
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
|
||||
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
|
||||
if (empty($reshook)) {
|
||||
// Actions add or modify an entry into a dictionary
|
||||
if (GETPOST('actionadd') || GETPOST('actionmodify')) {
|
||||
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
|
||||
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldvalue = explode(',', $tabfieldvalue[$id]);
|
||||
|
||||
// Check that all mandatory fields are filled
|
||||
$ok = 1;
|
||||
foreach ($listfield as $f => $value) {
|
||||
// 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'))) {
|
||||
continue; // For some pages, country is not mandatory
|
||||
// Check that all mandatory fields are filled
|
||||
$ok = 1;
|
||||
foreach ($listfield as $f => $value) {
|
||||
// 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'))) {
|
||||
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'))) {
|
||||
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
|
||||
)
|
||||
) {
|
||||
// Other checks
|
||||
if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) {
|
||||
$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');
|
||||
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
|
||||
}
|
||||
}
|
||||
// Other checks
|
||||
if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) {
|
||||
$ok = 0;
|
||||
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
|
||||
}
|
||||
if (GETPOSTISSET("code")) {
|
||||
if (GETPOST("code") == '0') {
|
||||
if (GETPOSTISSET("code")) {
|
||||
if (GETPOST("code") == '0') {
|
||||
$ok = 0;
|
||||
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
|
||||
}
|
||||
}
|
||||
if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) {
|
||||
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;
|
||||
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
|
||||
setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors');
|
||||
}
|
||||
}
|
||||
if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) {
|
||||
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');
|
||||
|
||||
// Clean some parameters
|
||||
if ((GETPOST("localtax1_type") || (GETPOST('localtax1_type') == '0')) && !GETPOST("localtax1")) {
|
||||
$_POST["localtax1"] = '0'; // If empty, we force to 0
|
||||
}
|
||||
if ((GETPOST("localtax2_type") || (GETPOST('localtax2_type') == '0')) && !GETPOST("localtax2")) {
|
||||
$_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 ((GETPOST("localtax1_type") || (GETPOST('localtax1_type') == '0')) && !GETPOST("localtax1")) {
|
||||
$_POST["localtax1"] = '0'; // If empty, we force to 0
|
||||
}
|
||||
if ((GETPOST("localtax2_type") || (GETPOST('localtax2_type') == '0')) && !GETPOST("localtax2")) {
|
||||
$_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 check ok and action add, add the line
|
||||
if ($ok && GETPOST('actionadd')) {
|
||||
if ($tabrowid[$id]) {
|
||||
// Get free id for insert
|
||||
$newid = 0;
|
||||
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$obj = $db->fetch_object($result);
|
||||
$newid = ($obj->newid + 1);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// If check ok and action add, add the line
|
||||
if ($ok && GETPOST('actionadd')) {
|
||||
if ($tabrowid[$id]) {
|
||||
// Get free id for insert
|
||||
$newid = 0;
|
||||
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$obj = $db->fetch_object($result);
|
||||
$newid = ($obj->newid + 1);
|
||||
// Add new entry
|
||||
$sql = "INSERT INTO ".$tabname[$id]." (";
|
||||
// List of fields
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
|
||||
$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 {
|
||||
$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 {
|
||||
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
|
||||
$sql = "INSERT INTO ".$tabname[$id]." (";
|
||||
// List of fields
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
|
||||
$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');
|
||||
// If verif ok and action modify, modify the line
|
||||
if ($ok && GETPOST('actionmodify')) {
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$sql .= "'".$db->escape(GETPOST($keycode, 'nohtml'))."'";
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
$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');
|
||||
// Modify entry
|
||||
$sql = "UPDATE ".$tabname[$id]." SET ";
|
||||
// Modifie valeur des champs
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
|
||||
$sql .= $tabrowid[$id]."=";
|
||||
$sql .= "'".$db->escape($rowid)."', ";
|
||||
}
|
||||
$_POST = array('id'=>$id);
|
||||
} else {
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
|
||||
$i = 0;
|
||||
foreach ($listfieldmodify as $field) {
|
||||
$keycode = $listfieldvalue[$i];
|
||||
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 {
|
||||
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 ($ok && GETPOST('actionmodify')) {
|
||||
if (GETPOST('actioncancel')) {
|
||||
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
// Modify entry
|
||||
$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;
|
||||
}
|
||||
$sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||
|
||||
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');
|
||||
dol_syslog("delete", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (!$result) {
|
||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
|
||||
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
|
||||
} 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')) {
|
||||
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||
}
|
||||
// activate
|
||||
if ($action == $acts[0]) {
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM ".$tabname[$id]." WHERE ".$rowidcol."='".$db->escape($rowid)."'".($entity != '' ? " AND entity = ".(int) $entity : '');
|
||||
|
||||
dol_syslog("delete", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (!$result) {
|
||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
|
||||
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
*/
|
||||
@@ -1466,6 +1491,9 @@ if ($id) {
|
||||
if ($value == 'block_if_negative') {
|
||||
$valuetoshow = $langs->trans('BlockHolidayIfNegative');
|
||||
}
|
||||
if ($value == 'type_duration') {
|
||||
$valuetoshow = $langs->trans('Unit');
|
||||
}
|
||||
|
||||
if ($id == 2) { // Special case for state page
|
||||
if ($value == 'region_id') {
|
||||
@@ -1818,6 +1846,9 @@ if ($id) {
|
||||
if ($value == 'block_if_negative') {
|
||||
$valuetoshow = $langs->trans('BlockHolidayIfNegative');
|
||||
}
|
||||
if ($value == 'type_duration') {
|
||||
$valuetoshow = $langs->trans('Unit');
|
||||
}
|
||||
|
||||
if ($value == 'region_id' || $value == 'country_id') {
|
||||
$showfield = 0;
|
||||
@@ -2055,6 +2086,9 @@ if ($id) {
|
||||
$valuetoshow = $langs->trans($obj->{$value});
|
||||
} elseif ($value == 'block_if_negative') {
|
||||
$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';
|
||||
if ($value == 'note' && $id == 10) {
|
||||
@@ -2411,10 +2445,10 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
|
||||
} elseif ($value == 'unit') {
|
||||
print '<td>';
|
||||
$units = array(
|
||||
'mm' => $langs->trans('SizeUnitmm'),
|
||||
'cm' => $langs->trans('SizeUnitcm'),
|
||||
'point' => $langs->trans('SizeUnitpoint'),
|
||||
'inch' => $langs->trans('SizeUnitinch')
|
||||
'mm' => $langs->trans('SizeUnitmm'),
|
||||
'cm' => $langs->trans('SizeUnitcm'),
|
||||
'point' => $langs->trans('SizeUnitpoint'),
|
||||
'inch' => $langs->trans('SizeUnitinch')
|
||||
);
|
||||
print $form->selectarray('unit', $units, (!empty($obj->{$value}) ? $obj->{$value}:''), 0, 0, 0);
|
||||
print '</td>';
|
||||
@@ -2450,6 +2484,10 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
|
||||
print '<td>';
|
||||
print $form->selectyesno("block_if_negative", (!empty($obj->{$value}) ? $obj->{$value}:''), 1);
|
||||
print '</td>';
|
||||
} elseif ($value == 'type_duration') {
|
||||
print '<td>';
|
||||
print $form->selectTypeDuration('', $obj->{$value}, array('i','h'));
|
||||
print '</td>';
|
||||
} else {
|
||||
$fieldValue = isset($obj->{$value}) ? $obj->{$value}: '';
|
||||
|
||||
|
||||
@@ -220,8 +220,9 @@ if ($action == 'edit') {
|
||||
foreach ($arrayofparameters as $constname => $val) {
|
||||
if ($val['enabled']==1) {
|
||||
$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 . '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 '</td><td>';
|
||||
|
||||
@@ -314,6 +315,7 @@ if ($action == 'edit') {
|
||||
$setupnotempty++;
|
||||
print '<tr class="oddeven"><td>';
|
||||
$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 '</td><td>';
|
||||
|
||||
|
||||
@@ -46,11 +46,12 @@ if ($action == 'test' || $action == 'send') {
|
||||
|
||||
$substitutionarrayfortest = array(
|
||||
'__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',
|
||||
//'__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__' => 'RecipientLogin',
|
||||
'__LASTNAME__' => 'RecipientLastname',
|
||||
'__FIRSTNAME__' => 'RecipientFirstname',
|
||||
'__ADDRESS__'=> 'RecipientAddress',
|
||||
@@ -662,7 +663,7 @@ if ($action == 'edit') {
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>';
|
||||
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))) {
|
||||
if (function_exists('openssl_open')) {
|
||||
print yn($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED);
|
||||
print yn(getDolGlobalInt('MAIN_MAIL_EMAIL_DKIM_ENABLED'));
|
||||
} else {
|
||||
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
|
||||
}
|
||||
@@ -762,9 +763,18 @@ if ($action == 'edit') {
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
|
||||
print '<td>';
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
|
||||
print $conf->global->MAIN_MAIL_AUTOCOPY_TO;
|
||||
if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
|
||||
print img_warning($langs->trans("ErrorBadEMail"));
|
||||
$listofemail = explode(',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
|
||||
$i = 0;
|
||||
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 {
|
||||
print ' ';
|
||||
@@ -887,7 +897,6 @@ if ($action == 'edit') {
|
||||
}
|
||||
|
||||
setEventMessages($errormsg, null, 'errors');
|
||||
print $errormsg;
|
||||
}
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$langs->loadLangs(array('companies', 'products', 'admin', 'mails', 'other', 'errors'));
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
@@ -40,17 +40,22 @@ if (!$user->admin) {
|
||||
$usersignature = $user->signature;
|
||||
// For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
|
||||
if ($action == 'test' || $action == 'send') {
|
||||
$usersignature = dol_string_nohtmltag($usersignature);
|
||||
$usersignature = dol_string_nohtmltag($usersignature, 2);
|
||||
}
|
||||
|
||||
$substitutionarrayfortest = array(
|
||||
'__LOGIN__' => $user->login,
|
||||
'__ID__' => 'TESTIdRecord',
|
||||
'__EMAIL__' => 'TESTEMail',
|
||||
'__LASTNAME__' => 'TESTLastname',
|
||||
'__FIRSTNAME__' => 'TESTFirstname',
|
||||
'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''),
|
||||
//'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet
|
||||
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
|
||||
'__ID__' => 'RecipientIdRecord',
|
||||
//'__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',
|
||||
'__FIRSTNAME__' => 'RecipientFirstname',
|
||||
'__ADDRESS__'=> 'RecipientAddress',
|
||||
'__ZIP__'=> 'RecipientZip',
|
||||
'__TOWN_'=> 'RecipientTown',
|
||||
'__COUNTRY__'=> 'RecipientCountry'
|
||||
);
|
||||
complete_substitutions_array($substitutionarrayfortest, $langs);
|
||||
|
||||
@@ -86,10 +91,10 @@ $trackid = (($action == 'testhtml') ? "testhtml" : "test");
|
||||
$sendcontext = 'emailing'; // Force to use dedicated context of setup for emailing
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||
|
||||
if ($action == 'presend' && GETPOST('trackid') == 'test') {
|
||||
if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') {
|
||||
$action = 'test';
|
||||
}
|
||||
if ($action == 'presend' && GETPOST('trackid') == 'testhtml') {
|
||||
if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') {
|
||||
$action = 'testhtml';
|
||||
}
|
||||
|
||||
@@ -271,12 +276,15 @@ if ($action == 'edit') {
|
||||
|
||||
// Host server
|
||||
|
||||
print '<tr class="oddeven hideifdefault"><td>';
|
||||
print '<tr class="oddeven hideifdefault">';
|
||||
if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail') {
|
||||
print '<td>';
|
||||
print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
|
||||
print '</td><td>';
|
||||
print $langs->trans("SeeLocalSendMailSetup");
|
||||
print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td>';
|
||||
$mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_SERVER_EMAILING : '');
|
||||
$smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined");
|
||||
if ($linuxlike) {
|
||||
@@ -287,17 +295,19 @@ if ($action == 'edit') {
|
||||
print '</td><td>';
|
||||
// SuperAdministrator access only
|
||||
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
|
||||
print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="'.$mainserver.'">';
|
||||
print '<input class="flat minwidth300" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" size="18" value="'.$mainserver.'">';
|
||||
print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" name="MAIN_MAIL_SMTP_SERVER_EMAILING_sav" value="'.$mainserver.'">';
|
||||
print '<span id="smtp_server_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
|
||||
print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
|
||||
print ' <span class="opacitymedium smtp_method">'.$langs->trans("SeeLinkToOnlineDocumentation").'</span>';
|
||||
} else {
|
||||
$text = !empty($mainserver) ? $mainserver : $smtpserver;
|
||||
$htmltext = $langs->trans("ContactSuperAdminForChange");
|
||||
print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
|
||||
print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_EMAILING" name="MAIN_MAIL_SMTP_SERVER_EMAILING" value="'.$mainserver.'">';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '</tr>';
|
||||
|
||||
// Port
|
||||
|
||||
@@ -305,7 +315,7 @@ if ($action == 'edit') {
|
||||
if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail') {
|
||||
print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
|
||||
print '</td><td>';
|
||||
print $langs->trans("SeeLocalSendMailSetup");
|
||||
print '<span class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
|
||||
} else {
|
||||
$mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : '');
|
||||
$smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined");
|
||||
@@ -319,7 +329,7 @@ if ($action == 'edit') {
|
||||
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
|
||||
print '<input class="flat" id="MAIN_MAIL_SMTP_PORT_EMAILING" name="MAIN_MAIL_SMTP_PORT_EMAILING" size="3" value="'.$mainport.'">';
|
||||
print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_EMAILING_sav" name="MAIN_MAIL_SMTP_PORT_EMAILING_sav" value="'.$mainport.'">';
|
||||
print '<span id="smtp_port_mess">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
|
||||
print '<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
|
||||
} else {
|
||||
$text = (!empty($mainport) ? $mainport : $smtpport);
|
||||
$htmltext = $langs->trans("ContactSuperAdminForChange");
|
||||
@@ -360,7 +370,6 @@ if ($action == 'edit') {
|
||||
}
|
||||
|
||||
// TLS
|
||||
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
|
||||
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
|
||||
if (function_exists('openssl_open')) {
|
||||
@@ -374,7 +383,6 @@ if ($action == 'edit') {
|
||||
print '</td></tr>';
|
||||
|
||||
// STARTTLS
|
||||
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
|
||||
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
|
||||
if (function_exists('openssl_open')) {
|
||||
@@ -388,7 +396,6 @@ if ($action == 'edit') {
|
||||
print '</td></tr>';
|
||||
|
||||
// SMTP_ALLOW_SELF_SIGNED_EMAILING
|
||||
|
||||
print '<tr class="oddeven hideifdefault"><td>'.$langs->trans("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED").'</td><td>';
|
||||
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
|
||||
if (function_exists('openssl_open')) {
|
||||
@@ -414,6 +421,7 @@ if ($action == 'edit') {
|
||||
print '<span class="opacitymedium">'.$langs->trans("EMailsDesc")."</span><br>\n";
|
||||
print "<br><br>\n";
|
||||
|
||||
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
@@ -460,7 +468,7 @@ if ($action == 'edit') {
|
||||
print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
|
||||
}
|
||||
} else {
|
||||
print yn(0).' ('.$langs->trans("NotSupported").')';
|
||||
print '<span class="opacitymedium">'.yn(0).' ('.$langs->trans("NotSupported").')</span>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@@ -492,6 +500,7 @@ if ($action == 'edit') {
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
@@ -543,6 +552,7 @@ if ($action == 'edit') {
|
||||
|
||||
// Run the test to connect
|
||||
if ($action == 'testconnect') {
|
||||
print '<div id="formmailaftertstconnect" name="formmailaftertstconnect"></div>';
|
||||
print load_fiche_titre($langs->trans("DoTestServerAvailability"));
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
@@ -573,16 +583,18 @@ if ($action == 'edit') {
|
||||
// Cree l'objet formulaire mail
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
$formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
|
||||
$formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname', 'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
|
||||
$formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail', 'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM);
|
||||
$formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
|
||||
$formmail->fromid = $user->id;
|
||||
$formmail->fromalsorobot = 1;
|
||||
$formmail->withfromreadonly = 0;
|
||||
$formmail->withsubstit = 0;
|
||||
$formmail->withfrom = 1;
|
||||
$formmail->witherrorsto = 1;
|
||||
$formmail->withto = (!GETPOST('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
|
||||
$formmail->withtocc = (!GETPOST(['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty
|
||||
$formmail->withtoccc = (!GETPOST(['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty
|
||||
$formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
|
||||
$formmail->withtocc = (GETPOSTISSET(['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty
|
||||
$formmail->withtoccc = (GETPOSTISSET(['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty
|
||||
$formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
|
||||
$formmail->withtopicreadonly = 0;
|
||||
$formmail->withfile = 2;
|
||||
@@ -601,7 +613,7 @@ if ($action == 'edit') {
|
||||
$formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
|
||||
|
||||
// Init list of files
|
||||
if (GETPOST("mode") == 'init') {
|
||||
if (GETPOST("mode", "aZ09") == 'init') {
|
||||
$formmail->clear_attached_files();
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ if (!empty($conf->expedition->enabled)) {
|
||||
$elementList['shipping_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendShipment'));
|
||||
}
|
||||
if (!empty($conf->reception->enabled)) {
|
||||
$elementList['reception_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendReception'));
|
||||
$elementList['reception_send'] = img_picto('', 'dollyrevert', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendReception'));
|
||||
}
|
||||
if (!empty($conf->ficheinter->enabled)) {
|
||||
$elementList['fichinter_send'] = img_picto('', 'intervention', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendIntervention'));
|
||||
|
||||
@@ -267,6 +267,7 @@ $constantes = array();
|
||||
foreach ($listofnotifiedevents as $notifiedevent) {
|
||||
$label = $langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
|
||||
$elementLabel = $langs->trans(ucfirst($notifiedevent['elementtype']));
|
||||
$model = $notifiedevent['elementtype'].'_send';
|
||||
|
||||
if ($notifiedevent['elementtype'] == 'order_supplier') {
|
||||
$elementLabel = $langs->trans('SupplierOrder');
|
||||
|
||||
@@ -198,6 +198,37 @@ if ($action == 'updateMask') {
|
||||
// par appel methode canBeActivated
|
||||
|
||||
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 '</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 '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
|
||||
@@ -36,6 +36,14 @@ if (!$user->admin) {
|
||||
}
|
||||
|
||||
$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;
|
||||
|
||||
@@ -73,8 +81,6 @@ if ($action == 'updateform') {
|
||||
} else {
|
||||
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);
|
||||
|
||||
// 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', '');
|
||||
|
||||
// End of page
|
||||
|
||||
@@ -214,10 +214,6 @@ if (in_array($type, array('mysql', 'mysqli'))) {
|
||||
|
||||
print '<br>';
|
||||
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)) {
|
||||
print '<div class="formelementrow">';
|
||||
@@ -239,14 +235,35 @@ if (in_array($type, array('mysql', 'mysqli'))) {
|
||||
print '<option value="ORACLE">ORACLE</option>';
|
||||
print '<option value="POSTGRESQL">POSTGRESQL</option>';
|
||||
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 $form->textwithpicto($langs->trans('ExportUseMySQLQuickParameter'), $langs->trans('ExportUseMySQLQuickParameterHelp'));
|
||||
print '</label>';
|
||||
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 '<label for="checkbox_drop_database">'.$langs->trans("AddDropDatabase").'</label>';
|
||||
print '-->';
|
||||
|
||||
@@ -137,7 +137,8 @@ $dirtocompress = basename($fulldirtocompress);
|
||||
|
||||
if ($compression == 'zip') {
|
||||
$file .= '.zip';
|
||||
$excludefiles = '/(\.back|\.old|\.log|\.pdf_preview-.*\.png|[\/\\\]temp[\/\\\]|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i';
|
||||
|
||||
$excludefiles = '/(\.back|\.old|\.log|\.pdf_preview-.*\.png|[\/\\\]temp[\/\\\]|[\/\\\]admin[\/\\\]documents[\/\\\])/i';
|
||||
|
||||
//var_dump($fulldirtocompress);
|
||||
//var_dump($outputdir."/".$file);exit;
|
||||
|
||||
@@ -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).
|
||||
* @return array List of documents
|
||||
*
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
* @throws RestException 501
|
||||
* @throws RestException 400
|
||||
* @throws RestException 401
|
||||
@@ -249,7 +249,7 @@ class Documents extends DolibarrApi
|
||||
* @throws RestException 400
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*
|
||||
* @url GET /
|
||||
*/
|
||||
@@ -546,7 +546,7 @@ class Documents extends DolibarrApi
|
||||
* @throws RestException 400
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*
|
||||
* @url POST /upload
|
||||
*/
|
||||
|
||||
@@ -158,6 +158,25 @@ if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $
|
||||
$api = new DolibarrApi($db, '', $refreshcache);
|
||||
//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.
|
||||
// See https://github.com/Luracast/Restler-API-Explorer for more info.
|
||||
$api->r->addAPIClass('Luracast\\Restler\\Explorer');
|
||||
|
||||
@@ -519,7 +519,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$keyforbreak = 'duration';
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
|
||||
$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>';
|
||||
|
||||
// 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';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("mrp", "other"));
|
||||
$langs->loadLangs(array("mrp", "other", "stocks"));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
@@ -170,7 +170,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$keyforbreak = 'duration';
|
||||
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>';
|
||||
|
||||
// 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 '</td>';
|
||||
print '<td class="linecolqty">'.$langs->trans('Quantity').'</td>';
|
||||
print '<td class="linecolstock">'.$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="linecolqty right">'.$langs->trans('Quantity').'</td>';
|
||||
print '<td class="linecolstock right">'.$form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1).'</td>';
|
||||
print '<td class="linecoltheoricalstock right">'.$form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")).'</td>';
|
||||
print '</tr>';
|
||||
if (! empty($TChildBom)) {
|
||||
if ($action == 'treeview') {
|
||||
@@ -227,9 +227,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print img_picto('', 'folder-open');
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
print '<td class="linecolqty">'.$TProduct['qty'].'</td>';
|
||||
print '<td class="linecolstock"></td>';
|
||||
print '<td class="linecoltheoricalstock"></td>';
|
||||
print '<td class="linecolqty right">'.$TProduct['qty'].'</td>';
|
||||
print '<td class="linecolstock right"></td>';
|
||||
print '<td class="linecoltheoricalstock right"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
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.'">';
|
||||
else print '<tr class="oddeven">';
|
||||
print '<td class="linecoldescription">'.str_repeat($repeatChar, $TInfos['level']).$prod->getNomUrl(1).'</td>';
|
||||
print '<td class="linecolqty">'.$TInfos['qty'].'</td>';
|
||||
print '<td class="linecolstock">'.$prod->stock_reel.'</td>';
|
||||
print '<td class="linecoltheoricalstock">'.$prod->stock_theorique.'</td>';
|
||||
print '<td class="linecolqty right">'.$TInfos['qty'].'</td>';
|
||||
print '<td class="linecolstock right">'.price2num($prod->stock_reel, 'MS').'</td>';
|
||||
print '<td class="linecoltheoricalstock right">'.$prod->stock_theorique.'</td>';
|
||||
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;
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="linecoldescription">'.$prod->getNomUrl(1).'</td>';
|
||||
print '<td class="linecolqty">'.$qty.'</td>';
|
||||
print '<td class="linecolstock">'.$prod->stock_reel.'</td>';
|
||||
print '<td class="linecoltheoricalstock">'.$prod->stock_theorique.'</td>';
|
||||
print '<td class="linecolqty right">'.$qty.'</td>';
|
||||
print '<td class="linecolstock right">'.price2num($prod->stock_reel, 'MS').'</td>';
|
||||
print '<td class="linecoltheoricalstock right">'.$prod->stock_theorique.'</td>';
|
||||
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_...).
|
||||
* '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).
|
||||
* '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.
|
||||
* '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.
|
||||
@@ -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",),
|
||||
'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',),
|
||||
'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'=>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'),
|
||||
|
||||
@@ -126,7 +126,7 @@ print '</td>';
|
||||
$total_cost = 0;
|
||||
print '<td id="costline_'.$line->id.'" class="linecolcost nowrap right">';
|
||||
$coldisplay++;
|
||||
echo price($line->total_cost);
|
||||
echo '<span class="amount">'.price($line->total_cost).'</span>';
|
||||
print '</td>';
|
||||
|
||||
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">';
|
||||
$coldisplay++;
|
||||
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');
|
||||
print '</a>';
|
||||
}
|
||||
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');
|
||||
print '</a>';
|
||||
}
|
||||
@@ -236,15 +236,16 @@ if ($resql) {
|
||||
// Efficiency
|
||||
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)) {
|
||||
$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;
|
||||
} 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;
|
||||
} 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;
|
||||
} 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';
|
||||
@@ -254,7 +255,7 @@ if ($resql) {
|
||||
$obj = $object->db->fetch_object($resql_supplier_price);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -266,11 +267,12 @@ if ($resql) {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
$line->total_cost = price($total_cost);
|
||||
?>
|
||||
<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>
|
||||
<?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 "</td>\n";
|
||||
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 "\t</tr>\n";
|
||||
}
|
||||
|
||||
@@ -1491,6 +1491,10 @@ if ($id > 0) {
|
||||
$("#fullday").change(function() {
|
||||
setdatefields();
|
||||
});
|
||||
$("#actioncode").change(function() {
|
||||
if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
|
||||
else $("#dateend").removeClass("fieldrequired");
|
||||
});
|
||||
})';
|
||||
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>';
|
||||
|
||||
// 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');
|
||||
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) {
|
||||
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 {
|
||||
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 ' - ';
|
||||
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) {
|
||||
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 {
|
||||
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>';
|
||||
|
||||
@@ -1988,11 +1996,15 @@ if ($id > 0) {
|
||||
|
||||
// Date start
|
||||
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)) {
|
||||
print dol_print_date($object->datep, 'dayhour', 'tzuser');
|
||||
print dol_print_date($object->datep, 'dayhour', 'tzuserrel');
|
||||
} else {
|
||||
$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)) {
|
||||
print img_warning($langs->trans("Late"));
|
||||
@@ -2003,10 +2015,10 @@ if ($id > 0) {
|
||||
// Date end
|
||||
print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td>';
|
||||
if (empty($object->fulldayevent)) {
|
||||
print dol_print_date($object->datef, 'dayhour', 'tzuser');
|
||||
print dol_print_date($object->datef, 'dayhour', 'tzuserrel');
|
||||
} else {
|
||||
$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)) {
|
||||
print img_warning($langs->trans("Late"));
|
||||
|
||||
@@ -931,7 +931,7 @@ if ($showbirthday) {
|
||||
$sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
|
||||
$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') {
|
||||
$sql .= ' AND MONTH(birthday) = '.((int) $month);
|
||||
$sql .= ' AND DAY(birthday) = '.((int) $day);
|
||||
|
||||
@@ -943,8 +943,8 @@ while ($i < min($num, $limit)) {
|
||||
// Description
|
||||
if (!empty($arrayfields['a.note']['checked'])) {
|
||||
print '<td class="tdoverflowonsmartphone">';
|
||||
$text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 0));
|
||||
print $form->textwithtooltip(dol_trunc($text, 40), $actionstatic->note_private);
|
||||
$text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 1));
|
||||
print $form->textwithtooltip(dol_trunc($text, 48), $actionstatic->note_private);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
* Copyright (C) 2015-2021 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* 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
|
||||
* 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.'/core/class/html.formcompany.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)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
}
|
||||
@@ -112,6 +114,7 @@ $cancel = GETPOST('cancel', 'alpha');
|
||||
|
||||
$object = new Client($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$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_ttc = $objp->total_ttc;
|
||||
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) {
|
||||
print " ".img_warning();
|
||||
}
|
||||
@@ -940,7 +973,38 @@ if ($object->id > 0) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowraponall">';
|
||||
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" class="nowrap">'.$commande_static->LibStatut($objp->fk_statut, $objp->facture, 5).'</td></tr>';
|
||||
$i++;
|
||||
@@ -1003,6 +1067,35 @@ if ($object->id > 0) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowraponall">';
|
||||
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>';
|
||||
if ($objp->date_creation > 0) {
|
||||
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 '<td class="nowraponall">';
|
||||
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 "</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 '<td class="nowraponall">';
|
||||
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 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";
|
||||
@@ -1213,6 +1364,7 @@ if ($object->id > 0) {
|
||||
print '<td class="nowrap">';
|
||||
print $invoicetemplate->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
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>';
|
||||
} else {
|
||||
@@ -1301,6 +1453,35 @@ if ($object->id > 0) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowraponall">';
|
||||
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>';
|
||||
if ($objp->df > 0) {
|
||||
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 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
|
||||
$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) {
|
||||
$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) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($socid) {
|
||||
$sql .= " AND s.rowid = $socid";
|
||||
// Add where from hooks
|
||||
$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 .= $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) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($socid) {
|
||||
$sql .= " AND s.rowid = ".((int) $socid);
|
||||
// Add where from hooks
|
||||
$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 .= $db->plimit($max, 0);
|
||||
|
||||
|
||||
@@ -686,7 +686,7 @@ class AdvanceTargetingMailing extends CommonObject
|
||||
|
||||
$sqlwhere = array();
|
||||
|
||||
$sqlwhere[] = 't.entity IN ('.getEntity('socpeople').')';
|
||||
$sqlwhere[] = 't.entity IN ('.getEntity('contact').')';
|
||||
|
||||
if (count($arrayquery) > 0) {
|
||||
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)));
|
||||
$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;
|
||||
$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) {
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
|
||||
exit();
|
||||
@@ -246,8 +246,11 @@ if (empty($reshook)) {
|
||||
// Remove line
|
||||
$result = $object->deleteline($lineid);
|
||||
// reorder lines
|
||||
if ($result) {
|
||||
if ($result > 0) {
|
||||
$object->line_order(true);
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
@@ -1914,8 +1917,8 @@ if ($action == 'create') {
|
||||
$formquestion = array(
|
||||
// 'text' => $langs->trans("ConfirmClone"),
|
||||
// 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)) {
|
||||
$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 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*/
|
||||
public function deleteContact($id, $contactid, $type)
|
||||
{
|
||||
@@ -799,7 +799,7 @@ class Proposals extends DolibarrApi
|
||||
* @throws RestException 304
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
@@ -992,6 +992,8 @@ class Propal extends CommonObject
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $line->error;
|
||||
$this->errors = $line->errors;
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@@ -1324,11 +1326,12 @@ class Propal extends CommonObject
|
||||
* @param User $user User making the clone
|
||||
* @param int $socid Id of thirdparty
|
||||
* @param int $forceentity Entity id to force
|
||||
* @param bool $update_prices [=false] Update prices if true
|
||||
* @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');
|
||||
|
||||
@@ -1375,6 +1378,55 @@ class Propal extends CommonObject
|
||||
$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->ref = '';
|
||||
$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 = '')
|
||||
{
|
||||
global $langs, $conf;
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
$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,';
|
||||
@@ -4194,36 +4247,40 @@ class PropaleLigne extends CommonObjectLine
|
||||
$error = 0;
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".((int) $this->rowid);
|
||||
dol_syslog("PropaleLigne::delete", LOG_DEBUG);
|
||||
if ($this->db->query($sql)) {
|
||||
// Remove extrafields
|
||||
if (!$error) {
|
||||
$this->id = $this->rowid;
|
||||
$result = $this->deleteExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
|
||||
}
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('LINEPROPAL_DELETE', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('LINEPROPAL_DELETE', $user);
|
||||
if ($result < 0) {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "propaldet WHERE rowid = " . ((int) $this->rowid);
|
||||
dol_syslog("PropaleLigne::delete", LOG_DEBUG);
|
||||
if ($this->db->query($sql)) {
|
||||
// Remove extrafields
|
||||
if (!$error) {
|
||||
$this->id = $this->rowid;
|
||||
$result = $this->deleteExtraFields();
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
dol_syslog(get_class($this) . "::delete error -4 " . $this->error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->error() . " sql=" . $sql;
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->error()." sql=".$sql;
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -356,9 +356,9 @@ if ($action == 'validate' && $permissiontovalidate) {
|
||||
$db->begin();
|
||||
$error = 0;
|
||||
foreach ($toselect as $checked) {
|
||||
if ($tmpproposal->fetch($checked)) {
|
||||
if ($tmpproposal->statut == 0) {
|
||||
if ($tmpproposal->valid($user)) {
|
||||
if ($tmpproposal->fetch($checked) > 0) {
|
||||
if ($tmpproposal->statut == $tmpproposal::STATUS_DRAFT) {
|
||||
if ($tmpproposal->valid($user) > 0) {
|
||||
setEventMessage($langs->trans('hasBeenValidated', $tmpproposal->ref), 'mesgs');
|
||||
} else {
|
||||
setEventMessage($langs->trans('CantBeValidated'), 'errors');
|
||||
@@ -370,7 +370,7 @@ if ($action == 'validate' && $permissiontovalidate) {
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@@ -388,13 +388,13 @@ if ($action == "sign" && $permissiontoclose) {
|
||||
$db->begin();
|
||||
$error = 0;
|
||||
foreach ($toselect as $checked) {
|
||||
if ($tmpproposal->fetch($checked)) {
|
||||
if ($tmpproposal->fetch($checked) > 0) {
|
||||
if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) {
|
||||
$tmpproposal->statut = $tmpproposal::STATUS_SIGNED;
|
||||
if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_SIGNED)) {
|
||||
if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_SIGNED) >= 0) {
|
||||
setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs');
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
@@ -402,7 +402,7 @@ if ($action == "sign" && $permissiontoclose) {
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@@ -413,27 +413,28 @@ if ($action == "sign" && $permissiontoclose) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == "nosign" && $permissiontoclose) {
|
||||
if (GETPOST('confirm') == 'yes') {
|
||||
$tmpproposal = new Propal($db);
|
||||
$db->begin();
|
||||
$error = 0;
|
||||
foreach ($toselect as $checked) {
|
||||
if ($tmpproposal->fetch($checked)) {
|
||||
if ($tmpproposal->fetch($checked) > 0) {
|
||||
if ($tmpproposal->statut == $tmpproposal::STATUS_VALIDATED) {
|
||||
$tmpproposal->statut = $tmpproposal::STATUS_NOTSIGNED;
|
||||
if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_NOTSIGNED)) {
|
||||
if ($tmpproposal->closeProposal($user, $tmpproposal::STATUS_NOTSIGNED) > 0) {
|
||||
setEventMessage($tmpproposal->ref." ".$langs->trans('NoSigned'), 'mesgs');
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeClosed'), 'errors');
|
||||
setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeNoSign'), 'errors');
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
setEventMessages($tmpproposal->error, $tmpproposal->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,7 +574,7 @@ class Orders extends DolibarrApi
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*/
|
||||
public function deleteContact($id, $contactid, $type)
|
||||
{
|
||||
@@ -704,7 +704,7 @@ class Orders extends DolibarrApi
|
||||
* @throws RestException 304
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -974,7 +974,7 @@ class Orders extends DolibarrApi
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*/
|
||||
public function getOrderShipments($id)
|
||||
{
|
||||
@@ -1030,7 +1030,7 @@ class Orders extends DolibarrApi
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*/
|
||||
public function createOrderShipment($id, $warehouse_id)
|
||||
{
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2016-2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2021-2022 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2016-2022 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2021-2022 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
|
||||
@@ -519,6 +519,7 @@ class Commande extends CommonOrder
|
||||
if ($this->lines[$i]->fk_product > 0) {
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
$mouvP->origin = &$this;
|
||||
$mouvP->setOrigin($this->element, $this->id);
|
||||
// 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));
|
||||
if ($result < 0) {
|
||||
@@ -647,6 +648,7 @@ class Commande extends CommonOrder
|
||||
if ($this->lines[$i]->fk_product > 0) {
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
$mouvP->origin = &$this;
|
||||
$mouvP->setOrigin($this->element, $this->id);
|
||||
// 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));
|
||||
if ($result < 0) {
|
||||
@@ -828,6 +830,7 @@ class Commande extends CommonOrder
|
||||
for ($i = 0; $i < $num; $i++) {
|
||||
if ($this->lines[$i]->fk_product > 0) {
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
$mouvP->setOrigin($this->element, $this->id);
|
||||
// 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
|
||||
if ($result < 0) {
|
||||
@@ -2028,8 +2031,9 @@ class Commande extends CommonOrder
|
||||
*/
|
||||
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
|
||||
{
|
||||
global $langs, $conf;
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
$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,';
|
||||
@@ -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);
|
||||
}
|
||||
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)) {
|
||||
$label .= '<br><b>'.$langs->trans('DeliveryDate').':</b> '.dol_print_date($this->delivery_date, 'dayhour');
|
||||
|
||||
@@ -170,7 +170,7 @@ $arrayfields = array(
|
||||
'balancebefore'=>array('label'=>$langs->trans("BalanceBefore"), 'checked'=>0, 'position'=>1000),
|
||||
'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1001),
|
||||
'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
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
@@ -60,10 +60,11 @@ $newbankreceipt = GETPOST('newbankreceipt', 'alpha');
|
||||
|
||||
// Security check
|
||||
$fieldid = (!empty($ref) ? $ref : $id);
|
||||
$fieldname = isset($ref) ? 'ref' : 'rowid';
|
||||
$fieldname = (!empty($ref) ? 'ref' : 'rowid');
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
|
||||
$result = restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname);
|
||||
|
||||
if ($user->rights->banque->consolidate && $action == 'dvnext' && !empty($dvid)) {
|
||||
|
||||
@@ -208,6 +208,9 @@ if (empty($reshook)) {
|
||||
$object->model_pdf = GETPOST('modelpdf', '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->unit_frequency = GETPOST('unit_frequency', 'alpha');
|
||||
$object->nb_gen_max = $nb_gen_max;
|
||||
@@ -261,8 +264,6 @@ if (empty($reshook)) {
|
||||
} else {
|
||||
$db->rollback();
|
||||
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = "create";
|
||||
}
|
||||
}
|
||||
@@ -1027,12 +1028,14 @@ if ($action == 'create') {
|
||||
|
||||
// Payment term
|
||||
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>";
|
||||
|
||||
// Payment mode
|
||||
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>";
|
||||
|
||||
// Project
|
||||
@@ -1040,8 +1043,9 @@ if ($action == 'create') {
|
||||
$projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
|
||||
$langs->load('projects');
|
||||
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, '');
|
||||
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>';
|
||||
}
|
||||
|
||||
@@ -1074,7 +1078,8 @@ if ($action == 'create') {
|
||||
|
||||
// Frequency + unit
|
||||
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>";
|
||||
|
||||
// Date next run
|
||||
@@ -1474,15 +1479,16 @@ if ($action == 'create') {
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<table class="nobordernopadding">';
|
||||
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 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>';
|
||||
} else {
|
||||
if ($object->frequency > 0) {
|
||||
print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
|
||||
} else {
|
||||
print $langs->trans("NotARecurringInvoiceTemplate");
|
||||
print '<span class="opacitymedium">'.$langs->trans("NotARecurringInvoiceTemplate").'</span>';
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
@@ -3058,7 +3058,7 @@ if ($action == 'create') {
|
||||
if (empty($conf->global->INVOICE_DISABLE_AUTOMATIC_RECURRING_INVOICE)) {
|
||||
$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">';
|
||||
@@ -3857,7 +3857,6 @@ if ($action == 'create') {
|
||||
print "</form>\n";
|
||||
} elseif ($id > 0 || !empty($ref)) {
|
||||
if (empty($object->id)) {
|
||||
llxHeader();
|
||||
$langs->load('errors');
|
||||
echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
|
||||
llxFooter();
|
||||
@@ -4818,6 +4817,7 @@ if ($action == 'create') {
|
||||
|
||||
// List of previous situation invoices
|
||||
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 '<tr class="liste_titre">';
|
||||
@@ -4956,15 +4956,16 @@ if ($action == 'create') {
|
||||
|
||||
// List of payments already done
|
||||
|
||||
print '<!-- List of payments already done -->';
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder paymenttable centpercent">';
|
||||
|
||||
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">'.$langs->trans('Date').'</td>';
|
||||
print '<td class="liste_titre">'.$langs->trans('Type').'</td>';
|
||||
print '<td class="liste_titre"><span class="hideonsmartphone">'.$langs->trans('Date').'</span></td>';
|
||||
print '<td class="liste_titre"><span class="hideonsmartphone">'.$langs->trans('Type').'</span></td>';
|
||||
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" width="18"> </td>';
|
||||
|
||||
@@ -519,7 +519,7 @@ class Invoices extends DolibarrApi
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*/
|
||||
public function deleteContact($id, $contactid, $type)
|
||||
{
|
||||
@@ -661,7 +661,7 @@ class Invoices extends DolibarrApi
|
||||
|
||||
$result = $this->invoice->delete(DolibarrApiAccess::$user);
|
||||
if ($result < 0) {
|
||||
throw new RestException(500);
|
||||
throw new RestException(500, 'Error when deleting invoice');
|
||||
}
|
||||
|
||||
return array(
|
||||
@@ -780,7 +780,7 @@ class Invoices extends DolibarrApi
|
||||
* @throws RestException 304
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*
|
||||
*/
|
||||
public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0)
|
||||
@@ -829,7 +829,7 @@ class Invoices extends DolibarrApi
|
||||
* @throws RestException 304
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*
|
||||
*/
|
||||
public function settodraft($id, $idwarehouse = -1)
|
||||
@@ -932,7 +932,7 @@ class Invoices extends DolibarrApi
|
||||
* @throws RestException 304
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*/
|
||||
public function settopaid($id, $close_code = '', $close_note = '')
|
||||
{
|
||||
@@ -982,7 +982,7 @@ class Invoices extends DolibarrApi
|
||||
* @throws RestException 304
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*/
|
||||
public function settounpaid($id)
|
||||
{
|
||||
@@ -1069,7 +1069,7 @@ class Invoices extends DolibarrApi
|
||||
* @throws RestException 304
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
* @throws RestException 500
|
||||
* @throws RestException 500 System error
|
||||
*/
|
||||
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->model_pdf) ? ("'".$this->db->escape($this->model_pdf)."'") : "NULL");
|
||||
$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 .= ", ".($facsrc->cond_reglement_id > 0 ? ((int) $facsrc->cond_reglement_id) : "null");
|
||||
$sql .= ", ".($facsrc->mode_reglement_id > 0 ? ((int) $facsrc->mode_reglement_id) : "null");
|
||||
$sql .= ", ".($this->cond_reglement_id > 0 ? ((int) $this->cond_reglement_id) : "null");
|
||||
$sql .= ", ".($this->mode_reglement_id > 0 ? ((int) $this->mode_reglement_id) : "null");
|
||||
$sql .= ", ".((int) $this->usenewprice);
|
||||
$sql .= ", ".((int) $this->frequency);
|
||||
$sql .= ", '".$this->db->escape($this->unit_frequency)."'";
|
||||
@@ -344,6 +344,9 @@ class FactureRec extends CommonInvoice
|
||||
$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(
|
||||
$facsrc->lines[$i]->desc,
|
||||
$facsrc->lines[$i]->subprice,
|
||||
@@ -363,8 +366,8 @@ class FactureRec extends CommonInvoice
|
||||
$facsrc->lines[$i]->label,
|
||||
$facsrc->lines[$i]->fk_unit,
|
||||
$facsrc->lines[$i]->multicurrency_subprice,
|
||||
0,
|
||||
0,
|
||||
$default_start_fill,
|
||||
$default_end_fill,
|
||||
null,
|
||||
$facsrc->lines[$i]->pa_ht
|
||||
);
|
||||
@@ -655,18 +658,18 @@ class FactureRec extends CommonInvoice
|
||||
*/
|
||||
public function fetch_lines()
|
||||
{
|
||||
global $extrafields;
|
||||
|
||||
// phpcs:enable
|
||||
|
||||
$this->lines = array();
|
||||
|
||||
// Retrieve all extrafield for line
|
||||
// fetch optionals attributes and labels
|
||||
if (!is_object($extrafields)) {
|
||||
/*if (!is_object($extrafields)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
}
|
||||
$extrafields->fetch_name_optionals_label($this->table_element_line, true);
|
||||
*/
|
||||
|
||||
$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,';
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
|
||||
* 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 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* 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)
|
||||
{
|
||||
global $langs, $conf;
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
$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,';
|
||||
@@ -2326,6 +2327,7 @@ class Facture extends CommonInvoice
|
||||
if ($this->lines[$i]->fk_product > 0) {
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
$mouvP->origin = &$this;
|
||||
$mouvP->setOrigin($this->element, $this->id);
|
||||
// We decrease stock for product
|
||||
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));
|
||||
@@ -2763,6 +2765,7 @@ class Facture extends CommonInvoice
|
||||
if ($this->lines[$i]->fk_product > 0) {
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
$mouvP->origin = &$this;
|
||||
$mouvP->setOrigin($this->element, $this->id);
|
||||
// We decrease stock for product
|
||||
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));
|
||||
@@ -3055,6 +3058,7 @@ class Facture extends CommonInvoice
|
||||
if ($this->lines[$i]->fk_product > 0) {
|
||||
$mouvP = new MouvementStock($this->db);
|
||||
$mouvP->origin = &$this;
|
||||
$mouvP->setOrigin($this->element, $this->id);
|
||||
// We decrease stock for product
|
||||
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));
|
||||
|
||||
@@ -721,7 +721,6 @@ if ($resql) {
|
||||
if (!empty($arrayfields['f.titre']['checked'])) {
|
||||
print '<td class="nowrap tdoverflowmax200">';
|
||||
print $invoicerectmp->getNomUrl(1);
|
||||
print "</a>";
|
||||
print "</td>\n";
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
@@ -765,7 +764,7 @@ if ($resql) {
|
||||
}
|
||||
// Payment term
|
||||
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');
|
||||
print '</td>'."\n";
|
||||
if (!$i) {
|
||||
@@ -774,7 +773,7 @@ if ($resql) {
|
||||
}
|
||||
// Payment mode
|
||||
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');
|
||||
print '</td>'."\n";
|
||||
if (!$i) {
|
||||
|
||||
@@ -45,7 +45,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
|
||||
$trclass .= ' liste_sub_total';
|
||||
}
|
||||
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) {
|
||||
case Facture::TYPE_REPLACEMENT:
|
||||
echo $langs->trans("InvoiceReplacement");
|
||||
|
||||
@@ -46,7 +46,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
|
||||
}
|
||||
?>
|
||||
<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-ref" align="center"></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) {
|
||||
print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></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>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
@@ -501,26 +503,27 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
|
||||
|
||||
// Bank check number
|
||||
print '<tr><td>'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print ' <em class="opacitymedium">('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.'"></td></tr>';
|
||||
|
||||
// Check transmitter
|
||||
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><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
|
||||
|
||||
// Bank name
|
||||
print '<tr><td>'.$langs->trans('Bank');
|
||||
print ' <em>('.$langs->trans("ChequeBank").')</em>';
|
||||
print ' <em class="opacitymedium">('.$langs->trans("ChequeBank").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
|
||||
|
||||
// Comments
|
||||
print '<tr><td>'.$langs->trans('Comments').'</td>';
|
||||
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>';
|
||||
|
||||
|
||||
@@ -730,7 +730,7 @@ class RemiseCheque extends CommonObject
|
||||
$bankline = new AccountLine($db);
|
||||
$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)
|
||||
{
|
||||
$this->error='ActionRefusedLineAlreadyConciliated';
|
||||
@@ -739,7 +739,7 @@ class RemiseCheque extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Not conciliated, we can delete it
|
||||
// Not reconciled, we can delete it
|
||||
//$bankline->delete($user); // We delete
|
||||
|
||||
$bankaccount = $payment->fk_account;
|
||||
|
||||
@@ -309,20 +309,22 @@ if ($id > 0 || $ref) {
|
||||
// Actions
|
||||
if ($action != 'settransmitted' && $action != 'setcredited') {
|
||||
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 ($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) && $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);
|
||||
}
|
||||
|
||||
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>';
|
||||
}
|
||||
|
||||
|
||||
@@ -1831,7 +1831,7 @@ class BonPrelevement extends CommonObject
|
||||
$DtOfSgntr = dol_print_date($row_datec, '%Y-%m-%d');
|
||||
|
||||
if ($type != 'bank-transfer') {
|
||||
// SEPA Paiement Information of buyer for Direct debit
|
||||
// SEPA Paiement Information of buyer for Direct Debit
|
||||
$XML_DEBITOR = '';
|
||||
$XML_DEBITOR .= ' <DrctDbtTxInf>'.$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)
|
||||
$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;
|
||||
if ($this->sepa_xml_pti_in_ctti) {
|
||||
if (!empty($this->sepa_xml_pti_in_ctti)) {
|
||||
$XML_CREDITOR .= ' <PmtTpInf>' . $CrLf;
|
||||
|
||||
// Can be 'NORM' for normal or 'HIGH' for high priority level
|
||||
@@ -2076,7 +2076,7 @@ class BonPrelevement extends CommonObject
|
||||
$RefBon = $obj->ref;
|
||||
|
||||
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 .= ' <PmtInf>'.$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 .= ' <NbOfTxs>'.$nombre.'</NbOfTxs>'.$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 .= ' <SvcLvl>' . $CrLf;
|
||||
$XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf;
|
||||
|
||||
@@ -139,7 +139,7 @@ class ChargeSociales extends CommonObject
|
||||
{
|
||||
$sql = "SELECT cs.rowid, cs.date_ech";
|
||||
$sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key";
|
||||
$sql .= ", cs.fk_account, cs.fk_mode_reglement, cs.fk_user";
|
||||
$sql .= ", cs.fk_account, cs.fk_mode_reglement, cs.fk_user, note_public, note_private";
|
||||
$sql .= ", c.libelle as type_label";
|
||||
$sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as cs";
|
||||
@@ -172,6 +172,8 @@ class ChargeSociales extends CommonObject
|
||||
$this->amount = $obj->amount;
|
||||
$this->fk_project = $obj->fk_project;
|
||||
$this->fk_user = $obj->fk_user;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->paye = $obj->paye;
|
||||
$this->periode = $this->db->jdate($obj->periode);
|
||||
$this->import_key = $this->import_key;
|
||||
|
||||
@@ -81,7 +81,7 @@ $object->info($id);
|
||||
|
||||
$head = tax_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'info', $langs->trans("SocialContribution"), -1, 'bill');
|
||||
print dol_get_fiche_head($head, 'info', $langs->trans("SocialContribution"), -1, $object->picto);
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
// Label of social contribution
|
||||
@@ -115,7 +115,7 @@ print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table width="100%"><tr><td>';
|
||||
print '<table class="centpercent"><tr><td>';
|
||||
dol_print_object_info($object);
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
||||
135
htdocs/compta/sociales/note.php
Normal file
135
htdocs/compta/sociales/note.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2022 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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/compta/sociales/note.php
|
||||
* \ingroup tax
|
||||
* \brief Tab for notes on Taxes
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('compta', 'bills'));
|
||||
|
||||
// Get parameters
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
|
||||
$object = new ChargeSociales($db);
|
||||
if ($id > 0) {
|
||||
$object->fetch($id);
|
||||
}
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST('socid', 'int');
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges');
|
||||
|
||||
$permissiontoread = $user->rights->tax->charges->lire;
|
||||
$permissiontoadd = $user->rights->tax->charges->creer;
|
||||
$permissionnote = $user->rights->tax->charges->creer; // Used by the include of actions_setnotes.inc.php
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$parameters = array();
|
||||
$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 (empty($reshook)) {
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans("SocialContribution").' - '.$langs->trans("Note");
|
||||
$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head = tax_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'note', $langs->trans("SocialContribution"), -1, $object->picto);
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
// Label of social contribution
|
||||
$morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
|
||||
$morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
|
||||
// Project
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$langs->load("projects");
|
||||
$morehtmlref .= '<br>'.$langs->trans('Project').' : ';
|
||||
if (!empty($object->fk_project)) {
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$morehtmlref .= ' : '.$proj->getNomUrl(1);
|
||||
if ($proj->title) {
|
||||
$morehtmlref .= ' - '.dol_escape_htmltag($proj->title);
|
||||
}
|
||||
} else {
|
||||
$morehtmlref .= '';
|
||||
}
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
// Object card
|
||||
// ------------------------------------------------------------
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/sociales/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
//$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
$cssclass = "titlefield";
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@@ -376,7 +376,7 @@ class Contact extends CommonObject
|
||||
public function load_state_board()
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user;
|
||||
global $user, $hookmanager;
|
||||
|
||||
$this->nb = array();
|
||||
$clause = "WHERE";
|
||||
@@ -394,6 +394,12 @@ class Contact extends CommonObject
|
||||
if ($user->socid > 0) {
|
||||
$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);
|
||||
if ($resql) {
|
||||
@@ -1820,7 +1826,7 @@ class Contact extends CommonObject
|
||||
|
||||
$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);
|
||||
if (!$result) {
|
||||
|
||||
@@ -384,7 +384,7 @@ if (!empty($conf->mailing->enabled)) {
|
||||
}
|
||||
// Add fields from hooks
|
||||
$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 .= " 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'])) {
|
||||
@@ -405,7 +405,7 @@ if (!empty($search_categ_supplier) && $search_categ_supplier != '-1') {
|
||||
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 .= ' WHERE p.entity IN ('.getEntity('socpeople').')';
|
||||
$sql .= ' WHERE p.entity IN ('.getEntity('contact').')';
|
||||
if (empty($user->rights->societe->client->voir) && !$socid) { //restriction
|
||||
$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';
|
||||
// Add where from hooks
|
||||
$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;
|
||||
// Add order
|
||||
if ($view == "recent") {
|
||||
@@ -767,7 +767,7 @@ $moreforfilter .= '</div>';
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
$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 '</div>';
|
||||
|
||||
@@ -910,7 +910,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||
|
||||
// Fields from hook
|
||||
$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;
|
||||
// Date creation
|
||||
if (!empty($arrayfields['p.datec']['checked'])) {
|
||||
@@ -1018,7 +1018,7 @@ $parameters = array(
|
||||
'sortfield'=>$sortfield,
|
||||
'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;
|
||||
if (!empty($arrayfields['p.datec']['checked'])) {
|
||||
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';
|
||||
// Fields from hook
|
||||
$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;
|
||||
// Date creation
|
||||
if (!empty($arrayfields['p.datec']['checked'])) {
|
||||
@@ -1312,7 +1312,7 @@ while ($i < min($num, $limit)) {
|
||||
$db->free($resql);
|
||||
|
||||
$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 "</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
|
||||
|
||||
if (empty($reshook)) {
|
||||
$params = array(
|
||||
'attr' => array(
|
||||
'title' => '',
|
||||
'class' => 'classfortooltip'
|
||||
)
|
||||
);
|
||||
|
||||
// Send
|
||||
if (empty($user->socid)) {
|
||||
if ($object->statut == 1) {
|
||||
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 {
|
||||
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 ($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 {
|
||||
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 ($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 {
|
||||
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) {
|
||||
$langs->load("orders");
|
||||
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 {
|
||||
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) {
|
||||
$langs->load("bills");
|
||||
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 {
|
||||
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 ($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 {
|
||||
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 ($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 {
|
||||
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)
|
||||
@@ -2104,16 +2115,17 @@ if ($action == 'create') {
|
||||
|
||||
// Clone
|
||||
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
|
||||
// - Droit de creer + mode brouillon (erreur creation)
|
||||
// - Droit de 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 {
|
||||
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),
|
||||
'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_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', '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_suivi' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk commercial suivi', '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_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'=>'SaleRepresentative Signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80),
|
||||
'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'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90),
|
||||
'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),
|
||||
'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),
|
||||
'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),
|
||||
'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
|
||||
|
||||
@@ -751,15 +751,14 @@ class Contrat extends CommonObject
|
||||
* Load lines array into this->lines.
|
||||
* This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed
|
||||
*
|
||||
* @param int $only_product Return only physical products
|
||||
* @param int $loadalsotranslation Return translation for products
|
||||
*
|
||||
* @return ContratLigne[] Return array of contract lines
|
||||
* @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 0=Default, 1=Load also translations of product descriptions
|
||||
* @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
|
||||
global $langs, $conf, $extrafields;
|
||||
global $langs, $conf;
|
||||
|
||||
$this->nbofservices = 0;
|
||||
$this->nbofserviceswait = 0;
|
||||
@@ -773,13 +772,15 @@ class Contrat extends CommonObject
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
/*
|
||||
if (!is_object($extrafields)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($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();
|
||||
$pos = 0;
|
||||
@@ -802,6 +803,9 @@ class Contrat extends CommonObject
|
||||
$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 .= " WHERE d.fk_contrat = ".((int) $this->id);
|
||||
if ($only_services == 1) {
|
||||
$sql .= " AND d.product_type = 1";
|
||||
}
|
||||
$sql .= " ORDER by d.rowid ASC";
|
||||
|
||||
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
|
||||
@@ -814,6 +818,7 @@ class Contrat extends CommonObject
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
$line = new ContratLigne($this->db);
|
||||
|
||||
$line->id = $objp->rowid;
|
||||
$line->ref = $objp->rowid;
|
||||
$line->fk_contrat = $objp->fk_contrat;
|
||||
@@ -840,7 +845,7 @@ class Contrat extends CommonObject
|
||||
$line->type = $objp->type;
|
||||
|
||||
$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->fk_user_author = $objp->fk_user_author;
|
||||
@@ -882,6 +887,7 @@ class Contrat extends CommonObject
|
||||
}
|
||||
|
||||
$this->lines[$pos] = $line;
|
||||
|
||||
$this->lines_id_index_mapper[$line->id] = $pos;
|
||||
|
||||
//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),
|
||||
//'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),
|
||||
'fk_user_ouverture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserOpen', '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_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'=>'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'))
|
||||
);
|
||||
// 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 .= $db->order($sortfield, $sortorder);
|
||||
|
||||
$totalnboflines = 0;
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$totalnboflines = $db->num_rows($result);
|
||||
}
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
//$result = $db->query($sql);
|
||||
//$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
|
||||
$page = 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);
|
||||
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="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";
|
||||
$modelmail = "contract";
|
||||
|
||||
@@ -255,6 +255,12 @@ if ($action == 'update' && !empty($permissiontoadd)) {
|
||||
$result = $object->update($user);
|
||||
if ($result > 0) {
|
||||
$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 {
|
||||
$error++;
|
||||
// Creation KO
|
||||
|
||||
@@ -32,7 +32,7 @@ $addlinkid = GETPOST('idtolinkto', 'int');
|
||||
$addlinkref = GETPOST('reftolinkto', 'alpha');
|
||||
$cancellink = GETPOST('cancel', 'alpha');
|
||||
|
||||
// Link invoice to order
|
||||
// Link object to another object
|
||||
if ($action == 'addlink' && !empty($permissiondellink) && !$cancellink && $id > 0 && $addlinkid > 0) {
|
||||
$object->fetch($id);
|
||||
$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) {
|
||||
$result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid);
|
||||
if ($result < 0) {
|
||||
|
||||
@@ -635,6 +635,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
||||
|
||||
$TFact = array();
|
||||
$TFactThird = array();
|
||||
$TFactThirdNbLines = array();
|
||||
|
||||
$nb_bills_created = 0;
|
||||
$lastid= 0;
|
||||
@@ -685,6 +686,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
||||
$lastid = $objecttmp->id;
|
||||
|
||||
$TFactThird[$cmd->socid] = $objecttmp;
|
||||
$TFactThirdNbLines[$cmd->socid] = 0; //init nblines to have lines ordered by expedition and rang
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
$errors[] = $cmd->ref.' : '.$langs->trans($objecttmp->error);
|
||||
@@ -774,6 +776,11 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
||||
|
||||
$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(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
@@ -791,7 +798,7 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
||||
'HT',
|
||||
0,
|
||||
$product_type,
|
||||
$lines[$i]->rang,
|
||||
$rang,
|
||||
$lines[$i]->special_code,
|
||||
$objecttmp->origin,
|
||||
$lines[$i]->rowid,
|
||||
@@ -806,6 +813,8 @@ if ($massaction == 'confirm_createbills') { // Create bills from orders.
|
||||
);
|
||||
if ($result > 0) {
|
||||
$lineid = $result;
|
||||
if (!empty($createbills_onebythird)) //increment rang to keep order
|
||||
$TFactThirdNbLines[$rcp->socid]++;
|
||||
} else {
|
||||
$lineid = 0;
|
||||
$error++;
|
||||
|
||||
@@ -81,8 +81,6 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'facturedet_rec' && $user->rights->facture->creer) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'ecm_files' && $user->rights->ecm->creer) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'emailcollector_emailcollectoraction' && $user->admin) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'bom_bomline' && $user->rights->bom->write) {
|
||||
@@ -97,10 +95,20 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'facture_fourn_det_rec' && $user->rights->fournisseur->facture->creer) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'ecm_files' && $fk_element == 'fk_product' && (!empty($user->rights->produit->creer) || !empty($user->rights->service->creer))) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'ecm_files' && $fk_element == 'fk_ticket' && !empty($user->rights->ticket->write)) {
|
||||
} 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"
|
||||
if (!empty($user->rights->ecm->creer)) {
|
||||
$perm = 1;
|
||||
} elseif ($fk_element == 'fk_product' && (!empty($user->rights->produit->creer) || !empty($user->rights->service->creer))) {
|
||||
$perm = 1;
|
||||
} elseif ($fk_element == 'fk_ticket' && !empty($user->rights->ticket->write)) {
|
||||
$perm = 1;
|
||||
} elseif ($fk_element == 'fk_holiday' && !empty($user->rights->holiday->write)) {
|
||||
$perm = 1;
|
||||
} elseif ($fk_element == 'fk_soc' && !empty($user->rights->societe->creer)) {
|
||||
$perm = 1;
|
||||
}
|
||||
} elseif ($table_element_line == 'product_association' && $fk_element == 'fk_product' && (!empty($user->rights->produit->creer) || !empty($user->rights->service->creer))) {
|
||||
$perm = 1;
|
||||
} elseif ($table_element_line == 'projet_task' && $fk_element == 'fk_projet' && $user->rights->projet->creer) {
|
||||
|
||||
@@ -76,7 +76,7 @@ class box_clients extends ModeleBoxes
|
||||
*/
|
||||
public function loadBox($max = 5)
|
||||
{
|
||||
global $user, $langs, $conf;
|
||||
global $user, $langs, $hookmanager;
|
||||
$langs->load("boxes");
|
||||
|
||||
$this->max = $max;
|
||||
@@ -100,9 +100,15 @@ class box_clients extends ModeleBoxes
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
$sql .= " AND s.rowid = ".((int) $user->socid);
|
||||
// Add where from hooks
|
||||
$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 .= $this->db->plimit($max, 0);
|
||||
|
||||
|
||||
@@ -74,11 +74,15 @@ class box_contacts extends ModeleBoxes
|
||||
*/
|
||||
public function loadBox($max = 5)
|
||||
{
|
||||
global $user, $langs, $conf;
|
||||
global $user, $langs, $conf, $hookmanager;
|
||||
|
||||
$langs->load("boxes");
|
||||
|
||||
$this->max = $max;
|
||||
|
||||
$contactstatic = new Contact($this->db);
|
||||
$societestatic = new Societe($this->db);
|
||||
|
||||
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max));
|
||||
|
||||
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) {
|
||||
$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) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
$sql .= " AND sp.fk_soc = ".((int) $user->socid);
|
||||
// Add where from hooks
|
||||
$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 .= $this->db->plimit($max, 0);
|
||||
|
||||
@@ -120,9 +130,6 @@ class box_contacts extends ModeleBoxes
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
|
||||
$contactstatic = new Contact($this->db);
|
||||
$societestatic = new Societe($this->db);
|
||||
|
||||
$line = 0;
|
||||
while ($line < $num) {
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
@@ -71,7 +71,7 @@ class box_fournisseurs extends ModeleBoxes
|
||||
*/
|
||||
public function loadBox($max = 5)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
global $conf, $user, $langs, $hookmanager;
|
||||
$langs->load("boxes");
|
||||
|
||||
$this->max = $max;
|
||||
@@ -95,9 +95,15 @@ class box_fournisseurs extends ModeleBoxes
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
$sql .= " AND s.rowid = ".((int) $user->socid);
|
||||
// Add where from hooks
|
||||
$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 .= $this->db->plimit($max, 0);
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@ class box_produits extends ModeleBoxes
|
||||
}
|
||||
// Add where from hooks
|
||||
if (is_object($hookmanager)) {
|
||||
$parameters = array('boxproductlist'=>1);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array('boxproductlist' => 1, 'boxcode' => $this->boxcode);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $productstatic); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
}
|
||||
$sql .= $this->db->order('p.datec', 'DESC');
|
||||
|
||||
@@ -103,8 +103,8 @@ class box_produits_alerte_stock extends ModeleBoxes
|
||||
}
|
||||
// Add where from hooks
|
||||
if (is_object($hookmanager)) {
|
||||
$parameters = array('boxproductalertstocklist'=>1);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$parameters = array('boxproductalertstocklist' => 1, 'boxcode' => $this->boxcode);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $productstatic); // Note that $action and $object may have been modified by hook
|
||||
$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,";
|
||||
|
||||
@@ -78,7 +78,7 @@ class box_prospect extends ModeleBoxes
|
||||
*/
|
||||
public function loadBox($max = 5)
|
||||
{
|
||||
global $user, $langs, $conf;
|
||||
global $user, $langs, $hookmanager;
|
||||
|
||||
$this->max = $max;
|
||||
|
||||
@@ -101,9 +101,15 @@ class box_prospect extends ModeleBoxes
|
||||
if (empty($user->rights->societe->client->voir) && !$user->socid) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($user->socid) {
|
||||
$sql .= " AND s.rowid = ".((int) $user->socid);
|
||||
// Add where from hooks
|
||||
$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 .= $this->db->plimit($max, 0);
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes
|
||||
|
||||
$this->info_box_contents[$line][] = array(
|
||||
'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
|
||||
);
|
||||
|
||||
|
||||
@@ -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 = '')
|
||||
{
|
||||
global $conf, $dolibarr_main_data_root;
|
||||
global $conf, $dolibarr_main_data_root, $user;
|
||||
|
||||
// Clean values of $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)
|
||||
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) && !preg_match('/'.preg_quote($conf->global->MAIN_MAIL_AUTOCOPY_TO, '/').'/i', $to)) {
|
||||
$addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
|
||||
// Add auto copy to if not already in $to (Note: Adding bcc for specific modules are also done from pages)
|
||||
// For example MAIN_MAIL_AUTOCOPY_TO can be 'email@example.com, __USER_EMAIL__, ...'
|
||||
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;
|
||||
|
||||
@@ -827,8 +827,10 @@ abstract class CommonInvoice extends CommonObject
|
||||
$tmplang->load("main");
|
||||
|
||||
$datestring = dol_print_date($this->date, 'dayhourrfc');
|
||||
$pricewithtaxstring = price($this->total_ttc, 0, $tmplang, 0, -1, 2);
|
||||
$pricetaxstring = price($this->total_tva, 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);
|
||||
$pricewithtaxstring = price2num($this->total_ttc, 2, 1);
|
||||
$pricetaxstring = price2num($this->total_tva, 2, 1);
|
||||
|
||||
/*
|
||||
$name = implode(unpack("H*", $this->thirdparty->name));
|
||||
@@ -857,7 +859,7 @@ abstract class CommonInvoice extends CommonObject
|
||||
// Using TLV format
|
||||
$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', 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', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring;
|
||||
$s .= ''; // Hash of xml invoice
|
||||
|
||||
@@ -2931,15 +2931,20 @@ abstract class CommonObject
|
||||
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)
|
||||
$nl = 0;
|
||||
$sql = "SELECT count(rowid) FROM ".$this->db->prefix().$this->table_element_line;
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
if (!$renum) {
|
||||
$sql .= ' AND rang = 0';
|
||||
$sql .= " AND " . $fieldposition . " = 0";
|
||||
}
|
||||
if ($renum) {
|
||||
$sql .= ' AND rang <> 0';
|
||||
$sql .= " AND " . $fieldposition . " <> 0";
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::line_order", LOG_DEBUG);
|
||||
@@ -2960,7 +2965,7 @@ abstract class CommonObject
|
||||
if ($fk_parent_line) {
|
||||
$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);
|
||||
$resql = $this->db->query($sql);
|
||||
@@ -3001,12 +3006,17 @@ abstract class CommonObject
|
||||
*/
|
||||
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();
|
||||
|
||||
$sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line;
|
||||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->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);
|
||||
$resql = $this->db->query($sql);
|
||||
@@ -3077,7 +3087,7 @@ abstract class CommonObject
|
||||
{
|
||||
global $hookmanager;
|
||||
$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';
|
||||
}
|
||||
|
||||
@@ -3123,13 +3133,13 @@ abstract class CommonObject
|
||||
{
|
||||
if ($rang > 1) {
|
||||
$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';
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
||||
$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)) {
|
||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1));
|
||||
$sql .= ' WHERE rowid = '.((int) $rowid);
|
||||
@@ -3154,13 +3164,13 @@ abstract class CommonObject
|
||||
{
|
||||
if ($rang < $max) {
|
||||
$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';
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
||||
$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)) {
|
||||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1));
|
||||
$sql .= ' WHERE rowid = '.((int) $rowid);
|
||||
@@ -3181,7 +3191,12 @@ abstract class CommonObject
|
||||
*/
|
||||
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);
|
||||
|
||||
dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG);
|
||||
@@ -3200,9 +3215,14 @@ abstract class CommonObject
|
||||
*/
|
||||
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 .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
||||
$sql .= " AND rang = ".((int) $rang);
|
||||
$sql .= " AND " . $fieldposition . " = ".((int) $rang);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$row = $this->db->fetch_row($resql);
|
||||
@@ -3221,7 +3241,7 @@ abstract class CommonObject
|
||||
{
|
||||
// phpcs:enable
|
||||
$positionfield = 'rang';
|
||||
if ($this->table_element == 'bom_bom') {
|
||||
if (in_array($this->table_element, array('bom_bom', 'product_attribute'))) {
|
||||
$positionfield = 'position';
|
||||
}
|
||||
|
||||
@@ -6648,7 +6668,7 @@ abstract class CommonObject
|
||||
|
||||
// Add validation state class
|
||||
if (!empty($validationClass)) {
|
||||
$morecss.= ' '.$validationClass;
|
||||
$morecss.= $validationClass;
|
||||
}
|
||||
|
||||
if (in_array($type, array('date'))) {
|
||||
@@ -7067,6 +7087,8 @@ abstract class CommonObject
|
||||
$paramforthenewlink = '';
|
||||
$paramforthenewlink .= (GETPOSTISSET('action') ? '&action='.GETPOST('action', 'aZ09') : '');
|
||||
$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--';
|
||||
// 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>';
|
||||
|
||||
@@ -616,15 +616,15 @@ class Conf
|
||||
if (!empty($this->productbatch->enabled)) {
|
||||
$this->global->STOCK_CALCULATE_ON_BILL = 0;
|
||||
$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
|
||||
$this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
|
||||
$this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 0;
|
||||
if (empty($this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
|
||||
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_VALIDATE_ORDER = 0;
|
||||
if (empty($this->reception->enabled)) {
|
||||
$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
|
||||
} else {
|
||||
$this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
|
||||
$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0;
|
||||
if (empty($this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) $this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
|
||||
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 $discount_type; // 0 => customer discount, 1 => supplier discount
|
||||
public $amount_ht; //
|
||||
public $amount_tva; //
|
||||
public $amount_ttc; //
|
||||
public $multicurrency_amount_ht;
|
||||
public $multicurrency_amount_tva;
|
||||
public $multicurrency_amount_ttc;
|
||||
|
||||
public $total_ht;
|
||||
public $total_tva;
|
||||
public $total_ttc;
|
||||
public $amount_ht; // deprecated
|
||||
public $amount_tva; // deprecated
|
||||
public $amount_ttc; // deprecated
|
||||
|
||||
public $multicurrency_total_ht;
|
||||
public $multicurrency_total_tva;
|
||||
public $multicurrency_total_ttc;
|
||||
public $multicurrency_amount_ht; // deprecated
|
||||
public $multicurrency_amount_tva; // deprecated
|
||||
public $multicurrency_amount_ttc; // deprecated
|
||||
|
||||
// Vat rate
|
||||
public $tva_tx;
|
||||
public $vat_src_code;
|
||||
@@ -163,13 +172,21 @@ class DiscountAbsolute
|
||||
$this->fk_soc = $obj->fk_soc;
|
||||
$this->discount_type = $obj->discount_type;
|
||||
|
||||
$this->amount_ht = $obj->amount_ht;
|
||||
$this->amount_tva = $obj->amount_tva;
|
||||
$this->amount_ttc = $obj->amount_ttc;
|
||||
$this->total_ht = $obj->amount_ht;
|
||||
$this->total_tva = $obj->amount_tva;
|
||||
$this->total_ttc = $obj->amount_ttc;
|
||||
// For backward compatibility
|
||||
$this->amount_ht = $this->total_ht;
|
||||
$this->amount_tva = $this->total_tva;
|
||||
$this->amount_ttc = $this->total_ttc;
|
||||
|
||||
$this->multicurrency_amount_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht;
|
||||
$this->multicurrency_amount_tva = $obj->multicurrency_amount_tva;
|
||||
$this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc;
|
||||
$this->multicurrency_total_ht = $this->multicurrency_subprice = $obj->multicurrency_amount_ht;
|
||||
$this->multicurrency_total_tva = $obj->multicurrency_amount_tva;
|
||||
$this->multicurrency_total_ttc = $obj->multicurrency_amount_ttc;
|
||||
// For backward compatibility
|
||||
$this->multicurrency_amount_ht = $this->multicurrency_total_ht;
|
||||
$this->multicurrency_amount_tva = $this->multicurrency_total_tva;
|
||||
$this->multicurrency_amount_ttc = $this->multicurrency_total_ttc;
|
||||
|
||||
$this->tva_tx = $obj->tva_tx;
|
||||
$this->vat_src_code = $obj->vat_src_code;
|
||||
|
||||
@@ -193,10 +193,10 @@ class DolEditor
|
||||
removePlugins : \''.$pluginstodisable.'\',
|
||||
readOnly : '.($this->readonly ? 'true' : 'false').',
|
||||
htmlEncodeOutput :'.$htmlencode_force.',
|
||||
allowedContent :'.($disallowAnyContent ? 'false' : 'true').',
|
||||
extraAllowedContent : \'a[target];div{float,display}\', /* Add the style float and display into div to default other allowed tags */
|
||||
disallowedContent : '.($disallowAnyContent ? '\'\'' : '\'\'').',
|
||||
fullPage : '.($fullpage ? 'true' : 'false').',
|
||||
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 */
|
||||
disallowedContent : '.($disallowAnyContent ? '\'\'' : '\'\'').', /* Tags that are not allowed */
|
||||
fullPage : '.($fullpage ? 'true' : 'false').', /* if true, the html, header and body tags are kept */
|
||||
toolbar: \''.$this->toolbarname.'\',
|
||||
toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').',
|
||||
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_dyn.' '.(!empty($colspan)?'colspan="' . $colspan . '"':'').'>';
|
||||
// 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 .= $langs->trans($this->attributes[$object->table_element]['label'][$key]);
|
||||
$out .= '</strong>';
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.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 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2018 Christophe Battarel <christophe@altairis.fr>
|
||||
@@ -1320,6 +1320,7 @@ class Form
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $user, $langs;
|
||||
global $hookmanager;
|
||||
|
||||
$out = '';
|
||||
$num = 0;
|
||||
@@ -1367,6 +1368,10 @@ class Form
|
||||
if (!empty($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
|
||||
if ($filterkey && $filterkey != '') {
|
||||
$sql .= " AND (";
|
||||
@@ -1672,13 +1677,17 @@ class Form
|
||||
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 .= " WHERE sp.entity IN (".getEntity('socpeople').")";
|
||||
$sql .= " WHERE sp.entity IN (".getEntity('contact').")";
|
||||
if ($socid > 0 || $socid == -1) {
|
||||
$sql .= " AND sp.fk_soc = ".((int) $socid);
|
||||
}
|
||||
if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) {
|
||||
$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";
|
||||
|
||||
dol_syslog(get_class($this)."::selectcontacts", LOG_DEBUG);
|
||||
@@ -2462,6 +2471,7 @@ class Form
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
global $hookmanager;
|
||||
|
||||
$out = '';
|
||||
$outarray = array();
|
||||
@@ -2607,6 +2617,10 @@ class Form
|
||||
} elseif (empty($conf->service->enabled)) { // when service module is disabled, show products only
|
||||
$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
|
||||
if ($filterkey != '') {
|
||||
$sql .= ' AND (';
|
||||
@@ -3180,6 +3194,7 @@ class Form
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf, $user;
|
||||
global $hookmanager;
|
||||
|
||||
$out = '';
|
||||
$outarray = array();
|
||||
@@ -3229,6 +3244,10 @@ class Form
|
||||
if (!empty($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
|
||||
if ($filterkey != '') {
|
||||
$sql .= ' AND (';
|
||||
@@ -6680,7 +6699,7 @@ class Form
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
$retstring = '';
|
||||
$retstring = '<span class="nowraponall">';
|
||||
|
||||
$hourSelected = 0;
|
||||
$minSelected = 0;
|
||||
@@ -6712,7 +6731,7 @@ class Form
|
||||
if ($typehour != 'text') {
|
||||
$retstring .= ' '.$langs->trans('HourShort');
|
||||
} else {
|
||||
$retstring .= '<span class="hideonsmartphone">:</span>';
|
||||
$retstring .= '<span class="">:</span>';
|
||||
}
|
||||
|
||||
// Minutes
|
||||
@@ -6740,7 +6759,7 @@ class Form
|
||||
$retstring .= ' '.$langs->trans('MinuteShort');
|
||||
}
|
||||
|
||||
//$retstring.=" ";
|
||||
$retstring.="</span>";
|
||||
|
||||
if (!empty($nooutput)) {
|
||||
return $retstring;
|
||||
@@ -8587,6 +8606,7 @@ class Form
|
||||
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="action" value="addlinkbyref">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="addlink" value="' . $key . '">';
|
||||
print '<table class="noborder">';
|
||||
print '<tr>';
|
||||
|
||||
@@ -618,7 +618,7 @@ class FormCompany extends Form
|
||||
*/
|
||||
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)) {
|
||||
// Use Ajax search
|
||||
@@ -718,6 +718,10 @@ class FormCompany extends Form
|
||||
if (is_array($limitto) && count($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";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@@ -1283,12 +1283,22 @@ class FormFile
|
||||
}
|
||||
print '<td></td>';
|
||||
print '<td></td>';
|
||||
if (!$disablemove) {
|
||||
if (empty($disablemove) && count($filearray) > 1) {
|
||||
print '<td></td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
// Get list of files stored into database for same relative directory
|
||||
if ($relativedir) {
|
||||
completeFileArrayWithDatabaseInfo($filearray, $relativedir);
|
||||
|
||||
//var_dump($sortfield.' - '.$sortorder);
|
||||
if ($sortfield && $sortorder) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
|
||||
$filearray = dol_sort_array($filearray, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr class="liste_titre nodrag nodrop">';
|
||||
//print $url.' sortfield='.$sortfield.' sortorder='.$sortorder;
|
||||
print_liste_field_titre('Documents2', $url, "name", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
@@ -1301,21 +1311,11 @@ class FormFile
|
||||
print_liste_field_titre('');
|
||||
// Action button
|
||||
print_liste_field_titre('');
|
||||
if (!$disablemove) {
|
||||
if (empty($disablemove) && count($filearray) > 1) {
|
||||
print_liste_field_titre('');
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
// Get list of files stored into database for same relative directory
|
||||
if ($relativedir) {
|
||||
completeFileArrayWithDatabaseInfo($filearray, $relativedir);
|
||||
|
||||
//var_dump($sortfield.' - '.$sortorder);
|
||||
if ($sortfield && $sortorder) { // If $sortfield is for example 'position_name', we will sort on the property 'position_name' (that is concat of position+name)
|
||||
$filearray = dol_sort_array($filearray, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
|
||||
$nboffiles = count($filearray);
|
||||
if ($nboffiles > 0) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
@@ -1506,22 +1506,22 @@ class FormFile
|
||||
if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) {
|
||||
$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>";
|
||||
|
||||
if (empty($disablemove)) {
|
||||
if (empty($disablemove) && count($filearray) > 1) {
|
||||
if ($nboffiles > 1 && $conf->browser->layout != 'phone') {
|
||||
print '<td class="linecolmove tdlineupdown center">';
|
||||
if ($i > 0) {
|
||||
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&rowid='.$line->id.'">'.img_up('default', 0, 'imgupforline').'</a>';
|
||||
}
|
||||
if ($i < $nboffiles - 1) {
|
||||
if ($i < ($nboffiles - 1)) {
|
||||
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&rowid='.$line->id.'">'.img_down('default', 0, 'imgdownforline').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
} else {
|
||||
print '<td'.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>';
|
||||
print '<td'.(($conf->browser->layout != 'phone') ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>';
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
@@ -1531,7 +1531,7 @@ class FormFile
|
||||
print '<input type="submit" class="button button-save" name="renamefilesave" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
|
||||
print '</td>';
|
||||
if (empty($disablemove)) {
|
||||
if (empty($disablemove) && count($filearray) > 1) {
|
||||
print '<td class="right"></td>';
|
||||
}
|
||||
}
|
||||
@@ -1542,7 +1542,7 @@ class FormFile
|
||||
}
|
||||
if ($nboffiles == 0) {
|
||||
$colspan = '6';
|
||||
if (empty($disablemove)) {
|
||||
if (empty($disablemove) && count($filearray) > 1) {
|
||||
$colspan++; // 6 columns or 7
|
||||
}
|
||||
print '<tr class="oddeven"><td colspan="'.$colspan.'">';
|
||||
@@ -2032,7 +2032,7 @@ class FormFile
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].($param ? '?'.$param : '').'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
|
||||
print '<table width="100%" class="liste noborder nobottom">';
|
||||
print '<table class="liste noborder nobottom centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre(
|
||||
$langs->trans("Links"),
|
||||
@@ -2117,7 +2117,7 @@ class FormFile
|
||||
print '<td class="right">';
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=update&linkid='.$link->id.$param.'&token='.newToken().'" class="editfilelink editfielda reposition" >'.img_edit().'</a>'; // id= is included into $param
|
||||
if ($permissiontodelete) {
|
||||
print ' <a class="deletefilelink" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&linkid='.$link->id.$param.'">'.img_delete().'</a>'; // id= is included into $param
|
||||
print ' <a class="deletefilelink reposition" href="'.$_SERVER['PHP_SELF'].'?action=deletelink&token='.newToken().'&linkid='.((int) $link->id).$param.'">'.img_delete().'</a>'; // id= is included into $param
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class FormOther
|
||||
$stringaddbarcode = str_replace("tmphtml", $htmltoreplaceby, $stringaddbarcode);
|
||||
$out .= $stringaddbarcode.' <input type="text" name="barcodeproductqty" class="width50 right" value="1"><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>';
|
||||
|
||||
@@ -110,7 +110,7 @@ class FormOther
|
||||
$out .= 'jQuery("#scantoolmessage").text("");';
|
||||
$out .= '});'."\n";
|
||||
$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).'();
|
||||
return false; /* We want to stay on the scan tool */
|
||||
})';
|
||||
|
||||
@@ -608,7 +608,7 @@ class Notify
|
||||
$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)) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ class Utils
|
||||
* @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 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)
|
||||
*/
|
||||
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)) {
|
||||
$param .= " -P ".$dolibarr_main_db_port;
|
||||
}
|
||||
if (!GETPOST("use_transaction", "alpha")) {
|
||||
$param .= " -l --single-transaction";
|
||||
if (GETPOST("use_transaction", "alpha")) {
|
||||
$param .= " --single-transaction";
|
||||
}
|
||||
if (GETPOST("disable_fk", "alpha") || $usedefault) {
|
||||
$param .= " -K";
|
||||
@@ -342,17 +342,42 @@ class Utils
|
||||
|
||||
$handle = '';
|
||||
|
||||
$lowmemorydump = GETPOSTISSET("lowmemorydump", "alpha") ? GETPOST("lowmemorydump") : getDolGlobalString('MAIN_LOW_MEMORY_DUMP');
|
||||
|
||||
// Start call method to execute dump
|
||||
$fullcommandcrypted = $command." ".$paramcrypted." 2>&1";
|
||||
$fullcommandclear = $command." ".$paramclear." 2>&1";
|
||||
if ($compression == 'none') {
|
||||
$handle = fopen($outputfile, 'w');
|
||||
} elseif ($compression == 'gz') {
|
||||
$handle = gzopen($outputfile, 'w');
|
||||
} elseif ($compression == 'bz') {
|
||||
$handle = bzopen($outputfile, 'w');
|
||||
} elseif ($compression == 'zstd') {
|
||||
$handle = fopen($outputfile, 'w');
|
||||
if (!$lowmemorydump) {
|
||||
if ($compression == 'none') {
|
||||
$handle = fopen($outputfile, 'w');
|
||||
} elseif ($compression == 'gz') {
|
||||
$handle = gzopen($outputfile, 'w');
|
||||
} elseif ($compression == 'bz') {
|
||||
$handle = bzopen($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;
|
||||
@@ -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) {
|
||||
$output_arr = array();
|
||||
$retval = null;
|
||||
@@ -394,16 +420,23 @@ class Utils
|
||||
if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) {
|
||||
continue;
|
||||
}
|
||||
fwrite($handle, $read.($execmethod == 2 ? '' : "\n"));
|
||||
if (preg_match('/'.preg_quote('-- Dump completed').'/i', $read)) {
|
||||
$ok = 1;
|
||||
} elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i', $read)) {
|
||||
$ok = 1;
|
||||
if (!$lowmemorydump) {
|
||||
fwrite($handle, $read.($execmethod == 2 ? '' : "\n"));
|
||||
if (preg_match('/'.preg_quote('-- Dump completed', '/').'/i', $read)) {
|
||||
$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
|
||||
$handlein = popen($fullcommandclear, 'r');
|
||||
$i = 0;
|
||||
@@ -848,8 +881,13 @@ class Utils
|
||||
$resarray = $utils->executeCLI($command, $outfile);
|
||||
if ($resarray['result'] != '0') {
|
||||
$this->error = $resarray['error'].' '.$resarray['output'];
|
||||
$this->errors[] = $this->error;
|
||||
}
|
||||
$result = ($resarray['result'] == 0) ? 1 : 0;
|
||||
if ($result < 0 && empty($this->errors)) {
|
||||
$this->error = $langs->trans("ErrorFailToGenerateFile", $FILENAMEDOC);
|
||||
$this->errors[] = $this->error;
|
||||
}
|
||||
|
||||
// Build PDF doc
|
||||
$command = $conf->global->MODULEBUILDER_ASCIIDOCTORPDF.' '.$destfile.' -n -o '.$dirofmoduledoc.'/'.$FILENAMEDOCPDF;
|
||||
@@ -857,8 +895,13 @@ class Utils
|
||||
$resarray = $utils->executeCLI($command, $outfile);
|
||||
if ($resarray['result'] != '0') {
|
||||
$this->error = $resarray['error'].' '.$resarray['output'];
|
||||
$this->errors[] = $this->error;
|
||||
}
|
||||
$result = ($resarray['result'] == 0) ? 1 : 0;
|
||||
if ($result < 0 && empty($this->errors)) {
|
||||
$this->error = $langs->trans("ErrorFailToGenerateFile", $FILENAMEDOCPDF);
|
||||
$this->errors[] = $this->error;
|
||||
}
|
||||
|
||||
chdir($currentdir);
|
||||
} else {
|
||||
@@ -869,8 +912,6 @@ class Utils
|
||||
return 1;
|
||||
} else {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans("ErrorFailToGenerateFile", $outputfiledoc);
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
|
||||
@@ -212,6 +212,29 @@ if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) {
|
||||
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
|
||||
if ($action == 'viewgraph') {
|
||||
if (!count($search_measures)) {
|
||||
@@ -253,10 +276,18 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT ".$fieldtocount." as val";
|
||||
|
||||
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 {
|
||||
$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
|
||||
@@ -272,7 +303,7 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
||||
}
|
||||
}*/
|
||||
|
||||
$sql .= ' LIMIT '.($MAXUNIQUEVALFORGROUP + 1);
|
||||
$sql .= " LIMIT ".((int) ($MAXUNIQUEVALFORGROUP + 1));
|
||||
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
@@ -319,8 +350,17 @@ if (is_array($search_groupby) && count($search_groupby)) {
|
||||
|
||||
$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]);
|
||||
|
||||
// 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) {
|
||||
$langs->load("errors");
|
||||
if (strpos($fieldtocount, 'te.') === 0) {
|
||||
@@ -380,15 +420,6 @@ print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
// Select object
|
||||
print '<div class="divadvancedsearchfield center floatnone">';
|
||||
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);
|
||||
if (empty($conf->use_javascript_ajax)) {
|
||||
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
|
||||
$count = 0;
|
||||
$arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count);
|
||||
//var_dump($arrayofmesures);
|
||||
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 $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>';
|
||||
|
||||
// XAxis
|
||||
$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="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);
|
||||
@@ -431,8 +463,6 @@ print '</div>';
|
||||
|
||||
// Group by
|
||||
$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="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
|
||||
@@ -454,18 +484,38 @@ if ($mode == 'grid') {
|
||||
continue;
|
||||
}
|
||||
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.'-month'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => $val['position']);
|
||||
$arrayofyaxis['t.'.$key.'-day'] = array('label' => $langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => $val['position']);
|
||||
$arrayofyaxis['t.'.$key.'-year'] = array(
|
||||
'label' => $langs->trans($val['label']).' ('.$YYYY.')',
|
||||
'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 {
|
||||
$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
|
||||
if ($object->isextrafieldmanaged) {
|
||||
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'))) {
|
||||
$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)) {
|
||||
$fieldid = 'rowid';
|
||||
|
||||
$sql = 'SELECT ';
|
||||
$sql = "SELECT ";
|
||||
foreach ($search_xaxis as $key => $val) {
|
||||
if (preg_match('/\-year$/', $val)) {
|
||||
$tmpval = preg_replace('/\-year$/', '', $val);
|
||||
@@ -542,23 +592,72 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
||||
}
|
||||
}
|
||||
$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
|
||||
if ($object->isextrafieldmanaged) {
|
||||
$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) {
|
||||
// Nothing here
|
||||
// No table to add here
|
||||
} else {
|
||||
$tmparray = explode('@', $object->ismultientitymanaged);
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1]." as parenttable ON t.".$tmparray[0]." = parenttable.rowid";
|
||||
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1]." as parenttableforentity ON t.".$tmparray[0]." = parenttableforentity.rowid";
|
||||
$sql .= " AND parenttableforentity.entity IN (".getEntity($tmparray[1]).")";
|
||||
}
|
||||
}
|
||||
$sql .= ' WHERE 1 = 1';
|
||||
if ($object->ismultientitymanaged == 1) {
|
||||
$sql .= ' AND entity IN ('.getEntity($object->element).')';
|
||||
|
||||
$listoftablesalreadyadded = array($object->table_element => $object->table_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
|
||||
$sqlfilters = $search_component_params_hidden;
|
||||
@@ -571,7 +670,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
||||
print $errormessage;
|
||||
}
|
||||
}
|
||||
$sql .= ' GROUP BY ';
|
||||
$sql .= " GROUP BY ";
|
||||
foreach ($search_xaxis as $key => $val) {
|
||||
if (preg_match('/\-year$/', $val)) {
|
||||
$tmpval = preg_replace('/\-year$/', '', $val);
|
||||
@@ -636,7 +735,7 @@ if (!empty($search_measures) && !empty($search_xaxis)) {
|
||||
|
||||
$legend = array();
|
||||
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));
|
||||
@@ -667,7 +766,7 @@ if ($sql) {
|
||||
if (!empty($object->fields[$xvalwithoutprefix]['arrayofkeyval'])) {
|
||||
$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)) {
|
||||
$xi++; // Increase $xi
|
||||
@@ -861,26 +960,62 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
|
||||
|
||||
if ($level == 0) {
|
||||
// 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
|
||||
foreach ($object->fields as $key => $val) {
|
||||
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>';
|
||||
$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.'-min'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Minimum").')</span>';
|
||||
$arrayofmesures[$tablealias.'.'.$key.'-max'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Maximum").')</span>';
|
||||
$arrayofmesures[$tablealias.'.'.$key.'-sum'] = array(
|
||||
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
|
||||
'position' => ($val['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' => ($val['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' => ($val['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' => ($val['position']+($count * 100000)).'.4',
|
||||
'table' => $object->table_element
|
||||
);
|
||||
}
|
||||
}
|
||||
// Add extrafields to Measures
|
||||
if ($object->isextrafieldmanaged) {
|
||||
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'))) {
|
||||
$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>';
|
||||
$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.'-min'] = img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Minimum").')</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>';
|
||||
$arrayofmesures[$tablealias.'e.'.$key.'-sum'] = array(
|
||||
'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' <span class="opacitymedium">('.$langs->trans("Sum").')</span>',
|
||||
'position' => ($val['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' => ($val['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' => ($val['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' => ($val['position']+($count * 100000)).'.4',
|
||||
'table' => $object->table_element
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -888,19 +1023,16 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
||||
$tmptype = explode(':', $val['type'], 4);
|
||||
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
|
||||
if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
|
||||
$newobject = $tmptype[1];
|
||||
dol_include_once($tmptype[2]);
|
||||
if (class_exists($newobject)) {
|
||||
$tmpobject = new $newobject($db);
|
||||
/*var_dump($val['label']);
|
||||
var_dump($tmptype);
|
||||
var_dump($arrayofmesures);
|
||||
var_dump('t-'.$key);*/
|
||||
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
||||
$count++;
|
||||
$arrayofmesures = fillArrayOfMeasures($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofmesures, $level + 1, $count);
|
||||
} 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 +1046,7 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu
|
||||
* Fill arrayofmesures for an 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 array $arrayofxaxis Array of xaxis already filled
|
||||
* @param int $level Level
|
||||
@@ -964,14 +1096,31 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
|
||||
continue;
|
||||
}
|
||||
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');
|
||||
$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.'-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');
|
||||
$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',
|
||||
'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' => ($val['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' => ($val['position']+($count * 100000)).'.3',
|
||||
'table' => $object->table_element
|
||||
);
|
||||
} 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' => ($val['position']+($count * 100000)),
|
||||
'table' => $object->table_element
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add extrafields to X-Axis
|
||||
if ($object->isextrafieldmanaged) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
@@ -981,26 +1130,28 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis,
|
||||
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
|
||||
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
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
||||
$tmptype = explode(':', $val['type'], 4);
|
||||
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
|
||||
if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
|
||||
$newobject = $tmptype[1];
|
||||
dol_include_once($tmptype[2]);
|
||||
if (class_exists($newobject)) {
|
||||
$tmpobject = new $newobject($db);
|
||||
/*var_dump($val['label']);
|
||||
var_dump($tmptype);
|
||||
var_dump($arrayofmesures);
|
||||
var_dump('t-'.$key);*/
|
||||
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
||||
$count++;
|
||||
$arrayofxaxis = fillArrayOfXAxis($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofxaxis, $level + 1, $count);
|
||||
} 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 +1215,31 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
|
||||
continue;
|
||||
}
|
||||
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');
|
||||
$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.'-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');
|
||||
$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',
|
||||
'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' => ($val['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' => ($val['position']+($count * 100000)).'.3',
|
||||
'table' => $object->table_element
|
||||
);
|
||||
} 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' => ($val['position']+($count * 100000)),
|
||||
'table' => $object->table_element
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add extrafields to Group by
|
||||
if ($object->isextrafieldmanaged) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
@@ -1081,26 +1249,28 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup
|
||||
if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key])) {
|
||||
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
|
||||
foreach ($object->fields as $key => $val) {
|
||||
if (preg_match('/^[^:]+:[^:]+:/', $val['type'])) {
|
||||
$tmptype = explode(':', $val['type'], 4);
|
||||
if ($tmptype[0] = 'integer' && $tmptype[1] && $tmptype[2]) {
|
||||
if ($tmptype[0] == 'integer' && $tmptype[1] && $tmptype[2]) {
|
||||
$newobject = $tmptype[1];
|
||||
dol_include_once($tmptype[2]);
|
||||
if (class_exists($newobject)) {
|
||||
$tmpobject = new $newobject($db);
|
||||
/*var_dump($val['label']);
|
||||
var_dump($tmptype);
|
||||
var_dump($arrayofmesures);
|
||||
var_dump('t-'.$key);*/
|
||||
//var_dump($key); var_dump($tmpobject->element); var_dump($val['label']); var_dump($tmptype); var_dump('t-'.$key);
|
||||
$count++;
|
||||
$arrayofgroupby = fillArrayOfGroupBy($tmpobject, $tablealias.'__'.$key, $langs->trans($val['label']), $arrayofgroupby, $level + 1, $count);
|
||||
} 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).
|
||||
* 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 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
|
||||
*/
|
||||
public function query($query, $usesavepoint = 0, $type = 'auto', $result_mode = 0)
|
||||
|
||||
@@ -65,6 +65,7 @@ function SetCurrentFolder( resourceType, folderPath )
|
||||
|
||||
function OnSubmit()
|
||||
{
|
||||
console.log("Click on OnSubmit");
|
||||
if ( document.getElementById('NewFile').value.length == 0 )
|
||||
{
|
||||
alert( 'Please select a file from your computer' );
|
||||
@@ -80,6 +81,8 @@ function OnSubmit()
|
||||
|
||||
function OnUploadCompleted( errorNumber, data )
|
||||
{
|
||||
console.log("errorNumber = "+errorNumber);
|
||||
|
||||
// Reset the Upload Worker Frame.
|
||||
window.parent.frames['frmUploadWorker'].location = 'javascript:void(0)' ;
|
||||
|
||||
@@ -106,7 +109,7 @@ function OnUploadCompleted( errorNumber, data )
|
||||
alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + data + '"' );
|
||||
break;
|
||||
case 202:
|
||||
alert( 'Invalid file' );
|
||||
alert( 'Invalid file (Bad extension)' );
|
||||
break;
|
||||
default:
|
||||
alert( 'Error on file upload. Error number: ' + errorNumber );
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user