Merge remote-tracking branch 'Dolibarr/develop' into develop

This commit is contained in:
Nicolas ZABOURI 2019-05-10 09:08:10 +02:00
commit 19c18ad555
2596 changed files with 110516 additions and 71783 deletions

View File

@ -31,7 +31,6 @@ addons:
- pgloader - pgloader
php: php:
- '5.4'
- '5.5' - '5.5'
- '5.6' - '5.6'
- '7.0' - '7.0'
@ -62,8 +61,6 @@ matrix:
- php: nightly - php: nightly
# We exclude some combinations not usefull to save Travis CPU # We exclude some combinations not usefull to save Travis CPU
exclude: exclude:
- php: '5.5'
env: DB=mariadb
- php: '5.6' - php: '5.6'
env: DB=mariadb env: DB=mariadb
- php: '7.0' - php: '7.0'
@ -72,8 +69,6 @@ matrix:
env: DB=mariadb env: DB=mariadb
- php: '7.2' - php: '7.2'
env: DB=mariadb env: DB=mariadb
- php: '5.5'
env: DB=postgresql
- php: '5.6' - php: '5.6'
env: DB=postgresql env: DB=postgresql
- php: '7.0' - php: '7.0'

View File

@ -14,7 +14,7 @@ Component Version License GPL Compatible
PHP libraries: PHP libraries:
AdoDb-Date 0.36 Modified BSD License Yes Date convertion (not into rpm package) AdoDb-Date 0.36 Modified BSD License Yes Date convertion (not into rpm package)
ChromePHP 4.1.0 Apache Software License 2.0 Yes Return server log to chrome browser console ChromePHP 4.1.0 Apache Software License 2.0 Yes Return server log to chrome browser console
CKEditor 4.6.2 LGPL-2.1+ Yes Editor WYSIWYG CKEditor 4.11.4 LGPL-2.1+ Yes Editor WYSIWYG
PHPDebugBar 1.15.0 MIT License Yes Used only by the module "debugbar" for developers PHPDebugBar 1.15.0 MIT License Yes Used only by the module "debugbar" for developers
EvalMath 1.0 BSD Yes Safe math expressions evaluation EvalMath 1.0 BSD Yes Safe math expressions evaluation
Escpos-php ? MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers Escpos-php ? MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers

View File

@ -2,33 +2,123 @@
English Dolibarr ChangeLog English Dolibarr ChangeLog
-------------------------------------------------------------- --------------------------------------------------------------
***** ChangeLog for 10.0.0 compared to 9.0.0 ***** ***** ChangeLog for 10.0.0 compared to 9.0.0 *****
For Users: For Users:
NEW: Module Ticket is available as a stable module. NEW: Module "Ticket" is available as a stable module.
NEW: module "Email Collector" is available as a stable module.
NEW: module "TakePOS" is available as a stable module.
NEW: Experimental module "Vendor receptions". NEW: Experimental module "Vendor receptions".
NEW: Experimental module "BOM". NEW: Experimental module "BOM".
FIX: Disallow line start date to be after end date FIX: Disallow line start date if after end date.
For Developers: For Developers:
NEW: Module DebugBar is available as a stable module. NEW: Module "DebugBar" is available as a stable module.
WARNING: WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* PHP 5.4 is no more supported. Minimum PHP is now 5.5+.
* The PHP extension php-intl is not mandatory but should be installed to have new features working correctly.
* Method GetUrlTrackingStatus were renamed into getUrlTrackingStatus for consistency with naming rules. * Method GetUrlTrackingStatus were renamed into getUrlTrackingStatus for consistency with naming rules.
* API getListOfCivility has been renamed into getListOfCivilities for consistency with naming rules. * API getListOfCivility has been renamed into getListOfCivilities for consistency with naming rules.
* Deprecated function img_phone as been removed. You can use img_picto(..., 'call|call_out') instead.; * Deprecated function img_phone as been removed. You can use img_picto(..., 'call|call_out') instead.;
* Files for variables of themes were renamed from graph-color.php into theme_vars.inc.php to match naming * Files for variables of themes were renamed from graph-color.php into theme_vars.inc.php to match naming
convention of extension .inc.php for files to be included. convention of extension .inc.php for files to be included.
* All methods set_draft() were renamed into setDraft(). * All methods set_draft() were renamed into setDraft().
* Signatures of methods createFromClone() has been standardized. All methods requires the object User as first parameter.
* Removed deprecated function function test_sql_and_script_inject that was replaced with testSqlAndScriptInject. * Removed deprecated function function test_sql_and_script_inject that was replaced with testSqlAndScriptInject.
* Method load_measuring_units were renamed into selectMeasuringUnits and select_measuring_units was deprecated. * Method load_measuring_units were renamed into selectMeasuringUnits and select_measuring_units was deprecated.
* Hidden option CHANGE_ORDER_CONCAT_DESCRIPTION were renamed into MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION. * Hidden option CHANGE_ORDER_CONCAT_DESCRIPTION were renamed into MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION.
* Method dolEscapeXML was moved from functions.lib.php into function2.lib.php (not used enough to be loaded by default). * Method dolEscapeXML was moved from functions.lib.php into function2.lib.php (not used enough to be loaded by default).
* Removed deprecated use of string in dol_print_date(). Only date allowed. * Removed deprecated use of string in dol_print_date(). Only date allowed.
* Deprecated property ->fk_departement is now ->state_id everywhere.
* Removed the method 4 of GETPOST (to get $_COOKIE). It was not used and not recommanded to use in Dolibarr.
***** ChangeLog for 9.0.3 compared to 9.0.2 *****
FIX: #11013
FIX: #11041
FIX: actioncomm: sort events by date after external calendars and hook (into 7.0)
FIX: better test
FIX: Combo list was limited to 20 in stock correction
FIX: Confusion between expired and late
FIX: Cursor pointer in payment screen for autofill
FIX: CVE-2019-11199
FIX: CVE-2019-11200
FIX: CVE-2019-11201
FIX: Default value on form to send email
FIX: error messages not displayed
FIX: Massive debug in lettering function
FIX: missing compatibility with multicompany
FIX: missing global $user
FIX: missing situation invoice in list
FIX: MultiEntity in lettering functionality
FIX: Product accountancey sell intra code must be visible if main feature level 1
FIX: ref for table without ref manager are set to NULL.
FIX: Sending email to mass actions send same email on same customer
FIX: Several fixes on import of services/products
FIX: shipping default warehouse if only one warehouse
FIX: sortfield on lettering function
FIX: Status of opportunity should never be -1
FIX: test to display create invoice button on supplier_order card
FIX: The autocopy feature was ko for suppliers
FIX: Total per day in timespent per week
FIX: Total per day shows 00:00 if the total time spent is equal to 12:00
FIX: Update/delete currency on same languages
FIX: Wrong variable name make contact of supplier order not used on PDF.
FIX: Add hidden option MAIN_PDF_HIDE_SITUATION to hide situation (quick hack to fix output pb).
***** ChangeLog for 9.0.2 compared to 9.0.1 *****
FIX: #10822
FIX: Accountancy - Format EBP import
FIX: A page of a site replaced with another when switching in edit mode
FIX: Autodetect buy price for invoices autogenerated with templates.
FIX: Avoid error 500 when extension php-intl not loaded
FIX: bad check on type of expense report (mandatory status not working)
FIX: Bad label of status for members (must be short version in list)
FIX: Can not create contract with numbering module without autogen rule
FIX: Can't set default value of extrafield of type varchar
FIX: check only if invoice module is enabled (bank is check after)
FIX: counter of permissions in badge was wrong
FIX: default value of language of thirdparty
FIX: Don't show accountingjournal:getNomUrl without data
FIX: Duplicate executeHook function
FIX: Edit of personalized groups
FIX: Error with various & salary payment on project
FIX: extrafields always visible on view mode
FIX: function not found
FIX: If we build one invoice for several orders, we must put the ref of
orders on lines.
FIX: expensereport must be in $check array
FIX: missing entity filter and wrong var name
FIX: Missing field "In sale" in list
FIX: missing hook completeTabsHead in margins module
FIX: missing hook in agenda export
FIX: missing vat_src_code when inserting an expense report line
FIX: More complete auto setup of barcode module
FIX: need to round with 2 decimals to avoid movements not correctly balanced
FIX: no need to test anything to display documents tabs on expense report
FIX: old export models was not visible
FIX: Param keepn must be 1 when dol_escape_htmltag used for textarea
FIX: possibility to set up payment mode when invoice module is disabled
FIX: problem with sign of various payment in project preview
FIX: Remane of project
FIX: setup of module export
FIX: several hooks in shipping/delivery cards
FIX: supplier discount was not retrieved when choosing a product
FIX: The minimum amount filter does not work in the VAT report per customer
FIX: Tooltip on click was ko on smartphone
FIX: translation
FIX: useless join
FIX: Vat src code lost after editing expense report line
FIX: we need to keep originline special_code
FIX: Can't insert if there is extrafields mandatory on another entity.
FIX: error in create object when 2 extra fields are mandatory in 2 different entities
FIX: when we create deposit with multi tva, we mustn't add line if amount = 0 (example when we have a 100% reduc on one of origin invoice line)
FIX: wrong redirect link on holiday refuse
NEW: Add more complete error messages in log on stripe payments
***** ChangeLog for 9.0.1 compared to 9.0.0 ***** ***** ChangeLog for 9.0.1 compared to 9.0.0 *****
FIX: #10381 FIX: #10381
@ -510,7 +600,7 @@ NEW: Filter export model is now by user
NEW: Finish implementation of option PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES NEW: Finish implementation of option PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES
NEW: generalize use of button to create new element from list NEW: generalize use of button to create new element from list
NEW: hidden conf AGENDA_NB_WEEKS_IN_VIEW_PER_USER to set nb weeks to show into per user view NEW: hidden conf AGENDA_NB_WEEKS_IN_VIEW_PER_USER to set nb weeks to show into per user view
NEW: hidden conf to assign category to thirparty that are neither customer nor prospect or supplier NEW: hidden conf to assign category to thirdparty that are neither customer nor prospect or supplier
NEW: hidden conf to set nb weeks to show into user view NEW: hidden conf to set nb weeks to show into user view
NEW: hidden option MAIN_DISABLE_FREE_LINES NEW: hidden option MAIN_DISABLE_FREE_LINES
NEW: improve way of adding users/sales representative to thirdparty NEW: improve way of adding users/sales representative to thirdparty

View File

@ -129,7 +129,7 @@ $BUILDROOT="$TEMP/buildroot";
$result = open( IN, "<" . $SOURCE . "/htdocs/filefunc.inc.php" ); $result = open( IN, "<" . $SOURCE . "/htdocs/filefunc.inc.php" );
if ( !$result ) { die "Error: Can't open descriptor file " . $SOURCE . "/htdocs/filefunc.inc.php\n"; } if ( !$result ) { die "Error: Can't open descriptor file " . $SOURCE . "/htdocs/filefunc.inc.php\n"; }
while (<IN>) { while (<IN>) {
if ( $_ =~ /define\('DOL_VERSION','([\d\.a-z\-]+)'\)/ ) { $PROJVERSION = $1; break; } if ( $_ =~ /define\('DOL_VERSION',\s*'([\d\.a-z\-]+)'\)/ ) { $PROJVERSION = $1; break; }
} }
close IN; close IN;
($MAJOR,$MINOR,$BUILD)=split(/\./,$PROJVERSION,3); ($MAJOR,$MINOR,$BUILD)=split(/\./,$PROJVERSION,3);

View File

@ -8,9 +8,11 @@
<exclude-pattern type="relative">documents</exclude-pattern> <exclude-pattern type="relative">documents</exclude-pattern>
<exclude-pattern type="relative">htdocs/custom</exclude-pattern> <exclude-pattern type="relative">htdocs/custom</exclude-pattern>
<exclude-pattern type="relative">htdocs/includes</exclude-pattern> <exclude-pattern type="relative">htdocs/includes</exclude-pattern>
<exclude-pattern type="relative">htdocs/install/doctemplates/websites</exclude-pattern>
<exclude-pattern type="relative">htdocs/conf.php</exclude-pattern> <exclude-pattern type="relative">htdocs/conf.php</exclude-pattern>
<exclude-pattern type="relative">*/nltechno*</exclude-pattern> <exclude-pattern type="relative">*/nltechno*</exclude-pattern>
<exclude-pattern type="relative">*/htdocs/includes</exclude-pattern> <exclude-pattern type="relative">*/htdocs/includes</exclude-pattern>
<exclude-pattern type="relative">*/htdocs/includes</exclude-pattern>
<!-- List of all tests --> <!-- List of all tests -->

View File

@ -258,7 +258,7 @@ if ($resql)
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">'; print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
$sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code"; $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_system as a";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON a.fk_country = c.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON a.fk_country = c.rowid AND c.active = 1";
$sql .= " WHERE a.active = 1"; $sql .= " WHERE a.active = 1";
dol_syslog('accountancy/admin/account.php $sql='.$sql); dol_syslog('accountancy/admin/account.php $sql='.$sql);
print $sql; print $sql;

View File

@ -522,7 +522,6 @@ if ($id)
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
{ {
$valuetoshow=$langs->trans("Label"); $valuetoshow=$langs->trans("Label");
if ($id != 25) $valuetoshow.="*";
} }
if ($fieldlist[$field]=='country') { if ($fieldlist[$field]=='country') {
if (in_array('region_id', $fieldlist)) { print '<td>&nbsp;</td>'; continue; } // For region page, we do not show the country input if (in_array('region_id', $fieldlist)) { print '<td>&nbsp;</td>'; continue; } // For region page, we do not show the country input
@ -583,10 +582,6 @@ if ($id)
$colspan=count($fieldlist)+3; $colspan=count($fieldlist)+3;
if (! empty($alabelisused)) // If there is one label among fields, we show legend of *
{
print '<tr><td colspan="'.$colspan.'">* '.$langs->trans("LabelUsedByDefault").'.</td></tr>';
}
print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
} }
@ -667,7 +662,6 @@ if ($id)
} }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') {
$valuetoshow=$langs->trans("Label"); $valuetoshow=$langs->trans("Label");
if ($id != 25) $valuetoshow.="*";
} }
if ($fieldlist[$field]=='country') { if ($fieldlist[$field]=='country') {
$valuetoshow=$langs->trans("Country"); $valuetoshow=$langs->trans("Country");

View File

@ -154,7 +154,7 @@ if ($result)
$i++; $i++;
} }
} else { } else {
print '<tr class="oddeven"><td colspan="5" class="opacitymedium">' . $langs->trans("None") . '</td></tr>'; print '<tr class="oddeven"><td colspan="7" class="opacitymedium">' . $langs->trans("None") . '</td></tr>';
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';

View File

@ -1,187 +0,0 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2018 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountancy/admin/importaccounts.php
* \ingroup Advanced accountancy
* \brief Page import accounting account
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta","bills","accountancy"));
// Security check
if (! $user->admin)
accessforbidden();
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = 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;
/*
* View
*/
llxHeader('', $langs->trans("ImportAccount"));
$to_import = GETPOST("mesCasesCochees");
if ($_POST["action"] == 'import') {
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (is_array($to_import) && count($to_import) > 0) {
print '<div><font color="red">' . count($to_import) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
$result = $db->query($sql);
if ($result && ($db->num_rows($result) > 0)) {
$obj = $db->fetch_object($result);
$cpt = 0;
foreach ($to_import as $maLigneCochee) {
$accounting = new AccountingAccount($db);
$monLabel = (string) GETPOST('label' . $maLigneCochee);
$monParentAccount = (string) GETPOST('AccountParent' . $maLigneCochee);
$monType = (string) GETPOST('pcgType' . $maLigneCochee);
$monSubType = (string) GETPOST('pcgSubType' . $maLigneCochee);
$accounting->fk_pcg_version = $obj->pcg_version;
$accounting->account_number = $maLigneCochee;
$accounting->label = $monLabel;
$accounting->account_parent = $monParentAccount;
$accounting->pcg_type = $monType;
$accounting->pcg_subtype = $monSubType;
$accounting->active = 1;
$result = $accounting->create($user);
if ($result > 0) {
setEventMessages($langs->trans("AccountingAccountAdd"), null, 'mesgs');
} else {
setEventMessages($accounting->error, $accounting->errors, 'errors');
}
$cpt ++;
}
} else {
setEventMessages($langs->trans('AccountPlanNotFoundCheckSetting'), null, 'errors');
}
} else {
print '<div><font color="red">' . $langs->trans("AnyLineImport") . '</font></div>';
}
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
}
// list accounting account from product
$sql = "(SELECT p.rowid as product_id, p.accountancy_code_sell as accounting ";
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p ";
$sql .= " WHERE p.accountancy_code_sell >=0";
$sql .= " GROUP BY accounting ";
$sql .= ")";
$sql .= "UNION ALL(SELECT p.rowid as product_id, p.accountancy_code_buy as accounting ";
$sql .= " FROM " . MAIN_DB_PREFIX . "product as p ";
$sql .= " WHERE p.accountancy_code_buy >=0";
$sql .= " GROUP BY accounting ";
$sql .= ") ";
$sql .= " ORDER BY accounting DESC " . $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/admin/importaccounts.php:: $sql=' . $sql);
$result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
print_barre_liste($langs->trans("ImportAccount"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="action" value="import">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>' . $langs->trans("AccountAccouting") . '</td>';
print '<td>' . $langs->trans("label") . '</td>';
print '<td>' . $langs->trans("Accountparent") . '</td>';
print '<td>' . $langs->trans("Pcgtype") . '</td>';
print '<td>' . $langs->trans("Pcgsubtype") . '</td>';
print '<td class="center">' . $langs->trans("Import") . '</td>';
print '</tr>';
$form = new Form($db);
$formaccounting = new FormAccounting($db);
while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result);
print '<tr class="oddeven">';
print '<td class="left">';
print $objp->accounting;
print '</td>';
print '<td class="left">';
print '<input name="label" size="30" value="">';
print '</td>';
// Colonne choix du compte
print '<td>';
print $formaccounting->select_account($accounting->account_parent, 'AccountParent');
print '</td>';
print '<td>';
print '<input type="text" name="pcgType" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype', 'alpha'):$accounting->pcg_type).'">';
print '</td>';
print '<td>';
print '<input type="text" name="pcgSubType" value="'.dol_escape_htmltag(isset($_POST['pcg_subtype'])?GETPOST('pcg_subtype', 'alpha'):$accounting->pcg_subtype).'">';
print '</td>';
// Colonne choix ligne a ventiler
$checked = ('label' == 'O') ? ' checked' : '';
print '<td class="center">';
print '<input type="checkbox" name="mesCasesCochees[]" ' . $checked . ' value="' . $objp->accounting . '"/>';
print '</td>';
print '</tr>';
$i ++;
}
print '<tr><td colspan="8">&nbsp;</td></tr><tr><td colspan="8" class="center"><input type="submit" class="butAction" value="' . $langs->trans("Import") . '"></td></tr>';
print '</table>';
print '</form>';
} else {
print $db->error();
}
// End of page
llxFooter();
$db->close();

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
@ -111,6 +111,8 @@ if ($action == 'update') {
$accounting_product_modes = array ( $accounting_product_modes = array (
'ACCOUNTANCY_SELL', 'ACCOUNTANCY_SELL',
'ACCOUNTANCY_SELL_INTRA',
'ACCOUNTANCY_SELL_EXPORT',
'ACCOUNTANCY_BUY' 'ACCOUNTANCY_BUY'
); );
@ -158,6 +160,12 @@ if ($action == 'update') {
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
$sql .= " SET accountancy_code_sell = " . $accounting->account_number; $sql .= " SET accountancy_code_sell = " . $accounting->account_number;
} }
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$sql .= " SET accountancy_code_sell_intra = " . $accounting->account_number;
}
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$sql .= " SET accountancy_code_sell_export = " . $accounting->account_number;
}
$sql .= " WHERE rowid = " . $productid; $sql .= " WHERE rowid = " . $productid;
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG); dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
@ -192,16 +200,20 @@ $form = new FormAccounting($db);
// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid // at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
// so we need to get those default value rowid first // so we need to get those default value rowid first
$accounting = new AccountingAccount($db); $accounting = new AccountingAccount($db);
// TODO: we should need to check if result is a really exist accountaccount rowid..... // TODO: we should need to check if result is already exists accountaccount rowid.....
$aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); $aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
$aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1); $aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
$aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1); $aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
$aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1); $aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
$aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT, 1);
$aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1);
$aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodsell_intra = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$aacompta_prodsell_export = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
llxHeader('', $langs->trans("ProductsBinding")); llxHeader('', $langs->trans("ProductsBinding"));
@ -209,27 +221,45 @@ $pcgverid = $conf->global->CHARTOFACCOUNTS;
$pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
if (empty($pcgvercode)) $pcgvercode=$pcgverid; if (empty($pcgvercode)) $pcgvercode=$pcgverid;
$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type,"; $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type,";
$sql.= " aa.rowid as aaid"; $sql.= " aa.rowid as aaid";
$sql.= " FROM " . MAIN_DB_PREFIX . "product as p"; $sql.= " FROM " . MAIN_DB_PREFIX . "product as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$sql.=" p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; $sql.=" p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
} }
else elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL')
{ {
$sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; $sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
} }
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA')
{
$sql.=" p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
}
else
{
$sql.=" p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'";
}
$sql.= ' WHERE p.entity IN ('.getEntity('product').')'; $sql.= ' WHERE p.entity IN ('.getEntity('product').')';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_buy", $search_current_account); $sql .= natural_search("p.accountancy_code_buy", $search_current_account);
} }
} else { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_sell", $search_current_account); $sql .= natural_search("p.accountancy_code_sell", $search_current_account);
} }
} }
elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account);
}
}
else {
if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_sell_export", $search_current_account);
}
}
if ($search_current_account_valid == 'withoutvalidaccount') if ($search_current_account_valid == 'withoutvalidaccount')
{ {
$sql .= " AND aa.account_number IS NULL"; $sql .= " AND aa.account_number IS NULL";
@ -279,6 +309,7 @@ if ($result)
if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc); if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc);
if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account); if ($search_current_account > 0) $param.="&search_current_account=".urlencode($search_current_account);
if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid); if ($search_current_account_valid && $search_current_account_valid != '-1') $param.="&search_current_account_valid=".urlencode($search_current_account_valid);
if ($accounting_product_mode) $param.='&accounting_product_mode='.urlencode($accounting_product_mode);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">'; print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -300,9 +331,18 @@ if ($result)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>'; print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>'; print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode == 'ACCOUNTANCY_SELL' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>';
print '<td>'.$langs->trans('OptionModeProductSellDesc'); print '<td>'.$langs->trans('OptionModeProductSellDesc');
print "</td></tr>\n"; print "</td></tr>\n";
if ($mysoc->isInEEC())
{
print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_INTRA"' . ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSellIntra') . '</td>';
print '<td>'.$langs->trans('OptionModeProductSellIntraDesc');
print "</td></tr>\n";
}
print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_EXPORT"' . ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSellExport') . '</td>';
print '<td>'.$langs->trans('OptionModeProductSellExportDesc');
print "</td></tr>\n";
print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>'; print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>';
print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n"; print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
print "</table>\n"; print "</table>\n";
@ -317,8 +357,11 @@ if ($result)
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
$buttonsave = '<input type="submit" class="button" id="changeaccount" name="changeaccount" value="' . $langs->trans("Save") . '">';
//print '<br><div class="center">'.$buttonsave.'</div>';
$texte=$langs->trans("ListOfProductsServices"); $texte=$langs->trans("ListOfProductsServices");
print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $buttonsave, $num, $nbtotalofrecords, '', 0, '', '', $limit);
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">'; print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
@ -328,7 +371,7 @@ if ($result)
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>'; if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
// On sell // On sell
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') print '<td class="liste_titre"></td>'; if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') print '<td class="liste_titre"></td>';
// On buy // On buy
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print '<td class="liste_titre"></td>'; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print '<td class="liste_titre"></td>';
// Current account // Current account
@ -348,10 +391,19 @@ if ($result)
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') $fieldtosortaccount="p.accountancy_code_buy"; $fieldtosortaccount="p.accountancy_code_sell";
else $fieldtosortaccount="p.accountancy_code_sell"; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount="p.accountancy_code_sell_intra";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount="p.accountancy_code_sell_export";
} else {
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount="p.accountancy_code_buy";
}
print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("AssignDedicatedAccountingAccount"); print_liste_field_titre("AssignDedicatedAccountingAccount");
$clickpitco=$form->showCheckAddButtons('checkforselect', 1); $clickpitco=$form->showCheckAddButtons('checkforselect', 1);
@ -374,10 +426,16 @@ if ($result)
$product_static->status = $obj->tosell; $product_static->status = $obj->tosell;
$product_static->status_buy = $obj->tobuy; $product_static->status_buy = $obj->tobuy;
if ($obj->product_type == 0) { if ($obj->product_type == 0 && $accounting_product_mode == 'ACCOUNTANCY_SELL') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell; $compta_prodsell_id = $aarowid_prodsell;
} else { } elseif ($obj->product_type == 0 && $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_intra;
} elseif ($obj->product_type == 0 && $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_export;
} else {
$compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_servsell; $compta_prodsell_id = $aarowid_servsell;
} }
@ -407,7 +465,7 @@ if ($result)
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>'; print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
} }
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT')
print '<td class="center">'.$product_static->getLibStatut(3, 0).'</td>'; print '<td class="center">'.$product_static->getLibStatut(3, 0).'</td>';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') if ($accounting_product_mode == 'ACCOUNTANCY_BUY')
@ -418,12 +476,16 @@ if ($result)
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
print length_accountg($obj->accountancy_code_buy); print length_accountg($obj->accountancy_code_buy);
if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
else print length_accountg($obj->accountancy_code_sell);
{ if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
print length_accountg($obj->accountancy_code_sell); } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); print length_accountg($obj->accountancy_code_sell_intra);
} if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
} else {
print length_accountg($obj->accountancy_code_sell_export);
if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
}
print '</td>'; print '</td>';
// Dedicated account // Dedicated account
@ -437,7 +499,7 @@ if ($result)
if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1);
print '</td>'; print '</td>';
} else { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
// Accounting account sell // Accounting account sell
print '<td class="left">'; print '<td class="left">';
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
@ -447,7 +509,26 @@ if ($result)
if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1);
print '</td>'; print '</td>';
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
// Accounting account sell intra (In EEC)
print '<td class="left">';
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
if (empty($defaultvalue)) $defaultvalue=$compta_prodsell;
$codesell=length_accountg($obj->accountancy_code_sell_intra);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1);
print '</td>';
} else {
// Accounting account sell export (Out of EEC)
print '<td class="left">';
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
if (empty($defaultvalue)) $defaultvalue=$compta_prodsell;
$codesell=length_accountg($obj->accountancy_code_sell_export);
if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1);
print '</td>';
}
// Checkbox select // Checkbox select
print '<td class="center">'; print '<td class="center">';
@ -458,7 +539,6 @@ if ($result)
print '</table>'; print '</table>';
print '</div>'; print '</div>';
// Example : Adding jquery code
print '<script type="text/javascript" language="javascript"> print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
function init_savebutton() function init_savebutton()
@ -473,8 +553,8 @@ if ($result)
if (atleastoneselected) jQuery("#changeaccount").removeAttr(\'disabled\'); if (atleastoneselected) jQuery("#changeaccount").removeAttr(\'disabled\');
else jQuery("#changeaccount").attr(\'disabled\',\'disabled\'); else jQuery("#changeaccount").attr(\'disabled\',\'disabled\');
if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'butAction\'); if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'button\');
else jQuery("#changeaccount").attr(\'class\',\'butActionRefused\'); else jQuery("#changeaccount").attr(\'class\',\'button\');
} }
jQuery(".checkforselect, #checkallactions").click(function() { jQuery(".checkforselect, #checkallactions").click(function() {
init_savebutton(); init_savebutton();
@ -492,9 +572,6 @@ if ($result)
}); });
</script>'; </script>';
print '<br><div class="center"><input type="submit" class="butAction" id="changeaccount" name="changeaccount" value="' . $langs->trans("Save") . '"></div>';
print '</form>'; print '</form>';
$db->free($result); $db->free($result);

View File

@ -3,8 +3,8 @@
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -30,17 +30,19 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.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/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.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 . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta","accountancy")); $langs->loadLangs(array("compta","accountancy"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
@ -53,26 +55,31 @@ $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if ($sortorder == "") if ($sortorder == "")
$sortorder = "DESC"; $sortorder = "ASC";
if ($sortfield == "") if ($sortfield == "")
$sortfield = "bk.doc_date"; $sortfield = "bk.doc_date";
$search_year = GETPOST("search_year", 'int'); /*
$search_doc_type = GETPOST("search_doc_type", 'alpha'); $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'); $search_doc_ref = GETPOST("search_doc_ref", 'alpha');
*/
$lettering = GETPOST('lettering', 'alpha'); $lettering = GETPOST('lettering', 'alpha');
if (! empty($lettering)) { if (! empty($lettering)) {
$action = $lettering; $action = $lettering;
} }
// Did we click on purge search criteria ? /*
// All tests are required to be compatible with all browsers 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
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { {
$search_year = ''; $search_date_start = '';
$search_doc_type = ''; $search_date_end = '';
//$search_doc_type = '';
$search_doc_ref = ''; $search_doc_ref = '';
} }
*/
// Security check // Security check
$socid = GETPOST("socid", 'int'); $socid = GETPOST("socid", 'int');
@ -102,6 +109,7 @@ if ($action == 'lettering') {
} }
} }
/*
if ($action == 'autolettrage') { if ($action == 'autolettrage') {
$result = $lettering->letteringThirdparty($socid); $result = $lettering->letteringThirdparty($socid);
@ -111,9 +119,9 @@ if ($action == 'autolettrage') {
$error++; $error++;
} }
} }
*/
/*
/*
* View * View
*/ */
@ -136,20 +144,19 @@ dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'n
dol_fiche_end(); dol_fiche_end();
print '<br>';
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; $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.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 .= " 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 .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE (bk.subledger_account = '" . $object->code_compta . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . "' )"; $sql .= " WHERE (bk.subledger_account = '" . $object->code_compta . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . "' )";
if (dol_strlen($search_year)) { /*
$date_start = dol_mktime(0, 0, 0, 1, 1, $search_year); if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
$date_end = dol_mktime(23, 59, 59, 12, 31, $search_year); $sql .= " AND ( bk.doc_date BETWEEN '" . $db->idate($search_date_start) . "' AND '" . $db->idate($search_date_end) . "' )";
$sql .= " AND ( bk.doc_date BETWEEN '" . $db->idate($date_start) . "' AND '" . $db->idate($date_end) . "' )";
} }
*/
$sql.= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')';
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$debit = 0; $debit = 0;
@ -180,92 +187,123 @@ if (! $resql) {
exit(); exit();
} }
$param='';
$param.="&socid=".urlencode($socid);
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEBUG); dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEBUG);
if ($resql) { if ($resql) {
$i = 0; $i = 0;
$param="&socid=".$socid;
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">'; print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
print '<input type="hidden" name="socid" value="' . $object->id . '">'; print '<input type="hidden" name="socid" value="' . $object->id . '">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); $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" width="100%">'."\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">&nbsp;</td>';
print '<td class="right">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
*/
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Doctype", $_SERVER["PHP_SELF"], "bk.doc_type", "", $param, "", $sortfield, $sortorder); //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); print_liste_field_titre("Docdate", $_SERVER["PHP_SELF"], "bk.doc_date", "", $param, "", $sortfield, $sortorder, 'center ');
print_liste_field_titre("Docref", $_SERVER["PHP_SELF"], "bk.doc_ref", "", $param, "", $sortfield, $sortorder); 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("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("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("Credit", $_SERVER["PHP_SELF"], "bk.credit", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $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); 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); 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"; print "</tr>\n";
print '<tr class="liste_titre">';
print '<td><input type="text" name="search_doc_type" value="' . $search_doc_type . '"></td>';
print '<td><input type="text" name="search_year" value="' . $search_year . '"></td>';
print '<td><input type="text" name="search_doc_refe" value="' . $search_doc_ref . '"></td>';
print '<td colspan="5">&nbsp;</td>';
print '<td class="right">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
$solde = 0; $solde = 0;
$tmp = ''; $tmp = '';
while ( $obj = $db->fetch_object($resql) ) {
while ( $obj = $db->fetch_object($resql) ) {
if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; 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); /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if (empty($obj->lettering_code)) { //print '<td>' . $obj->doc_type . '</td>' . "\n";
print '<td><a href="' . dol_buildpath('/accountancy/bookkeeping/card.php', 1) . '?piece_num=' . $obj->piece_num . '">'; print '<td class="center">' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
print img_edit();
print '</a>&nbsp;' . $obj->doc_type . '</td>' . "\n";
} else {
print '<td>' . $obj->doc_type . '</td>' . "\n";
}
print '<td>' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
print '<td>' . $obj->doc_ref . '</td>'; print '<td>' . $obj->doc_ref . '</td>';
print '<td>' . $obj->label_compte . '</td>'; print '<td>' . $obj->label_compte . '</td>';
print '<td class="right">' . price($obj->debit) . '</td>'; print '<td class="right">' . price($obj->debit) . '</td>';
print '<td class="right">' . price($obj->credit) . '</td>'; print '<td class="right">' . price($obj->credit) . '</td>';
print '<td class="right">' . price(round($solde, 2)) . '</td>'; print '<td class="right">' . price(round($solde, 2)) . '</td>';
print '<td class="center">' . $obj->code_journal . '</td>';
if (empty($obj->lettering_code)) { // Journal
print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="' . $obj->rowid . '" /></td>'; $accountingjournal = new AccountingJournal($db);
} else $result = $accountingjournal->fetch('', $obj->code_journal);
print '<td class="center">' . $obj->lettering_code . '</td>'; $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
print '<td class="center">' . $journaltoshow . '</td>';
if (empty($obj->lettering_code)) {
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>\n";
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="right" colspan="4">'.$langs->trans("Total").':</td>' . "\n"; print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>' . "\n";
print '<td class="right"><strong>' . price($debit) . '</strong></td>'; print '<td class="right"><strong>' . price($debit) . '</strong></td>';
print '<td class="right"><strong>' . price($credit) . '</strong></td>'; print '<td class="right"><strong>' . price($credit) . '</strong></td>';
print '<td colspan="5"></td>'; print '<td colspan="4"></td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="right" colspan="4">'.$langs->trans("Balancing").':</td>' . "\n"; print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>' . "\n";
print '<td colspan="2">&nbsp;</td>'; print '<td colspan="2">&nbsp;</td>';
print '<td class="right"><strong>' . price($credit - $debit) . '</strong></td>'; print '<td class="right"><strong>' . price($credit - $debit) . '</strong></td>';
print '<td colspan="3"></td>'; print '<td colspan="6"></td>';
print "</tr>\n"; print "</tr>\n";
print "</table>"; print "</table>";
print '<input class="butAction" type="submit" value="lettering" name="lettering" id="lettering">'; print '<div class="tabsAction tabsActionNoBottom">'."\n";
//print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '&action=autolettering">' . $langs->trans('AccountancyAutoLettering') . '</a>'; print $letteringbutton;
print '</div>';
print "</form>"; print "</form>";
$db->free($resql); $db->free($resql);
} else { } else {

View File

@ -3,8 +3,8 @@
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -18,7 +18,6 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/ */
/** /**
@ -30,17 +29,19 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.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/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.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 . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("compta","accountancy")); $langs->loadLangs(array("compta","accountancy"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
@ -53,27 +54,31 @@ $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if ($sortorder == "") if ($sortorder == "")
$sortorder = "DESC"; $sortorder = "ASC";
if ($sortfield == "") if ($sortfield == "")
$sortfield = "bk.doc_date"; $sortfield = "bk.doc_date";
$search_year = GETPOST("search_year", 'int'); /*
$search_doc_type = GETPOST("search_doc_type", 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$search_doc_ref = GETPOST("search_doc_ref", 'alpha'); $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'); $lettering = GETPOST('lettering', 'alpha');
if (!empty($lettering)) { if (!empty($lettering)) {
$action=$lettering; $action=$lettering;
} }
// Did we click on purge search criteria ? /*
// All tests are required to be compatible with all browsers 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
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha'))
{ {
$search_year=''; $search_date_start = '';
$search_doc_type=''; $search_date_end = '';
//$search_doc_type='';
$search_doc_ref=''; $search_doc_ref='';
} }
*/
// Security check // Security check
@ -103,6 +108,7 @@ if ($action == 'lettering') {
} }
} }
/*
if ($action == 'autolettrage') { if ($action == 'autolettrage') {
$result = $lettering->letteringThirdparty($socid); $result = $lettering->letteringThirdparty($socid);
@ -112,7 +118,7 @@ if ($action == 'autolettrage') {
$error++; $error++;
} }
} }
*/
/* /*
* View * View
@ -142,13 +148,10 @@ $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 .= " 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 .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE (bk.subledger_account = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . "' )"; $sql .= " WHERE (bk.subledger_account = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . "' )";
if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
if (dol_strlen($search_year)) { $sql .= " AND (bk.doc_date BETWEEN '".$db->idate($search_date_start)."' AND '".$db->idate($search_date_end)."' )";
$date_start = dol_mktime(0, 0, 0, 1, 1, $search_year);
$date_end = dol_mktime(23, 59, 59, 12, 31, $search_year);
$sql .= " AND ( bk.doc_date BETWEEN '".$db->idate($date_start)."' AND '".$db->idate($date_end)."' )";
} }
$sql.= ' AND bk.entity IN ('.getEntity('accountingbookkeeping').')';
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
$debit = 0; $debit = 0;
@ -173,50 +176,75 @@ while ($obj = $db->fetch_object($resql)) {
$sql.= $db->plimit($limit+1, $offset); $sql.= $db->plimit($limit+1, $offset);
dol_syslog("/accountancy/bookkeeping/thirdparty_lettrage_supplier.php", LOG_DEBUG); dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_supplier.php", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if (! $resql) { if (! $resql) {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
$param='';
$param.="&socid=".urlencode($socid);
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
dol_syslog("/accountancy/bookkeeping/thirdparty_lettrage_supplier.php", LOG_DEBUG); dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_supplier.php", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$param="&socid=".$socid;
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid=' . $object->id . '" method="POST">'; print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid=' . $object->id . '" method="POST">';
print '<input type="hidden" name="socid" value="' . $object->id . '">'; print '<input type="hidden" name="socid" value="' . $object->id . '">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); $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" width="100%">'."\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">&nbsp;</td>';
print '<td class="right">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
*/
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Doctype", $_SERVER["PHP_SELF"], "bk.doc_type", "", $param, "", $sortfield, $sortorder); //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); print_liste_field_titre("Docdate", $_SERVER["PHP_SELF"], "bk.doc_date", "", $param, "", $sortfield, $sortorder, 'center ');
print_liste_field_titre("Docref", $_SERVER["PHP_SELF"], "bk.doc_ref", "", $param, "", $sortfield, $sortorder); 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("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("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("Credit", $_SERVER["PHP_SELF"], "bk.credit", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $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); 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); 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"; print "</tr>\n";
print '<tr class="liste_titre">';
print '<td><input type="text" name="search_doc_type" value="' . $search_doc_type . '"></td>';
print '<td><input type="text" name="search_year" value="' . $search_year . '"></td>';
print '<td><input type="text" name="search_doc_refe" value="' . $search_doc_ref . '"></td>';
print '<td colspan="6">&nbsp;</td>';
print '<td class="right">';
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
$solde = 0; $solde = 0;
$tmp = ''; $tmp = '';
while ($obj = $db->fetch_object($resql)) { while ($obj = $db->fetch_object($resql)) {
@ -226,48 +254,53 @@ if ($resql) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if (empty($obj->lettering_code)) { //print '<td>' . $obj->doc_type . '</td>' . "\n";
print '<td><a href="' . dol_buildpath('/accountancy/bookkeeping/card.php', 1) . '?piece_num=' . $obj->piece_num . '">'; print '<td class="center">' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
print img_edit();
print '</a>&nbsp;' . $obj->doc_type . '</td>' . "\n";
} else {
print '<td>' . $obj->doc_type . '</td>' . "\n";
}
print '<td>' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>';
print '<td>' . $obj->doc_ref . '</td>'; print '<td>' . $obj->doc_ref . '</td>';
print '<td>' . $obj->label_compte . '</td>'; print '<td>' . $obj->label_compte . '</td>';
print '<td class="right">' . price($obj->debit) . '</td>'; print '<td class="right">' . price($obj->debit) . '</td>';
print '<td class="right">' . price($obj->credit) . '</td>'; print '<td class="right">' . price($obj->credit) . '</td>';
print '<td class="right">' . price(round($solde, 2)) . '</td>'; print '<td class="right">' . price(round($solde, 2)) . '</td>';
print '<td class="center">' . $obj->code_journal . '</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)) { if (empty($obj->lettering_code)) {
print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="' . $obj->rowid . '" /></td>'; print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="' . $obj->rowid . '" /></td>';
} else print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num=' . $obj->piece_num . '">';
print '<td class="center">' . $obj->lettering_code . '</td>'; print img_edit();
print '</a></td>' . "\n";
} else {
print '<td class="center">' . $obj->lettering_code . '</td>';
print '<td></td>';
}
print "</tr>\n"; print "</tr>\n";
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="right" colspan="4">'.$langs->trans("Total").':</td>' . "\n"; print '<td class="right" colspan="3">'.$langs->trans("Total").':</td>' . "\n";
print '<td class="right"><strong>' . price($debit) . '</strong></td>'; print '<td class="right"><strong>' . price($debit) . '</strong></td>';
print '<td class="right"><strong>' . price($credit) . '</strong></td>'; print '<td class="right"><strong>' . price($credit) . '</strong></td>';
print '<td colspan="5"></td>'; print '<td colspan="6"></td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="right" colspan="4">'.$langs->trans("Balancing").':</td>' . "\n"; print '<td class="right" colspan="3">'.$langs->trans("Balancing").':</td>' . "\n";
print '<td colspan="2">&nbsp;</td>'; print '<td colspan="2">&nbsp;</td>';
print '<td class="right"><strong>' . price($credit - $debit) . '</strong></td>'; print '<td class="right"><strong>' . price($credit - $debit) . '</strong></td>';
print '<td colspan="3"></td>'; print '<td colspan="4"></td>';
print "</tr>\n"; print "</tr>\n";
print "</table>"; print "</table>";
print '<input class="butAction" type="submit" value="' . $langs->trans('AccountancyLettering') . '" name="lettering" id="lettering">'; print '<div class="tabsAction tabsActionNoBottom">'."\n";
//print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid=' . $object->id . '&action=autolettrage">'.$langs->trans('AccountancyAutoLettering').'</a>'; print $letteringbutton;
print '</div>';
print "</form>"; print "</form>";
$db->free($resql); $db->free($resql);
} else { } else {

View File

@ -538,7 +538,7 @@ class AccountancyExport
//print substr(length_accountg($line->numero_compte), 0, 2) . $separator; //print substr(length_accountg($line->numero_compte), 0, 2) . $separator;
print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"' . $separator; print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"' . $separator;
print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator; print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator;
print price2num($line->montant).$separator; print price2num(abs($line->montant)).$separator;
print $line->sens.$separator; print $line->sens.$separator;
print $date . $separator; print $date . $separator;
//print 'EUR'; //print 'EUR';

View File

@ -233,16 +233,8 @@ class AccountingAccount extends CommonObject
$this->pcg_subtype = trim($this->pcg_subtype); $this->pcg_subtype = trim($this->pcg_subtype);
if (isset($this->account_number)) if (isset($this->account_number))
$this->account_number = trim($this->account_number); $this->account_number = trim($this->account_number);
if (isset($this->account_parent))
$this->account_parent = trim($this->account_parent);
if (isset($this->label)) if (isset($this->label))
$this->label = trim($this->label); $this->label = trim($this->label);
if (isset($this->account_category))
$this->account_category = trim($this->account_category);
if (isset($this->fk_user_author))
$this->fk_user_author = trim($this->fk_user_author);
if (isset($this->active))
$this->active = trim($this->active);
if (empty($this->pcg_type) || $this->pcg_type == '-1') if (empty($this->pcg_type) || $this->pcg_type == '-1')
{ {

View File

@ -1409,16 +1409,14 @@ class BookKeeping extends CommonObject
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param int $fromid Id of object to clone * @param User $user User making the clone
* * @param int $fromid Id of object to clone
* @return int New id of clone * @return int New id of clone
*/ */
public function createFromClone($fromid) public function createFromClone(User $user, $fromid)
{ {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
global $user;
$error = 0; $error = 0;
$object = new BookKeeping($this->db); $object = new BookKeeping($this->db);

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -66,13 +66,13 @@ class Lettering extends BookKeeping
$sql .= " , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type "; $sql .= " , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) "; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
$sql .= " WHERE ( "; $sql .= " WHERE ( ";
if (! empty($object->code_compta)) if (! empty($object->code_compta))
$sql .= " bk.subledger_account = '" . $object->code_compta . "' "; $sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur))
$sql .= " OR "; $sql .= " OR ";
if (! empty($object->code_compta_fournisseur)) if (! empty($object->code_compta_fournisseur))
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; $sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) "; $sql .= " ) AND (bk.date_lettering ='' OR bk.date_lettering IS NULL) ";
$sql .= " AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) "; $sql .= " AND (bk.lettering_code != '' OR bk.lettering_code IS NULL) ";
@ -128,15 +128,15 @@ class Lettering extends BookKeeping
$sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND facf.entity = ".$conf->entity;
$sql .= " AND ( "; $sql .= " AND ( ";
if (! empty($object->code_compta)) { if (! empty($object->code_compta)) {
$sql .= " bk.subledger_account = '" . $object->code_compta . "' "; $sql .= " bk.subledger_account = '" . $object->code_compta . "' ";
} }
if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) { if (! empty($object->code_compta) && ! empty($object->code_compta_fournisseur)) {
$sql .= " OR "; $sql .= " OR ";
} }
if (! empty($object->code_compta_fournisseur)) { if (! empty($object->code_compta_fournisseur)) {
$sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' "; $sql .= " bk.subledger_account = '" . $object->code_compta_fournisseur . "' ";
} }
$sql .= " ) "; $sql .= ") ";
$resql2 = $this->db->query($sql); $resql2 = $this->db->query($sql);
if ($resql2) { if ($resql2) {
@ -253,7 +253,7 @@ class Lettering extends BookKeeping
$error++; $error++;
} }
$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE "; $sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
$sql .= " rowid IN (" . implode(',', $ids) . ") "; $sql .= " rowid IN (" . implode(',', $ids) . ") ";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {

View File

@ -341,7 +341,7 @@ if ($result) {
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
@ -421,6 +421,8 @@ if ($result) {
$facture_static = new Facture($db); $facture_static = new Facture($db);
$product_static = new Product($db); $product_static = new Product($db);
$isSellerInEEC = isInEEC($mysoc);
while ( $i < min($num_lines, $limit) ) { while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
@ -440,7 +442,7 @@ if ($result) {
$code_sell_p_notset = ''; $code_sell_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid; $objp->aarowid_suggest = $objp->aarowid;
$isinEEC = isInEEC($objp->country_code); $isBuyerInEEC = isInEEC($objp);
if ($objp->type_l == 1) { if ($objp->type_l == 1) {
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : ''); $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
@ -455,15 +457,17 @@ if ($result) {
} }
if ($objp->code_sell_l == -1) $objp->code_sell_l=''; if ($objp->code_sell_l == -1) $objp->code_sell_l='';
if ($objp->country_sell == '1') { if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_p = $objp->code_sell; $objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid; $objp->aarowid_suggest = $objp->aarowid;
} elseif ($isinEEC === true) {
$objp->code_sell_p = $objp->code_sell_intra;
$objp->aarowid_suggest = $objp->aarowid_intra;
} else { } else {
$objp->code_sell_p = $objp->code_sell_export; if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->aarowid_suggest = $objp->aarowid_export; $objp->code_sell_p = $objp->code_sell_intra;
$objp->aarowid_suggest = $objp->aarowid_intra;
} else { // Foreign sale
$objp->code_sell_p = $objp->code_sell_export;
$objp->aarowid_suggest = $objp->aarowid_export;
}
} }
if (! empty($objp->code_sell)) { if (! empty($objp->code_sell)) {

View File

@ -273,7 +273,7 @@ if ($result) {
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);

View File

@ -340,7 +340,7 @@ if ($result) {
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1); $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);

View File

@ -82,7 +82,7 @@ if (! empty($canvas))
} }
// Security check // Security check
$result=restrictedArea($user, 'adherent', $id, '', '', 'fk_soc', 'rowid', $objcanvas); $result=restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objcanvas);
if ($id > 0) if ($id > 0)
{ {
@ -163,10 +163,10 @@ if (empty($reshook))
$error=0; $error=0;
if (! $error) if (! $error)
{ {
if ($socid != $object->fk_soc) // If link differs from currently in database if ($socid != $object->socid) // If link differs from currently in database
{ {
$sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
$sql.=" WHERE fk_soc = '".$socid."'"; $sql.=" WHERE socid = '".$socid."'";
$sql.=" AND entity = ".$conf->entity; $sql.=" AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
@ -492,7 +492,7 @@ if (empty($reshook))
//$object->note = $comment; //$object->note = $comment;
$object->morphy = $morphy; $object->morphy = $morphy;
$object->user_id = $userid; $object->user_id = $userid;
$object->fk_soc = $socid; $object->socid = $socid;
$object->public = $public; $object->public = $public;
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
@ -1333,10 +1333,10 @@ else
if (! empty($conf->societe->enabled)) if (! empty($conf->societe->enabled))
{ {
print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td colspan="2" class="valeur">'; print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td colspan="2" class="valeur">';
if ($object->fk_soc) if ($object->socid)
{ {
$company=new Societe($db); $company=new Societe($db);
$result=$company->fetch($object->fk_soc); $result=$company->fetch($object->socid);
print $company->getNomUrl(1); print $company->getNomUrl(1);
} }
else else
@ -1421,7 +1421,7 @@ else
$text=$langs->trans("ConfirmCreateLogin").'<br>'; $text=$langs->trans("ConfirmCreateLogin").'<br>';
if (! empty($conf->societe->enabled)) if (! empty($conf->societe->enabled))
{ {
if ($object->fk_soc > 0) $text.=$langs->trans("UserWillBeExternalUser"); if ($object->socid > 0) $text.=$langs->trans("UserWillBeExternalUser");
else $text.=$langs->trans("UserWillBeInternalUser"); else $text.=$langs->trans("UserWillBeInternalUser");
} }
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes'); print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes');
@ -1688,17 +1688,17 @@ else
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
print '<tr><td>'; print '<tr><td>';
print $form->select_company($object->fk_soc, 'socid', '', 1); print $form->select_company($object->socid, 'socid', '', 1);
print '</td>'; print '</td>';
print '<td class="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>'; print '<td class="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>'; print '</tr></table></form>';
} }
else else
{ {
if ($object->fk_soc) if ($object->socid)
{ {
$company=new Societe($db); $company=new Societe($db);
$result=$company->fetch($object->fk_soc); $result=$company->fetch($object->socid);
print $company->getNomUrl(1); print $company->getNomUrl(1);
} }
else else
@ -1848,7 +1848,7 @@ else
} }
// Create third party // Create third party
if (! empty($conf->societe->enabled) && ! $object->fk_soc) if (! empty($conf->societe->enabled) && ! $object->socid)
{ {
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {

View File

@ -10,6 +10,7 @@
* Copyright (C) 2015-2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2015-2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018-2019 Thibault FOUCART <support@ptibogxiv.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -557,7 +558,7 @@ class Adherent extends CommonObject
$sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman' $sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'
$sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null"); $sql.= ", login = ".($this->login?"'".$this->db->escape($this->login)."'":"null");
$sql.= ", societe = ".($this->societe?"'".$this->db->escape($this->societe)."'":"null"); $sql.= ", societe = ".($this->societe?"'".$this->db->escape($this->societe)."'":"null");
$sql.= ", fk_soc = ".($this->fk_soc > 0?$this->db->escape($this->fk_soc):"null"); $sql.= ", fk_soc = ".($this->socid > 0?$this->db->escape($this->socid):"null");
$sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null"); $sql.= ", address = ".($this->address?"'".$this->db->escape($this->address)."'":"null");
$sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null"); $sql.= ", zip = ".($this->zip?"'".$this->db->escape($this->zip)."'":"null");
$sql.= ", town = ".($this->town?"'".$this->db->escape($this->town)."'":"null"); $sql.= ", town = ".($this->town?"'".$this->db->escape($this->town)."'":"null");
@ -1223,7 +1224,7 @@ class Adherent extends CommonObject
{ {
global $langs; global $langs;
$sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_id, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
$sql.= " d.note_public,"; $sql.= " d.note_public,";
$sql.= " d.email, d.skype, d.twitter, d.facebook, d.linkedin, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql.= " d.email, d.skype, d.twitter, d.facebook, d.linkedin, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
$sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy, d.entity,";
@ -1267,14 +1268,19 @@ class Adherent extends CommonObject
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref_ext = $obj->ref_ext; $this->ref_ext = $obj->ref_ext;
$this->civility_id = $obj->civility_id;
$this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility
$this->civility_code = $obj->civility_code;
$this->civility = $obj->civility_code?($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code):'';
$this->firstname = $obj->firstname; $this->firstname = $obj->firstname;
$this->lastname = $obj->lastname; $this->lastname = $obj->lastname;
$this->gender = $obj->gender; $this->gender = $obj->gender;
$this->login = $obj->login; $this->login = $obj->login;
$this->societe = $obj->company; $this->societe = $obj->company;
$this->company = $obj->company; $this->company = $obj->company;
$this->fk_soc = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->fk_soc = $obj->fk_soc; // For backward comaptibility
$this->address = $obj->address; $this->address = $obj->address;
$this->zip = $obj->zip; $this->zip = $obj->zip;
$this->town = $obj->town; $this->town = $obj->town;

View File

@ -1,8 +1,9 @@
<?php <?php
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com> * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2018-2019 Thibault Foucart <support@ptibogxiv.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -56,7 +57,7 @@ class AdherentType extends CommonObject
/** /**
* @var string * @var string
* @deprecated Use label * @deprecated Use label
* @see label * @see $label
*/ */
public $libelle; public $libelle;
@ -65,6 +66,11 @@ class AdherentType extends CommonObject
*/ */
public $label; public $label;
/**
* @var string Adherent type nature
*/
public $morphy;
/** /**
* @var int Subsription required (0 or 1) * @var int Subsription required (0 or 1)
* @since 5.0 * @since 5.0
@ -184,6 +190,7 @@ class AdherentType extends CommonObject
$sql.= "SET "; $sql.= "SET ";
$sql.= "statut = ".$this->statut.","; $sql.= "statut = ".$this->statut.",";
$sql.= "libelle = '".$this->db->escape($this->label) ."',"; $sql.= "libelle = '".$this->db->escape($this->label) ."',";
$sql.= "morphy = '".$this->db->escape($this->morphy) ."',";
$sql.= "subscription = '".$this->db->escape($this->subscription)."',"; $sql.= "subscription = '".$this->db->escape($this->subscription)."',";
$sql.= "note = '".$this->db->escape($this->note)."',"; $sql.= "note = '".$this->db->escape($this->note)."',";
$sql.= "vote = ".(integer) $this->db->escape($this->vote).","; $sql.= "vote = ".(integer) $this->db->escape($this->vote).",";
@ -274,7 +281,7 @@ class AdherentType extends CommonObject
*/ */
public function fetch($rowid) public function fetch($rowid)
{ {
$sql = "SELECT d.rowid, d.libelle as label, d.statut, d.subscription, d.mail_valid, d.note, d.vote"; $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut, d.subscription, d.mail_valid, d.note, d.vote";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.rowid = ".(int) $rowid; $sql .= " WHERE d.rowid = ".(int) $rowid;
@ -290,6 +297,7 @@ class AdherentType extends CommonObject
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->label = $obj->label; $this->label = $obj->label;
$this->morphy = $obj->morphy;
$this->statut = $obj->statut; $this->statut = $obj->statut;
$this->subscription = $obj->subscription; $this->subscription = $obj->subscription;
$this->mail_valid = $obj->mail_valid; $this->mail_valid = $obj->mail_valid;
@ -403,6 +411,21 @@ class AdherentType extends CommonObject
} }
} }
/**
* Return translated label by the nature of a adherent (physical or moral)
*
* @param string $morphy Nature of the adherent (physical or moral)
* @return string Label
*/
public function getmorphylib($morphy = '')
{
global $langs;
if ($morphy == 'phy') { return $langs->trans("Physical"); }
elseif ($morphy == 'mor') { return $langs->trans("Moral"); }
else return $langs->trans("Physical & Morale");
//return $morphy;
}
/** /**
* Return clicable name (with picto eventually) * Return clicable name (with picto eventually)
* *

View File

@ -358,7 +358,7 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);

View File

@ -5,6 +5,7 @@
* Copyright (C) 2012-2017 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2012-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -668,7 +669,7 @@ if ($rowid > 0)
{ {
$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe,"; $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe,";
$sql.= " c.rowid as crowid, c.subscription,"; $sql.= " c.rowid as crowid, c.subscription,";
$sql.= " c.datec,"; $sql.= " c.datec, c.fk_type as cfk_type,";
$sql.= " c.dateadh as dateh,"; $sql.= " c.dateadh as dateh,";
$sql.= " c.datef,"; $sql.= " c.datef,";
$sql.= " c.fk_bank,"; $sql.= " c.fk_bank,";
@ -693,6 +694,7 @@ if ($rowid > 0)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder);
print '<td class="center">'.$langs->trans("DateCreation").'</td>'; print '<td class="center">'.$langs->trans("DateCreation").'</td>';
print '<td align="center">'.$langs->trans("Type").'</td>';
print '<td class="center">'.$langs->trans("DateStart").'</td>'; print '<td class="center">'.$langs->trans("DateStart").'</td>';
print '<td class="center">'.$langs->trans("DateEnd").'</td>'; print '<td class="center">'.$langs->trans("DateEnd").'</td>';
print '<td class="right">'.$langs->trans("Amount").'</td>'; print '<td class="right">'.$langs->trans("Amount").'</td>';
@ -703,6 +705,7 @@ if ($rowid > 0)
print "</tr>\n"; print "</tr>\n";
$accountstatic=new Account($db); $accountstatic=new Account($db);
$adht = new AdherentType($db);
while ($i < $num) while ($i < $num)
{ {
@ -711,9 +714,20 @@ if ($rowid > 0)
$subscriptionstatic->ref=$objp->crowid; $subscriptionstatic->ref=$objp->crowid;
$subscriptionstatic->id=$objp->crowid; $subscriptionstatic->id=$objp->crowid;
if ($objp->cfk_type > 0)
{
$adht->fetch($objp->cfk_type);
}
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>'; print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'dayhour')."</td>\n"; print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'dayhour')."</td>\n";
print '<td class="center">';
if ($objp->cfk_type > 0)
{
print $adht->getNomUrl(1);
}
print '</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->dateh), 'day')."</td>\n"; print '<td class="center">'.dol_print_date($db->jdate($objp->dateh), 'day')."</td>\n";
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day')."</td>\n"; print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day')."</td>\n";
print '<td class="right">'.price($objp->subscription).'</td>'; print '<td class="right">'.price($objp->subscription).'</td>';

View File

@ -240,7 +240,7 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
//if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); //if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
@ -339,7 +339,7 @@ if (! empty($arrayfields['t.libelle']['checked']))
if (! empty($arrayfields['d.bank']['checked'])) if (! empty($arrayfields['d.bank']['checked']))
{ {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_comptes($search_account, 'search_account', 0, '', 1); $form->select_comptes($search_account, 'search_account', 0, '', 1);
print '</td>'; print '</td>';
} }

View File

@ -1,10 +1,11 @@
<?php <?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2019 Thibault Foucart <support@ptibogxiv.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -57,6 +58,7 @@ if (! $sortorder) { $sortorder="DESC"; }
if (! $sortfield) { $sortfield="d.lastname"; } if (! $sortfield) { $sortfield="d.lastname"; }
$label=GETPOST("label", "alpha"); $label=GETPOST("label", "alpha");
$morphy=GETPOST("morphy", "alpha");
$statut=GETPOST("statut", "int"); $statut=GETPOST("statut", "int");
$subscription=GETPOST("subscription", "int"); $subscription=GETPOST("subscription", "int");
$vote=GETPOST("vote", "int"); $vote=GETPOST("vote", "int");
@ -103,6 +105,7 @@ if ($cancel) {
if ($action == 'add' && $user->rights->adherent->configurer) { if ($action == 'add' && $user->rights->adherent->configurer) {
$object->label = trim($label); $object->label = trim($label);
$object->morphy = trim($morphy);
$object->statut = (int) $statut; $object->statut = (int) $statut;
$object->subscription = (int) $subscription; $object->subscription = (int) $subscription;
$object->note = trim($comment); $object->note = trim($comment);
@ -157,6 +160,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
$object->oldcopy = clone $object; $object->oldcopy = clone $object;
$object->label = trim($label); $object->label = trim($label);
$object->morphy = trim($morphy);
$object->statut = (int) $statut; $object->statut = (int) $statut;
$object->subscription = (int) $subscription; $object->subscription = (int) $subscription;
$object->note = trim($comment); $object->note = trim($comment);
@ -215,7 +219,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
{ {
//dol_fiche_head(''); //dol_fiche_head('');
$sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut"; $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote, d.statut, d.morphy";
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql.= " WHERE d.entity IN (".getEntity('member_type').")"; $sql.= " WHERE d.entity IN (".getEntity('member_type').")";
@ -256,6 +260,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Ref").'</th>'; print '<th>'.$langs->trans("Ref").'</th>';
print '<th>'.$langs->trans("Label").'</th>'; print '<th>'.$langs->trans("Label").'</th>';
print '<th class="center">'.$langs->trans("Nature").'</th>';
print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>'; print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>';
print '<th class="center">'.$langs->trans("VoteAllowed").'</th>'; print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
print '<th class="center">'.$langs->trans("Status").'</th>'; print '<th class="center">'.$langs->trans("Status").'</th>';
@ -277,6 +282,11 @@ if (! $rowid && $action != 'create' && $action != 'edit')
//<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a> //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
print '</td>'; print '</td>';
print '<td>'.dol_escape_htmltag($objp->label).'</td>'; print '<td>'.dol_escape_htmltag($objp->label).'</td>';
print '<td class="center">';
if ($objp->morphy == 'phy') { print $langs->trans("Physical"); }
elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); }
else print $langs->trans("Physical & Morale");
print '</td>';
print '<td class="center">'.yn($objp->subscription).'</td>'; print '<td class="center">'.yn($objp->subscription).'</td>';
print '<td class="center">'.yn($objp->vote).'</td>'; print '<td class="center">'.yn($objp->vote).'</td>';
print '<td class="center">'; print '<td class="center">';
@ -331,6 +341,14 @@ if ($action == 'create')
print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), 1); print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), 1);
print '</td></tr>'; print '</td></tr>';
// Morphy
$morphys[""] = $langs->trans("Physical & Morale");
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Morale");
print '<tr><td><span>'.$langs->trans("Nature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print "</td></tr>";
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>'; print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
print $form->selectyesno("subscription", 1, 1); print $form->selectyesno("subscription", 1, 1);
print '</td></tr>'; print '</td></tr>';
@ -412,6 +430,10 @@ if ($rowid > 0)
} }
print '</tr>'; print '</tr>';
// Morphy
print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$object->getmorphylib($object->morphy).'</td>';
print '</tr>';
print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>';
print yn($object->subscription); print yn($object->subscription);
print '</tr>'; print '</tr>';
@ -752,6 +774,14 @@ if ($rowid > 0)
print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $object->statut); print $form->selectarray('statut', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')), $object->statut);
print '</td></tr>'; print '</td></tr>';
// Morphy
$morphys[""] = $langs->trans("Physical & Morale");
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Morale");
print '<tr><td><span>'.$langs->trans("Nature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print "</td></tr>";
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>'; print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
print $form->selectyesno("subscription", $object->subscription, 1); print $form->selectyesno("subscription", $object->subscription, 1);
print '</td></tr>'; print '</td></tr>';

View File

@ -134,8 +134,7 @@ $head=agenda_prepare_head();
dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action'); dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"), -1, 'action');
print $langs->trans("AgendaAutoActionDesc")."<br>\n"; print '<span class="opacitymedium">'.$langs->trans("AgendaAutoActionDesc")." ".$langs->trans("OnlyActiveElementsAreShown", 'modules.php').'</span><br>';
print $langs->trans("OnlyActiveElementsAreShown", 'modules.php').'<br>';
print "<br>\n"; print "<br>\n";
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table

View File

@ -140,7 +140,7 @@ $head=agenda_prepare_head();
dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action'); dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action');
print $langs->trans("AgendaExtSitesDesc")."<br>\n"; print '<span class="opacitymedium">'.$langs->trans("AgendaExtSitesDesc")."</span><br>\n";
print "<br>\n"; print "<br>\n";

View File

@ -84,7 +84,7 @@ $head=agenda_prepare_head();
dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action'); dol_fiche_head($head, 'xcal', $langs->trans("Agenda"), -1, 'action');
print $langs->trans("AgendaSetupOtherDesc")."<br>\n"; print '<span class="opacitymedium">'.$langs->trans("AgendaSetupOtherDesc")."</span><br>\n";
print "<br>\n"; print "<br>\n";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';

View File

@ -251,6 +251,7 @@ print '<tr class="liste_titre">';
$texthelp=$langs->trans("PageUrlForDefaultValues"); $texthelp=$langs->trans("PageUrlForDefaultValues");
if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2'); if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2'); else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
$texthelp.='<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
$texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp);
print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder);
// Field // Field

View File

@ -652,6 +652,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder'; if ($fieldnamekey == 'sortorder') $fieldnamekey = 'SortOrder';
if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated'; if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated';
if ($fieldnamekey == 'revenuestamp_type') $fieldnamekey = 'TypeOfRevenueStamp'; if ($fieldnamekey == 'revenuestamp_type') $fieldnamekey = 'TypeOfRevenueStamp';
if ($fieldnamekey == 'use_default') $fieldnamekey = 'UseByDefault';
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
} }
@ -1053,11 +1054,12 @@ if ($id)
continue; continue;
} }
// Determine le nom du champ par rapport aux noms possibles // Define field friedly name from its technical name
// dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut $valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate $valuetoshow=$langs->trans($valuetoshow); // try to translate
$class=''; $class='';
if ($fieldlist[$field]=='pos') { $valuetoshow=$langs->trans("Position"); $class='width100'; }
if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
if ($fieldlist[$field]=='taux') { if ($fieldlist[$field]=='taux') {
@ -1125,6 +1127,7 @@ if ($id)
if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); } if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); }
if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); } if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); }
if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); } if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); }
if ($fieldlist[$field]=='use_default') { $valuetoshow=$langs->trans('Default'); }
if ($id == 2) // Special cas for state page if ($id == 2) // Special cas for state page
{ {
@ -1197,8 +1200,10 @@ if ($id)
print '</form>'; print '</form>';
print '<br>'; print '<br>';
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">'; print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
@ -1221,7 +1226,7 @@ if ($id)
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
// Title line with search boxes // Title line with search input fields
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
$filterfound=0; $filterfound=0;
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
@ -1276,17 +1281,12 @@ if ($id)
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$showfield=1; // By defaut $showfield=1; // By defaut
$align="left"; $align="left";
$cssprefix='';
$sortable=1; $sortable=1;
$valuetoshow='';
/*
$tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield'];
$valuetoshow=$tmp['valuetoshow'];
$align=$tmp['align'];
$sortable=$tmp['sortable'];
*/
$valuetoshow=ucfirst($fieldlist[$field]); // By defaut $valuetoshow=ucfirst($fieldlist[$field]); // By defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate $valuetoshow=$langs->trans($valuetoshow); // try to translate
// Special cases
if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); } if ($fieldlist[$field]=='source') { $valuetoshow=$langs->trans("Contact"); }
if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); } if ($fieldlist[$field]=='price') { $valuetoshow=$langs->trans("PriceUHT"); }
if ($fieldlist[$field]=='taux') { if ($fieldlist[$field]=='taux') {
@ -1304,10 +1304,7 @@ if ($id)
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='position') { $align='right'; } if ($fieldlist[$field]=='position') { $align='right'; }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
if ($fieldlist[$field]=='libelle_facture') { if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments"); }
//$valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,''));
$valuetoshow=$langs->trans("LabelOnDocuments");
}
if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); } if ($fieldlist[$field]=='country') { $valuetoshow=$langs->trans("Country"); }
if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; } if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=$langs->trans("NPR"); $align="center"; }
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
@ -1316,7 +1313,6 @@ if ($id)
if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); } if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); }
if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); } if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); }
if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); } if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); }
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; } if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; }
if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; } if ($fieldlist[$field]=='accountancy_code_buy'){ $valuetoshow=$langs->trans("AccountancyCodeBuy"); $sortable=0; }
@ -1347,11 +1343,14 @@ if ($id)
if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); } if ($fieldlist[$field]=='range_ik') { $valuetoshow=$langs->trans("RangeIk"); }
if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); } if ($fieldlist[$field]=='fk_c_exp_tax_cat') { $valuetoshow=$langs->trans("CarCategory"); }
if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); } if ($fieldlist[$field]=='revenuestamp_type') { $valuetoshow=$langs->trans('TypeOfRevenueStamp'); }
if ($fieldlist[$field]=='use_default') { $valuetoshow=$langs->trans('Default'); }
// Affiche nom du champ if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
// Show field title
if ($showfield) if ($showfield)
{ {
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder); print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder, $cssprefix);
} }
} }
// Favorite - Only activated on country dictionary // Favorite - Only activated on country dictionary
@ -1806,7 +1805,6 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
if (in_array('region_id', $fieldlist)) if (in_array('region_id', $fieldlist))
{ {
print '<td>'; print '<td>';
//print join(',',$fieldlist);
print '</td>'; print '</td>';
continue; continue;
} // For state page, we do not show the country input (we link to region, not country) } // For state page, we do not show the country input (we link to region, not country)
@ -1912,7 +1910,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
print '<td><input type="text" class="flat minwidth75" value="'.price((! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')).'" name="'.$fieldlist[$field].'"></td>'; print '<td><input type="text" class="flat minwidth75" value="'.price((! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'')).'" name="'.$fieldlist[$field].'"></td>';
} }
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
print '<td class="maxxxx"><input type="text" class="flat minwidth75 maxwidth100" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>'; print '<td><input type="text" class="flat minwidth75 maxwidth100" value="'.(! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'"></td>';
} }
elseif ($fieldlist[$field]=='unit') { elseif ($fieldlist[$field]=='unit') {
print '<td>'; print '<td>';
@ -1972,12 +1970,8 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
$classtd=''; $class=''; $classtd=''; $class='';
if ($fieldlist[$field]=='code') $classtd='width100'; if ($fieldlist[$field]=='code') $classtd='width100';
if ($fieldlist[$field]=='affect') $class='maxwidth50'; if (in_array($fieldlist[$field], array('pos', 'use_default', 'affect', 'delay', 'position', 'sortorder', 'sens', 'category_type'))) $class='maxwidth50';
if ($fieldlist[$field]=='delay') $class='maxwidth50'; if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) $class='quatrevingtpercent';
if ($fieldlist[$field]=='position') $class='maxwidth50';
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $class='quatrevingtpercent';
if ($fieldlist[$field]=='tracking') $class='quatrevingtpercent';
if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $class='maxwidth50';
print '<td class="'.$classtd.'">'; print '<td class="'.$classtd.'">';
$transfound=0; $transfound=0;
if (in_array($fieldlist[$field], array('label','libelle'))) if (in_array($fieldlist[$field], array('label','libelle')))

View File

@ -17,7 +17,10 @@
*/ */
include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php'; if (! class_exists('PrestaShopWebservice')) // We keep this because some modules add this lib too into a different path. This is to avoid "Cannot declare class PrestaShopWebservice" errors.
{
include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php';
}
/** /**

View File

@ -33,8 +33,8 @@ include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectorfilter.class
include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.class.php'; include_once DOL_DOCUMENT_ROOT.'/emailcollector/class/emailcollectoraction.class.php';
include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php'; include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php';
if (!$user->admin) if (!$user->admin) accessforbidden();
accessforbidden(); if (empty($conf->emailcollector->enabled)) accessforbidden();
// Load traductions files requiredby by page // Load traductions files requiredby by page
$langs->loadLangs(array("admin", "mails", "other")); $langs->loadLangs(array("admin", "mails", "other"));
@ -48,6 +48,8 @@ $cancel = GETPOST('cancel', 'aZ09');
$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectcard'; // To manage different context of search $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectcard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$operationid = GETPOST('operationid', 'int');
// Initialize technical objects // Initialize technical objects
$object = new EmailCollector($db); $object = new EmailCollector($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
@ -64,10 +66,11 @@ foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha');
} }
if (GETPOST('saveoperation2')) $action = 'updateoperation';
if (empty($action) && empty($id) && empty($ref)) $action='view'; if (empty($action) && empty($id) && empty($ref)) $action='view';
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) access_forbidden();
@ -75,6 +78,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
//$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
$permissionnote=$user->rights->emailcollector->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->emailcollector->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->emailcollector->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->emailcollector->write; // Used by the include of actions_addupdatedelete.inc.php
$debuginfo='';
/* /*
* Actions * Actions
@ -97,7 +107,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
// Actions when linking object each other // Actions when linking object each other
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
// Actions when printing a doc from card // Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
@ -158,6 +168,24 @@ if (GETPOST('addoperation', 'alpha'))
} }
} }
if ($action == 'updateoperation')
{
$emailcollectoroperation = new EmailCollectorAction($db);
$emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int'));
$emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none');
$result = $emailcollectoroperation->update($user);
if ($result > 0)
{
$object->fetchActions();
}
else
{
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
}
}
if ($action == 'deleteoperation') if ($action == 'deleteoperation')
{ {
$emailcollectoroperation = new EmailCollectorAction($db); $emailcollectoroperation = new EmailCollectorAction($db);
@ -180,11 +208,13 @@ if ($action == 'confirm_collect')
$res = $object->doCollectOneCollector(); $res = $object->doCollectOneCollector();
if ($res > 0) if ($res > 0)
{ {
$debuginfo = $object->debuginfo;
setEventMessages($object->lastresult, null, 'mesgs'); setEventMessages($object->lastresult, null, 'mesgs');
} }
else else
{ {
setEventMessages($object->error, null, 'errors'); $debuginfo = $object->debuginfo;
setEventMessages($object->error, null, 'errors');
} }
$action = ''; $action = '';
@ -443,22 +473,51 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
$arrayoftypes=array( $arrayoftypes=array(
'from'=>'MailFrom', 'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')),
'to'=>'MailTo', 'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')),
'cc'=>'Cc', 'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')),
'bcc'=>'Bcc', 'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')),
'subject'=>'Subject', 'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')),
'body'=>'Body', 'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')),
'X1'=>'---', // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2
'seen'=>'AlreadyRead', //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'), // HEADER key value
'unseen'=>'NotRead', //'X1'=>'---',
//'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'),
//'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'),
'X2'=>'---', 'X2'=>'---',
'withtrackingid'=>'WithDolTrackingID', 'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1),
'withouttrackingid'=>'WithoutDolTrackingID' 'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1),
'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1),
'answered'=>array('label'=>'Answered', 'data-noparam'=>1),
'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
'X3'=>'---',
'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1),
'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1)
); );
print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', '', 0, '', 2); print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', '', 0, '', 2);
print "\n";
print '<script>';
print 'jQuery("#filtertype").change(function() {
console.log("We change a filter");
if (jQuery("#filtertype option:selected").attr("data-noparam")) {
jQuery("#rulevalue").attr("placeholder", "");
jQuery("#rulevalue").text(""); jQuery("#rulevalue").prop("disabled", true);
}
else { jQuery("#rulevalue").prop("disabled", false); }
jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder")));
';
$noparam=array();
foreach($arrayoftypes as $key => $value)
{
if ($value['noparam']) $noparam[]=$key;
}
print '})';
print '</script>'."\n";
print '</td><td>'; print '</td><td>';
print '<input type="text" name="rulevalue">'; print '<input type="text" name="rulevalue" id="rulevalue">';
print '</td>'; print '</td>';
print '<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button" value="'.$langs->trans("Add").'"></td>'; print '<td class="right"><input type="submit" name="addfilter" id="addfilter" class="flat button" value="'.$langs->trans("Add").'"></td>';
print '</tr>'; print '</tr>';
@ -470,7 +529,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
print $langs->trans($arrayoftypes[$rulefilter['type']]); print $langs->trans($arrayoftypes[$rulefilter['type']]['label']);
print '</td>'; print '</td>';
print '<td>'.$rulefilter['rulevalue'].'</td>'; print '<td>'.$rulefilter['rulevalue'].'</td>';
print '<td class="right">'; print '<td class="right">';
@ -492,9 +551,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Add operation // Add operation
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
$arrayoftypes=array('loadthirdparty'=>'LoadThirdPartyFromName', 'loadandcreatethirdparty'=>'LoadThirdPartyFromNameOrCreate', 'recordevent'=>'RecordEvent'); $arrayoftypes=array(
'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
'recordevent'=>'RecordEvent');
if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty'; if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty';
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1); if ($conf->ticket->enabled) $arrayoftypes['ticket']='CreateTicketAndThirdParty';
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300');
print '</td><td>'; print '</td><td>';
print '<input type="text" name="operationparam">'; print '<input type="text" name="operationparam">';
$htmltext=$langs->transnoentitiesnoconv("OperationParamDesc"); $htmltext=$langs->transnoentitiesnoconv("OperationParamDesc");
@ -517,12 +580,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<tr class="drag drop oddeven" id="row-'.$ruleaction['id'].'">'; print '<tr class="drag drop oddeven" id="row-'.$ruleaction['id'].'">';
print '<td>'; print '<td>';
print $langs->trans($arrayoftypes[$ruleaction['type']]); print $langs->trans($arrayoftypes[$ruleaction['type']]);
if (in_array($ruleaction['type'], array('recordevent')))
{
print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
}
print '</td>'; print '</td>';
print '<td>'.$ruleaction['actionparam'].'</td>'; print '<td>';
print '<td class="right">'; if ($action == 'editoperation' && $ruleaction['id'] == $operationid)
//print $ruleactionobj->getLibStatut(3); {
print ' <a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deleteoperation&operationid='.$ruleaction['id'].'">'.img_delete().'</a>'; print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>';
print '<input type="submit" class="button" name="saveoperation2" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
}
else
{
print $ruleaction['actionparam'];
}
print '</td>'; print '</td>';
// Move up/down
print '<td class="center linecolmove tdlineupdown">'; print '<td class="center linecolmove tdlineupdown">';
if ($i > 0) if ($i > 0)
{ {
@ -532,6 +607,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=down&amp;rowid='.$ruleaction['id'].'">'.img_down('default', 0, 'imgdownforline').'</a>'; print '<a class="lineupdown" href="'.$_SERVER['PHP_SELF'].'?action=down&amp;rowid='.$ruleaction['id'].'">'.img_down('default', 0, 'imgdownforline').'</a>';
} }
print '</td>'; print '</td>';
// Delete
print '<td class="right">';
print ' <a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editoperation&operationid='.$ruleaction['id'].'">'.img_edit().'</a>';
print ' &nbsp; ';
print ' <a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deleteoperation&operationid='.$ruleaction['id'].'">'.img_delete().'</a>';
print '</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
@ -540,6 +621,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</table>'; print '</table>';
if (! empty($conf->use_javascript_ajax)) { if (! empty($conf->use_javascript_ajax)) {
$urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id;
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
} }
@ -562,15 +644,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (empty($reshook)) if (empty($reshook))
{ {
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=edit">' . $langs->trans("Edit") . '</a>' . "\n"; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=edit">' . $langs->trans("Edit") . '</a></div>';
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=collect">' . $langs->trans("CollectNow") . '</a>' . "\n"; // Clone
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=order">' . $langs->trans("ToClone") . '</a></div>';
print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a>' . "\n"; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=collect">' . $langs->trans("CollectNow") . '</a></div>';
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a></div>';
} }
print '</div>' . "\n"; print '</div>' . "\n";
} }
if (! empty($debuginfo))
{
print info_admin($debuginfo);
}
// Select mail models is same action as presend // Select mail models is same action as presend
if (GETPOST('modelselected')) { if (GETPOST('modelselected')) {
$action = 'presend'; $action = 'presend';

View File

@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
dol_include_once('/emailcollector/class/emailcollector.class.php'); dol_include_once('/emailcollector/class/emailcollector.class.php');
if (!$user->admin) accessforbidden(); if (!$user->admin) accessforbidden();
if (empty($conf->emailcollector->enabled)) accessforbidden();
// Load traductions files requiredby by page // Load traductions files requiredby by page
$langs->loadLangs(array("admin", "other")); $langs->loadLangs(array("admin", "other"));
@ -304,7 +305,7 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->emailcollector->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);

View File

@ -186,7 +186,7 @@ else
show_skin(null, 1); show_skin(null, 1);
print '<br>'."\n"; print '<br>'."\n";
$listofmodes=array('dolibarr_mailings','dolibarr_notes','dolibarr_details','dolibarr_readonly','Full'); $listofmodes=array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline');
$linkstomode=''; $linkstomode='';
foreach($listofmodes as $newmode) foreach($listofmodes as $newmode)
{ {
@ -200,10 +200,19 @@ else
$linkstomode.=''; $linkstomode.='';
print load_fiche_titre($langs->trans("TestSubmitForm"), $linkstomode, ''); print load_fiche_titre($langs->trans("TestSubmitForm"), $linkstomode, '');
print '<input type="hidden" name="mode" value="'.dol_escape_htmltag($mode).'">'; print '<input type="hidden" name="mode" value="'.dol_escape_htmltag($mode).'">';
$uselocalbrowser=true; if ($mode != 'Full_inline')
$readonly=($mode=='dolibarr_readonly'?1:0); {
$editor=new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST)?$conf->global->FCKEDITOR_TEST:'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); $uselocalbrowser=true;
$editor->Create(); $readonly=($mode=='dolibarr_readonly'?1:0);
$editor=new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST)?$conf->global->FCKEDITOR_TEST:'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly);
$editor->Create();
}
else
{
print '<div style="border: 1px solid #888;" contenteditable="true">';
print $conf->global->FCKEDITOR_TEST;
print '</div>';
}
print '<br><div class="center"><input class="button" type="submit" name="save" value="'.$langs->trans("Save").'"></div>'."\n"; print '<br><div class="center"><input class="button" type="submit" name="save" value="'.$langs->trans("Save").'"></div>'."\n";
print '<div id="divforlog"></div>'; print '<div id="divforlog"></div>';
print '</form>'."\n"; print '</form>'."\n";

View File

@ -131,11 +131,13 @@ if ($action == 'update')
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity); else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity);
if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black) $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array()))));
else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $_POST["THEME_ELDY_USE_HOVER"], 'chaine', 0, '', $conf->entity); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_HOVER', $conf->entity);
else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $val, 'chaine', 0, '', $conf->entity);
if (GETPOST('THEME_ELDY_USE_CHECKED') == '') dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", '0', 'chaine', 0, '', $conf->entity); $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array()))));
else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $_POST["THEME_ELDY_USE_CHECKED"], 'chaine', 0, '', $conf->entity); if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity);
else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"], 'chaine', 0, '', $conf->entity);
@ -239,14 +241,14 @@ if ($action == 'edit') // Edit
print '</tr>'; print '</tr>';
// Default language // Default language
print '<tr><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300', 2); print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300', 2);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Multilingual GUI // Multilingual GUI
print '<tr><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
print $form->selectyesno('MAIN_MULTILANGS', $conf->global->MAIN_MULTILANGS, 1); print $form->selectyesno('MAIN_MULTILANGS', $conf->global->MAIN_MULTILANGS, 1);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
@ -265,19 +267,19 @@ if ($action == 'edit') // Edit
print '</tr>'; print '</tr>';
// Disable javascript and ajax // Disable javascript and ajax
print '<tr><td>'.$langs->trans("DisableJavascript").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("DisableJavascript").'</td><td>';
print $form->selectyesno('MAIN_DISABLE_JAVASCRIPT', isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0, 1); print $form->selectyesno('MAIN_DISABLE_JAVASCRIPT', isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0, 1);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Max size of lists // Max size of lists
print '<tr><td>'.$langs->trans("DefaultMaxSizeList").'</td><td><input class="flat" name="main_size_liste_limit" size="4" value="' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '"></td>'; print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeList").'</td><td><input class="flat" name="main_size_liste_limit" size="4" value="' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '"></td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Max size of short lists on customer card // Max size of short lists on customer card
print '<tr><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>'; print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
@ -291,28 +293,28 @@ if ($action == 'edit') // Edit
*/ */
// First day for weeks // First day for weeks
print '<tr><td class="titlefield">'.$langs->trans("WeekStartOnDay").'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("WeekStartOnDay").'</td><td>';
print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'), 'MAIN_START_WEEK', 0); print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'), 'MAIN_START_WEEK', 0);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// DefaultWorkingDays // DefaultWorkingDays
print '<tr><td class="titlefield">'.$langs->trans("DefaultWorkingDays").'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultWorkingDays").'</td><td>';
print '<input type="text" name="MAIN_DEFAULT_WORKING_DAYS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5').'">'; print '<input type="text" name="MAIN_DEFAULT_WORKING_DAYS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5').'">';
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// DefaultWorkingHours // DefaultWorkingHours
print '<tr><td class="titlefield">'.$langs->trans("DefaultWorkingHours").'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultWorkingHours").'</td><td>';
print '<input type="text" name="MAIN_DEFAULT_WORKING_HOURS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18').'">'; print '<input type="text" name="MAIN_DEFAULT_WORKING_HOURS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18').'">';
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Firstname/Name // Firstname/Name
print '<tr><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>';
$array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname")); $array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname"));
print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0)); print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
print '</td>'; print '</td>';
@ -320,14 +322,14 @@ if ($action == 'edit') // Edit
print '</tr>'; print '</tr>';
// Hide unauthorized button // Hide unauthorized button
print '<tr><td class="titlefield">'.$langs->trans("ButtonHideUnauthorized").'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("ButtonHideUnauthorized").'</td><td>';
print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0, 1); print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED', isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0, 1);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Show logo // Show logo
print '<tr><td class="titlefield">'.$langs->trans("EnableShowLogo").'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableShowLogo").'</td><td>';
print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1); print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
@ -344,7 +346,7 @@ if ($action == 'edit') // Edit
*/ */
// Show bugtrack link // Show bugtrack link
print '<tr><td class="titlefield">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
print $form->selectyesno('MAIN_BUGTRACK_ENABLELINK', $conf->global->MAIN_BUGTRACK_ENABLELINK, 1); print $form->selectyesno('MAIN_BUGTRACK_ENABLELINK', $conf->global->MAIN_BUGTRACK_ENABLELINK, 1);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
@ -352,7 +354,7 @@ if ($action == 'edit') // Edit
// Hide wiki link on login page // Hide wiki link on login page
$pictohelp='<span class="fa fa-question-circle"></span>'; $pictohelp='<span class="fa fa-question-circle"></span>';
print '<tr><td class="titlefield">'.$langs->trans("DisableLinkToHelp", $pictohelp).'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelp", $pictohelp).'</td><td>';
print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0, 1); print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0, 1);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
@ -362,7 +364,7 @@ if ($action == 'edit') // Edit
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount')); $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'));
complete_substitutions_array($substitutionarray, $langs); complete_substitutions_array($substitutionarray, $langs);
print '<tr><td class="titlefield">'; print '<tr class="oddeven"><td class="titlefield">';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val) foreach($substitutionarray as $key => $val)
{ {
@ -390,7 +392,7 @@ if ($action == 'edit') // Edit
// Message on login page // Message on login page
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount','user')); $substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount','user'));
complete_substitutions_array($substitutionarray, $langs); complete_substitutions_array($substitutionarray, $langs);
print '<tr><td>'; print '<tr class="oddeven"><td>';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val) foreach($substitutionarray as $key => $val)
{ {
@ -403,14 +405,14 @@ if ($action == 'edit') // Edit
print '</td></tr>'."\n"; print '</td></tr>'."\n";
// Hide helpcenter link on login page // Hide helpcenter link on login page
print '<tr><td class="titlefield">'.$langs->trans("DisableLinkToHelpCenter").'</td><td>'; print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelpCenter").'</td><td>';
print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK', isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0, 1); print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK', isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0, 1);
print '</td>'; print '</td>';
print '<td width="20">&nbsp;</td>'; print '<td width="20">&nbsp;</td>';
print '</tr>'; print '</tr>';
// Background // Background
print '<tr><td><label for="imagebackground">'.$langs->trans("BackgroundImageLogin").' (png,jpg)</label></td><td colspan="2">'; print '<tr class="oddeven"><td><label for="imagebackground">'.$langs->trans("BackgroundImageLogin").' (png,jpg)</label></td><td colspan="2">';
print '<div class="centpercent inline-block">'; print '<div class="centpercent inline-block">';
print '<input type="file" class="flat class=minwidth200" name="imagebackground" id="imagebackground">'; print '<input type="file" class="flat class=minwidth200" name="imagebackground" id="imagebackground">';
if (! empty($conf->global->MAIN_LOGIN_BACKGROUND)) { if (! empty($conf->global->MAIN_LOGIN_BACKGROUND)) {

View File

@ -291,7 +291,7 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);

View File

@ -709,8 +709,8 @@ if ($mode == 'common')
{ {
if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) print $langs->trans("Used"); if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) print $langs->trans("Used");
else { else {
print img_picto($langs->trans("Required"), 'switch_on'); print img_picto($langs->trans("Required"), 'switch_on', '', false, 0, 0, '', 'opacitymedium');
print $langs->trans("Required"); //print $langs->trans("Required");
} }
if (! empty($conf->multicompany->enabled) && $user->entity) $disableSetup++; if (! empty($conf->multicompany->enabled) && $user->entity) $disableSetup++;
} }

View File

@ -76,9 +76,7 @@ elseif ($action == 'update_currency')
{ {
$error = 0; $error = 0;
$submit = GETPOST('submit', 'alpha'); if (GETPOST('updatecurrency', 'alpha'))
if ($submit == $langs->trans('Modify'))
{ {
$fk_multicurrency = GETPOST('fk_multicurrency', 'int'); $fk_multicurrency = GETPOST('fk_multicurrency', 'int');
$rate = price2num(GETPOST('rate', 'alpha')); $rate = price2num(GETPOST('rate', 'alpha'));
@ -97,7 +95,7 @@ elseif ($action == 'update_currency')
} }
} }
} }
elseif ($submit == $langs->trans('Delete')) elseif (GETPOST('deletecurrency', 'alpha'))
{ {
$fk_multicurrency = GETPOST('fk_multicurrency', 'int'); $fk_multicurrency = GETPOST('fk_multicurrency', 'int');
$currency = new MultiCurrency($db); $currency = new MultiCurrency($db);
@ -109,9 +107,18 @@ elseif ($action == 'update_currency')
} }
} }
} }
elseif ($action == 'synchronize') elseif ($action == 'setapilayer')
{ {
MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); if (GETPOSTISSET('modify_apilayer'))
{
dolibarr_set_const($db, 'MULTICURRENCY_APP_ID', GETPOST('MULTICURRENCY_APP_ID', 'alpha'));
dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha'));
//dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha'));
}
else
{
MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID);
}
} }
@ -177,17 +184,20 @@ if ($conf->use_javascript_ajax) {
} }
print '</td></tr>'; print '</td></tr>';
//Online payment with currency on document // Online payment with currency on document. This option should be on by default.
print '<tr class="oddeven">'; if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_useCurrency").'</td>'; {
print '<td align="center">'; print '<tr class="oddeven">';
if ($conf->use_javascript_ajax) { print '<td>'.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT").'</td>';
print ajax_constantonoff('MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT'); print '<td align="center">';
} else { if ($conf->use_javascript_ajax) {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print ajax_constantonoff('MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT');
print $form->selectarray("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT", $arrval, $conf->global->MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT); } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT", $arrval, $conf->global->MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT);
}
print '</td></tr>';
} }
print '</td></tr>';
/* TODO uncomment when the functionality will integrated /* TODO uncomment when the functionality will integrated
@ -224,59 +234,48 @@ print '<br>';
if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION)) if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
{ {
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" id="form_sync">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setapilayer">';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; $urlforapilayer='https://currencylayer.com'; //https://apilayer.net
print '<td>'.$form->textwithpicto($langs->trans("CurrencyLayerAccount"), $langs->trans("CurrencyLayerAccount_help_to_synchronize")).'</td>'."\n";
print '<td class="right">';
print '<form id="form_sync" action="" method="POST">';
print '<input type="hidden" name="action" value="synchronize" />';
print '<textarea id="response" class="hideobject" name="response"></textarea>';
print $langs->trans("Value").'&nbsp;<input type="button" id="bt_sync" class="button" onclick="javascript:getRates();" value="'.$langs->trans('Synchronize').'" />';
print '</form>';
print '</td></tr>';
print '<tr class="liste_titre">';
print '<td>'.$form->textwithpicto($langs->trans("CurrencyLayerAccount"), $langs->trans("CurrencyLayerAccount_help_to_synchronize", $urlforapilayer)).'</td>'."\n";
print '<td class="right">';
print '<textarea id="response" class="hideobject" name="response"></textarea>';
print '<input type="submit" name="modify_apilayer" class="button" value="'.$langs->trans("Modify").'">';
print '<input type="submit" id="bt_sync" name="bt_sync_apilayer" class="button" value="'.$langs->trans('Synchronize').'" />';
print '</td></tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td><a target="_blank" href="https://currencylayer.com">'.$langs->transnoentitiesnoconv("multicurrency_appId").'</a></td>'; print '<td class="fieldrequired"><a target="_blank" href="'.$urlforapilayer.'">'.$langs->transnoentitiesnoconv("multicurrency_appId").'</a></td>';
print '<td class="right">'; print '<td class="right">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_APP_ID">';
print '<input type="text" name="MULTICURRENCY_APP_ID" value="'.$conf->global->MULTICURRENCY_APP_ID.'" size="28" />&nbsp;'; print '<input type="text" name="MULTICURRENCY_APP_ID" value="'.$conf->global->MULTICURRENCY_APP_ID.'" size="28" />&nbsp;';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_appCurrencySource").'</td>'; print '<td>'.$langs->transnoentitiesnoconv("multicurrency_appCurrencySource").'</td>';
print '<td class="right">'; print '<td class="right">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_APP_SOURCE">';
print '<input type="text" name="MULTICURRENCY_APP_SOURCE" value="'.$conf->global->MULTICURRENCY_APP_SOURCE.'" size="10" placeholder="USD" />&nbsp;'; // Default: USD print '<input type="text" name="MULTICURRENCY_APP_SOURCE" value="'.$conf->global->MULTICURRENCY_APP_SOURCE.'" size="10" placeholder="USD" />&nbsp;'; // Default: USD
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>'; print '</form>';
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven">'; /*print '<tr class="oddeven">';
print '<td>'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").'</td>'; print '<td>'.$langs->transnoentitiesnoconv("multicurrency_alternateCurrencySource").'</td>';
print '<td class="right">'; print '<td class="right">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_MULTICURRENCY_ALTERNATE_SOURCE">';
print '<input type="text" name="MULTICURRENCY_ALTERNATE_SOURCE" value="'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE.'" size="10" placeholder="EUR" />&nbsp;'; // Example: EUR print '<input type="text" name="MULTICURRENCY_ALTERNATE_SOURCE" value="'.$conf->global->MULTICURRENCY_ALTERNATE_SOURCE.'" size="10" placeholder="EUR" />&nbsp;'; // Example: EUR
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '</td></tr>';*/
print '</form>';
print '</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<br>'; print '<br>';
}
print '</form>';
}
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -287,15 +286,17 @@ print '<td align="center">'.$langs->trans("Rate").'</td>'."\n";
print '</tr>'; print '</tr>';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<tr class="oddeven">';
print '<td>'.$form->selectCurrency('', 'code').'</td>';
print '<td class="right">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add_currency">'; print '<input type="hidden" name="action" value="add_currency">';
print '<tr class="oddeven">';
print '<td>'.$form->selectCurrency('', 'code', 1).'</td>';
print '<td class="right">';
print '<input type="text" name="rate" value="" size="13" placeholder="'.$langs->trans('Rate').'" />&nbsp;'; print '<input type="text" name="rate" value="" size="13" placeholder="'.$langs->trans('Rate').'" />&nbsp;';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '</form>'; print '</form>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -316,8 +317,8 @@ foreach ($TCurrency as &$currency)
print '<input type="hidden" name="fk_multicurrency" value="'.$currency->id.'">'; print '<input type="hidden" name="fk_multicurrency" value="'.$currency->id.'">';
print '1 '.$conf->currency.' = '; print '1 '.$conf->currency.' = ';
print '<input type="text" name="rate" value="'.($currency->rate->rate ? $currency->rate->rate : '').'" size="13" />&nbsp;'.$currency->code.'&nbsp;'; print '<input type="text" name="rate" value="'.($currency->rate->rate ? $currency->rate->rate : '').'" size="13" />&nbsp;'.$currency->code.'&nbsp;';
print '<input type="submit" name="submit" class="button" value="'.$langs->trans("Modify").'">&nbsp;'; print '<input type="submit" name="updatecurrency" class="button" value="'.$langs->trans("Modify").'">&nbsp;';
print '<input type="submit" name="submit" class="button" value="'.$langs->trans("Delete").'">'; print '<input type="submit" name="deletecurrency" class="button" value="'.$langs->trans("Delete").'">';
print '</form>'; print '</form>';
print '</td></tr>'; print '</td></tr>';
} }
@ -330,15 +331,7 @@ print '
function getRates() function getRates()
{ {
$("#bt_sync").attr("disabled", true); $("#bt_sync").attr("disabled", true);
var url_sync = "http://apilayer.net/api/live?access_key='.$conf->global->MULTICURRENCY_APP_ID.'&format=1'.(!empty($conf->global->MULTICURRENCY_APP_SOURCE) ? '&source='.$conf->global->MULTICURRENCY_APP_SOURCE : '').'"; return true;
$.ajax({
url: url_sync,
dataType: "jsonp"
}).done(function(response) {
$("#response").val(JSON.stringify(response));
$("#form_sync").submit();
});
} }
</script> </script>
'; ';

View File

@ -16,8 +16,8 @@
*/ */
/** /**
* \file htdocs/admin/confexped.php * \file htdocs/admin/reception_setup.php
* \ingroup produit * \ingroup reception
* \brief Page to setup reception module * \brief Page to setup reception module
*/ */
@ -27,13 +27,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
$langs->load("admin"); $langs->loadLangs(array("admin", "receptions", 'other'));
$langs->load("receptions");
$langs->load('other');
if (!$user->admin) if (!$user->admin) accessforbidden();
accessforbidden();
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$value=GETPOST('value', 'alpha'); $value=GETPOST('value', 'alpha');

View File

@ -286,7 +286,8 @@ $configfileparameters=array(
'dolibarr_main_document_root'=> $langs->trans("DocumentRootServer"), 'dolibarr_main_document_root'=> $langs->trans("DocumentRootServer"),
'?dolibarr_main_document_root_alt' => $langs->trans("DocumentRootServer").' (alt)', '?dolibarr_main_document_root_alt' => $langs->trans("DocumentRootServer").' (alt)',
'dolibarr_main_data_root' => $langs->trans("DataRootServer"), 'dolibarr_main_data_root' => $langs->trans("DataRootServer"),
'separator1' => '', 'dolibarr_main_instance_unique_id' => $langs->trans("InstanceUniqueID"),
'separator1' => '',
'dolibarr_main_db_host' => $langs->trans("DatabaseServer"), 'dolibarr_main_db_host' => $langs->trans("DatabaseServer"),
'dolibarr_main_db_port' => $langs->trans("DatabasePort"), 'dolibarr_main_db_port' => $langs->trans("DatabasePort"),
'dolibarr_main_db_name' => $langs->trans("DatabaseName"), 'dolibarr_main_db_name' => $langs->trans("DatabaseName"),
@ -391,7 +392,20 @@ foreach($configfileparameters as $key => $value)
++$i; ++$i;
} }
} }
else print ${$newkey}; elseif ($newkey == 'dolibarr_main_instance_unique_id')
{
//print $conf->file->instance_unique_id;
global $dolibarr_main_cookie_cryptkey;
$valuetoshow = ${$newkey} ? ${$newkey} : $dolibarr_main_cookie_cryptkey;
print $valuetoshow;
if (empty($valuetoshow)) {
print img_warning("EditConfigFileToAddEntry", 'dolibarr_main_instance_unique_id');
}
}
else
{
print ${$newkey};
}
if ($newkey == 'dolibarr_main_url_root' && ${$newkey} != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')'; if ($newkey == 'dolibarr_main_url_root' && ${$newkey} != DOL_MAIN_URL_ROOT) print ' (currently overwritten by autodetected value: '.DOL_MAIN_URL_ROOT.')';
print "</td>"; print "</td>";
} }

View File

@ -66,7 +66,7 @@ if ($action == 'updateMask') {
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
dolibarr_set_const($db, "TICKETSUP_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'setvar') { } elseif ($action == 'setvar') {
include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
@ -181,7 +181,7 @@ $page_name = "TicketSetup";
llxHeader('', $langs->trans($page_name), $help_url); llxHeader('', $langs->trans($page_name), $help_url);
// Subheader // Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
@ -256,7 +256,7 @@ foreach ($dirmodels as $reldir) {
print '</td>' . "\n"; print '</td>' . "\n";
print '<td align="center">'; print '<td align="center">';
if ($conf->global->TICKETSUP_ADDON == 'mod_' . $classname) { if ($conf->global->TICKET_ADDON == 'mod_' . $classname) {
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmod&amp;value=mod_' . $classname . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>'; print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setmod&amp;value=mod_' . $classname . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';

View File

@ -66,7 +66,7 @@ $help_url = "FR:Module_Ticket";
$page_name = "TicketSetup"; $page_name = "TicketSetup";
llxHeader('', $langs->trans($page_name), $help_url); llxHeader('', $langs->trans($page_name), $help_url);
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans("TicketSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("TicketSetup"), $linkback, 'title_setup');
$head = ticketAdminPrepareHead(); $head = ticketAdminPrepareHead();

View File

@ -103,7 +103,7 @@ if ($action == 'setvar') {
} }
$url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha');
if (!empty($mail_signature)) { if (!empty($url_interface)) {
$res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity);
} else { } else {
$res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity);
@ -113,7 +113,7 @@ if ($action == 'setvar') {
} }
$topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha'); $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha');
if (!empty($mail_signature)) { if (!empty($topic_interface)) {
$res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity);
} else { } else {
$res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity);
@ -123,7 +123,7 @@ if ($action == 'setvar') {
} }
$text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha'); $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha');
if (!empty($mail_signature)) { if (!empty($text_home)) {
$res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity);
} else { } else {
$res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity);
@ -208,7 +208,7 @@ $page_name = "TicketSetup";
llxHeader('', $langs->trans($page_name), $help_url); llxHeader('', $langs->trans($page_name), $help_url);
// Subheader // Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>'; $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');

View File

@ -50,7 +50,7 @@ if (! $user->admin)
if ($action == 'delete') if ($action == 'delete')
{ {
$file=$conf->admin->dir_output.'/'.GETPOST('urlfile'); $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha'));
$ret=dol_delete_file($file, 1); $ret=dol_delete_file($file, 1);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
@ -113,7 +113,7 @@ jQuery(document).ready(function() {
print load_fiche_titre($langs->trans("Backup"), '', 'title_setup'); print load_fiche_titre($langs->trans("Backup"), '', 'title_setup');
//print_barre_liste($langs->trans("Backup"), '', '', '', '', '', $langs->trans("BackupDesc",DOL_DATA_ROOT), 0, 0, 'title_setup'); //print_barre_liste($langs->trans("Backup"), '', '', '', '', '', $langs->trans("BackupDesc",DOL_DATA_ROOT), 0, 0, 'title_setup');
print '<div class="center">'; print '<div class="center opacitymedium">';
print $langs->trans("BackupDesc", DOL_DATA_ROOT); print $langs->trans("BackupDesc", DOL_DATA_ROOT);
print '</div>'; print '</div>';
print '<br>'; print '<br>';

View File

@ -67,7 +67,7 @@ jQuery(document).ready(function() {
print load_fiche_titre($langs->trans("Restore"), '', 'title_setup'); print load_fiche_titre($langs->trans("Restore"), '', 'title_setup');
print '<div class="center">'; print '<div class="center opacitymedium">';
print $langs->trans("RestoreDesc", DOL_DATA_ROOT); print $langs->trans("RestoreDesc", DOL_DATA_ROOT);
print '</div>'; print '</div>';
print '<br>'; print '<br>';

View File

@ -133,7 +133,8 @@ if ($what == 'mysql')
dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump);
foreach($arrayofallowedcommand as $allowedcommand) foreach($arrayofallowedcommand as $allowedcommand)
{ {
if (preg_match('/'.preg_quote($allowedcommand, '/').'/', $cmddump)) $basenamecmddump=basename($cmddump);
if (preg_match('/^'.preg_quote($allowedcommand, '/').'$/', $basenamecmddump)) // the provided command $cmddump must be an allowed command
{ {
$ok=1; $ok=1;
break; break;

View File

@ -137,7 +137,7 @@ $form = new Form($db);
$help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:M&oacute;dulo_Usuarios'; $help_url='EN:Module_Users|FR:Module_Utilisateurs|ES:M&oacute;dulo_Usuarios';
llxHeader('', $langs->trans("UsersSetup"), $help_url); llxHeader('', $langs->trans("UsersSetup"), $help_url);
$linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("UsersSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("UsersSetup"), $linkback, 'title_setup');
@ -183,8 +183,6 @@ print '<br>';
$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
$form=new Form($db);
// Defini tableau def des modeles // Defini tableau def des modeles
$def = array(); $def = array();
$sql = "SELECT nom"; $sql = "SELECT nom";

View File

@ -216,7 +216,7 @@ class DolibarrApi
* *
* @param string $resource element to check * @param string $resource element to check
* @param int $resource_id Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional). * @param int $resource_id Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
* @param type $dbtablename 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity. Not used if objectid is null (optional) * @param string $dbtablename 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity. Not used if objectid is null (optional)
* @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'. * @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
* @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)

View File

@ -234,12 +234,13 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' &&
$classname = ucwords($module); $classname = ucwords($module);
dol_syslog('Search /' . $moduledirforclass . '/class/api_' . $classfile . '.class.php => dir_part_file=' . $dir_part_file . ' classname=' . $classname); dol_syslog('Search api file /' . $moduledirforclass . '/class/api_' . $classfile . '.class.php => dir_part_file=' . $dir_part_file . ' classname=' . $classname);
$res = false; $res = false;
if ($dir_part_file) if ($dir_part_file)
$res = include_once $dir_part_file; $res = include_once $dir_part_file;
if (! $res) { if (! $res) {
dol_syslog('Failed to make include_once '.$dir_part_file, LOG_WARNING);
print 'API not found (failed to include API file)'; print 'API not found (failed to include API file)';
header('HTTP/1.1 501 API not found (failed to include API file)'); header('HTTP/1.1 501 API not found (failed to include API file)');
exit(0); exit(0);

View File

@ -66,8 +66,12 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
$permissionnote=$user->rights->asset->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->asset->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->asset->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php
/* /*

View File

@ -291,10 +291,18 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->asset->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->asset->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
$newcardbutton='';
if ($user->rights->asset->write)
{
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/asset/card.php?action=create"><span class="valignmiddle text-plus-circle">'.$langs->trans('NewAsset').'</span>';
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -305,7 +313,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit);
// Add code for pre mass action (confirmation or email presend form) // Add code for pre mass action (confirmation or email presend form)
$topicmail="SendAssetsRef"; $topicmail="SendAssetsRef";

View File

@ -220,6 +220,14 @@ if (! $rowid && $action != 'create' && $action != 'edit')
$param = ''; $param = '';
$newcardbutton='';
if ($user->rights->asset->configurer)
{
$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/asset/type.php?action=create"><span class="valignmiddle text-plus-circle">'.$langs->trans('NewAssetType').'</span>';
$newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
$newcardbutton.= '</a>';
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -229,7 +237,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); print_barre_liste($langs->trans("AssetsTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit);
$moreforfilter = ''; $moreforfilter = '';

View File

@ -61,7 +61,7 @@ foreach($object->fields as $key => $val)
if (empty($action) && empty($id) && empty($ref)) $action='view'; if (empty($action) && empty($id) && empty($ref)) $action='view';
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Security check - Protection if external user // Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) access_forbidden();
@ -69,6 +69,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
//$isdraft = (($object->statut == BillOfMaterials::STATUS_DRAFT) ? 1 : 0); //$isdraft = (($object->statut == BillOfMaterials::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); //$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
$permissionnote=$user->rights->bom->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->bom->write; // Used by the include of actions_dellink.inc.php
$permissionedit=$user->rights->bom->write; // Used by the include of actions_lineupdown.inc.php
$permissiontoadd=$user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php
/* /*
* Actions * Actions
@ -109,7 +114,6 @@ if (empty($reshook))
/* /*
* View * View
* *

View File

@ -299,7 +299,7 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->bom->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->bom->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions=array(); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
@ -452,11 +452,13 @@ while ($i < min($num, $limit))
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$cssforfield=''; $cssforfield='';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right'; elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield.=($cssforfield?' ':'').'right';
if (! empty($arrayfields['t.'.$key]['checked'])) if (! empty($arrayfields['t.'.$key]['checked']))
{ {

View File

@ -28,21 +28,13 @@ require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
*/ */
/** /**
* API class for bom bom * API class for bom
* *
* @access protected * @access protected
* @class DolibarrApiAccess {@requires user,external} * @class DolibarrApiAccess {@requires user,external}
*/ */
class BOMs extends DolibarrApi class Boms extends DolibarrApi
{ {
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
'label'
);
/** /**
* @var BOM $bom {@type BOM} * @var BOM $bom {@type BOM}
*/ */
@ -71,16 +63,16 @@ class BOMs extends DolibarrApi
*/ */
public function get($id) public function get($id)
{ {
if(! DolibarrApiAccess::$user->rights->bom->read) { if (! DolibarrApiAccess::$user->rights->bom->read) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->bom->fetch($id); $result = $this->bom->fetch($id);
if( ! $result ) { if (! $result) {
throw new RestException(404, 'BOM not found'); throw new RestException(404, 'BOM not found');
} }
if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { if (! DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@ -107,33 +99,33 @@ class BOMs extends DolibarrApi
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
$tmpobject = new BOM($db);
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : '';
$restictonsocid = 0; // Set to 1 if there is a field socid in table of object $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object
// If the internal user must only see his customers, force searching by him // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if ($restictonsocid && ! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; if ($restrictonsocid && ! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."bom_mytable as t"; $sql.= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= " WHERE 1 = 1"; $sql.= " WHERE 1 = 1";
// Example of use $mode // Example of use $mode
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
$tmpobject = new BOM($db);
if ($tmpobject->ismultientitymanaged) $sql.= ' AND t.entity IN ('.getEntity('bom').')'; if ($tmpobject->ismultientitymanaged) $sql.= ' AND t.entity IN ('.getEntity('bom').')';
if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($restictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid; if ($restrictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid;
if ($restictonsocid && $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale if ($restrictonsocid && $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Insert sale filter // Insert sale filter
if ($restictonsocid && $search_sale > 0) if ($restrictonsocid && $search_sale > 0)
{ {
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
@ -190,7 +182,7 @@ class BOMs extends DolibarrApi
*/ */
public function post($request_data = null) public function post($request_data = null)
{ {
if(! DolibarrApiAccess::$user->rights->bom->create) { if(! DolibarrApiAccess::$user->rights->bom->write) {
throw new RestException(401); throw new RestException(401);
} }
// Check mandatory fields // Check mandatory fields
@ -215,7 +207,7 @@ class BOMs extends DolibarrApi
*/ */
public function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if(! DolibarrApiAccess::$user->rights->bom->create) { if(! DolibarrApiAccess::$user->rights->bom->write) {
throw new RestException(401); throw new RestException(401);
} }
@ -224,7 +216,7 @@ class BOMs extends DolibarrApi
throw new RestException(404, 'BOM not found'); throw new RestException(404, 'BOM not found');
} }
if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@ -239,7 +231,7 @@ class BOMs extends DolibarrApi
} }
else else
{ {
throw new RestException(500, $this->commande->error); throw new RestException(500, $this->bom->error);
} }
} }
@ -259,7 +251,7 @@ class BOMs extends DolibarrApi
throw new RestException(404, 'BOM not found'); throw new RestException(404, 'BOM not found');
} }
if (! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { if (! DolibarrApi::_checkAccessToResource('bom', $this->bom->id, 'bom_bom')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
@ -309,12 +301,13 @@ class BOMs extends DolibarrApi
*/ */
private function _validate($data) private function _validate($data)
{ {
$bom = array(); $myobject = array();
foreach (BOMs::$FIELDS as $field) { foreach ($this->myobject->fields as $field => $propfield) {
if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) continue; // Not a mandatory field
if (!isset($data[$field])) if (!isset($data[$field]))
throw new RestException(400, "$field field missing"); throw new RestException(400, "$field field missing");
$bom[$field] = $data[$field]; $myobject[$field] = $data[$field];
} }
return $bom; return $myobject;
} }
} }

View File

@ -66,7 +66,7 @@ function bomAdminPrepareHead()
/** /**
* Prepare array of tabs for BillOfMaterials * Prepare array of tabs for BillOfMaterials
* *
* @param BillOfMaterials $object BillOfMaterials * @param BOM $object BillOfMaterials
* @return array Array of tabs * @return array Array of tabs
*/ */
function bomPrepareHead($object) function bomPrepareHead($object)

View File

@ -142,7 +142,11 @@ class Facturation
$this->montantRemise($montant_remise_ht); $this->montantRemise($montant_remise_ht);
$newcartarray=$_SESSION['poscart']; $newcartarray=$_SESSION['poscart'];
$i=count($newcartarray);
$i = 0;
if (!is_null($newcartarray) && !empty($newcartarray)) {
$i=count($newcartarray);
}
$newcartarray[$i]['id']=$i; $newcartarray[$i]['id']=$i;
$newcartarray[$i]['ref']=$product->ref; $newcartarray[$i]['ref']=$product->ref;
@ -281,7 +285,7 @@ class Facturation
* Getter for id * Getter for id
* *
* @param int $aId Id * @param int $aId Id
* @return id * @return int Id
*/ */
public function id($aId = null) public function id($aId = null)
{ {
@ -542,8 +546,8 @@ class Facturation
/** /**
* Get payment date * Get payment date
* *
* @param date $aPaiementLe Date * @param integer $aPaiementLe Date
* @return date Date * @return integer Date
*/ */
public function paiementLe($aPaiementLe = null) public function paiementLe($aPaiementLe = null)
{ {

View File

@ -55,17 +55,6 @@ $langs->loadLangs(array("main","bills","cashdesk"));
onfocus="javascript: this.select();" /> onfocus="javascript: this.select();" />
</td> </td>
<td class="select_design maxwidthonsmartphone"> <td class="select_design maxwidthonsmartphone">
<?php /*
$selected='';
$htmlname='idprod';
$status=-1;
$rice_level=$company->price_level;
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', 'outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
if (! $hidelabel) print $langs->trans("RefOrLabel").' : ';
print '<input type="text" size="4" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'" />';
*/
?>
<select id="selProduit" class="maxwidthonsmartphone" name="selProduit" onchange="javascript: setSource('LISTE');"> <select id="selProduit" class="maxwidthonsmartphone" name="selProduit" onchange="javascript: setSource('LISTE');">
<?php <?php
print '<option value="0">'.$top_liste_produits.'</option>'."\n"; print '<option value="0">'.$top_liste_produits.'</option>'."\n";

View File

@ -15,10 +15,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
use Luracast\Restler\RestException; use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/api_members.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/api_products.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/api_contacts.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/api_thirdparties.class.php';
/** /**
* API class for categories * API class for categories
@ -335,4 +340,64 @@ class Categories extends DolibarrApi
} }
return $category; return $category;
} }
/**
* Get the list of objects in a category.
*
* @param int $id ID of category
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
* @param int $onlyids Return only ids of objects (consume less memory)
*
* @return mixed
*
* @url GET {id}/objects
*/
public function getObjects($id, $type, $onlyids = 0)
{
dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG);
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
throw new RestException(401);
}
if (empty($type))
{
throw new RestException(500, 'The "type" parameter is required.');
}
$result = $this->category->fetch($id);
if (! $result) {
throw new RestException(404, 'category not found');
}
if (! DolibarrApi::_checkAccessToResource('category', $this->category->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->category->getObjectsInCateg($type, $onlyids);
if ($result < 0) {
throw new RestException(503, 'Error when retrieving objects list : '.$this->category->error);
}
$objects = $result;
$cleaned_objects = array();
if ($type == 'member') {
$objects_api = new Members();
} elseif ($type == 'customer' || $type == 'supplier') {
$objects_api = new Thirdparties();
} elseif ($type == 'product') {
$objects_api = new Products();
} elseif ($type == 'contact') {
$objects_api = new Contacts();
}
if (is_object($objects_api))
{
foreach ($objects as $obj) {
$cleaned_objects[] = $objects_api->_cleanObjectDatas($obj);
}
}
return $cleaned_objects;
}
} }

View File

@ -983,19 +983,43 @@ class Categorie extends CommonObject
* fulllabel = nom avec chemin complet de la categorie * fulllabel = nom avec chemin complet de la categorie
* fullpath = chemin complet compose des id * fullpath = chemin complet compose des id
* *
* @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...). * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...).
* @param int $markafterid Removed all categories including the leaf $markafterid in category tree. * @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id.
* @param int $keeponlyifinleafid Keep only of category is inside the leaf starting with this id. * $markafterid can be an :
* @return array|int Array of categories. this->cats and this->motherof are set, -1 on error * - int (id of category)
* - string (categories ids seprated by comma)
* - array (list of categories ids)
* @param int $include [=0] Removed or 1=Keep only
* @return array|int Array of categories. this->cats and this->motherof are set, -1 on error
*/ */
public function get_full_arbo($type, $markafterid = 0, $keeponlyifinleafid = 0) public function get_full_arbo($type, $markafterid = 0, $include = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
if (! is_numeric($type)) $type = $this->MAP_ID[$type]; if (! is_numeric($type)) $type = $this->MAP_ID[$type];
$this->cats = array(); if (is_string($markafterid))
{
$markafterid = explode(',', $markafterid);
}
elseif (is_numeric($markafterid))
{
if ($markafterid > 0)
{
$markafterid = array($markafterid);
}
else
{
$markafterid = array();
}
}
elseif (!is_array($markafterid))
{
$markafterid = array();
}
$this->cats = array();
// Init this->motherof that is array(id_son=>id_parent, ...) // Init this->motherof that is array(id_son=>id_parent, ...)
$this->load_motherof(); $this->load_motherof();
@ -1040,39 +1064,22 @@ class Categorie extends CommonObject
$this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent)
} }
// Exclude leaf including $markafterid from tree // Include or exclude leaf including $markafterid from tree
if ($markafterid) if (count($markafterid) > 0)
{ {
$keyfiltercatid = implode('|', $markafterid);
//print "Look to discard category ".$markafterid."\n"; //print "Look to discard category ".$markafterid."\n";
$keyfilter1='^'.$markafterid.'$'; $keyfilter1 = '^' . $keyfiltercatid . '$';
$keyfilter2='_'.$markafterid.'$'; $keyfilter2 = '_' . $keyfiltercatid . '$';
$keyfilter3='^'.$markafterid.'_'; $keyfilter3 = '^' . $keyfiltercatid . '_';
$keyfilter4='_'.$markafterid.'_'; $keyfilter4 = '_' . $keyfiltercatid . '_';
foreach($this->cats as $key => $val) foreach($this->cats as $key => $val)
{ {
if (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) $test = (preg_match('/' . $keyfilter1 . '/', $val['fullpath']) || preg_match('/' . $keyfilter2 . '/', $val['fullpath'])
|| preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])) || preg_match('/' . $keyfilter3 . '/', $val['fullpath']) || preg_match('/' . $keyfilter4 . '/', $val['fullpath']));
{
unset($this->cats[$key]); if (($test && !$include) || (!$test && $include))
}
}
}
// Exclude leaf including $markafterid from tree
if ($keeponlyifinleafid)
{
//print "Look to discard category ".$keeponlyifinleafid."\n";
$keyfilter1='^'.$keeponlyifinleafid.'$';
$keyfilter2='_'.$keeponlyifinleafid.'$';
$keyfilter3='^'.$keeponlyifinleafid.'_';
$keyfilter4='_'.$keeponlyifinleafid.'_';
foreach($this->cats as $key => $val)
{
if (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath'])
|| preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath']))
{
// We keep
}
else
{ {
unset($this->cats[$key]); unset($this->cats[$key]);
} }

View File

@ -33,10 +33,7 @@ $langs->loadLangs(array("admin","other","website"));
if (! $user->admin) accessforbidden(); if (! $user->admin) accessforbidden();
if (! ((GETPOST('testmenuhider', 'int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) $conf->dol_hide_leftmenu = 1; // Force hide of left menu.
{
$conf->dol_hide_leftmenu = 1; // Force hide of left menu.
}
$error=0; $error=0;
$website=GETPOST('website', 'alpha'); $website=GETPOST('website', 'alpha');

View File

@ -164,7 +164,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
reset($object->socpeopleassigned); reset($object->socpeopleassigned);
$object->contactid = key($object->socpeopleassigned); $object->contactid = key($object->socpeopleassigned);
} }
$result = $object->createFromClone(GETPOST('fk_userowner'), GETPOST('socid')); $result = $object->createFromClone($user, GETPOST('fk_userowner'), GETPOST('socid'));
if ($result > 0) { if ($result > 0) {
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
exit(); exit();
@ -903,7 +903,7 @@ if ($action == 'create')
$numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1);
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$societe->id.'&action=create"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$societe->id.'&action=create"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
$urloption='?action=create'; $urloption='?action=create';
$url = dol_buildpath('comm/action/card.php', 2).$urloption; $url = dol_buildpath('comm/action/card.php', 2).$urloption;
@ -1301,7 +1301,7 @@ if ($id > 0)
$numprojet=$formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0); $numprojet=$formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0);
if ($numprojet==0) if ($numprojet==0)
{ {
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->socid.'&action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->socid.'&action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
} }
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -281,6 +281,7 @@ class ActionComm extends CommonObject
if (! empty($this->datep) && ! empty($this->datef) && $this->datep > $this->datef) $this->datef=$this->datep; if (! empty($this->datep) && ! empty($this->datef) && $this->datep > $this->datef) $this->datef=$this->datep;
//if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date; //if (! empty($this->date) && ! empty($this->dateend) && $this->date > $this->dateend) $this->dateend=$this->date;
if (! isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0; if (! isset($this->fk_project) || $this->fk_project < 0) $this->fk_project = 0;
// For backward compatibility
if ($this->elementtype=='facture') $this->elementtype='invoice'; if ($this->elementtype=='facture') $this->elementtype='invoice';
if ($this->elementtype=='commande') $this->elementtype='order'; if ($this->elementtype=='commande') $this->elementtype='order';
if ($this->elementtype=='contrat') $this->elementtype='contract'; if ($this->elementtype=='contrat') $this->elementtype='contract';
@ -504,13 +505,13 @@ class ActionComm extends CommonObject
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param user $fuser Object user making action * @param User $fuser Object user making action
* @param int $socid Id of thirdparty * @param int $socid Id of thirdparty
* @return int New id of clone * @return int New id of clone
*/ */
public function createFromClone($fuser, $socid) public function createFromClone(User $fuser, $socid)
{ {
global $db, $user, $langs, $conf, $hookmanager; global $db, $conf, $hookmanager;
$error=0; $error=0;
$now=dol_now(); $now=dol_now();
@ -529,20 +530,6 @@ class ActionComm extends CommonObject
$this->id=0; $this->id=0;
if (!is_object($fuser))
{
if ($fuser > 0)
{
$u = new User($db);
$u->fetch($fuser);
$fuser = $u;
}
else
{
$fuser = $user;
}
}
// Create clone // Create clone
$this->context['createfromclone']='createfromclone'; $this->context['createfromclone']='createfromclone';
$result=$this->create($fuser); $result=$this->create($fuser);

View File

@ -614,18 +614,9 @@ if ($resql)
// Defined date_start_in_calendar and date_end_in_calendar property // Defined date_start_in_calendar and date_end_in_calendar property
// They are date start and end of action but modified to not be outside calendar view. // They are date start and end of action but modified to not be outside calendar view.
if ($event->percentage <= 0) $event->date_start_in_calendar=$event->datep;
{ if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef;
$event->date_start_in_calendar=$event->datep; else $event->date_end_in_calendar=$event->datep;
if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef;
else $event->date_end_in_calendar=$event->datep;
}
else
{
$event->date_start_in_calendar=$event->datep;
if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef;
else $event->date_end_in_calendar=$event->datep;
}
// Define ponctual property // Define ponctual property
if ($event->date_start_in_calendar == $event->date_end_in_calendar) if ($event->date_start_in_calendar == $event->date_end_in_calendar)
{ {
@ -1009,6 +1000,11 @@ if (! empty($hookmanager->resArray['eventarray'])) {
} }
} }
// Sort events
foreach($eventarray as $keyDate => &$dateeventarray)
{
usort($dateeventarray, 'sort_events_by_date');
}
$maxnbofchar=0; $maxnbofchar=0;
@ -1701,3 +1697,22 @@ function dol_color_minus($color, $minus, $minusunit = 16)
} }
return $newcolor; return $newcolor;
} }
/**
* Sort events by date
*
* @param object $a Event A
* @param object $b Event B
* @return int < 0 if event A should be before event B, > 0 otherwise, 0 if they have the exact same time slot
*/
function sort_events_by_date($a, $b)
{
if($a->datep != $b->datep)
{
return $a->datep - $b->datep;
}
// If both events have the same start time, longest first
return $b->datef - $a->datef;
}

View File

@ -97,7 +97,7 @@ if (empty($reshook))
} }
else else
{ {
$result=$object->createFromClone($object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]); $result=$object->createFromClone($user, $object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);

View File

@ -114,22 +114,17 @@ class AdvanceTargetingMailing extends CommonObject
$error=0; $error=0;
// Clean parameters // Clean parameters
if (isset($this->fk_element)) $this->fk_element=trim($this->fk_element); if (isset($this->fk_element)) $this->fk_element=(int) $this->fk_element;
if (isset($this->type_element)) $this->type_element=trim($this->type_element); if (isset($this->type_element)) $this->type_element=trim($this->type_element);
if (isset($this->name)) $this->name=trim($this->name); if (isset($this->name)) $this->name=trim($this->name);
if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue);
if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author);
if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."advtargetemailing("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."advtargetemailing(";
$sql.= "name,"; $sql.= "name,";
$sql.= "entity,"; $sql.= "entity,";
$sql.= "fk_element,"; $sql.= "fk_element,";
@ -138,10 +133,7 @@ class AdvanceTargetingMailing extends CommonObject
$sql.= "fk_user_author,"; $sql.= "fk_user_author,";
$sql.= "datec,"; $sql.= "datec,";
$sql.= "fk_user_mod"; $sql.= "fk_user_mod";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= " ".(! isset($this->name)?'NULL':"'".$this->db->escape($this->name)."'").","; $sql.= " ".(! isset($this->name)?'NULL':"'".$this->db->escape($this->name)."'").",";
$sql.= " ".$conf->entity.","; $sql.= " ".$conf->entity.",";
$sql.= " ".(! isset($this->fk_element)?'NULL':"'".$this->db->escape($this->fk_element)."'").","; $sql.= " ".(! isset($this->fk_element)?'NULL':"'".$this->db->escape($this->fk_element)."'").",";
@ -149,9 +141,7 @@ class AdvanceTargetingMailing extends CommonObject
$sql.= " ".(! isset($this->filtervalue)?'NULL':"'".$this->db->escape($this->filtervalue)."'").","; $sql.= " ".(! isset($this->filtervalue)?'NULL':"'".$this->db->escape($this->filtervalue)."'").",";
$sql.= " ".$user->id.","; $sql.= " ".$user->id.",";
$sql.= " '".$this->db->idate(dol_now())."',"; $sql.= " '".$this->db->idate(dol_now())."',";
$sql.= " ".$user->id; $sql.= " null";
$sql.= ")"; $sql.= ")";
$this->db->begin(); $this->db->begin();
@ -396,14 +386,10 @@ class AdvanceTargetingMailing extends CommonObject
$error=0; $error=0;
// Clean parameters // Clean parameters
if (isset($this->fk_element)) $this->fk_element=trim($this->fk_element); if (isset($this->fk_element)) $this->fk_element=(int) $this->fk_element;
if (isset($this->type_element)) $this->type_element=trim($this->type_element); if (isset($this->type_element)) $this->type_element=trim($this->type_element);
if (isset($this->name)) $this->name=trim($this->name); if (isset($this->name)) $this->name=trim($this->name);
if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue);
if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author);
if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod);
// Check parameters // Check parameters
// Put here code to add a control on parameters values // Put here code to add a control on parameters values

View File

@ -266,14 +266,15 @@ class Mailing extends CommonObject
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param User $user User making the clone
* @param int $fromid Id of object to clone * @param int $fromid Id of object to clone
* @param int $option1 1=Copy content, 0=Forget content * @param int $option1 1=Copy content, 0=Forget content
* @param int $option2 Not used * @param int $option2 Not used
* @return int New id of clone * @return int New id of clone
*/ */
public function createFromClone($fromid, $option1, $option2) public function createFromClone(User $user, $fromid, $option1, $option2)
{ {
global $user,$langs; global $langs;
$error=0; $error=0;
@ -668,7 +669,7 @@ class Mailing extends CommonObject
* *
* @param int $statut Id statut * @param int $statut Id statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @param strin $desc Desc error * @param string $desc Desc error
* @return string Label * @return string Label
*/ */
public static function libStatutDest($statut, $mode = 0, $desc = '') public static function libStatutDest($statut, $mode = 0, $desc = '')

View File

@ -192,7 +192,7 @@ if (empty($reshook))
} }
} }
$result = $object->createFromClone($socid); $result = $object->createFromClone($user, $socid);
if ($result > 0) { if ($result > 0) {
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
exit(); exit();
@ -623,7 +623,7 @@ if (empty($reshook))
{ {
$db->begin(); $db->begin();
$result=$object->cloture($user, 4, ''); $result=$object->cloture($user, Propal::STATUS_BILLED, '');
if ($result < 0) if ($result < 0)
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -839,6 +839,7 @@ if (empty($reshook))
$qty = GETPOST('qty' . $predef); $qty = GETPOST('qty' . $predef);
$remise_percent = GETPOST('remise_percent' . $predef); $remise_percent = GETPOST('remise_percent' . $predef);
if (empty($remise_percent)) $remise_percent=0;
// Extrafields // Extrafields
$extrafieldsline = new ExtraFields($db); $extrafieldsline = new ExtraFields($db);
@ -1591,7 +1592,7 @@ if ($action == 'create')
}); });
</script>'; </script>';
} }
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
print '</td>'; print '</td>';
} }
print '</tr>' . "\n"; print '</tr>' . "\n";
@ -1624,7 +1625,7 @@ if ($action == 'create')
print '<tr><td class="fieldrequired">' . $langs->trans("ValidityDuration") . '</td><td><input name="duree_validite" size="5" value="' . $conf->global->PROPALE_VALIDITY_DURATION . '"> ' . $langs->trans("days") . '</td></tr>'; print '<tr><td class="fieldrequired">' . $langs->trans("ValidityDuration") . '</td><td><input name="duree_validite" size="5" value="' . $conf->global->PROPALE_VALIDITY_DURATION . '"> ' . $langs->trans("days") . '</td></tr>';
// Terms of payment // Terms of payment
print '<tr><td class="nowrap fieldrequired">' . $langs->trans('PaymentConditionsShort') . '</td><td>'; print '<tr><td class="nowrap">' . $langs->trans('PaymentConditionsShort') . '</td><td>';
$form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id', -1, 1); $form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id', -1, 1);
print '</td></tr>'; print '</td></tr>';

View File

@ -1226,12 +1226,13 @@ class Propal extends CommonObject
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param int $socid Id of thirdparty * @param User $user User making the clone
* @return int New id of clone * @param int $socid Id of thirdparty
* @return int New id of clone
*/ */
public function createFromClone($socid = 0) public function createFromClone(User $user, $socid = 0)
{ {
global $user,$conf,$hookmanager; global $conf,$hookmanager;
dol_include_once('/projet/class/project.class.php'); dol_include_once('/projet/class/project.class.php');

View File

@ -430,7 +430,7 @@ if ($resql)
'presend'=>$langs->trans("SendByMail"), 'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"), 'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->propal->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->propal->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if ($user->rights->propal->cloturer) $arrayofmassactions['closed']=$langs->trans("Close"); if ($user->rights->propal->cloturer) $arrayofmassactions['closed']=$langs->trans("Close");
if (in_array($massaction, array('presend','predelete','closed'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete','closed'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
@ -968,6 +968,7 @@ if ($resql)
print '&nbsp'; print '&nbsp';
} }
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++;
} }
// Extra fields // Extra fields

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -127,6 +128,8 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
$db->begin(); $db->begin();
$discount->fk_facture_source=0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source $discount->fk_facture_source=0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source
// This is to delete only the require record (that we will recreate with two records) and not all family with same fk_invoice_supplier_source
$discount->fk_invoice_supplier_source=0;
$res=$discount->delete($user); $res=$discount->delete($user);
$newid1=$newdiscount1->create($user); $newid1=$newdiscount1->create($user);
$newid2=$newdiscount2->create($user); $newid2=$newdiscount2->create($user);

4
htdocs/commande/card.php Executable file → Normal file
View File

@ -142,7 +142,7 @@ if (empty($reshook))
// Because createFromClone modifies the object, we must clone it so that we can restore it later // Because createFromClone modifies the object, we must clone it so that we can restore it later
$orig = clone $object; $orig = clone $object;
$result=$object->createFromClone($socid); $result=$object->createFromClone($user, $socid);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
@ -1637,7 +1637,7 @@ if ($action == 'create' && $user->rights->commande->creer)
}); });
</script>'; </script>';
} }
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
print '</td>'; print '</td>';
} }
print '</tr>' . "\n"; print '</tr>' . "\n";

View File

@ -161,7 +161,7 @@ class Commande extends CommonOrder
/** /**
* @deprecated * @deprecated
* @see date * @see $date
*/ */
public $date_commande; public $date_commande;
@ -1070,10 +1070,11 @@ class Commande extends CommonOrder
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param int $socid Id of thirdparty * @param User $user User making the clone
* @return int New id of clone * @param int $socid Id of thirdparty
* @return int New id of clone
*/ */
public function createFromClone($socid = 0) public function createFromClone(User $user, $socid = 0)
{ {
global $conf, $user,$hookmanager; global $conf, $user,$hookmanager;
@ -1331,7 +1332,7 @@ class Commande extends CommonOrder
* @param double $pu_ht_devise Unit price in currency * @param double $pu_ht_devise Unit price in currency
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
* *
* @see add_product * @see add_product()
* *
* Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
@ -2955,7 +2956,7 @@ class Commande extends CommonOrder
dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code"); dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
if ($this->statut == Propal::STATUS_DRAFT) if ($this->statut == Commande::STATUS_DRAFT)
{ {
// Clean parameters // Clean parameters
@ -3905,7 +3906,7 @@ class OrderLine extends CommonOrderLine
* Id of parent order * Id of parent order
* @var int * @var int
* @deprecated Use fk_commande * @deprecated Use fk_commande
* @see fk_commande * @see $fk_commande
*/ */
public $commande_id; public $commande_id;
@ -3932,7 +3933,7 @@ class OrderLine extends CommonOrderLine
/** /**
* @deprecated * @deprecated
* @see remise_percent, fk_remise_except * @see $remise_percent, $fk_remise_except
*/ */
public $remise; public $remise;

View File

@ -434,7 +434,7 @@ if ($resql)
); );
if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->commande->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->commande->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);

View File

@ -282,7 +282,7 @@ if ($mode == 'customer')
Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"),
Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled") Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled")
); );
print $form->selectarray('object_status', $liststatus, GETPOST('object_status'), -4); print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4);
} }
if ($mode == 'supplier') if ($mode == 'supplier')
{ {

View File

@ -564,7 +564,7 @@ if ($resql)
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
//if ($user->rights->bank->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); //if ($user->rights->bank->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);

View File

@ -639,11 +639,12 @@ else
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>'; print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<td>'; print '<td>';
$accountingjournal = new AccountingJournal($db); if ($object->fk_accountancy_journal > 0) {
$accountingjournal->fetch($object->fk_accountancy_journal); $accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($object->fk_accountancy_journal);
print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
}
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -269,13 +269,12 @@ class BankCateg // extends CommonObject
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param int $fromid Id of object to clone * @param User $user User making the clone
* @return int New id of clone * @param int $fromid Id of object to clone
* @return int New id of clone
*/ */
public function createFromClone($fromid) public function createFromClone(User $user, $fromid)
{ {
global $user;
$error = 0; $error = 0;
$object = new BankCateg($this->db); $object = new BankCateg($this->db);

View File

@ -220,7 +220,7 @@ $arrayofmassactions = array(
// 'presend'=>$langs->trans("SendByMail"), // 'presend'=>$langs->trans("SendByMail"),
// 'builddoc'=>$langs->trans("PDFMerge"), // 'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->banque->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->banque->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
@ -575,7 +575,13 @@ foreach ($accounts as $key=>$type)
$i++; $i++;
} }
if (! $found) print '<tr class="oddeven"><td colspan="'.$totalarray['nbfield'].'" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; // If no record found
if (! $found)
{
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
// Show total line // Show total line
if (isset($totalarray['totalbalancefield']) && $lastcurrencycode != 'various') // If there is several currency, $lastcurrencycode is set to 'various' before if (isset($totalarray['totalbalancefield']) && $lastcurrencycode != 'various') // If there is several currency, $lastcurrencycode is set to 'various' before

View File

@ -57,7 +57,7 @@ if (! $sortfield) $sortfield="name";
$object = new PaymentVarious($db); $object = new PaymentVarious($db);
$object->fetch($id, $ref); $object->fetch($id, $ref);
$upload_dir = $conf->banque->dir_output.'/'.dol_sanitizeFileName($object->id); $upload_dir = $conf->bank->dir_output.'/'.dol_sanitizeFileName($object->id);
$modulepart='banque'; $modulepart='banque';

View File

@ -200,7 +200,7 @@ if ($action == 'confirm_delete' && ! empty($permissiontodelete))
} }
$result=$object->delete($user); $result=$object->delete($user);
var_dump($result); //var_dump($result);
if ($result > 0) if ($result > 0)
{ {
// Delete OK // Delete OK
@ -234,6 +234,8 @@ if ($action=="create" || $action=="start")
{ {
$posmodule = GETPOST('posmodule', 'alpha'); $posmodule = GETPOST('posmodule', 'alpha');
$terminalid = GETPOST('posnumber', 'alpha'); $terminalid = GETPOST('posnumber', 'alpha');
$terminaltouse = $terminalid;
if ($terminaltouse == '1') $terminaltouse = '';
// Calculate $initialbalanceforterminal for terminal 0 // Calculate $initialbalanceforterminal for terminal 0
foreach($arrayofpaymentmode as $key => $val) foreach($arrayofpaymentmode as $key => $val)
@ -245,24 +247,33 @@ if ($action=="create" || $action=="start")
} }
// Get the bank account dedicated to this point of sale module/terminal // Get the bank account dedicated to this point of sale module/terminal
$bankid = $conf->global->CASHDESK_ID_BANKACCOUNT_CASH; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) $vartouse=CASHDESK_ID_BANKACCOUNT_CASH.$terminaltouse;
$bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal)
// Hook to get the good bank id according to posmodule and posnumber. // Hook to get the good bank id according to posmodule and posnumber.
// @TODO add hook here // @TODO add hook here
$sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; if ($bankid > 0)
$sql.= " WHERE fk_account = ".$bankid;
if ($syear && ! $smonth) $sql.= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'";
elseif ($syear && $smonth && ! $sday) $sql.= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'";
elseif ($syear && $smonth && $sday) $sql.= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'";
else dol_print_error('', 'Year not defined');
$resql = $db->query($sql);
if ($resql)
{ {
$obj = $db->fetch_object($resql); $sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank";
if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total; $sql.= " WHERE fk_account = ".$bankid;
if ($syear && ! $smonth) $sql.= " AND dateo < '".$db->idate(dol_get_first_day($syear, 1))."'";
elseif ($syear && $smonth && ! $sday) $sql.= " AND dateo < '".$db->idate(dol_get_first_day($syear, $smonth))."'";
elseif ($syear && $smonth && $sday) $sql.= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'";
else dol_print_error('', 'Year not defined');
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $initialbalanceforterminal[$terminalid][$key] = $obj->total;
}
else dol_print_error($db);
}
else
{
setEventMessages($langs->trans("SetupOfTerminalNotComplete", $terminalid), null, 'errors');
$error++;
} }
else dol_print_error($db);
} }
// Calculate $theoricalamountforterminal for terminal 0 // Calculate $theoricalamountforterminal for terminal 0
@ -332,7 +343,16 @@ if ($action=="create" || $action=="start")
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable)>1?1:0)).'</td>'; print '<td>'.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable)>1?1:0)).'</td>';
print '<td><input name="posnumber" type="text" class="maxwidth50" value="'.(GETPOSTISSET('posnumber')?GETPOST('posnumber', 'alpha'):'0').'"></td>'; print '<td>';
$array=array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6", 7=>"7", 8=>"8", 9=>"9");
$selectedposnumber=0; $showempty=1;
if ($conf->global->TAKEPOS_NUM_TERMINALS == '1')
{
$selectedposnumber=1; $showempty=0;
}
print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber')?GETPOST('posnumber', 'int'):$selectedposnumber, $showempty);
//print '<input name="posnumber" type="text" class="maxwidth50" value="'.(GETPOSTISSET('posnumber')?GETPOST('posnumber', 'alpha'):'0').'">';
print '</td>';
// Year // Year
print '<td>'; print '<td>';
$retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'year" name="'.$prefix.'year">'; $retstring='<select'.($disabled?' disabled':'').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'year" name="'.$prefix.'year">';
@ -380,6 +400,7 @@ if ($action=="create" || $action=="start")
print '</td>'; print '</td>';
print '</table>'; print '</table>';
// Table to see/enter balance
if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1')
{ {
$posmodule = GETPOST('posmodule', 'alpha'); $posmodule = GETPOST('posmodule', 'alpha');
@ -561,7 +582,7 @@ if (empty($action) || $action=="view")
print '<div class="inline-block divButAction"><a target="_blank" class="butAction" href="report.php?id='.$id.'">' . $langs->trans('PrintTicket') . '</a></div>'; print '<div class="inline-block divButAction"><a target="_blank" class="butAction" href="report.php?id='.$id.'">' . $langs->trans('PrintTicket') . '</a></div>';
if ($object->status == CashControl::STATUS_DRAFT) if ($object->status == CashControl::STATUS_DRAFT)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '&amp;action=close">' . $langs->trans('Close') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '&amp;action=close">' . $langs->trans('ValidateAndClose') . '</a></div>';
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '&amp;action=confirm_delete">' . $langs->trans('Delete') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '&amp;action=confirm_delete">' . $langs->trans('Delete') . '</a></div>';
} }

View File

@ -212,7 +212,7 @@ else $sql.=" WHERE 1 = 1";
foreach($search as $key => $val) foreach($search as $key => $val)
{ {
if ($key == 'status' && $search[$key] == -1) continue; if ($key == 'status' && $search[$key] == -1) continue;
$mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search));
} }
if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
@ -320,7 +320,7 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if ($user->rights->monmodule->delete) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
@ -387,10 +387,11 @@ print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"")
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$cssforfield=''; $cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right';
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>'; if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($cssforfield?' '.$cssforfield:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
} }
// Extra fields // Extra fields
@ -413,14 +414,15 @@ print '</tr>'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$cssforfield=''; $cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right';
if (! empty($arrayfields['t.'.$key]['checked'])) if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
{ if (! empty($arrayfields['t.'.$key]['checked']))
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n"; {
} print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield?'class="'.$cssforfield.'"':''), $sortfield, $sortorder, ($cssforfield?$cssforfield.' ':''))."\n";
}
} }
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
@ -463,10 +465,15 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">'; print '<tr class="oddeven">';
foreach($object->fields as $key => $val) foreach($object->fields as $key => $val)
{ {
$cssforfield=''; $cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price'))) $cssforfield.=($cssforfield?' ':'').'right';
if (! empty($arrayfields['t.'.$key]['checked'])) if (! empty($arrayfields['t.'.$key]['checked']))
{ {
print '<td'; print '<td';

View File

@ -55,20 +55,20 @@ class CashControl extends CommonObject
public $picto = 'account'; public $picto = 'account';
public $fields=array( public $fields=array(
'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>10), 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>15), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>15),
'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>18), 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>18),
'posmodule' =>array('type'=>'varchar(30)', 'label'=>'Module', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>19), 'posmodule' =>array('type'=>'varchar(30)', 'label'=>'Module', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>19),
'posnumber' =>array('type'=>'varchar(30)', 'label'=>'CashDesk', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>20), 'posnumber' =>array('type'=>'varchar(30)', 'label'=>'CashDesk', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>20),
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>0, 'position'=>24), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>0, 'position'=>24),
'opening' =>array('type'=>'double(24,8)', 'label'=>'Opening', 'enabled'=>1, 'visible'=>1, 'position'=>25), 'opening' =>array('type'=>'price', 'label'=>'Opening', 'enabled'=>1, 'visible'=>1, 'position'=>25),
'cash' =>array('type'=>'double(24,8)', 'label'=>'Cash', 'enabled'=>1, 'visible'=>1, 'position'=>30), 'cash' =>array('type'=>'price', 'label'=>'Cash', 'enabled'=>1, 'visible'=>1, 'position'=>30),
'cheque' =>array('type'=>'double(24,8)', 'label'=>'Cheque', 'enabled'=>1, 'visible'=>1, 'position'=>33), 'cheque' =>array('type'=>'price', 'label'=>'Cheque', 'enabled'=>1, 'visible'=>1, 'position'=>33),
'card' =>array('type'=>'double(24,8)', 'label'=>'CreditCard', 'enabled'=>1, 'visible'=>1, 'position'=>36), 'card' =>array('type'=>'price', 'label'=>'CreditCard', 'enabled'=>1, 'visible'=>1, 'position'=>36),
'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>50), 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>50, 'css'=>'center'),
'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55), 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55, 'css'=>'center'),
'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>60), 'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>60, 'css'=>'center'),
'date_valid' =>array('type'=>'datetime', 'label'=>'DateValid', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>490), 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>490),
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>505), 'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>505),
'import_key' =>array('type'=>'varchar(14)', 'label'=>'Import key', 'enabled'=>1, 'visible'=>0, 'position'=>510), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'Import key', 'enabled'=>1, 'visible'=>0, 'position'=>510),
@ -355,66 +355,68 @@ class CashControl extends CommonObject
} }
/** /**
* Return clicable link of object (with eventually picto) * Return clicable link of object (with eventually picto)
* *
* @param int $withpicto Add picto into link * @param int $withpicto Add picto into link
* @param string $option Where point the link ('stock', 'composition', 'category', 'supplier', '') * @param string $option On what the link point to ('nolink', ...)
* @param int $maxlength Maxlength of ref * @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param string $morecss Add more css on link
* @param int $notooltip No tooltip * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL * @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0) public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{ {
global $conf, $langs, $hookmanager; global $conf, $langs, $hookmanager;
include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result=''; $result='';
$newref=($this->ref?$this->ref:$this->id); $newref=($this->ref?$this->ref:$this->id);
if ($maxlength) { $newref=dol_trunc($newref, $maxlength, 'middle'); }
$label = '<u>' . $langs->trans("ShowCashFence") . '</u>'; $label = '<u>' . $langs->trans("ShowCashFence") . '</u>';
$label .= '<br><b>' . $langs->trans('ProductRef') . ':</b> ' . ($this->ref?$this->ref:$this->id); $label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . ($this->ref?$this->ref:$this->id);
$linkclose='';
if (empty($notooltip)) {
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label=$langs->trans("ShowCashFence");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"';
$linkclose.= ' class="classfortooltip"';
/*
$hookmanager->initHooks(array('productdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/
}
$url = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$this->id; $url = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$this->id;
if ($option !== 'nolink') { if ($option != 'nolink')
// Add param to save lastsearch_values or not {
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); // Add param to save lastsearch_values or not
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values=1; $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
} if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) { $url.='&save_lastsearch_values=1'; if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
}
} }
$linkclose='';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowMyObject");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
/*
$hookmanager->initHooks(array('myobjectdao'));
$parameters=array('id'=>$this->id);
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>'; $linkstart.=$linkclose.'>';
$linkend='</a>'; $linkend='</a>';
$result.=$linkstart; $result .= $linkstart;
if ($withpicto) { if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
$result.=(img_object(($notooltip?'':$label), 'bank', ($notooltip?'class="paddingright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1)); if ($withpicto != 2) $result.= $this->ref;
} $result .= $linkend;
$result.= $newref; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
$result.= $linkend;
global $action; global $action;
$hookmanager->initHooks(array('cashfencedao')); $hookmanager->initHooks(array('cashfencedao'));

View File

@ -72,7 +72,7 @@ llxHeader('', $langs->trans("CashControl"), '', '', 0, 0, array(), array(), $par
$sql.= " b.fk_account, b.fk_type,"; $sql.= " b.fk_account, b.fk_type,";
$sql.= " ba.rowid as bankid, ba.ref as bankref,"; $sql.= " ba.rowid as bankid, ba.ref as bankref,";
$sql.= " bu.url_id,"; $sql.= " bu.url_id,";
$sql.= " f.module_source, f.facnumber as facnumber"; $sql.= " f.module_source, f.ref as ref";
$sql.= " FROM "; $sql.= " FROM ";
//if ($bid) $sql.= MAIN_DB_PREFIX."bank_class as l,"; //if ($bid) $sql.= MAIN_DB_PREFIX."bank_class as l,";
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba,"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba,";
@ -95,7 +95,7 @@ $sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CB;
$sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; $sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE;
$sql.=")"; $sql.=")";
*/ */
$sql = "SELECT f.rowid as facid, f.facnumber, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code"; $sql = "SELECT f.rowid as facid, f.ref, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp, ".MAIN_DB_PREFIX."bank as b"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp, ".MAIN_DB_PREFIX."bank as b";
$sql.= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement AND p.fk_bank = b.rowid"; $sql.= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement AND p.fk_bank = b.rowid";
$sql.= " AND f.module_source = '".$db->escape($posmodule)."'"; $sql.= " AND f.module_source = '".$db->escape($posmodule)."'";

161
htdocs/compta/facture/card.php Executable file → Normal file
View File

@ -126,6 +126,7 @@ $usercancreatewithdrarequest = $user->rights->prelevement->bons->creer;
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdonw.inc.php $permissiontoedit = $usercancreate; // Used by the include of actions_lineupdonw.inc.php
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php
// Security check // Security check
$fieldid = (! empty($ref) ? 'ref' : 'rowid'); $fieldid = (! empty($ref) ? 'ref' : 'rowid');
@ -160,21 +161,21 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd)
// if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { {
// $mesgs [] = '<div class="error">' . $langs->trans("NoCloneOptionsSpecified") . '</div>'; $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone. We use native clone to keep this->db valid.
// } else {
if ($object->fetch($id) > 0) { $objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
$result = $object->createFromClone($socid); $objectutil->socid = $socid;
if ($result > 0) { $result = $objectutil->createFromClone($user, $id);
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result); if ($result > 0) {
exit(); header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $result);
} else { exit();
setEventMessages($object->error, $object->errors, 'errors'); } else {
$action = ''; $langs->load("errors");
} setEventMessages($object->error, $object->errors, 'errors');
} $action = '';
// } }
} }
// Change status of invoice // Change status of invoice
@ -1391,7 +1392,7 @@ if (empty($reshook))
$desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle);
if ($object->situation_counter == 1) $lines[$i]->situation_percent = 0; if ($object->situation_counter == 1) $lines[$i]->situation_percent = 0;
if ($lines[$i]->subprice < 0) if ($lines[$i]->subprice < 0 && empty($conf->global->INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN))
{ {
// Negative line, we create a discount line // Negative line, we create a discount line
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
@ -1542,14 +1543,16 @@ if (empty($reshook))
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($datefacture)) { if (empty($datefacture)) {
$error++; $error++;
$mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("Date")) . '</div>'; $mesg = $langs->trans("ErrorFieldRequired", $langs->trans("Date"));
setEventMessages($mesg, null, 'errors');
} }
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
if (!($_POST['situations'] > 0)) { if (!($_POST['situations'] > 0)) {
$error++; $error++;
$mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceSituation")) . '</div>'; $mesg = $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceSituation"));
setEventMessages($mesg, null, 'errors');
} }
if (!$error) { if (!$error) {
@ -2191,11 +2194,13 @@ $result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GET
if (!$object->fetch($id) > 0) dol_print_error($db); if (!$object->fetch($id) > 0) dol_print_error($db);
if (!is_null(GETPOST('all_progress')) && GETPOST('all_progress') != "") if (!is_null(GETPOST('all_progress')) && GETPOST('all_progress') != "")
{ {
$all_progress = GETPOST('all_progress', 'int');
foreach ($object->lines as $line) foreach ($object->lines as $line)
{ {
$percent = $line->get_prev_progress($object->id); $percent = $line->get_prev_progress($object->id);
if (GETPOST('all_progress') < $percent) { if (floatval($all_progress) < floatval($percent)) {
$mesg = '<div class="warning">' . $langs->trans("CantBeLessThanMinPercent") . '</div>'; $mesg = $langs->trans("Line") . ' ' . $i . ' '. $line->ref .' : ' . $langs->trans("CantBeLessThanMinPercent");
setEventMessages($mesg, null, 'warnings');
$result = -1; $result = -1;
} else } else
$object->update_percent($line, $_POST['all_progress']); $object->update_percent($line, $_POST['all_progress']);
@ -2588,22 +2593,47 @@ if ($action == 'create')
if (empty($socid)) if (empty($socid))
$soc = $objectsrc->thirdparty; $soc = $objectsrc->thirdparty;
$cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0)); $dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice);
$mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
$fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0));
$remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0));
$remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0));
$dateinvoice = (empty($dateinvoice)?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$dateinvoice);
if (!empty($conf->multicurrency->enabled)) if ($element == 'expedition') {
{ $ref_client = (! empty($objectsrc->ref_customer)?$objectsrc->ref_customer:'');
if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; $elem = $subelem = $objectsrc->origin;
$expeoriginid = $objectsrc->origin_id;
dol_include_once('/'.$elem.'/class/'.$subelem.'.class.php');
$classname = ucfirst($subelem);
$expesrc = new $classname($db);
$expesrc->fetch($expeoriginid);
$cond_reglement_id = (! empty($expesrc->cond_reglement_id)?$expesrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
$mode_reglement_id = (! empty($expesrc->mode_reglement_id)?$expesrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
$fk_account = (! empty($expesrc->fk_account)?$expesrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0));
$remise_percent = (! empty($expesrc->remise_percent)?$expesrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0));
$remise_absolue = (! empty($expesrc->remise_absolue)?$expesrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0));
//Replicate extrafields
$expesrc->fetch_optionals($expeoriginid);
$object->array_options=$expesrc->array_options;
} }
else
{
$cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:0));
$mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
$fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0));
$remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0));
$remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0));
// Replicate extrafields if (!empty($conf->multicurrency->enabled))
$objectsrc->fetch_optionals($originid); {
$object->array_options = $objectsrc->array_options; if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
}
// Replicate extrafields
$objectsrc->fetch_optionals($originid);
$object->array_options = $objectsrc->array_options;
}
} }
} }
else else
@ -2698,7 +2728,7 @@ if ($action == 'create')
}); });
</script>'; </script>';
} }
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>'; print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="valignmiddle text-plus-circle">'.$langs->trans("AddThirdParty").'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span></a>';
print '</td>'; print '</td>';
} }
print '</tr>' . "\n"; print '</tr>' . "\n";
@ -2864,7 +2894,7 @@ if ($action == 'create')
{ {
// First situation invoice // First situation invoice
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">'; print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input id="radio_situation invoice" type="radio" name="type" value="5"' . (GETPOST('type') == 5 ? ' checked' : '') . '> '; $tmp='<input id="radio_situation" type="radio" name="type" value="5"' . (GETPOST('type') == 5 ? ' checked' : '') . '> ';
$tmp = $tmp.'<label for="radio_situation invoice" >'.$langs->trans("InvoiceFirstSituationAsk").'</label>'; $tmp = $tmp.'<label for="radio_situation invoice" >'.$langs->trans("InvoiceFirstSituationAsk").'</label>';
$desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3);
print $desc; print $desc;
@ -2919,7 +2949,23 @@ if ($action == 'create')
} }
else else
{ {
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">'; print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" id="radio_situation" value="0" disabled> ';
$text = '<label>'.$tmp.$langs->trans("InvoiceFirstSituationAsk") . '</label> ';
$text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') ';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3);
print $desc;
print '</div></div>';
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" id="radio_situation" value="0" disabled> ';
$text = '<label>'.$tmp.$langs->trans("InvoiceSituationAsk") . '</label> ';
$text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') ';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3);
print $desc;
print '</div></div>';
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" id="radio_replacement" value="0" disabled> '; $tmp='<input type="radio" name="type" id="radio_replacement" value="0" disabled> ';
$text = '<label>'.$tmp.$langs->trans("InvoiceReplacement") . '</label> '; $text = '<label>'.$tmp.$langs->trans("InvoiceReplacement") . '</label> ';
$text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $text.= '('.$langs->trans("YouMustCreateInvoiceFromThird").') ';
@ -3606,11 +3652,11 @@ elseif ($id > 0 || ! empty($ref))
{ {
// Create an array for form // Create an array for form
$formquestion = array( $formquestion = array(
// 'text' => $langs->trans("ConfirmClone"), array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1)),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1) array('type' => 'date', 'name' => 'newdate', 'label' => $langs->trans("Date"), 'value' => dol_now())
array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company($object->socid, 'socid', '(s.client=1 OR s.client=2 OR s.client=3)', 1))); );
// Paiement incomplet. On demande si motif = escompte ou autre // Ask confirmatio to clone
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 250);
} }
// Call Hook formConfirm // Call Hook formConfirm
@ -4427,7 +4473,9 @@ elseif ($id > 0 || ! empty($ref))
// Show global modifiers // Show global modifiers
if (! empty($conf->global->INVOICE_USE_SITUATION)) if (! empty($conf->global->INVOICE_USE_SITUATION))
{ {
if ($object->situation_cycle_ref && $object->statut == 0) { if ($object->situation_cycle_ref && $object->statut == 0)
{
print '<!-- Area to change globally the situation percent -->'."\n";
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<form name="updatealllines" id="updatealllines" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '#updatealllines" method="POST">'; print '<form name="updatealllines" id="updatealllines" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '#updatealllines" method="POST">';
@ -4443,38 +4491,19 @@ elseif ($id > 0 || ! empty($ref))
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td align="center" width="5">&nbsp;</td>'; print '<td align="center" width="5">&nbsp;</td>';
} }
print '<td>' . $langs->trans('ModifyAllLines') . '</td>'; print '<td class="minwidth500imp">' . $langs->trans('ModifyAllLines') . '</td>';
print '<td class="right" width="50">&nbsp;</td>'; print '<td class="right">' . $langs->trans('Progress') . '</td>';
print '<td class="right" width="80">&nbsp;</td>';
if ($inputalsopricewithtax) print '<td class="right" width="80">&nbsp;</td>';
print '<td class="right" width="50">&nbsp</td>';
print '<td class="right" width="50">&nbsp</td>';
print '<td class="right" width="50">' . $langs->trans('Progress') . '</td>';
if (! empty($conf->margin->enabled) && empty($user->societe_id))
{
print '<td class="margininfos right" width="80">&nbsp;</td>';
if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $usercanreadallmargin) {
print '<td class="margininfos right" width="50">&nbsp;</td>';
}
}
print '<td class="right" width="50">&nbsp;</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td width="10">&nbsp;</td>';
print '<td width="10">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="nodrag nodrop">';
// Adds a line numbering column // Adds a line numbering column
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td align="center" width="5">&nbsp;</td>'; print '<td align="center" width="5">&nbsp;</td>';
} }
print '<tr width="100%" class="nodrag nodrop">';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td width="50">&nbsp;</td>';
print '<td width="80">&nbsp;</td>';
print '<td width="50">&nbsp;</td>';
print '<td width="50">&nbsp;</td>';
print '<td class="nowrap right"><input type="text" size="1" value="" name="all_progress">%</td>'; print '<td class="nowrap right"><input type="text" size="1" value="" name="all_progress">%</td>';
print '<td colspan="4" class="right"><input class="button" type="submit" name="all_percent" value="Modifier" /></td>'; print '<td class="right"><input class="button" type="submit" name="all_percent" value="Modifier" /></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';

View File

@ -936,7 +936,7 @@ class Invoices extends DolibarrApi
*/ */
public function markAsCreditAvailable($id) public function markAsCreditAvailable($id)
{ {
if(! DolibarrApiAccess::$user->rights->facture->creer) { if( ! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401); throw new RestException(401);
} }
@ -949,89 +949,145 @@ class Invoices extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$result = $this->invoice->fetch_thirdparty(); if ($this->invoice->paye) {
if( ! $result ) { throw new RestException(500, 'Alreay payed');
throw new RestException(404, 'Thirdparty not found');
} }
if (! $this->invoice->paye) // protection against multiple submit $this->invoice->fetch($id);
{ $this->invoice->fetch_thirdparty();
$this->db->begin();
$this->invoice->fetch_lines(); // Check if there is already a discount (protection to avoid duplicate creation when resubmit post)
$discountcheck=new DiscountAbsolute($this->db);
$result=$discountcheck->fetch(0, $this->invoice->id);
$amount_ht = $amount_tva = $amount_ttc = array(); $canconvert=0;
if ($this->invoice->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc)
if (($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_STANDARD) && $this->invoice->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc)
if ($canconvert)
{
$this->db->begin();
// Loop on each vat rate $amount_ht = $amount_tva = $amount_ttc = array();
$i=0; $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
$amount_ht = array();
$amount_tva = array();
$amount_ttc = array();
foreach($this->invoice->lines as $line)
{
$amount_ht[$line->tva_tx]+=$line->total_ht;
$amount_tva[$line->tva_tx]+=$line->total_tva;
$amount_ttc[$line->tva_tx]+=$line->total_ttc;
$i++;
}
// Insert one discount by VAT rate category // Loop on each vat rate
$discount = new DiscountAbsolute($this->db); $i = 0;
if ($this->invoice->type == 2) $discount->description='(CREDIT_NOTE)'; foreach ($this->invoice->lines as $line)
elseif ($this->invoice->type == 3) $discount->description='(DEPOSIT)'; {
else { if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9
$this->error="CantConvertToReducAnInvoiceOfThisType"; { // no need to create discount if amount is null
return -1; $amount_ht[$line->tva_tx] += $line->total_ht;
} $amount_tva[$line->tva_tx] += $line->total_tva;
$discount->tva_tx=abs($this->invoice->total_ttc); $amount_ttc[$line->tva_tx] += $line->total_ttc;
$discount->fk_soc=$this->invoice->socid; $multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht;
$discount->fk_facture_source=$this->invoice->id; $multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva;
$multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc;
$i++;
}
}
$error=0; // Insert one discount by VAT rate category
foreach($amount_ht as $tva_tx => $xxx) $discount = new DiscountAbsolute($this->db);
{ if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) {
$discount->amount_ht=abs($amount_ht[$tva_tx]); $discount->description = '(CREDIT_NOTE)';
$discount->amount_tva=abs($amount_tva[$tva_tx]); }
$discount->amount_ttc=abs($amount_ttc[$tva_tx]); elseif ($this->invoice->type == Facture::TYPE_DEPOSIT) {
$discount->tva_tx=abs($tva_tx); $discount->description = '(DEPOSIT)';
}
elseif ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION) {
$discount->description = '(EXCESS RECEIVED)';
}
else {
throw new RestException(500, 'Cant convert to reduc an Invoice of this type');
}
$result=$discount->create(DolibarrApiAccess::$user); $discount->fk_soc = $this->invoice->socid;
if ($result < 0) $discount->fk_facture_source = $this->invoice->id;
{
$error++;
break;
}
}
if (! $error) $error = 0;
{
// Classe facture
$result=$this->invoice->set_paid(DolibarrApiAccess::$user);
if ($result > 0)
{
//$mesg='OK'.$discount->id;
$this->db->commit();
}
else
{
$this->db->rollback();
throw new RestException(500, 'Could not set paid');
}
}
else
{
$this->db->rollback();
throw new RestException(500, 'Discount creation error');
}
}
$result = $this->invoice->fetch($id); if ($this->invoice->type == Facture::TYPE_STANDARD || $this->invoice->type == Facture::TYPE_REPLACEMENT || $this->invoice->type == Facture::TYPE_SITUATION)
if( ! $result ) { {
throw new RestException(404, 'Invoice not found'); // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT
}
if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { // Total payments
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); $sql = 'SELECT SUM(pf.amount) as total_paiements';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
$sql.= ' WHERE pf.fk_facture = '.$this->invoice->id;
$sql.= ' AND pf.fk_paiement = p.rowid';
$sql.= ' AND p.entity IN ('.getEntity('invoice').')';
$resql = $this->db->query($sql);
if (! $resql) dol_print_error($this->db);
$res = $this->db->fetch_object($resql);
$total_paiements = $res->total_paiements;
// Total credit note and deposit
$total_creditnote_and_deposit = 0;
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
$sql .= " re.description, re.fk_facture_source";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re";
$sql .= " WHERE fk_facture = " . $this->invoice->id;
$resql = $this->db->query($sql);
if (!empty($resql)) {
while ($obj = $this->db->fetch_object($resql)) $total_creditnote_and_deposit += $obj->amount_ttc;
} else dol_print_error($this->db);
$discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $this->invoice->total_ttc;
$discount->amount_tva = 0;
$discount->tva_tx = 0;
$result = $discount->create(DolibarrApiAccess::$user);
if ($result < 0)
{
$error++;
}
}
if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE || $this->invoice->type == Facture::TYPE_DEPOSIT)
{
foreach ($amount_ht as $tva_tx => $xxx)
{
$discount->amount_ht = abs($amount_ht[$tva_tx]);
$discount->amount_tva = abs($amount_tva[$tva_tx]);
$discount->amount_ttc = abs($amount_ttc[$tva_tx]);
$discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]);
$discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]);
$discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]);
$discount->tva_tx = abs($tva_tx);
$result = $discount->create(DolibarrApiAccess::$user);
if ($result < 0)
{
$error++;
break;
}
}
}
if (empty($error))
{
if($this->invoice->type != Facture::TYPE_DEPOSIT) {
// Classe facture
$result = $this->invoice->set_paid(DolibarrApiAccess::$user);
if ($result >= 0)
{
$this->db->commit();
}
else
{
$this->db->rollback();
throw new RestException(500, 'Could not set paid');
}
} else {
$this->db->commit();
}
}
else
{
$this->db->rollback();
throw new RestException(500, 'Discount creation error');
}
} }
return $this->_cleanObjectDatas($this->invoice); return $this->_cleanObjectDatas($this->invoice);

View File

@ -965,82 +965,80 @@ class Facture extends CommonInvoice
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param int $socid Id of thirdparty * @param User $user User that clone
* @return int New id of clone * @param int $fromid Id of object to clone
* @return int New id of clone
*/ */
public function createFromClone($socid = 0) public function createFromClone(User $user, $fromid = 0)
{ {
global $user,$hookmanager, $conf; global $hookmanager;
$error=0; $error=0;
$object=new Facture($this->db);
$this->db->begin(); $this->db->begin();
// get extrafields so they will be clone $object->fetch($fromid);
foreach($this->lines as $line)
$line->fetch_optionals($line->rowid);
// Load source object
$objFrom = clone $this;
// Change socid if needed // Change socid if needed
if (! empty($socid) && $socid != $this->socid) if (! empty($this->socid) && $this->socid != $object->socid)
{ {
$objsoc = new Societe($this->db); $objsoc = new Societe($this->db);
if ($objsoc->fetch($socid)>0) if ($objsoc->fetch($this->socid)>0)
{ {
$this->socid = $objsoc->id; $object->socid = $objsoc->id;
$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); $object->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); $object->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$this->fk_project = ''; $object->fk_project = '';
$this->fk_delivery_address = ''; $object->fk_delivery_address = '';
} }
// TODO Change product price if multi-prices // TODO Change product price if multi-prices
} }
$this->id=0; $object->id=0;
$this->statut= self::STATUS_DRAFT; $object->statut= self::STATUS_DRAFT;
// Clear fields // Clear fields
$this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box $object->date = (empty($this->date) ? dol_now() : $this->date);
$this->user_author = $user->id; $object->user_author = $user->id;
$this->user_valid = ''; $object->user_valid = '';
$this->fk_facture_source = 0; $object->fk_facture_source = 0;
$this->date_creation = ''; $object->date_creation = '';
$this->date_modification = ''; $object->date_modification = '';
$this->date_validation = ''; $object->date_validation = '';
$this->ref_client = ''; $object->ref_client = '';
$this->close_code = ''; $object->close_code = '';
$this->close_note = ''; $object->close_note = '';
$this->products = $this->lines; // Tant que products encore utilise $object->products = $object->lines; // For backward compatibility
// Loop on each line of new invoice // Loop on each line of new invoice
foreach($this->lines as $i => $line) foreach($object->lines as $i => $line)
{ {
if (($this->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts
{ {
unset($this->lines[$i]); unset($object->lines[$i]);
unset($this->products[$i]); // Tant que products encore utilise unset($object->products[$i]); // Tant que products encore utilise
} }
} }
// Create clone // Create clone
$this->context['createfromclone'] = 'createfromclone'; $object->context['createfromclone'] = 'createfromclone';
$result=$this->create($user); $result=$object->create($user);
if ($result < 0) $error++; if ($result < 0) $error++;
else { else {
// copy internal contacts // copy internal contacts
if ($this->copy_linked_contact($objFrom, 'internal') < 0) if ($object->copy_linked_contact($this, 'internal') < 0)
$error++; $error++;
// copy external contacts if same company // copy external contacts if same company
elseif ($objFrom->socid == $this->socid) elseif ($this->socid == $object->socid)
{ {
if ($this->copy_linked_contact($objFrom, 'external') < 0) if ($object->copy_linked_contact($this, 'external') < 0)
$error++; $error++;
} }
} }
@ -1050,20 +1048,20 @@ class Facture extends CommonInvoice
// Hook of thirdparty module // Hook of thirdparty module
if (is_object($hookmanager)) if (is_object($hookmanager))
{ {
$parameters=array('objFrom'=>$objFrom); $parameters=array('objFrom'=>$this);
$action=''; $action='';
$reshook=$hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++; if ($reshook < 0) $error++;
} }
} }
unset($this->context['createfromclone']); unset($object->context['createfromclone']);
// End // End
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return $this->id; return $object->id;
} }
else else
{ {
@ -1556,7 +1554,7 @@ class Facture extends CommonInvoice
$line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_tva = $objp->multicurrency_total_tva;
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
$line->fetch_optionals(); $line->fetch_optionals();
$this->lines[$i] = $line; $this->lines[$i] = $line;

View File

@ -393,13 +393,12 @@ class PaymentTerm // extends CommonObject
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param User $user User making the clone
* @param int $fromid Id of object to clone * @param int $fromid Id of object to clone
* @return int New id of clone * @return int New id of clone
*/ */
public function createFromClone($fromid) public function createFromClone(User $user, $fromid)
{ {
global $user,$langs;
$error=0; $error=0;
$object=new PaymentTerm($this->db); $object=new PaymentTerm($this->db);

View File

@ -67,6 +67,11 @@ $confirm=GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoicelist'; $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoicelist';
if ($contextpage == 'poslist')
{
$_GET['optioncss'] = 'print';
}
$lineid=GETPOST('lineid', 'int'); $lineid=GETPOST('lineid', 'int');
$userid=GETPOST('userid', 'int'); $userid=GETPOST('userid', 'int');
$search_product_category=GETPOST('search_product_category', 'int'); $search_product_category=GETPOST('search_product_category', 'int');
@ -82,6 +87,7 @@ $search_montant_localtax2=GETPOST('search_montant_localtax2', 'alpha');
$search_montant_ttc=GETPOST('search_montant_ttc', 'alpha'); $search_montant_ttc=GETPOST('search_montant_ttc', 'alpha');
$search_status=GETPOST('search_status', 'intcomma'); $search_status=GETPOST('search_status', 'intcomma');
$search_paymentmode=GETPOST('search_paymentmode', 'int'); $search_paymentmode=GETPOST('search_paymentmode', 'int');
$search_paymentterms=GETPOST('search_paymentterms', 'int');
$search_town=GETPOST('search_town', 'alpha'); $search_town=GETPOST('search_town', 'alpha');
$search_zip=GETPOST('search_zip', 'alpha'); $search_zip=GETPOST('search_zip', 'alpha');
$search_state=trim(GETPOST("search_state")); $search_state=trim(GETPOST("search_state"));
@ -162,6 +168,7 @@ $arrayfields=array(
'country.code_iso'=>array('label'=>"Country", 'checked'=>0), 'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1), 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1),
'f.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>1),
'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1")), 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1")),
@ -214,6 +221,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
$search_montant_ttc=''; $search_montant_ttc='';
$search_status=''; $search_status='';
$search_paymentmode=''; $search_paymentmode='';
$search_paymentterms='';
$search_town=''; $search_town='';
$search_zip=""; $search_zip="";
$search_state=""; $search_state="";
@ -355,11 +363,9 @@ $facturestatic=new Facture($db);
$formcompany=new FormCompany($db); $formcompany=new FormCompany($db);
$thirdpartystatic=new Societe($db); $thirdpartystatic=new Societe($db);
// llxHeader('',$langs->trans('CustomersInvoices'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
$sql = 'SELECT'; $sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; $sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,';
$sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
$sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,';
$sql.= ' f.paye as paye, f.fk_statut,'; $sql.= ' f.paye as paye, f.fk_statut,';
@ -451,6 +457,7 @@ if ($search_status != '-1' && $search_status != '')
} }
} }
if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode); if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode);
if ($search_paymentterms > 0) $sql .= " AND f.fk_cond_reglement = ".$db->escape($search_paymentterms);
$sql.= dolSqlDateFilter("f.datef", $search_day, $search_month, $search_year); $sql.= dolSqlDateFilter("f.datef", $search_day, $search_month, $search_year);
$sql.= dolSqlDateFilter("f.date_lim_reglement", $search_day_lim, $search_month_lim, $search_year_lim); $sql.= dolSqlDateFilter("f.date_lim_reglement", $search_day_lim, $search_month_lim, $search_year_lim);
if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'";
@ -468,7 +475,7 @@ $sql.=$hookmanager->resPrint;
if (! $sall) if (! $sall)
{ {
$sql.= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.total, f.tva, f.total_ttc,'; $sql.= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,';
$sql.= ' f.localtax1, f.localtax2,'; $sql.= ' f.localtax1, f.localtax2,';
$sql.= ' f.datef, f.date_lim_reglement,'; $sql.= ' f.datef, f.date_lim_reglement,';
$sql.= ' f.paye, f.fk_statut,'; $sql.= ' f.paye, f.fk_statut,';
@ -562,6 +569,7 @@ if ($resql)
if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
if ($search_status != '') $param.='&search_status='.urlencode($search_status); if ($search_status != '') $param.='&search_status='.urlencode($search_status);
if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode); if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode);
if ($search_paymentterms > 0) $param.='&search_paymentterms='.urlencode($search_paymentterms);
if ($show_files) $param.='&show_files='.urlencode($show_files); if ($show_files) $param.='&show_files='.urlencode($show_files);
if ($option) $param.="&search_option=".urlencode($option); if ($option) $param.="&search_option=".urlencode($option);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
@ -776,6 +784,13 @@ if ($resql)
$form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10); $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10);
print '</td>'; print '</td>';
} }
// Payment terms
if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
{
print '<td class="liste_titre" align="left">';
$form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', -1, 1, 1);
print '</td>';
}
if (! empty($arrayfields['f.total_ht']['checked'])) if (! empty($arrayfields['f.total_ht']['checked']))
{ {
// Amount // Amount
@ -869,6 +884,7 @@ if ($resql)
if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder);
if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder);
if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder);
if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder);
@ -937,7 +953,12 @@ if ($resql)
$totalpay = $facturestatic->total_ttc - $remaintopay; $totalpay = $facturestatic->total_ttc - $remaintopay;
} }
print '<tr class="oddeven">'; print '<tr class="oddeven"';
if ($contextpage == 'poslist')
{
print ' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.'\', function() {parent.$.colorbox.close();});"';
}
print '>';
if (! empty($arrayfields['f.ref']['checked'])) if (! empty($arrayfields['f.ref']['checked']))
{ {
print '<td class="nowrap">'; print '<td class="nowrap">';
@ -945,7 +966,14 @@ if ($resql)
print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowraponall">'; print '<td class="nobordernopadding nowraponall">';
print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); if ($contextpage == 'poslist')
{
print $obj->ref;
}
else
{
print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1);
}
print empty($obj->increment)?'':' ('.$obj->increment.')'; print empty($obj->increment)?'':' ('.$obj->increment.')';
$filename=dol_sanitizeFileName($obj->ref); $filename=dol_sanitizeFileName($obj->ref);
@ -1081,6 +1109,15 @@ if ($resql)
if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['nbfield']++;
} }
// Payment terms
if (! empty($arrayfields['f.fk_cond_reglement']['checked']))
{
print '<td>';
$form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Amount HT // Amount HT
if (! empty($arrayfields['f.total_ht']['checked'])) if (! empty($arrayfields['f.total_ht']['checked']))
{ {

View File

@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadlangs(array('companies', 'other', 'compta')); $langs->loadlangs(array('companies', 'other', 'bills', 'compta'));
$date_startmonth=GETPOST('date_startmonth'); $date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday'); $date_startday=GETPOST('date_startday');

View File

@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('companies', 'other', 'compta')); $langs->loadLangs(array('companies', 'other', 'bills', 'compta'));
$date_startmonth=GETPOST('date_startmonth'); $date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday'); $date_startday=GETPOST('date_startday');

View File

@ -97,9 +97,6 @@ class Localtax extends CommonObject
$this->amount=trim($this->amount); $this->amount=trim($this->amount);
$this->label=trim($this->label); $this->label=trim($this->label);
$this->note=trim($this->note); $this->note=trim($this->note);
$this->fk_bank=trim($this->fk_bank);
$this->fk_user_creat=trim($this->fk_user_creat);
$this->fk_user_modif=trim($this->fk_user_modif);
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."localtax(";
@ -121,9 +118,9 @@ class Localtax extends CommonObject
$sql.= " '".$this->db->escape($this->amount)."',"; $sql.= " '".$this->db->escape($this->amount)."',";
$sql.= " '".$this->db->escape($this->label)."',"; $sql.= " '".$this->db->escape($this->label)."',";
$sql.= " '".$this->db->escape($this->note)."',"; $sql.= " '".$this->db->escape($this->note)."',";
$sql.= " ".($this->fk_bank <= 0 ? "NULL" : "'".$this->db->escape($this->fk_bank)."'").","; $sql.= " ".($this->fk_bank <= 0 ? "NULL" : (int) $this->fk_bank).",";
$sql.= " '".$this->db->escape($this->fk_user_creat)."',"; $sql.= " ".((int) $this->fk_user_creat).",";
$sql.= " '".$this->db->escape($this->fk_user_modif)."'"; $sql.= " ".((int) $this->fk_user_modif);
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
@ -173,9 +170,6 @@ class Localtax extends CommonObject
$this->amount=trim($this->amount); $this->amount=trim($this->amount);
$this->label=trim($this->label); $this->label=trim($this->label);
$this->note=trim($this->note); $this->note=trim($this->note);
$this->fk_bank=trim($this->fk_bank);
$this->fk_user_creat=trim($this->fk_user_creat);
$this->fk_user_modif=trim($this->fk_user_modif);
$this->db->begin(); $this->db->begin();
@ -188,9 +182,9 @@ class Localtax extends CommonObject
$sql.= " amount=".price2num($this->amount).","; $sql.= " amount=".price2num($this->amount).",";
$sql.= " label='".$this->db->escape($this->label)."',"; $sql.= " label='".$this->db->escape($this->label)."',";
$sql.= " note='".$this->db->escape($this->note)."',"; $sql.= " note='".$this->db->escape($this->note)."',";
$sql.= " fk_bank=".$this->fk_bank.","; $sql.= " fk_bank=".(int) $this->fk_bank.",";
$sql.= " fk_user_creat=".$this->fk_user_creat.","; $sql.= " fk_user_creat=".(int) $this->fk_user_creat.",";
$sql.= " fk_user_modif=".$this->fk_user_modif; $sql.= " fk_user_modif=".(int) $this->fk_user_modif;
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG); dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -299,7 +293,6 @@ class Localtax extends CommonObject
if ($result < 0) return -1; if ($result < 0) return -1;
// End call triggers // End call triggers
$sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax";
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
@ -324,6 +317,8 @@ class Localtax extends CommonObject
*/ */
public function initAsSpecimen() public function initAsSpecimen()
{ {
global $user;
$this->id=0; $this->id=0;
$this->tms=''; $this->tms='';
@ -333,9 +328,9 @@ class Localtax extends CommonObject
$this->amount=''; $this->amount='';
$this->label=''; $this->label='';
$this->note=''; $this->note='';
$this->fk_bank=''; $this->fk_bank=0;
$this->fk_user_creat=''; $this->fk_user_creat=$user->id;
$this->fk_user_modif=''; $this->fk_user_modif=$user->id;
} }
@ -347,7 +342,6 @@ class Localtax extends CommonObject
*/ */
public function solde($year = 0) public function solde($year = 0)
{ {
$reglee = $this->localtax_sum_reglee($year); $reglee = $this->localtax_sum_reglee($year);
$payee = $this->localtax_sum_payee($year); $payee = $this->localtax_sum_payee($year);
@ -528,7 +522,7 @@ class Localtax extends CommonObject
$sql.= "'".$this->db->idate($this->datev)."'," . $this->amount; $sql.= "'".$this->db->idate($this->datev)."'," . $this->amount;
if ($this->note) $sql.=", '".$this->db->escape($this->note)."'"; if ($this->note) $sql.=", '".$this->db->escape($this->note)."'";
if ($this->label) $sql.=", '".$this->db->escape($this->label)."'"; if ($this->label) $sql.=", '".$this->db->escape($this->label)."'";
$sql.=", '".$user->id."', NULL"; $sql.=", ".((int) $user->id).", NULL";
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::addPayment", LOG_DEBUG); dol_syslog(get_class($this)."::addPayment", LOG_DEBUG);

View File

@ -773,7 +773,7 @@ class RemiseCheque extends CommonObject
* Reopen linked invoices and create a new negative payment. * Reopen linked invoices and create a new negative payment.
* *
* @param int $bank_id Id of bank transaction line concerned * @param int $bank_id Id of bank transaction line concerned
* @param date $rejection_date Date to use on the negative payment * @param integer $rejection_date Date to use on the negative payment
* @return int Id of negative payment line created * @return int Id of negative payment line created
*/ */
public function rejectCheck($bank_id, $rejection_date) public function rejectCheck($bank_id, $rejection_date)

View File

@ -58,13 +58,13 @@ class Paiement extends CommonObject
/** /**
* @deprecated * @deprecated
* @see amount, amounts * @see $amount, $amounts
*/ */
public $total; public $total;
/** /**
* @deprecated * @deprecated
* @see amount, amounts * @see $amount, $amounts
*/ */
public $montant; public $montant;

View File

@ -26,7 +26,7 @@
/** /**
* \file htdocs/compta/paiement/list.php * \file htdocs/compta/paiement/list.php
* \ingroup compta * \ingroup compta
* \brief Page liste des paiements des factures clients * \brief Payment page for customer invoices
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
@ -37,9 +37,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('bills', 'compta', 'companies')); $langs->loadLangs(array('bills', 'banks', 'compta', 'companies'));
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$optioncss = GETPOST('optioncss', 'alpha');
// Security check
$facid = GETPOST('facid', 'int'); $facid = GETPOST('facid', 'int');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$userid = GETPOST('userid', 'int'); $userid = GETPOST('userid', 'int');
@ -47,6 +50,7 @@ $day = GETPOST('day', 'int');
$month = GETPOST('month', 'int'); $month = GETPOST('month', 'int');
$year = GETPOST('year', 'int'); $year = GETPOST('year', 'int');
// Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'facture', $facid, ''); $result = restrictedArea($user, 'facture', $facid, '');
@ -83,7 +87,7 @@ $arrayfields=array();
* Actions * Actions
*/ */
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers 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_ref=""; $search_ref="";
$search_account=""; $search_account="";
@ -94,22 +98,22 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
$day=''; $day='';
$year=''; $year='';
$month=''; $month='';
$search_array_options=array();
} }
/* /*
* View * View
*/ */
llxHeader('', $langs->trans('ListPayment'));
$form=new Form($db); $form=new Form($db);
$formother=new FormOther($db); $formother=new FormOther($db);
if (GETPOST("orphelins")) llxHeader('', $langs->trans('ListPayment'));
if (GETPOST("orphelins", "alpha"))
{ {
// Paiements lies a aucune facture (pour aide au diagnostic) // Payments not linked to an invoice. Should not happend. For debug only.
$sql = "SELECT p.rowid, p.ref, p.datep as dp, p.amount,"; $sql = "SELECT p.rowid, p.ref, p.datep as dp, p.amount,";
$sql.= " p.statut, p.num_paiement,"; $sql.= " p.statut, p.num_paiement,";
$sql.= " c.code as paiement_code"; $sql.= " c.code as paiement_code";
@ -197,7 +201,6 @@ $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0;
$param=''; $param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
@ -213,6 +216,7 @@ if ($resql)
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
@ -228,18 +232,18 @@ if ($resql)
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>'; print '</td>';
print '<td class="liste_titre" align="center">'; print '<td class="liste_titre center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">'; if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.dol_escape_htmltag($day).'">';
print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month" value="'.dol_escape_htmltag($month).'">'; print '<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month" value="'.dol_escape_htmltag($month).'">';
$formother->select_year($year?$year:-1, 'year', 1, 20, 5); $formother->select_year($year?$year:-1, 'year', 1, 20, 5);
print '</td>'; print '</td>';
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre">';
print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">'; print '<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
print '</td>'; print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1); $form->select_types_paiements($search_paymenttype, 'search_paymenttype', '', 2, 1, 1);
print '</td>'; print '</td>';
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre">';
print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">'; print '<input class="flat" type="text" size="4" name="search_payment_num" value="'.dol_escape_htmltag($search_payment_num).'">';
print '</td>'; print '</td>';
if (! empty($conf->banque->enabled)) if (! empty($conf->banque->enabled))
@ -264,7 +268,7 @@ if ($resql)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "dp", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "dp", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "c.libelle", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "c.libelle", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "p.num_paiement", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "p.num_paiement", "", $param, "", $sortfield, $sortorder);
@ -283,6 +287,8 @@ if ($resql)
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
$i = 0;
$totalarray=array();
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
@ -290,35 +296,39 @@ if ($resql)
$paymentstatic->id=$objp->rowid; $paymentstatic->id=$objp->rowid;
$paymentstatic->ref=$objp->ref; $paymentstatic->ref=$objp->ref;
$companystatic->id=$objp->socid;
$companystatic->name=$objp->name;
$companystatic->email=$objp->email;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
print $paymentstatic->getNomUrl(1); print $paymentstatic->getNomUrl(1);
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++;
// Date // Date
$dateformatforpayment = 'day'; $dateformatforpayment = 'day';
if (! empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment='dayhour'; if (! empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) $dateformatforpayment='dayhour';
print '<td align="center">'.dol_print_date($db->jdate($objp->dp), $dateformatforpayment).'</td>'; print '<td align="center">'.dol_print_date($db->jdate($objp->dp), $dateformatforpayment).'</td>';
if (! $i) $totalarray['nbfield']++;
// Thirdparty // Thirdparty
print '<td>'; print '<td>';
if ($objp->socid > 0) if ($objp->socid > 0)
{ {
$companystatic->id=$objp->socid;
$companystatic->name=$objp->name;
$companystatic->email=$objp->email;
print $companystatic->getNomUrl(1, '', 24); print $companystatic->getNomUrl(1, '', 24);
} }
else print '&nbsp;';
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++;
// Type // Type
print '<td>'.$langs->trans("PaymentTypeShort".$objp->paiement_code).'</td>'; print '<td>'.$langs->trans("PaymentTypeShort".$objp->paiement_code).'</td>';
if (! $i) $totalarray['nbfield']++;
// Payment number // Payment number
print '<td>'.$objp->num_paiement.'</td>'; print '<td>'.$objp->num_paiement.'</td>';
if (! $i) $totalarray['nbfield']++;
// Account // Account
if (! empty($conf->banque->enabled)) if (! empty($conf->banque->enabled))
@ -338,11 +348,15 @@ if ($resql)
print $accountstatic->getNomUrl(1); print $accountstatic->getNomUrl(1);
} }
else print '&nbsp;';
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++;
} }
// Amount // Amount
print '<td class="right">'.price($objp->amount).'</td>'; print '<td class="right">'.price($objp->amount).'</td>';
if (! $i) $totalarray['nbfield']++;
$totalarray['pos'][7]='amount';
$totalarray['val']['amount'] += $objp->amount;
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
{ {
@ -351,13 +365,39 @@ if ($resql)
print $paymentstatic->LibStatut($objp->statut, 5); print $paymentstatic->LibStatut($objp->statut, 5);
if ($objp->statut == 0) print '</a>'; if ($objp->statut == 0) print '</a>';
print '</td>'; print '</td>';
if (! $i) $totalarray['nbfield']++;
} }
print '<td>&nbsp;</td>'; print '<td></td>';
print '</tr>'; if (! $i) $totalarray['nbfield']++;
print '</tr>';
$i++; $i++;
} }
// Show total line
if (isset($totalarray['pos']))
{
print '<tr class="liste_total">';
$i=0;
while ($i < $totalarray['nbfield'])
{
$i++;
if (! empty($totalarray['pos'][$i])) print '<td class="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
else
{
if ($i == 1)
{
if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>';
else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
}
else print '<td></td>';
}
}
print '</tr>';
}
print "</table>\n"; print "</table>\n";
print "</div>"; print "</div>";
print "</form>\n"; print "</form>\n";

View File

@ -115,13 +115,9 @@ class PaymentSalary extends CommonObject
$error=0; $error=0;
// Clean parameters // Clean parameters
$this->fk_user=trim($this->fk_user);
$this->amount=trim($this->amount); $this->amount=trim($this->amount);
$this->label=trim($this->label); $this->label=trim($this->label);
$this->note=trim($this->note); $this->note=trim($this->note);
$this->fk_bank=trim($this->fk_bank);
$this->fk_user_author=trim($this->fk_user_author);
$this->fk_user_modif=trim($this->fk_user_modif);
// Check parameters // Check parameters
if (empty($this->fk_user) || $this->fk_user < 0) if (empty($this->fk_user) || $this->fk_user < 0)
@ -140,16 +136,16 @@ class PaymentSalary extends CommonObject
$sql.= " datep='".$this->db->idate($this->datep)."',"; $sql.= " datep='".$this->db->idate($this->datep)."',";
$sql.= " datev='".$this->db->idate($this->datev)."',"; $sql.= " datev='".$this->db->idate($this->datev)."',";
$sql.= " amount=".price2num($this->amount).","; $sql.= " amount=".price2num($this->amount).",";
$sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; $sql.= " fk_projet=".((int) $this->fk_project).",";
$sql.= " fk_typepayment=".$this->fk_typepayment."',"; $sql.= " fk_typepayment=".$this->fk_typepayment."',";
$sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; $sql.= " num_payment='".$this->db->escape($this->num_payment)."',";
$sql.= " label='".$this->db->escape($this->label)."',"; $sql.= " label='".$this->db->escape($this->label)."',";
$sql.= " datesp='".$this->db->idate($this->datesp)."',"; $sql.= " datesp='".$this->db->idate($this->datesp)."',";
$sql.= " dateep='".$this->db->idate($this->dateep)."',"; $sql.= " dateep='".$this->db->idate($this->dateep)."',";
$sql.= " note='".$this->db->escape($this->note)."',"; $sql.= " note='".$this->db->escape($this->note)."',";
$sql.= " fk_bank=".($this->fk_bank > 0 ? "'".$this->db->escape($this->fk_bank)."'":"null").","; $sql.= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").",";
$sql.= " fk_user_author=".$this->fk_user_author.","; $sql.= " fk_user_author=".((int) $this->fk_user_author).",";
$sql.= " fk_user_modif=".$this->fk_user_modif; $sql.= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null');
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;

View File

@ -121,7 +121,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes')
$result=$object->delete($user); $result=$object->delete($user);
if ($result > 0) if ($result > 0)
{ {
header("Location: index.php"); header("Location: list.php");
exit; exit;
} }
else else

View File

@ -346,15 +346,14 @@ class Cchargesociales
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param int $fromid Id of object to clone * @param User $user User making the clone
* * @param int $fromid Id of object to clone
* @return int New id of clone * @return int New id of clone
*/ */
public function createFromClone($fromid) public function createFromClone(User $user, $fromid)
{ {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
global $user;
$error = 0; $error = 0;
$object = new Cchargesociales($this->db); $object = new Cchargesociales($this->db);

View File

@ -448,13 +448,12 @@ class PaymentSocialContribution extends CommonObject
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param User $user User making the clone
* @param int $fromid Id of object to clone * @param int $fromid Id of object to clone
* @return int New id of clone * @return int New id of clone
*/ */
public function createFromClone($fromid) public function createFromClone(User $user, $fromid)
{ {
global $user,$langs;
$error=0; $error=0;
$object=new PaymentSocialContribution($this->db); $object=new PaymentSocialContribution($this->db);

Some files were not shown because too many files have changed in this diff Show More