Merge branch 'develop' into develop#5

This commit is contained in:
Hystepik 2021-03-01 09:03:38 +01:00 committed by GitHub
commit 460bc2dbde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1748 changed files with 139730 additions and 112283 deletions

View File

@ -18,7 +18,11 @@ 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:
* The ICS value for direct debit or credit transfer is now store on each bank account instead of into the global setup. * The ICS value for direct debit or credit transfer is now store on each bank account instead of into the global setup.
* API /setup/shipment_methods has been replaced with API /setup/shipping_methods
* Field "tva" renamed into "total_tva" in llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency
* Field "total" renamed into "total_ttc" in llx_propal, llx_supplier_proposal for better field name consistency
* If your database is PostgreSql, you must use version 9.1.0 or more (Dolibarr need the SQL function CONCAT)
* If your database is MySql or MariaDB, you need at least version 5.1
***** ChangeLog for 13.0.1 compared to 13.0.0 ***** ***** ChangeLog for 13.0.1 compared to 13.0.0 *****
@ -28,18 +32,19 @@ FIX: 11.0 when a mandatory extrafield of type sellist contains '0' it should be
FIX: 11.0 when a new intervention is created from an object, a new $extrafields object is instantiated but not initialized FIX: 11.0 when a new intervention is created from an object, a new $extrafields object is instantiated but not initialized
FIX: create MO, Column 'tms' cannot be null FIX: create MO, Column 'tms' cannot be null
FIX: #14290 #15900 FIX: #14290 #15900
FIX: #16076 FIX: #16076 patch user/list.php for extrafields
FIX: #16077 FIX: #16077 patch wrong timezone
FIX: #16079 FIX: #16079 error of service date at duplicated invoice
FIX: #16080 FIX: #16080 mailing list title
FIX: 16084 FIX: #16084 DB error at projects
FIX: #16107 FIX: #16107
FIX: #16118 Timezone problem on some fields FIX: #16118 Timezone problem on some fields
FIX: #16131 FIX: #16131
FIX: #16135 FIX: #16135
FIX: #16143 FIX: #16143
FIX: #16156 FIX: #16156
FIX: #16160 FIX: #16160
FIX: #16165 Create customer discount without vat
FIX: #16185 FIX: #16185
FIX: #16189, fix download/see check deposit PDF FIX: #16189, fix download/see check deposit PDF
FIX: #16215 FIX: #16215
@ -64,13 +69,17 @@ FIX: select default mail template
FIX: Select transport mode function when creating a supplier invoice and add unique key to the table llx_c_transport_mode in migrate sql FIX: Select transport mode function when creating a supplier invoice and add unique key to the table llx_c_transport_mode in migrate sql
FIX: Merge of thirdparties : "unknow column fk_soc" + "Delivery" label FIX: Merge of thirdparties : "unknow column fk_soc" + "Delivery" label
FIX: SQL Error in group by with postgres or mysql strict mode FIX: SQL Error in group by with postgres or mysql strict mode
FIX: takepos : load date function FIX: TakePOS : load date function
FIX: Timeout during import FIX: Timeout during import
FIX: Trigger on expense report was not fired FIX: Trigger on expense report was not fired
FIX: User creation of expense report not visible FIX: User creation of expense report not visible
FIX: warning when adding a line if $remise_percent is an empty string FIX: warning when adding a line if $remise_percent is an empty string
FIX: status late on purchase orders FIX: status late on purchase orders
FIX: ODT generation very slow FIX: ODT generation very slow
FIX: amount in summary of report
FIX: vat value when code contains number
FIX: payment term label on PDF
FIX: date selector when using reduced year (like on smartphone)
***** ChangeLog for 13.0.0 compared to 12.0.0 ***** ***** ChangeLog for 13.0.0 compared to 12.0.0 *****
@ -321,6 +330,63 @@ Following changes may create regressions for some external modules, but were nec
* Dolibarr v13 is still compatible with any PHP version between 5.6.0 and 7.4.*; Unit tests are OK with PHP 8.0 but some warnings or troubles may appears with PHP 8.0. * Dolibarr v13 is still compatible with any PHP version between 5.6.0 and 7.4.*; Unit tests are OK with PHP 8.0 but some warnings or troubles may appears with PHP 8.0.
* All your Ajax services must contains such a line at begin of file: if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal * All your Ajax services must contains such a line at begin of file: if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
***** ChangeLog for 12.0.5 compared to 12.0.4 *****
FIX: before crediting a withdrawal receipt, check whether it has been credited already
FIX: mandatory extrafields of type sellist
FIX: when a mandatory extrafield of type sellist contains '0' it should be considered empty and trigger an error message upon insertion
FIX: when a new intervention is created from an object, a new $extrafields object is instantiated but not initialized
FIX: "openall" filter on ticket list does not include read tickets
FIX: ticket - extrafields of type 'date' are not saved
FIX: ticket - the "openall" filter on the ticket list does not include tickets with status READ
FIX: #14290 #15900
FIX: #15388 #15891
FIX: #15465 External user sees last 5 shipments to other customers in the dashboard
FIX: #15629
FIX: #15751 Miscellaneous payment type change to 0 after updating subledger account
FIX: #15946
FIX: #15966 #15967
FIX: Accountancy - Fix some problems on CEGID export
FIX: Accountancy - label_operation is used instead of label_compte
FIX: Accountancy - Retire entire opening balance feature
FIX: add autofix of count of email target when data is corrupted
FIX: add categories params on llxHeader filter
FIX: Add critical price patch from 12 to 11.
FIX: Bad cleaning of VAT rate when numbers are into code
FIX: Bad dates filtering in the ticket list causes sql error
FIX: balance starting and ending fiscal month #14197
FIX: bom line unit display #13831
FIX: cash fence for takepos with multientity
FIX: Check of customer/vendor code fails in some cases
FIX: create ticket : thirdparty/contact notification #15629
FIX: Creation of thirdparty when setup is empty
FIX: Dates of sales start in TakePOS
FIX: dupliacete customer or supplier code must be error dipslayed with new code proposed
FIX: Export FEC - Force Carriage Return Line Feed
FIX: Facture Situation Out : status condition
FIX: Filter on date of next generation on template invoices
FIX: Fix detect dispatched product and set to received completely when the supplier order have services (support STOCK_SUPPORTS_SERVICES)
FIX: Invoice Situation Out : status condition
FIX: issue 15659 : Missing test if supplier conf is enabled
FIX: link to create event when task is in a project with a thirdparty
FIX: Localtax must be converted with price2num
FIX: manage price min for PRODUIT_CUSTOMER_PRICES
FIX: missing GETPOST parameters on card_presend.tpl.php
FIX: missing socid into link to create event from project agenda tab
FIX: Must delete extrafields before main table on product deletion.
FIX: (path) htdocs removed
FIX: php alert sms.php
FIX: right to show VAT rate in product list
FIX: select default mail template
FIX: Timeout during import
FIX: update order by api
FIX: useless tracking number displayed on pdf if empty issue #14501
FIX: Visible date of payment
FIX: warning when adding a line if $remise_percent is an empty string
FIX: When creating a new POS sell, the creation date must be modified.
FIX: wrong name for search status param issue #15516
***** ChangeLog for 12.0.4 compared to 12.0.3 ***** ***** ChangeLog for 12.0.4 compared to 12.0.3 *****
FIX: make formConfirm an addreplace-type hook FIX: make formConfirm an addreplace-type hook
FIX: regex to remove 'action' parameter: taking feedback from PR#15213 into account FIX: regex to remove 'action' parameter: taking feedback from PR#15213 into account

View File

@ -12,7 +12,7 @@ This file contains some policies about the security reports on Dolibarr ERP CRM
## Reporting a Vulnerability ## Reporting a Vulnerability
To report a vulnerability, please use GitHub security advisory (alternatively send an email to security@dolibarr.org) To report a vulnerability, please use GitHub security advisory at https://github.com/Dolibarr/dolibarr/security/advisories/new (or alternatively send an email to security@dolibarr.org)
## Hunting vulnerabilities on Dolibarr ## Hunting vulnerabilities on Dolibarr

View File

@ -153,6 +153,7 @@ $files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom
$regextoinclude='\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$'; $regextoinclude='\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs $regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname'); $files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname');
$dir=''; $dir='';
$needtoclose=0; $needtoclose=0;
foreach ($files as $filetmp) { foreach ($files as $filetmp) {
@ -160,9 +161,10 @@ foreach ($files as $filetmp) {
//$newdir = str_replace(dirname(__FILE__).'/../htdocs', '', dirname($file)); //$newdir = str_replace(dirname(__FILE__).'/../htdocs', '', dirname($file));
$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file)); $newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
if ($newdir!=$dir) { if ($newdir!=$dir) {
if ($needtoclose) if ($needtoclose) {
fputs($fp, ' </dir>'."\n"); fputs($fp, ' </dir>'."\n");
fputs($fp, ' <dir name="'.$newdir.'" >'."\n"); }
fputs($fp, ' <dir name="'.$newdir.'">'."\n");
$dir = $newdir; $dir = $newdir;
$needtoclose=1; $needtoclose=1;
} }

View File

@ -579,7 +579,6 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/timesheet*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/timesheet*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/webmail*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/webmail*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/workstation*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/allscreen*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/allscreen*`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`;
@ -624,7 +623,6 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_*`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/vendor`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/vendor`;

View File

@ -212,6 +212,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/product %_datadir/dolibarr/htdocs/product
%_datadir/dolibarr/htdocs/projet %_datadir/dolibarr/htdocs/projet
%_datadir/dolibarr/htdocs/public %_datadir/dolibarr/htdocs/public
%_datadir/dolibarr/htdocs/recruitment
%_datadir/dolibarr/htdocs/reception %_datadir/dolibarr/htdocs/reception
%_datadir/dolibarr/htdocs/resource %_datadir/dolibarr/htdocs/resource
%_datadir/dolibarr/htdocs/salaries %_datadir/dolibarr/htdocs/salaries

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

View File

@ -49,20 +49,30 @@ $search_pcgtype = GETPOST('search_pcgtype', 'alpha');
$chartofaccounts = GETPOST('chartofaccounts', 'int'); $chartofaccounts = GETPOST('chartofaccounts', 'int');
// Security check // Security check
if ($user->socid > 0) accessforbidden(); if ($user->socid > 0) {
if (!$user->rights->accounting->chartofaccount) accessforbidden(); accessforbidden();
}
if (!$user->rights->accounting->chartofaccount) {
accessforbidden();
}
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) $sortfield = "aa.account_number"; if (!$sortfield) {
if (!$sortorder) $sortorder = "ASC"; $sortfield = "aa.account_number";
}
if (!$sortorder) {
$sortorder = "ASC";
}
$arrayfields = array( $arrayfields = array(
'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
@ -74,7 +84,9 @@ $arrayfields = array(
'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
); );
if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['aa.reconcilable']); if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
unset($arrayfields['aa.reconcilable']);
}
$accounting = new AccountingAccount($db); $accounting = new AccountingAccount($db);
@ -84,21 +96,27 @@ $accounting = new AccountingAccount($db);
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha')) {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{ if (!empty($cancel)) {
if (!empty($cancel)) $action = ''; $action = '';
}
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All 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 test are required to be compatible with all browsers
{
$search_account = ""; $search_account = "";
$search_label = ""; $search_label = "";
$search_labelshort = ""; $search_labelshort = "";
@ -107,23 +125,21 @@ if (empty($reshook))
$search_array_options = array(); $search_array_options = array();
} }
if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on
|| (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) { // a submit of form is done and chartofaccounts combo has been modified
{ if ($chartofaccounts > 0) {
if ($chartofaccounts > 0)
{
// Get language code for this $chartofaccounts // Get language code for this $chartofaccounts
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a';
$sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$country_code = $obj->code; $country_code = $obj->code;
} else dol_print_error($db); } else {
dol_print_error($db);
}
// Try to load sql file // Try to load sql file
if ($country_code) if ($country_code) {
{
$sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql'; $sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql';
$offsetforchartofaccount = 0; $offsetforchartofaccount = 0;
@ -131,16 +147,14 @@ if (empty($reshook))
// and pass CCCNNNNN + (num of company * 100 000 000) as offset to the run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value. // and pass CCCNNNNN + (num of company * 100 000 000) as offset to the run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value.
// This is to be sure there is no conflict for each chart of account, whatever is country, whatever is company when multicompany is used. // This is to be sure there is no conflict for each chart of account, whatever is country, whatever is company when multicompany is used.
$tmp = file_get_contents($sqlfile); $tmp = file_get_contents($sqlfile);
if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg)) if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg)) {
{
$offsetforchartofaccount += $reg[1]; $offsetforchartofaccount += $reg[1];
} }
$offsetforchartofaccount += ($conf->entity * 100000000); $offsetforchartofaccount += ($conf->entity * 100000000);
$result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount); $result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount);
if ($result > 0) if ($result > 0) {
{
setEventMessages($langs->trans("ChartLoaded"), null, 'mesgs'); setEventMessages($langs->trans("ChartLoaded"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings'); setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings');
@ -198,8 +212,11 @@ $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.a
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity;
if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; if ($db->type == 'pgsql') {
else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
} else {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
}
$sql .= " WHERE asy.rowid = ".$pcgver; $sql .= " WHERE asy.rowid = ".$pcgver;
//print $sql; //print $sql;
if (strlen(trim($search_account))) { if (strlen(trim($search_account))) {
@ -224,31 +241,38 @@ if (strlen(trim($search_account))) {
$search_account_tmp_clean = $search_account_tmp; $search_account_tmp_clean = $search_account_tmp;
$search_account_clean = $search_account; $search_account_clean = $search_account;
$startchar = '%'; $startchar = '%';
if (strpos($search_account_tmp, '^') === 0) if (strpos($search_account_tmp, '^') === 0) {
{
$startchar = ''; $startchar = '';
$search_account_tmp_clean = preg_replace('/^\^/', '', $search_account_tmp); $search_account_tmp_clean = preg_replace('/^\^/', '', $search_account_tmp);
$search_account_clean = preg_replace('/^\^/', '', $search_account); $search_account_clean = preg_replace('/^\^/', '', $search_account);
} }
$sql .= " AND (aa.account_number LIKE '".$db->escape($startchar.$search_account_tmp_clean)."'"; $sql .= " AND (aa.account_number LIKE '".$db->escape($startchar.$search_account_tmp_clean)."'";
$sql .= " OR aa.account_number LIKE '".$db->escape($startchar.$search_account_clean)."%')"; $sql .= " OR aa.account_number LIKE '".$db->escape($startchar.$search_account_clean)."%')";
} else $sql .= natural_search("aa.account_number", $search_account_tmp); } else {
$sql .= natural_search("aa.account_number", $search_account_tmp);
}
} }
} }
if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); if (strlen(trim($search_label))) {
if (strlen(trim($search_labelshort))) $sql .= natural_search("aa.labelshort", $search_labelshort); $sql .= natural_search("aa.label", $search_label);
if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') $sql .= natural_search("aa.account_parent", $search_accountparent, 2); }
if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype); if (strlen(trim($search_labelshort))) {
$sql .= natural_search("aa.labelshort", $search_labelshort);
}
if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') {
$sql .= natural_search("aa.account_parent", $search_accountparent, 2);
}
if (strlen(trim($search_pcgtype))) {
$sql .= natural_search("aa.pcg_type", $search_pcgtype);
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -259,22 +283,36 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/admin/account.php:: $sql='.$sql); dol_syslog('accountancy/admin/account.php:: $sql='.$sql);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($search_account) $param .= '&search_account='.urlencode($search_account); }
if ($search_label) $param .= '&search_label='.urlencode($search_label); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort); $param .= '&limit='.urlencode($limit);
if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent); }
if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); if ($search_account) {
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); $param .= '&search_account='.urlencode($search_account);
}
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_labelshort) {
$param .= '&search_labelshort='.urlencode($search_labelshort);
}
if ($search_accountparent > 0 || $search_accountparent == '0') {
$param .= '&search_accountparent='.urlencode($search_accountparent);
}
if ($search_pcgtype) {
$param .= '&search_pcgtype='.urlencode($search_pcgtype);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
{
print '<!-- Add javascript to reload page when we click "Change plan" --> print '<!-- Add javascript to reload page when we click "Change plan" -->
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
@ -288,7 +326,9 @@ if ($resql)
} }
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
@ -322,7 +362,9 @@ if ($resql)
$i++; $i++;
} }
} else dol_print_error($db); } else {
dol_print_error($db);
}
print "</select>"; print "</select>";
print ajax_combobox("chartofaccounts"); print ajax_combobox("chartofaccounts");
print '<input type="'.(empty($conf->use_javascript_ajax) ? 'submit' : 'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">'; print '<input type="'.(empty($conf->use_javascript_ajax) ? 'submit' : 'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
@ -341,17 +383,31 @@ if ($resql)
// Line for search fields // Line for search fields
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_account" value="'.$search_account.'"></td>'; if (!empty($arrayfields['aa.account_number']['checked'])) {
if (!empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$search_label.'"></td>'; print '<td class="liste_titre"><input type="text" class="flat width100" name="search_account" value="'.$search_account.'"></td>';
if (!empty($arrayfields['aa.labelshort']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_labelshort" value="'.$search_labelshort.'"></td>'; }
if (!empty($arrayfields['aa.label']['checked'])) {
print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$search_label.'"></td>';
}
if (!empty($arrayfields['aa.labelshort']['checked'])) {
print '<td class="liste_titre"><input type="text" class="flat width100" name="search_labelshort" value="'.$search_labelshort.'"></td>';
}
if (!empty($arrayfields['aa.account_parent']['checked'])) { if (!empty($arrayfields['aa.account_parent']['checked'])) {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2); print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2);
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_pcgtype" value="'.$search_pcgtype.'"></td>'; if (!empty($arrayfields['aa.pcg_type']['checked'])) {
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; } print '<td class="liste_titre"><input type="text" class="flat width100" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; }
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
if (!empty($arrayfields['aa.reconcilable']['checked'])) {
print '<td class="liste_titre">&nbsp;</td>';
}
}
if (!empty($arrayfields['aa.active']['checked'])) {
print '<td class="liste_titre">&nbsp;</td>';
}
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
print $searchpicto; print $searchpicto;
@ -359,13 +415,29 @@ if ($resql)
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.account_number']['checked'])) {
if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); }
if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); if (!empty($arrayfields['aa.label']['checked'])) {
if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder);
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); } }
if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.labelshort']['checked'])) {
print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['aa.account_parent']['checked'])) {
print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
}
if (!empty($arrayfields['aa.pcg_type']['checked'])) {
print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']);
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
if (!empty($arrayfields['aa.reconcilable']['checked'])) {
print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder);
}
}
if (!empty($arrayfields['aa.active']['checked'])) {
print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
@ -374,8 +446,7 @@ if ($resql)
$totalarray = array(); $totalarray = array();
$i = 0; $i = 0;
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$accountstatic->id = $obj->rowid; $accountstatic->id = $obj->rowid;
@ -385,39 +456,40 @@ if ($resql)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Account number // Account number
if (!empty($arrayfields['aa.account_number']['checked'])) if (!empty($arrayfields['aa.account_number']['checked'])) {
{
print "<td>"; print "<td>";
print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1, 0, 'accountcard'); print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1, 0, 'accountcard');
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Account label // Account label
if (!empty($arrayfields['aa.label']['checked'])) if (!empty($arrayfields['aa.label']['checked'])) {
{
print "<td>"; print "<td>";
print $obj->label; print $obj->label;
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Account label to show (label short) // Account label to show (label short)
if (!empty($arrayfields['aa.labelshort']['checked'])) if (!empty($arrayfields['aa.labelshort']['checked'])) {
{
print "<td>"; print "<td>";
print $obj->labelshort; print $obj->labelshort;
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Account parent // Account parent
if (!empty($arrayfields['aa.account_parent']['checked'])) if (!empty($arrayfields['aa.account_parent']['checked'])) {
{
// Note: obj->account_parent is a foreign key to a rowid. It is field in child table and obj->rowid2 is same, but in parent table. // Note: obj->account_parent is a foreign key to a rowid. It is field in child table and obj->rowid2 is same, but in parent table.
// So for orphans, obj->account_parent is set but not obj->rowid2 // So for orphans, obj->account_parent is set but not obj->rowid2
if (!empty($obj->account_parent) && !empty($obj->rowid2)) if (!empty($obj->account_parent) && !empty($obj->rowid2)) {
{
print "<td>"; print "<td>";
print '<!-- obj->account_parent = '.$obj->account_parent.' obj->rowid2 = '.$obj->rowid2.' -->'; print '<!-- obj->account_parent = '.$obj->account_parent.' obj->rowid2 = '.$obj->rowid2.' -->';
$accountparent->id = $obj->rowid2; $accountparent->id = $obj->rowid2;
@ -425,24 +497,29 @@ if ($resql)
$accountparent->account_number = $obj->account_number2; // Sotre an account number for output $accountparent->account_number = $obj->account_number2; // Sotre an account number for output
print $accountparent->getNomUrl(1); print $accountparent->getNomUrl(1);
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} else { } else {
print '<td>'; print '<td>';
if (!empty($obj->account_parent)) { if (!empty($obj->account_parent)) {
print '<!-- Bad value for obj->account_parent = '.$obj->account_parent.': is a rowid that does not exists -->'; print '<!-- Bad value for obj->account_parent = '.$obj->account_parent.': is a rowid that does not exists -->';
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
} }
// Chart of accounts type // Chart of accounts type
if (!empty($arrayfields['aa.pcg_type']['checked'])) if (!empty($arrayfields['aa.pcg_type']['checked'])) {
{
print "<td>"; print "<td>";
print $obj->pcg_type; print $obj->pcg_type;
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
@ -466,8 +543,7 @@ if ($resql)
} }
// Activated or not // Activated or not
if (!empty($arrayfields['aa.active']['checked'])) if (!empty($arrayfields['aa.active']['checked'])) {
{
print '<td class="center">'; print '<td class="center">';
if (empty($obj->active)) { if (empty($obj->active)) {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=0">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=0">';
@ -479,7 +555,9 @@ if ($resql)
print '</a>'; print '</a>';
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Action // Action
@ -494,7 +572,9 @@ if ($resql)
print '</a>'; print '</a>';
} }
print '</td>'."\n"; print '</td>'."\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
print "</tr>\n"; print "</tr>\n";
$i++; $i++;

View File

@ -39,7 +39,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("errors", "admin", "companies", "resource", "holiday", "compta", "accountancy", "hrm")); $langs->loadLangs(array("errors", "admin", "companies", "resource", "holiday", "compta", "accountancy", "hrm"));
@ -62,7 +64,9 @@ $active = 1;
$sortfield = GETPOST("sortfield", 'aZ09comma'); $sortfield = GETPOST("sortfield", 'aZ09comma');
$sortorder = GETPOST("sortorder", 'aZ09comma'); $sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $listlimit * $page; $offset = $listlimit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -71,8 +75,12 @@ $search_country_id = GETPOST('search_country_id', 'int');
// Security check // Security check
if ($user->socid > 0) accessforbidden(); if ($user->socid > 0) {
if (!$user->rights->accounting->chartofaccount) accessforbidden(); accessforbidden();
}
if (!$user->rights->accounting->chartofaccount) {
accessforbidden();
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
@ -139,14 +147,12 @@ $sourceList = array();
* Actions * Actions
*/ */
if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
{
$search_country_id = ''; $search_country_id = '';
} }
// Actions add or modify an entry into a dictionary // Actions add or modify an entry into a dictionary
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
{
$listfield = explode(',', str_replace(' ', '', $tabfield[$id])); $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert = explode(',', $tabfieldinsert[$id]); $listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]); $listfieldmodify = explode(',', $tabfieldinsert[$id]);
@ -154,17 +160,21 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Check that all fields are filled // Check that all fields are filled
$ok = 1; $ok = 1;
foreach ($listfield as $f => $value) foreach ($listfield as $f => $value) {
{ if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) {
if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) continue; // For some pages, country is not mandatory continue; // For some pages, country is not mandatory
if ((!GETPOSTISSET($value)) || GETPOST($value) == '') }
{ if ((!GETPOSTISSET($value)) || GETPOST($value) == '') {
$ok = 0; $ok = 0;
$fieldnamekey = $listfield[$f]; $fieldnamekey = $listfield[$f];
// We take translate key of field // We take translate key of field
if ($fieldnamekey == 'pcg_version') $fieldnamekey = 'Pcg_version'; if ($fieldnamekey == 'pcg_version') {
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; $fieldnamekey = 'Pcg_version';
}
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
$fieldnamekey = 'Label';
}
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
} }
@ -174,36 +184,30 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
$ok = 0; $ok = 0;
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
} }
if (GETPOSTISSET("pcg_version")) if (GETPOSTISSET("pcg_version")) {
{ if (GETPOST("pcg_version") == '0') {
if (GETPOST("pcg_version") == '0')
{
$ok = 0; $ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
} }
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
{ {
$ok = 0; $ok = 0;
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>'; $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
}*/ }*/
} }
if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) {
{
$ok = 0; $ok = 0;
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
} }
// Si verif ok et action add, on ajoute la ligne // Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha')) if ($ok && GETPOST('actionadd', 'alpha')) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id])
{
// Recupere id libre pour insertion // Recupere id libre pour insertion
$newid = 0; $newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$newid = ($obj->newid + 1); $newid = ($obj->newid + 1);
} else { } else {
@ -214,34 +218,39 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry // Add new entry
$sql = "INSERT INTO ".$tabname[$id]." ("; $sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields // List of fields
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
$sql .= $tabrowid[$id].","; $sql .= $tabrowid[$id].",";
}
$sql .= $tabfieldinsert[$id]; $sql .= $tabfieldinsert[$id];
$sql .= ",active)"; $sql .= ",active)";
$sql .= " VALUES("; $sql .= " VALUES(";
// List of values // List of values
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
$sql .= $newid.","; $sql .= $newid.",";
}
$i = 0; $i = 0;
foreach ($listfieldinsert as $f => $value) foreach ($listfieldinsert as $f => $value) {
{
if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') { if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU'); $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
} elseif ($value == 'entity') { } elseif ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) {
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; $sql .= ",";
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; }
if ($_POST[$listfieldvalue[$i]] == '') {
$sql .= "null";
} else {
$sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
}
$i++; $i++;
} }
$sql .= ",1)"; $sql .= ",1)";
dol_syslog("actionadd", LOG_DEBUG); dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) // Add is ok if ($result) { // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST = array('id'=>$id); // Clean $_POST array, we keep only $_POST = array('id'=>$id); // Clean $_POST array, we keep only
} else { } else {
@ -254,30 +263,36 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
} }
// Si verif ok et action modify, on modifie la ligne // Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha')) if ($ok && GETPOST('actionmodify', 'alpha')) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
// Modify entry // Modify entry
$sql = "UPDATE ".$tabname[$id]." SET "; $sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs // Modifie valeur des champs
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
{
$sql .= $tabrowid[$id]."="; $sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', "; $sql .= "'".$db->escape($rowid)."', ";
} }
$i = 0; $i = 0;
foreach ($listfieldmodify as $field) foreach ($listfieldmodify as $field) {
{
if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') { if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU'); $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
} elseif ($field == 'entity') { } elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) {
$sql .= ",";
}
$sql .= $field."="; $sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; if ($_POST[$listfieldvalue[$i]] == '') {
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $sql .= "null";
} else {
$sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
}
$i++; $i++;
} }
$sql .= " WHERE ".$rowidcol." = ".((int) $rowid); $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
@ -285,31 +300,30 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("actionmodify", LOG_DEBUG);
//print $sql; //print $sql;
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
setEventMessages($db->error(), null, 'errors'); setEventMessages($db->error(), null, 'errors');
} }
} }
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
} }
if (GETPOST('actioncancel', 'alpha')) if (GETPOST('actioncancel', 'alpha')) {
{
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
} }
if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid); $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
dol_syslog("delete", LOG_DEBUG); dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{ if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -318,9 +332,12 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
} }
// activate // activate
if ($action == $acts[0]) if ($action == $acts[0]) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid);
@ -329,16 +346,18 @@ if ($action == $acts[0])
} }
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
// disable // disable
if ($action == $acts[1]) if ($action == $acts[1]) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid);
@ -347,16 +366,18 @@ if ($action == $acts[1])
} }
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
// favorite // favorite
if ($action == 'activate_favorite') if ($action == 'activate_favorite') {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid);
@ -365,16 +386,18 @@ if ($action == 'activate_favorite')
} }
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
// disable favorite // disable favorite
if ($action == 'disable_favorite') if ($action == 'disable_favorite') {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid);
@ -383,8 +406,7 @@ if ($action == 'disable_favorite')
} }
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
@ -406,8 +428,7 @@ print load_fiche_titre($titre, $linkback, 'title_accountancy');
// Confirmation de la suppression de la ligne // Confirmation de la suppression de la ligne
if ($action == 'delete') if ($action == 'delete') {
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.urlencode($page).'&' : '').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'&rowid='.urlencode($rowid).'&code='.urlencode($code).'&id='.urlencode($id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.urlencode($page).'&' : '').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'&rowid='.urlencode($rowid).'&code='.urlencode($code).'&id='.urlencode($id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
} }
//var_dump($elementList); //var_dump($elementList);
@ -415,20 +436,23 @@ if ($action == 'delete')
/* /*
* Show a dictionary * Show a dictionary
*/ */
if ($id) if ($id) {
{
// Complete requete recherche valeurs avec critere de tri // Complete requete recherche valeurs avec critere de tri
$sql = $tabsql[$id]; $sql = $tabsql[$id];
if ($search_country_id > 0) if ($search_country_id > 0) {
{ if (preg_match('/ WHERE /', $sql)) {
if (preg_match('/ WHERE /', $sql)) $sql .= " AND "; $sql .= " AND ";
else $sql .= " WHERE "; } else {
$sql .= " WHERE ";
}
$sql .= " c.rowid = ".$search_country_id; $sql .= " c.rowid = ".$search_country_id;
} }
// If sort order is "country", we use country_code instead // If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield = 'country_code'; if ($sortfield == 'country') {
$sortfield = 'country_code';
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($listlimit + 1, $offset); $sql .= $db->plimit($listlimit + 1, $offset);
//print $sql; //print $sql;
@ -442,30 +466,35 @@ if ($id)
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
// Form to add a new line // Form to add a new line
if ($tabname[$id]) if ($tabname[$id]) {
{
$fieldlist = explode(',', $tabfield[$id]); $fieldlist = explode(',', $tabfield[$id]);
// Line for title // Line for title
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // 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 = "left"; $class = "left";
if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } if ($fieldlist[$field] == 'code') {
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $valuetoshow = $langs->trans("Code");
{ }
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label"); $valuetoshow = $langs->trans("Label");
} }
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
$valuetoshow = $langs->trans("Country"); $valuetoshow = $langs->trans("Country");
} }
if ($fieldlist[$field] == 'country_id') { $valuetoshow = ''; } if ($fieldlist[$field] == 'country_id') {
if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { $valuetoshow = $langs->trans("Pcg_version"); } $valuetoshow = '';
}
if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') {
$valuetoshow = $langs->trans("Pcg_version");
}
if ($valuetoshow != '') { if ($valuetoshow != '') {
print '<td class="'.$class.'">'; print '<td class="'.$class.'">';
@ -492,12 +521,11 @@ if ($id)
$obj = new stdClass(); $obj = new stdClass();
// If data was already input, we define them in obj to populate input fields. // If data was already input, we define them in obj to populate input fields.
if (GETPOST('actionadd', 'alpha')) if (GETPOST('actionadd', 'alpha')) {
{ foreach ($fieldlist as $key => $val) {
foreach ($fieldlist as $key=>$val) if (GETPOST($val)) {
{
if (GETPOST($val))
$obj->$val = GETPOST($val); $obj->$val = GETPOST($val);
}
} }
} }
@ -506,8 +534,7 @@ if ($id)
$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook)) {
{
fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'add'); fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'add');
} }
@ -526,20 +553,24 @@ if ($id)
// List of available values in database // List of available values in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG); dol_syslog("htdocs/admin/dict", 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 = '&id='.$id; $param = '&id='.$id;
if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id; if ($search_country_id > 0) {
$param .= '&search_country_id='.$search_country_id;
}
$paramwithsearch = $param; $paramwithsearch = $param;
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder; if ($sortorder) {
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield; $paramwithsearch .= '&sortorder='.$sortorder;
}
if ($sortfield) {
$paramwithsearch .= '&sortfield='.$sortfield;
}
// There is several pages // There is several pages
if ($num > $listlimit) if ($num > $listlimit) {
{
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">'; print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>'); print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>'; print '</td></tr>';
@ -547,16 +578,15 @@ if ($id)
// Title line with search boxes // Title line with search boxes
print '<tr class="liste_titre liste_titre_add">'; print '<tr class="liste_titre liste_titre_add">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{
$showfield = 1; // By defaut $showfield = 1; // By defaut
if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
$showfield = 0;
}
if ($showfield) if ($showfield) {
{ if ($value == 'country') {
if ($value == 'country')
{
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>'; print '</td>';
@ -582,16 +612,13 @@ if ($id)
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print '</tr>'; print '</tr>';
if ($num) if ($num) {
{
// Lines with values // Lines with values
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
//print_r($obj); //print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">'; print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
{
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
@ -602,39 +629,35 @@ if ($id)
$reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'edit'); if (empty($reshook)) {
fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'edit');
}
print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">'; print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '&nbsp;<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>'; print '&nbsp;<input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
} else { } else {
$tmpaction = 'view'; $tmpaction = 'view';
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook)) {
{ foreach ($fieldlist as $field => $value) {
foreach ($fieldlist as $field => $value)
{
$showfield = 1; $showfield = 1;
$class = "left"; $class = "left";
$valuetoshow = $obj->{$fieldlist[$field]}; $valuetoshow = $obj->{$fieldlist[$field]};
if ($value == 'type_template') if ($value == 'type_template') {
{
$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
} }
if ($value == 'element') if ($value == 'element') {
{
$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
} elseif ($value == 'source') } elseif ($value == 'source') {
{
$valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow; $valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
} elseif ($valuetoshow == 'all') { } elseif ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All'); $valuetoshow = $langs->trans('All');
} elseif ($fieldlist[$field] == 'country') { } elseif ($fieldlist[$field] == 'country') {
if (empty($obj->country_code)) if (empty($obj->country_code)) {
{
$valuetoshow = '-'; $valuetoshow = '-';
} else { } else {
$key = $langs->trans("Country".strtoupper($obj->country_code)); $key = $langs->trans("Country".strtoupper($obj->country_code));
@ -645,9 +668,13 @@ if ($id)
} }
$class = 'tddict'; $class = 'tddict';
if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto'; if ($fieldlist[$field] == 'tracking') {
$class .= ' tdoverflowauto';
}
// Show value for field // Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>'; if ($showfield) {
print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
}
} }
} }
@ -655,22 +682,33 @@ if ($id)
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
if ($param) $url .= '&'.$param; if ($param) {
$url .= '&'.$param;
}
$url .= '&'; $url .= '&';
// Active // Active
print '<td class="center nowrap">'; print '<td class="center nowrap">';
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>'; if ($canbedisabled) {
else print $langs->trans("AlwaysActive"); print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
} else {
print $langs->trans("AlwaysActive");
}
print "</td>"; print "</td>";
// Modify link // Modify link
if ($canbemodified) print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>'; if ($canbemodified) {
else print '<td>&nbsp;</td>'; print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
} else {
print '<td>&nbsp;</td>';
}
// Delete link // Delete link
if ($iserasable) print '<td class="center"><a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a></td>'; if ($iserasable) {
else print '<td>&nbsp;</td>'; print '<td class="center"><a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a></td>';
} else {
print '<td>&nbsp;</td>';
}
print "</tr>\n"; print "</tr>\n";
} }
@ -714,12 +752,9 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{ if ($fieldlist[$field] == 'country') {
if ($fieldlist[$field] == 'country') if (in_array('region_id', $fieldlist)) {
{
if (in_array('region_id', $fieldlist))
{
print '<td>'; print '<td>';
//print join(',',$fieldlist); //print join(',',$fieldlist);
print '</td>'; print '</td>';
@ -729,18 +764,19 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
$fieldname = 'country'; $fieldname = 'country';
print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>'; print '</td>';
} elseif ($fieldlist[$field] == 'country_id') } elseif ($fieldlist[$field] == 'country_id') {
{ if (!in_array('country', $fieldlist)) { // If there is already a field country, we don't show country_id (avoid duplicate)
if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
{
$country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
print '<td>'; print '<td>';
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">'; print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
print '</td>'; print '</td>';
} }
} elseif ($fieldlist[$field] == 'type_cdr') { } elseif ($fieldlist[$field] == 'type_cdr') {
if ($fieldlist[$field] == 'type_cdr') print '<td class="center">'; if ($fieldlist[$field] == 'type_cdr') {
else print '<td>'; print '<td class="center">';
} else {
print '<td>';
}
if ($fieldlist[$field] == 'type_cdr') { if ($fieldlist[$field] == 'type_cdr') {
print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
} else { } else {
@ -752,10 +788,18 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
} else { } else {
print '<td>'; print '<td>';
$size = ''; $class = ''; $size = ''; $class = '';
if ($fieldlist[$field] == 'code') $size = 'size="8" '; if ($fieldlist[$field] == 'code') {
if ($fieldlist[$field] == 'position') $size = 'size="4" '; $size = 'size="8" ';
if ($fieldlist[$field] == 'libelle') $size = 'centpercent'; }
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') $size = 'size="2" '; if ($fieldlist[$field] == 'position') {
$size = 'size="4" ';
}
if ($fieldlist[$field] == 'libelle') {
$size = 'centpercent';
}
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') {
$size = 'size="2" ';
}
print '<input type="text" '.$size.' class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">'; print '<input type="text" '.$size.' class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
print '</td>'; print '</td>';
} }

View File

@ -46,8 +46,12 @@ $account_number = GETPOST('account_number', 'string');
$label = GETPOST('label', 'alpha'); $label = GETPOST('label', 'alpha');
// Security check // Security check
if ($user->socid > 0) accessforbidden(); if ($user->socid > 0) {
if (!$user->rights->accounting->chartofaccount) accessforbidden(); accessforbidden();
}
if (!$user->rights->accounting->chartofaccount) {
accessforbidden();
}
$object = new AccountingAccount($db); $object = new AccountingAccount($db);
@ -57,22 +61,18 @@ $object = new AccountingAccount($db);
* Action * Action
*/ */
if (GETPOST('cancel', 'alpha')) if (GETPOST('cancel', 'alpha')) {
{
$urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1);
header("Location: ".$urltogo); header("Location: ".$urltogo);
exit; exit;
} }
if ($action == 'add' && $user->rights->accounting->chartofaccount) if ($action == 'add' && $user->rights->accounting->chartofaccount) {
{
if (!$cancel) { if (!$cancel) {
if (!$account_number) if (!$account_number) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors');
$action = 'create'; $action = 'create';
} elseif (!$label) } elseif (!$label) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
$action = 'create'; $action = 'create';
} else { } else {
@ -130,12 +130,10 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
} }
} elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) { } elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) {
if (!$cancel) { if (!$cancel) {
if (!$account_number) if (!$account_number) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors');
$action = 'update'; $action = 'update';
} elseif (!$label) } elseif (!$label) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
$action = 'update'; $action = 'update';
} else { } else {
@ -286,8 +284,7 @@ if ($action == 'create') {
$head = accounting_prepare_head($object); $head = accounting_prepare_head($object);
// Edit mode // Edit mode
if ($action == 'update') if ($action == 'update') {
{
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr'); print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n"; print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";

View File

@ -46,8 +46,7 @@ if ($cat_id == 0) {
} }
// Security check // Security check
if (empty($user->rights->accounting->chartofaccount)) if (empty($user->rights->accounting->chartofaccount)) {
{
accessforbidden(); accessforbidden();
} }
@ -62,8 +61,9 @@ $accountingcategory = new AccountancyCategory($db);
if (!empty($selectcpt)) { if (!empty($selectcpt)) {
$cpts = array(); $cpts = array();
foreach ($selectcpt as $selectedoption) { foreach ($selectcpt as $selectedoption) {
if (!array_key_exists($selectedoption, $cpts)) if (!array_key_exists($selectedoption, $cpts)) {
$cpts[$selectedoption] = "'".$selectedoption."'"; $cpts[$selectedoption] = "'".$selectedoption."'";
}
} }
$return = $accountingcategory->updateAccAcc($cat_id, $cpts); $return = $accountingcategory->updateAccAcc($cat_id, $cpts);
@ -114,8 +114,7 @@ print '<input class="button" type="submit" value="'.$langs->trans("Select").'">'
print '</td></tr>'; print '</td></tr>';
// Select the accounts // Select the accounts
if (!empty($cat_id)) if (!empty($cat_id)) {
{
$return = $accountingcategory->getAccountsWithNoCategory($cat_id); $return = $accountingcategory->getAccountsWithNoCategory($cat_id);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $accountingcategory->errors, 'errors'); setEventMessages(null, $accountingcategory->errors, 'errors');
@ -124,8 +123,7 @@ if (!empty($cat_id))
print '<td>'; print '<td>';
$arraykeyvalue = array(); $arraykeyvalue = array();
foreach ($accountingcategory->lines_cptbk as $key => $val) foreach ($accountingcategory->lines_cptbk as $key => $val) {
{
$arraykeyvalue[length_accountg($val->numero_compte)] = length_accountg($val->numero_compte).' ('.$val->label_compte.($val->doc_ref ? ' '.$val->doc_ref : '').')'; $arraykeyvalue[length_accountg($val->numero_compte)] = length_accountg($val->numero_compte).' ('.$val->label_compte.($val->doc_ref ? ' '.$val->doc_ref : '').')';
} }
@ -152,8 +150,8 @@ print '</form>';
if ($action == 'display' || $action == 'delete') { if ($action == 'display' || $action == 'delete') {
print "<table class='noborder' width='100%'>\n"; print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre">'.$langs->trans("AccountAccounting")."</td>"; print '<td class="liste_titre">'.$langs->trans("AccountAccounting")."</td>";
print '<td class="liste_titre" colspan="2">'.$langs->trans("Label")."</td>"; print '<td class="liste_titre" colspan="2">'.$langs->trans("Label")."</td>";
print "</tr>\n"; print "</tr>\n";

View File

@ -57,7 +57,9 @@ $active = 1;
$sortfield = GETPOST("sortfield", 'aZ09comma'); $sortfield = GETPOST("sortfield", 'aZ09comma');
$sortorder = GETPOST("sortorder", 'aZ09comma'); $sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $listlimit * $page; $offset = $listlimit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -133,14 +135,12 @@ $sourceList = array();
* Actions * Actions
*/ */
if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
{
$search_country_id = ''; $search_country_id = '';
} }
// Actions add or modify an entry into a dictionary // Actions add or modify an entry into a dictionary
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
{
$listfield = explode(',', str_replace(' ', '', $tabfield[$id])); $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert = explode(',', $tabfieldinsert[$id]); $listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]); $listfieldmodify = explode(',', $tabfieldinsert[$id]);
@ -148,57 +148,73 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Check that all fields are filled // Check that all fields are filled
$ok = 1; $ok = 1;
foreach ($listfield as $f => $value) foreach ($listfield as $f => $value) {
{ if ($value == 'formula' && empty($_POST['formula'])) {
if ($value == 'formula' && empty($_POST['formula'])) continue; continue;
if ($value == 'range_account' && empty($_POST['range_account'])) continue; }
if ($value == 'country' || $value == 'country_id') continue; if ($value == 'range_account' && empty($_POST['range_account'])) {
if (!GETPOSTISSET($value) || GETPOST($value) == '') continue;
{ }
if ($value == 'country' || $value == 'country_id') {
continue;
}
if (!GETPOSTISSET($value) || GETPOST($value) == '') {
$ok = 0; $ok = 0;
$fieldnamekey = $listfield[$f]; $fieldnamekey = $listfield[$f];
// We take translate key of field // We take translate key of field
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; $fieldnamekey = 'Label';
if ($fieldnamekey == 'note') $fieldnamekey = 'Note'; }
if ($fieldnamekey == 'type') $fieldnamekey = 'Type'; if ($fieldnamekey == 'code') {
if ($fieldnamekey == 'position') $fieldnamekey = 'Position'; $fieldnamekey = 'Code';
if ($fieldnamekey == 'category_type') $fieldnamekey = 'Calculated'; }
if ($fieldnamekey == 'note') {
$fieldnamekey = 'Note';
}
if ($fieldnamekey == 'type') {
$fieldnamekey = 'Type';
}
if ($fieldnamekey == 'position') {
$fieldnamekey = 'Position';
}
if ($fieldnamekey == 'category_type') {
$fieldnamekey = 'Calculated';
}
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
} }
} }
if (GETPOSTISSET("code")) if (GETPOSTISSET("code")) {
{ if ($_POST["code"] == '0') {
if ($_POST["code"] == '0')
{
$ok = 0; $ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
} }
} }
if (!is_numeric(GETPOST('position', 'alpha'))) if (!is_numeric(GETPOST('position', 'alpha'))) {
{
$langs->loadLangs(array("errors")); $langs->loadLangs(array("errors"));
$ok = 0; $ok = 0;
setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors'); setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors');
} }
// Clean some parameters // Clean some parameters
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null if ($_POST["accountancy_code"] <= 0) {
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null $_POST["accountancy_code"] = ''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null }
if ($_POST["accountancy_code_sell"] <= 0) {
$_POST["accountancy_code_sell"] = ''; // If empty, we force to null
}
if ($_POST["accountancy_code_buy"] <= 0) {
$_POST["accountancy_code_buy"] = ''; // If empty, we force to null
}
// Si verif ok et action add, on ajoute la ligne // Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha')) if ($ok && GETPOST('actionadd', 'alpha')) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id])
{
// Recupere id libre pour insertion // Recupere id libre pour insertion
$newid = 0; $newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$newid = ($obj->newid + 1); $newid = ($obj->newid + 1);
} else { } else {
@ -209,30 +225,37 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry // Add new entry
$sql = "INSERT INTO ".$tabname[$id]." ("; $sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields // List of fields
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $tabrowid[$id].","; if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
$sql .= $tabrowid[$id].",";
}
$sql .= $tabfieldinsert[$id]; $sql .= $tabfieldinsert[$id];
$sql .= ",active)"; $sql .= ",active)";
$sql .= " VALUES("; $sql .= " VALUES(";
// List of values // List of values
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) $sql .= $newid.","; if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
$sql .= $newid.",";
}
$i = 0; $i = 0;
foreach ($listfieldinsert as $f => $value) foreach ($listfieldinsert as $f => $value) {
{
if ($value == 'entity') { if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) {
if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') $sql .= "null"; // For vat, we want/accept code = '' $sql .= ",";
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; }
if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'formula') {
$sql .= "null"; // For vat, we want/accept code = ''
} else {
$sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
}
$i++; $i++;
} }
$sql .= ",1)"; $sql .= ",1)";
dol_syslog("actionadd", LOG_DEBUG); dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) // Add is ok if ($result) { // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST = array('id'=>$id); // Clean $_POST array, we keep only $_POST = array('id'=>$id); // Clean $_POST array, we keep only
} else { } else {
@ -245,30 +268,36 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
} }
// Si verif ok et action modify, on modifie la ligne // Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha')) if ($ok && GETPOST('actionmodify', 'alpha')) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
// Modify entry // Modify entry
$sql = "UPDATE ".$tabname[$id]." SET "; $sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs // Modifie valeur des champs
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
{
$sql .= $tabrowid[$id]."="; $sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', "; $sql .= "'".$db->escape($rowid)."', ";
} }
$i = 0; $i = 0;
foreach ($listfieldmodify as $field) foreach ($listfieldmodify as $field) {
{
if ($field == 'fk_country' && $_POST['country'] > 0) { if ($field == 'fk_country' && $_POST['country'] > 0) {
$_POST[$listfieldvalue[$i]] = $_POST['country']; $_POST[$listfieldvalue[$i]] = $_POST['country'];
} elseif ($field == 'entity') { } elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) {
$sql .= ",";
}
$sql .= $field."="; $sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') $sql .= "null"; // For range_account, we want/accept code = '' if ($_POST[$listfieldvalue[$i]] == '' && !$listfieldvalue[$i] == 'range_account') {
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $sql .= "null"; // For range_account, we want/accept code = ''
} else {
$sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
}
$i++; $i++;
} }
$sql .= " WHERE ".$rowidcol." = ".((int) $rowid); $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
@ -276,31 +305,30 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("actionmodify", LOG_DEBUG);
//print $sql; //print $sql;
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
setEventMessages($db->error(), null, 'errors'); setEventMessages($db->error(), null, 'errors');
} }
} }
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
} }
if (GETPOST('actioncancel', 'alpha')) if (GETPOST('actioncancel', 'alpha')) {
{
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
} }
if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid); $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
dol_syslog("delete", LOG_DEBUG); dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{ if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -309,9 +337,12 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
} }
// activate // activate
if ($action == $acts[0]) if ($action == $acts[0]) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid);
@ -320,16 +351,18 @@ if ($action == $acts[0])
} }
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
// disable // disable
if ($action == $acts[1]) if ($action == $acts[1]) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid);
@ -338,16 +371,18 @@ if ($action == $acts[1])
} }
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
// favorite // favorite
if ($action == 'activate_favorite') if ($action == 'activate_favorite') {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid);
@ -356,16 +391,18 @@ if ($action == 'activate_favorite')
} }
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
// disable favorite // disable favorite
if ($action == 'disable_favorite') if ($action == 'disable_favorite') {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid);
@ -374,8 +411,7 @@ if ($action == 'disable_favorite')
} }
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
@ -399,8 +435,7 @@ print load_fiche_titre($titre, $linkback, $titlepicto);
print '<span class="opacitymedium">'.$langs->trans("AccountingAccountGroupsDesc", $langs->transnoentitiesnoconv("ByPersonalizedAccountGroups")).'</span><br><br>'; print '<span class="opacitymedium">'.$langs->trans("AccountingAccountGroupsDesc", $langs->transnoentitiesnoconv("ByPersonalizedAccountGroups")).'</span><br><br>';
// Confirmation de la suppression de la ligne // Confirmation de la suppression de la ligne
if ($action == 'delete') if ($action == 'delete') {
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id.($search_country_id > 0 ? '&search_country_id='.$search_country_id : ''), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
} }
//var_dump($elementList); //var_dump($elementList);
@ -408,20 +443,23 @@ if ($action == 'delete')
/* /*
* Show a dictionary * Show a dictionary
*/ */
if ($id) if ($id) {
{
// Complete requete recherche valeurs avec critere de tri // Complete requete recherche valeurs avec critere de tri
$sql = $tabsql[$id]; $sql = $tabsql[$id];
if ($search_country_id > 0) if ($search_country_id > 0) {
{ if (preg_match('/ WHERE /', $sql)) {
if (preg_match('/ WHERE /', $sql)) $sql .= " AND "; $sql .= " AND ";
else $sql .= " WHERE "; } else {
$sql .= " WHERE ";
}
$sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)"; $sql .= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)";
} }
// If sort order is "country", we use country_code instead // If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield = 'country_code'; if ($sortfield == 'country') {
$sortfield = 'country_code';
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($listlimit + 1, $offset); $sql .= $db->plimit($listlimit + 1, $offset);
//print $sql; //print $sql;
@ -436,14 +474,12 @@ if ($id)
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
// Form to add a new line // Form to add a new line
if ($tabname[$id]) if ($tabname[$id]) {
{
$fieldlist = explode(',', $tabfield[$id]); $fieldlist = explode(',', $tabfield[$id]);
// Line for title // Line for title
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
@ -489,9 +525,13 @@ if ($id)
if ($valuetoshow != '') { if ($valuetoshow != '') {
print '<td class="'.$class.'">'; print '<td class="'.$class.'">';
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>'; if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
else print $valuetoshow; } elseif (!empty($tabhelp[$id][$value])) {
print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
} else {
print $valuetoshow;
}
print '</td>'; print '</td>';
} }
} }
@ -509,12 +549,11 @@ if ($id)
$obj = new stdClass(); $obj = new stdClass();
// If data was already input, we define them in obj to populate input fields. // If data was already input, we define them in obj to populate input fields.
if (GETPOST('actionadd', 'alpha')) if (GETPOST('actionadd', 'alpha')) {
{ foreach ($fieldlist as $key => $val) {
foreach ($fieldlist as $key=>$val) if (GETPOST($val) != '') {
{
if (GETPOST($val) != '')
$obj->$val = GETPOST($val); $obj->$val = GETPOST($val);
}
} }
} }
@ -523,18 +562,19 @@ if ($id)
$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook)) {
{ fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'add');
fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'add');
} }
print '<td colspan="4" class="right">'; print '<td colspan="4" class="right">';
print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
$colspan = count($fieldlist) + 3; $colspan = count($fieldlist) + 3;
if ($id == 32) $colspan++; if ($id == 32) {
$colspan++;
}
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
} }
@ -542,20 +582,26 @@ if ($id)
// List of available record in database // List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG); dol_syslog("htdocs/admin/dict", 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 = '&id='.$id; $param = '&id='.$id;
if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id; if ($search_country_id > 0) {
$param .= '&search_country_id='.$search_country_id;
}
$paramwithsearch = $param; $paramwithsearch = $param;
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder; if ($sortorder) {
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield; $paramwithsearch .= '&sortorder='.$sortorder;
if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); }
if ($sortfield) {
$paramwithsearch .= '&sortfield='.$sortfield;
}
if (GETPOST('from', 'alpha')) {
$paramwithsearch .= '&from='.GETPOST('from', 'alpha');
}
// There is several pages // There is several pages
if ($num > $listlimit) if ($num > $listlimit) {
{
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">'; print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>'); print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>'; print '</td></tr>';
@ -564,16 +610,15 @@ if ($id)
// Title line with search boxes // Title line with search boxes
print '<tr class="liste_titre liste_titre_add liste_titre_filter">'; print '<tr class="liste_titre liste_titre_add liste_titre_filter">';
$filterfound = 0; $filterfound = 0;
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{
$showfield = 1; // By defaut $showfield = 1; // By defaut
if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; } if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
$showfield = 0;
}
if ($showfield) if ($showfield) {
{ if ($value == 'country') {
if ($value == 'country')
{
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
print '</td>'; print '</td>';
@ -587,8 +632,7 @@ if ($id)
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
if ($filterfound) if ($filterfound) {
{
$searchpicto = $form->showFilterAndCheckAddButtons(0); $searchpicto = $form->showFilterAndCheckAddButtons(0);
print $searchpicto; print $searchpicto;
} }
@ -597,8 +641,7 @@ if ($id)
// Title of lines // Title of lines
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$showfield = 1; // By defaut $showfield = 1; // By defaut
@ -677,23 +720,22 @@ if ($id)
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print '</tr>'; print '</tr>';
if ($num) if ($num) {
{
// Lines with values // Lines with values
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
//print_r($obj); //print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">'; print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
{
$tmpaction = 'edit'; $tmpaction = 'edit';
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
// Show fields // Show fields
if (empty($reshook)) fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit'); if (empty($reshook)) {
fieldListAccountingCategories($fieldlist, $obj, $tabname[$id], 'edit');
}
print '<td></td>'; print '<td></td>';
print '<td></td>'; print '<td></td>';
@ -712,21 +754,17 @@ if ($id)
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook)) {
{ foreach ($fieldlist as $field => $value) {
foreach ($fieldlist as $field => $value)
{
$showfield = 1; $showfield = 1;
$class = "left"; $class = "left";
$valuetoshow = $obj->{$fieldlist[$field]}; $valuetoshow = $obj->{$fieldlist[$field]};
if ($value == 'category_type') if ($value == 'category_type') {
{
$valuetoshow = yn($valuetoshow); $valuetoshow = yn($valuetoshow);
} elseif ($valuetoshow == 'all') { } elseif ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All'); $valuetoshow = $langs->trans('All');
} elseif ($fieldlist[$field] == 'country') { } elseif ($fieldlist[$field] == 'country') {
if (empty($obj->country_code)) if (empty($obj->country_code)) {
{
$valuetoshow = '-'; $valuetoshow = '-';
} else { } else {
$key = $langs->trans("Country".strtoupper($obj->country_code)); $key = $langs->trans("Country".strtoupper($obj->country_code));
@ -748,48 +786,59 @@ if ($id)
$class = 'tddict'; $class = 'tddict';
// Show value for field // Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>'; if ($showfield) {
print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
}
} }
} }
// Can an entry be erased or disabled ? // Can an entry be erased or disabled ?
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
if (isset($obj->code)) if (isset($obj->code)) {
{ if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { $iserasable = 0; $canbedisabled = 0; } $iserasable = 0; $canbedisabled = 0;
}
} }
$canbemodified = $iserasable; $canbemodified = $iserasable;
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
if ($param) $url .= '&'.$param; if ($param) {
$url .= '&'.$param;
}
$url .= '&'; $url .= '&';
// Active // Active
print '<td class="center" class="nowrap">'; print '<td class="center" class="nowrap">';
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>'; if ($canbedisabled) {
else { print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
} else {
print $langs->trans("AlwaysActive"); print $langs->trans("AlwaysActive");
} }
print "</td>"; print "</td>";
// Modify link // Modify link
if ($canbemodified) print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit">'.img_edit().'</a></td>'; if ($canbemodified) {
else print '<td>&nbsp;</td>'; print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit">'.img_edit().'</a></td>';
} else {
print '<td>&nbsp;</td>';
}
// Delete link // Delete link
if ($iserasable) if ($iserasable) {
{
print '<td class="center">'; print '<td class="center">';
if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>'; if ($user->admin) {
print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
}
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
print '</td>'; print '</td>';
} else print '<td>&nbsp;</td>'; } else {
print '<td>&nbsp;</td>';
}
// Link to setup the group // Link to setup the group
print '<td class="center">'; print '<td class="center">';
if (empty($obj->formula)) if (empty($obj->formula)) {
{
print '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories.php?action=display&save_lastsearch_values=1&account_category='.$obj->rowid.'">'; print '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories.php?action=display&save_lastsearch_values=1&account_category='.$obj->rowid.'">';
print $langs->trans("ListOfAccounts"); print $langs->trans("ListOfAccounts");
print '</a>'; print '</a>';
@ -836,26 +885,23 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); if (!empty($conf->accounting->enabled)) {
$formaccounting = new FormAccounting($db);
}
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{ if ($fieldlist[$field] == 'country') {
if ($fieldlist[$field] == 'country')
{
print '<td>'; print '<td>';
$fieldname = 'country'; $fieldname = 'country';
if ($context == 'add') if ($context == 'add') {
{
$fieldname = 'country_id'; $fieldname = 'country_id';
print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country(GETPOST('country_id', 'int'), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
} else { } else {
print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : $mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : $mysoc->country_code)), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
} }
print '</td>'; print '</td>';
} elseif ($fieldlist[$field] == 'country_id') } elseif ($fieldlist[$field] == 'country_id') {
{ if (!in_array('country', $fieldlist)) { // If there is already a field country, we don't show country_id (avoid duplicate)
if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
{
$country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0); $country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
print '<td>'; print '<td>';
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">'; print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
@ -870,10 +916,18 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co
} else { } else {
print '<td>'; print '<td>';
$size = ''; $class = ''; $size = ''; $class = '';
if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; if ($fieldlist[$field] == 'code') {
if ($fieldlist[$field] == 'position') $class = 'maxwidth50'; $class = 'maxwidth100';
if ($fieldlist[$field] == 'libelle') $class = 'quatrevingtpercent'; }
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'category_type') $size = 'size="2" '; if ($fieldlist[$field] == 'position') {
$class = 'maxwidth50';
}
if ($fieldlist[$field] == 'libelle') {
$class = 'quatrevingtpercent';
}
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'category_type') {
$size = 'size="2" ';
}
print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">'; print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
print '</td>'; print '</td>';
} }

View File

@ -62,7 +62,6 @@ if ($action == 'update') {
foreach ($list_account_main as $constname) { foreach ($list_account_main as $constname) {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++; $error++;
} }

View File

@ -38,8 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "loan")); $langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "loan"));
// Security check // Security check
if (empty($user->rights->accounting->chartofaccount)) if (empty($user->rights->accounting->chartofaccount)) {
{
accessforbidden(); accessforbidden();
} }

View File

@ -36,8 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
$langs->loadLangs(array("compta", "bills", "admin", "accountancy")); $langs->loadLangs(array("compta", "bills", "admin", "accountancy"));
// Security access // Security access
if (empty($user->rights->accounting->chartofaccount)) if (empty($user->rights->accounting->chartofaccount)) {
{
accessforbidden(); accessforbidden();
} }

View File

@ -32,21 +32,29 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) $sortfield = "f.rowid"; // Set here default search field if (!$sortfield) {
if (!$sortorder) $sortorder = "ASC"; $sortfield = "f.rowid"; // Set here default search field
}
if (!$sortorder) {
$sortorder = "ASC";
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "compta")); $langs->loadLangs(array("admin", "compta"));
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->fiscalyear->write) // If we can read accounting records, we should be able to see fiscal year. }
if (!$user->rights->accounting->fiscalyear->write) { // If we can read accounting records, we should be able to see fiscal year.
accessforbidden(); accessforbidden();
}
$error = 0; $error = 0;
@ -58,8 +66,9 @@ static $tmpstatut2label = array(
$statut2label = array( $statut2label = array(
'' ''
); );
foreach ($tmpstatut2label as $key => $val) foreach ($tmpstatut2label as $key => $val) {
$statut2label[$key] = $langs->trans($val); $statut2label[$key] = $langs->trans($val);
}
$errors = array(); $errors = array();
@ -92,12 +101,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -106,8 +113,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;

View File

@ -31,10 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
$langs->loadLangs(array("admin", "compta")); $langs->loadLangs(array("admin", "compta"));
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (empty($user->rights->accounting->fiscalyear->write)) }
if (empty($user->rights->accounting->fiscalyear->write)) {
accessforbidden(); accessforbidden();
}
$error = 0; $error = 0;
@ -50,8 +52,9 @@ static $tmpstatut2label = array(
$statut2label = array( $statut2label = array(
'' ''
); );
foreach ($tmpstatut2label as $key => $val) foreach ($tmpstatut2label as $key => $val) {
$statut2label[$key] = $langs->trans($val); $statut2label[$key] = $langs->trans($val);
}
$object = new Fiscalyear($db); $object = new Fiscalyear($db);
@ -113,10 +116,8 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
header("Location: ./fiscalyear.php"); header("Location: ./fiscalyear.php");
exit(); exit();
} }
} } elseif ($action == 'update') {
// Update record
// Update record
elseif ($action == 'update') {
if (!GETPOST('cancel', 'alpha')) { if (!GETPOST('cancel', 'alpha')) {
$result = $object->fetch($id); $result = $object->fetch($id);
@ -151,8 +152,7 @@ $title = $langs->trans("Fiscalyear")." - ".$langs->trans("Card");
$helpurl = ""; $helpurl = "";
llxHeader("", $title, $helpurl); llxHeader("", $title, $helpurl);
if ($action == 'create') if ($action == 'create') {
{
print load_fiche_titre($langs->trans("NewFiscalYear")); print load_fiche_titre($langs->trans("NewFiscalYear"));
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
@ -298,11 +298,10 @@ if ($action == 'create')
print dol_get_fiche_end(); print dol_get_fiche_end();
if (!empty($user->rights->accounting->fiscalyear->write)) if (!empty($user->rights->accounting->fiscalyear->write)) {
{
/* /*
* Barre d'actions * Barre d'actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$id.'">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$id.'">'.$langs->trans('Modify').'</a>';

View File

@ -30,10 +30,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
$langs->loadLangs(array("admin", "compta")); $langs->loadLangs(array("admin", "compta"));
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->fiscalyear->write) }
if (!$user->rights->accounting->fiscalyear->write) {
accessforbidden(); accessforbidden();
}
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');

View File

@ -279,6 +279,7 @@ print '</tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>'; print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enablesubsidiarylist&value=0">'; print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enablesubsidiarylist&value=0">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');

View File

@ -22,7 +22,9 @@
* \brief Setup page to configure journals * \brief Setup page to configure journals
*/ */
if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET if (!defined('CSRFCHECK_WITH_TOKEN')) {
define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
}
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
@ -43,8 +45,7 @@ $rowid = GETPOST('rowid', 'alpha');
$code = GETPOST('code', 'alpha'); $code = GETPOST('code', 'alpha');
// Security access // Security access
if (empty($user->rights->accounting->chartofaccount)) if (empty($user->rights->accounting->chartofaccount)) {
{
accessforbidden(); accessforbidden();
} }
@ -60,12 +61,18 @@ $active = 1;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $listlimit * $page; $offset = $listlimit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (empty($sortfield)) $sortfield = 'code'; if (empty($sortfield)) {
if (empty($sortorder)) $sortorder = 'ASC'; $sortfield = 'code';
}
if (empty($sortorder)) {
$sortorder = 'ASC';
}
$error = 0; $error = 0;
@ -145,14 +152,12 @@ $sourceList = array(
* Actions * Actions
*/ */
if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
{
$search_country_id = ''; $search_country_id = '';
} }
// Actions add or modify an entry into a dictionary // Actions add or modify an entry into a dictionary
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
{
$listfield = explode(',', str_replace(' ', '', $tabfield[$id])); $listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
$listfieldinsert = explode(',', $tabfieldinsert[$id]); $listfieldinsert = explode(',', $tabfieldinsert[$id]);
$listfieldmodify = explode(',', $tabfieldinsert[$id]); $listfieldmodify = explode(',', $tabfieldinsert[$id]);
@ -160,48 +165,53 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Check that all fields are filled // Check that all fields are filled
$ok = 1; $ok = 1;
foreach ($listfield as $f => $value) foreach ($listfield as $f => $value) {
{ if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label'; $fieldnamekey = 'Label';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code'; }
if ($fieldnamekey == 'nature') $fieldnamekey = 'NatureOfJournal'; if ($fieldnamekey == 'code') {
$fieldnamekey = 'Code';
}
if ($fieldnamekey == 'nature') {
$fieldnamekey = 'NatureOfJournal';
}
} }
// Other checks // Other checks
if (GETPOSTISSET("code")) if (GETPOSTISSET("code")) {
{ if (GETPOST("code") == '0') {
if (GETPOST("code") == '0')
{
$ok = 0; $ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
} }
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
{ {
$ok = 0; $ok = 0;
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>'; $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
}*/ }*/
} }
if (!GETPOST('label', 'alpha')) if (!GETPOST('label', 'alpha')) {
{
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
$ok = 0; $ok = 0;
} }
// Clean some parameters // Clean some parameters
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null if ($_POST["accountancy_code"] <= 0) {
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null $_POST["accountancy_code"] = ''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null }
if ($_POST["accountancy_code_sell"] <= 0) {
$_POST["accountancy_code_sell"] = ''; // If empty, we force to null
}
if ($_POST["accountancy_code_buy"] <= 0) {
$_POST["accountancy_code_buy"] = ''; // If empty, we force to null
}
// Si verif ok et action add, on ajoute la ligne // Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd', 'alpha')) if ($ok && GETPOST('actionadd', 'alpha')) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id])
{
// Recupere id libre pour insertion // Recupere id libre pour insertion
$newid = 0; $newid = 0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$newid = ($obj->newid + 1); $newid = ($obj->newid + 1);
} else { } else {
@ -212,32 +222,37 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// Add new entry // Add new entry
$sql = "INSERT INTO ".$tabname[$id]." ("; $sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields // List of fields
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
$sql .= $tabrowid[$id].","; $sql .= $tabrowid[$id].",";
}
$sql .= $tabfieldinsert[$id]; $sql .= $tabfieldinsert[$id];
$sql .= ",active,entity)"; $sql .= ",active,entity)";
$sql .= " VALUES("; $sql .= " VALUES(";
// List of values // List of values
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
$sql .= $newid.","; $sql .= $newid.",";
}
$i = 0; $i = 0;
foreach ($listfieldinsert as $f => $value) foreach ($listfieldinsert as $f => $value) {
{
if ($value == 'entity') { if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) {
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; // For vat, we want/accept code = '' $sql .= ",";
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; }
if ($_POST[$listfieldvalue[$i]] == '') {
$sql .= "null"; // For vat, we want/accept code = ''
} else {
$sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
}
$i++; $i++;
} }
$sql .= ",1,".$conf->entity.")"; $sql .= ",1,".$conf->entity.")";
dol_syslog("actionadd", LOG_DEBUG); dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) // Add is ok if ($result) { // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST = array('id'=>$id); // Clean $_POST array, we keep only $_POST = array('id'=>$id); // Clean $_POST array, we keep only
} else { } else {
@ -250,30 +265,36 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
} }
// Si verif ok et action modify, on modifie la ligne // Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify', 'alpha')) if ($ok && GETPOST('actionmodify', 'alpha')) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
// Modify entry // Modify entry
$sql = "UPDATE ".$tabname[$id]." SET "; $sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs // Modifie valeur des champs
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
{
$sql .= $tabrowid[$id]."="; $sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', "; $sql .= "'".$db->escape($rowid)."', ";
} }
$i = 0; $i = 0;
foreach ($listfieldmodify as $field) foreach ($listfieldmodify as $field) {
{
if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') { if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU'); $_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
} elseif ($field == 'entity') { } elseif ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql .= ","; if ($i) {
$sql .= ",";
}
$sql .= $field."="; $sql .= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = '' if ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) {
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $sql .= "null"; // For vat, we want/accept code = ''
} else {
$sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
}
$i++; $i++;
} }
$sql .= " WHERE ".$rowidcol." = ".((int) $rowid); $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
@ -282,8 +303,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
dol_syslog("actionmodify", LOG_DEBUG); dol_syslog("actionmodify", LOG_DEBUG);
//print $sql; //print $sql;
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
setEventMessages($db->error(), null, 'errors'); setEventMessages($db->error(), null, 'errors');
} }
} }
@ -295,19 +315,20 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
// $_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition // $_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
//} //}
if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid); $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
dol_syslog("delete", LOG_DEBUG); dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{ if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -316,9 +337,12 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
} }
// activate // activate
if ($action == $acts[0]) if ($action == $acts[0]) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid);
@ -328,16 +352,18 @@ if ($action == $acts[0])
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
// disable // disable
if ($action == $acts[1]) if ($action == $acts[1]) {
{ if ($tabrowid[$id]) {
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } $rowidcol = $tabrowid[$id];
} else {
$rowidcol = "rowid";
}
if ($rowid) { if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid); $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid);
@ -347,8 +373,7 @@ if ($action == $acts[1])
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
dol_print_error($db); dol_print_error($db);
} }
} }
@ -365,8 +390,7 @@ llxHeader();
$titre = $langs->trans("DictionarySetup"); $titre = $langs->trans("DictionarySetup");
$linkback = ''; $linkback = '';
if ($id) if ($id) {
{
$titre .= ' - '.$langs->trans($tablib[$id]); $titre .= ' - '.$langs->trans($tablib[$id]);
$titlepicto = 'title_accountancy'; $titlepicto = 'title_accountancy';
} }
@ -375,8 +399,7 @@ print load_fiche_titre($titre, $linkback, $titlepicto);
// Confirmation de la suppression de la ligne // Confirmation de la suppression de la ligne
if ($action == 'delete') if ($action == 'delete') {
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
} }
//var_dump($elementList); //var_dump($elementList);
@ -384,14 +407,15 @@ if ($action == 'delete')
/* /*
* Show a dictionary * Show a dictionary
*/ */
if ($id) if ($id) {
{
// Complete requete recherche valeurs avec critere de tri // Complete requete recherche valeurs avec critere de tri
$sql = $tabsql[$id]; $sql = $tabsql[$id];
$sql .= " WHERE a.entity = ".$conf->entity; $sql .= " WHERE a.entity = ".$conf->entity;
// If sort order is "country", we use country_code instead // If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield = 'country_code'; if ($sortfield == 'country') {
$sortfield = 'country_code';
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($listlimit + 1, $offset); $sql .= $db->plimit($listlimit + 1, $offset);
@ -405,14 +429,12 @@ if ($id)
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
// Form to add a new line // Form to add a new line
if ($tabname[$id]) if ($tabname[$id]) {
{
$fieldlist = explode(',', $tabfield[$id]); $fieldlist = explode(',', $tabfield[$id]);
// Line for title // Line for title
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
@ -430,9 +452,13 @@ if ($id)
if ($valuetoshow != '') { if ($valuetoshow != '') {
print '<td class="'.$class.'">'; print '<td class="'.$class.'">';
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>'; if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
elseif (!empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
else print $valuetoshow; } elseif (!empty($tabhelp[$id][$value])) {
print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
} else {
print $valuetoshow;
}
print '</td>'; print '</td>';
} }
} }
@ -450,12 +476,11 @@ if ($id)
$obj = new stdClass(); $obj = new stdClass();
// If data was already input, we define them in obj to populate input fields. // If data was already input, we define them in obj to populate input fields.
if (GETPOST('actionadd', 'alpha')) if (GETPOST('actionadd', 'alpha')) {
{ foreach ($fieldlist as $key => $val) {
foreach ($fieldlist as $key=>$val) if (GETPOST($val) != '') {
{
if (GETPOST($val) != '')
$obj->$val = GETPOST($val); $obj->$val = GETPOST($val);
}
} }
} }
@ -464,13 +489,12 @@ if ($id)
$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook)) {
{ fieldListJournal($fieldlist, $obj, $tabname[$id], 'add');
fieldListJournal($fieldlist, $obj, $tabname[$id], 'add');
} }
print '<td colspan="4" class="right">'; print '<td colspan="4" class="right">';
print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
print '</td>'; print '</td>';
print "</tr>"; print "</tr>";
@ -482,21 +506,27 @@ if ($id)
// List of available record in database // List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG); dol_syslog("htdocs/admin/dict", 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 = '&id='.$id; $param = '&id='.$id;
if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id; if ($search_country_id > 0) {
$param .= '&search_country_id='.$search_country_id;
}
$paramwithsearch = $param; $paramwithsearch = $param;
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder; if ($sortorder) {
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield; $paramwithsearch .= '&sortorder='.$sortorder;
if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); }
if ($sortfield) {
$paramwithsearch .= '&sortfield='.$sortfield;
}
if (GETPOST('from', 'alpha')) {
$paramwithsearch .= '&from='.GETPOST('from', 'alpha');
}
// There is several pages // There is several pages
if ($num > $listlimit) if ($num > $listlimit) {
{
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">'; print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>'); print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
print '</td></tr>'; print '</td></tr>';
@ -519,8 +549,7 @@ if ($id)
// Title of lines // Title of lines
print '<tr class="liste_titre liste_titre_add">'; print '<tr class="liste_titre liste_titre_add">';
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{
// Determine le nom du champ par rapport aux noms possibles // Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees // dans les dictionnaires de donnees
$showfield = 1; // By defaut $showfield = 1; // By defaut
@ -528,11 +557,11 @@ if ($id)
$sortable = 1; $sortable = 1;
$valuetoshow = ''; $valuetoshow = '';
/* /*
$tmparray=getLabelOfField($fieldlist[$field]); $tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield']; $showfield=$tmp['showfield'];
$valuetoshow=$tmp['valuetoshow']; $valuetoshow=$tmp['valuetoshow'];
$align=$tmp['align']; $align=$tmp['align'];
$sortable=$tmp['sortable']; $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
@ -557,23 +586,22 @@ if ($id)
print getTitleFieldOfList(''); print getTitleFieldOfList('');
print '</tr>'; print '</tr>';
if ($num) if ($num) {
{
// Lines with values // Lines with values
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
//print_r($obj); //print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">'; print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
{
$tmpaction = 'edit'; $tmpaction = 'edit';
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
// Show fields // Show fields
if (empty($reshook)) fieldListJournal($fieldlist, $obj, $tabname[$id], 'edit'); if (empty($reshook)) {
fieldListJournal($fieldlist, $obj, $tabname[$id], 'edit');
}
print '<td class="center" colspan="4">'; print '<td class="center" colspan="4">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
@ -583,17 +611,15 @@ if ($id)
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>'; print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
print '</td>'; print '</td>';
} else { } else {
$tmpaction = 'view'; $tmpaction = 'view';
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error = $hookmanager->error; $errors = $hookmanager->errors; $error = $hookmanager->error; $errors = $hookmanager->errors;
if (empty($reshook)) if (empty($reshook)) {
{
$langs->load("accountancy"); $langs->load("accountancy");
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{
$showfield = 1; $showfield = 1;
$class = "left"; $class = "left";
$valuetoshow = $obj->{$fieldlist[$field]}; $valuetoshow = $obj->{$fieldlist[$field]};
@ -608,7 +634,9 @@ if ($id)
$class = 'tddict'; $class = 'tddict';
// Show value for field // Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>'; if ($showfield) {
print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
}
} }
} }
@ -630,27 +658,38 @@ if ($id)
$canbemodified = $iserasable; $canbemodified = $iserasable;
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
if ($param) $url .= '&'.$param; if ($param) {
$url .= '&'.$param;
}
$url .= '&'; $url .= '&';
// Active // Active
print '<td class="nowrap center">'; print '<td class="nowrap center">';
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>'; if ($canbedisabled) {
else print $langs->trans("AlwaysActive"); print '<a href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
} else {
print $langs->trans("AlwaysActive");
}
print "</td>"; print "</td>";
// Modify link // Modify link
if ($canbemodified) print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>'; if ($canbemodified) {
else print '<td>&nbsp;</td>'; print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
} else {
print '<td>&nbsp;</td>';
}
// Delete link // Delete link
if ($iserasable) if ($iserasable) {
{
print '<td class="center">'; print '<td class="center">';
if ($user->admin) print '<a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>'; if ($user->admin) {
print '<a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
}
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin //else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
print '</td>'; print '</td>';
} else print '<td>&nbsp;</td>'; } else {
print '<td>&nbsp;</td>';
}
print '<td></td>'; print '<td></td>';
@ -698,10 +737,8 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value) {
{ if ($fieldlist[$field] == 'nature') {
if ($fieldlist[$field] == 'nature')
{
print '<td>'; print '<td>';
print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'')); print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
print '</td>'; print '</td>';
@ -710,9 +747,15 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
} else { } else {
print '<td>'; print '<td>';
$size = ''; $class = ''; $size = ''; $class = '';
if ($fieldlist[$field] == 'code') $class = 'maxwidth100'; if ($fieldlist[$field] == 'code') {
if ($fieldlist[$field] == 'label') $class = 'quatrevingtpercent'; $class = 'maxwidth100';
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') $size = 'size="2" '; }
if ($fieldlist[$field] == 'label') {
$class = 'quatrevingtpercent';
}
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') {
$size = 'size="2" ';
}
print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">'; print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
print '</td>'; print '</td>';
} }

View File

@ -41,8 +41,9 @@ $langs->loadLangs(array("companies", "compta", "accountancy", "products"));
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
accessforbidden(); accessforbidden();
} }
if (!$user->rights->accounting->bind->write) if (!$user->rights->accounting->bind->write) {
accessforbidden(); accessforbidden();
}
// search & action GETPOST // search & action GETPOST
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -60,7 +61,9 @@ $search_desc = GETPOST('search_desc', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha'); $search_vat = GETPOST('search_vat', 'alpha');
$search_current_account = GETPOST('search_current_account', 'alpha'); $search_current_account = GETPOST('search_current_account', 'alpha');
$search_current_account_valid = GETPOST('search_current_account_valid', 'alpha'); $search_current_account_valid = GETPOST('search_current_account_valid', 'alpha');
if ($search_current_account_valid == '') $search_current_account_valid = 'withoutvalidaccount'; if ($search_current_account_valid == '') {
$search_current_account_valid = 'withoutvalidaccount';
}
$search_onsell = GETPOST('search_onsell', 'alpha'); $search_onsell = GETPOST('search_onsell', 'alpha');
$search_onpurchase = GETPOST('search_onpurchase', 'alpha'); $search_onpurchase = GETPOST('search_onpurchase', 'alpha');
@ -68,20 +71,30 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
$btn_changeaccount = GETPOST('changeaccount', 'alpha'); $btn_changeaccount = GETPOST('changeaccount', 'alpha');
$btn_changetype = GETPOST('changetype', 'alpha'); $btn_changetype = GETPOST('changetype', 'alpha');
if (empty($accounting_product_mode)) $accounting_product_mode = 'ACCOUNTANCY_SELL'; if (empty($accounting_product_mode)) {
$accounting_product_mode = 'ACCOUNTANCY_SELL';
}
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $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'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) $sortfield = "p.ref"; if (!$sortfield) {
if (!$sortorder) $sortorder = "ASC"; $sortfield = "p.ref";
}
if (!$sortorder) {
$sortorder = "ASC";
}
if (empty($action)) $action = 'list'; if (empty($action)) {
$action = 'list';
}
$arrayfields = array(); $arrayfields = array();
@ -90,16 +103,21 @@ $arrayfields = array();
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All 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 test are required to be compatible with all browsers
{
$search_ref = ''; $search_ref = '';
$search_label = ''; $search_label = '';
$search_desc = ''; $search_desc = '';
@ -142,13 +160,11 @@ if ($action == 'update') {
$arrayofdifferentselectedvalues = array(); $arrayofdifferentselectedvalues = array();
$cpt = 0; $ok = 0; $ko = 0; $cpt = 0; $ok = 0; $ko = 0;
foreach ($chk_prod as $productid) foreach ($chk_prod as $productid) {
{
$accounting_account_id = GETPOST('codeventil_'.$productid); $accounting_account_id = GETPOST('codeventil_'.$productid);
$result = 0; $result = 0;
if ($accounting_account_id > 0) if ($accounting_account_id > 0) {
{
$arrayofdifferentselectedvalues[$accounting_account_id] = $accounting_account_id; $arrayofdifferentselectedvalues[$accounting_account_id] = $accounting_account_id;
$result = $accounting->fetch($accounting_account_id, null, 1); $result = $accounting->fetch($accounting_account_id, null, 1);
} }
@ -181,8 +197,7 @@ if ($action == 'update') {
$sql .= " WHERE rowid = ".((int) $productid); $sql .= " WHERE rowid = ".((int) $productid);
dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG);
if ($db->query($sql)) if ($db->query($sql)) {
{
$ok++; $ok++;
$db->commit(); $db->commit();
} else { } else {
@ -195,8 +210,12 @@ if ($action == 'update') {
} }
} }
if ($ko) setEventMessages($langs->trans("XLineFailedToBeBinded", $ko), null, 'errors'); if ($ko) {
if ($ok) setEventMessages($langs->trans("XLineSuccessfullyBinded", $ok), null, 'mesgs'); setEventMessages($langs->trans("XLineFailedToBeBinded", $ko), null, 'errors');
}
if ($ok) {
setEventMessages($langs->trans("XLineSuccessfullyBinded", $ok), null, 'mesgs');
}
} }
} }
@ -243,7 +262,9 @@ llxHeader('', $langs->trans("ProductsBinding"));
$pcgverid = $conf->global->CHARTOFACCOUNTS; $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.tva_tx,"; $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,";
$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
@ -254,17 +275,13 @@ $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 = '".$db->escape($pcgvercode)."'"; $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
{
$sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
{
$sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; $sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
{
$sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; $sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
{
$sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; $sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} else { } else {
$sql .= " p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; $sql .= " p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
@ -295,12 +312,10 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$sql .= natural_search("p.accountancy_code_sell_export", $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";
} }
if ($search_current_account_valid == 'withvalidaccount') if ($search_current_account_valid == 'withvalidaccount') {
{
$sql .= " AND aa.account_number IS NOT NULL"; $sql .= " AND aa.account_number IS NOT NULL";
} }
// Add search filter like // Add search filter like
@ -316,18 +331,20 @@ if (strlen(trim($search_desc))) {
if (strlen(trim($search_vat))) { if (strlen(trim($search_vat))) {
$sql .= natural_search("p.tva_tx", price2num($search_vat), 1); $sql .= natural_search("p.tva_tx", price2num($search_vat), 1);
} }
if ($search_onsell != '' && $search_onsell != '-1') $sql .= natural_search('p.tosell', $search_onsell, 1); if ($search_onsell != '' && $search_onsell != '-1') {
if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql .= natural_search('p.tobuy', $search_onpurchase, 1); $sql .= natural_search('p.tosell', $search_onsell, 1);
}
if ($search_onpurchase != '' && $search_onpurchase != '-1') {
$sql .= natural_search('p.tobuy', $search_onpurchase, 1);
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -337,24 +354,43 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog("/accountancy/admin/productaccount.php:: sql=".$sql, LOG_DEBUG); dol_syslog("/accountancy/admin/productaccount.php:: sql=".$sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref); }
if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc); $param .= '&limit='.urlencode($limit);
if ($search_vat > 0) $param .= '&search_vat='.urlencode($search_vat); }
if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account); if ($search_ref > 0) {
if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid); $param .= "&search_desc=".urlencode($search_ref);
if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode); }
if ($search_label > 0) {
$param .= "&search_desc=".urlencode($search_label);
}
if ($search_desc > 0) {
$param .= "&search_desc=".urlencode($search_desc);
}
if ($search_vat > 0) {
$param .= '&search_vat='.urlencode($search_vat);
}
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 ($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.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@ -375,8 +411,7 @@ if ($result)
print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"'.($accounting_product_mode == 'ACCOUNTANCY_SELL' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSell').'</td>'; print '<tr class="oddeven"><td><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()) if ($mysoc->isInEEC()) {
{
print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_INTRA"'.($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSellIntra').'</td>'; print '<tr class="oddeven"><td><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>'.$langs->trans('OptionModeProductSellIntraDesc');
print "</td></tr>\n"; print "</td></tr>\n";
@ -386,8 +421,7 @@ if ($result)
print "</td></tr>\n"; print "</td></tr>\n";
print '<tr class="oddeven"><td><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><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";
if ($mysoc->isInEEC()) if ($mysoc->isInEEC()) {
{
print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY_INTRA"'.($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuyIntra').'</td>'; print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY_INTRA"'.($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuyIntra').'</td>';
print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n"; print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
} }
@ -419,13 +453,14 @@ 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>';
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" size="5" name="search_vat" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></td>'; print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" size="5" name="search_vat" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></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' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
print '<td class="liste_titre center">'.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).'</td>'; print '<td class="liste_titre center">'.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).'</td>';
} } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
// On buy // On buy
elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
print '<td class="liste_titre center">'.$form->selectyesno('search_onpurchase', $search_onpurchase, 1, false, 1).'</td>'; print '<td class="liste_titre center">'.$form->selectyesno('search_onpurchase', $search_onpurchase, 1, false, 1).'</td>';
} }
// Current account // Current account
@ -444,7 +479,9 @@ if ($result)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
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);
}
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
// On sell / On purchase // On sell / On purchase
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
@ -466,7 +503,7 @@ if ($result)
print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount = "p.accountancy_code_buy_export"; $fieldtosortaccount = "p.accountancy_code_buy_export";
} }
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);
print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center ');
@ -475,8 +512,7 @@ if ($result)
$product_static = new Product($db); $product_static = new Product($db);
$i = 0; $i = 0;
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// Ref produit as link // Ref produit as link
@ -558,8 +594,7 @@ if ($result)
print '<td class="left">'.$obj->label.'</td>'; print '<td class="left">'.$obj->label.'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) {
{
// TODO ADJUST DESCRIPTION SIZE // TODO ADJUST DESCRIPTION SIZE
// print '<td class="left">' . $obj->description . '</td>'; // print '<td class="left">' . $obj->description . '</td>';
// TODO: we should set a user defined value to adjust user square / wide screen size // TODO: we should set a user defined value to adjust user square / wide screen size
@ -572,32 +607,46 @@ if ($result)
print vatrate($obj->tva_tx); print vatrate($obj->tva_tx);
print '</td>'; print '</td>';
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') 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' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') if ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
print '<td class="center">'.$product_static->getLibStatut(3, 1).'</td>'; print '<td class="center">'.$product_static->getLibStatut(3, 1).'</td>';
}
// Current accounting account // Current accounting account
print '<td class="left">'; print '<td class="left">';
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_BUY_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
print length_accountg($obj->accountancy_code_buy_intra); print length_accountg($obj->accountancy_code_buy_intra);
if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) {
print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
}
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
print length_accountg($obj->accountancy_code_buy_export); print length_accountg($obj->accountancy_code_buy_export);
if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_buy_export && empty($obj->aaid)) {
print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
}
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
print length_accountg($obj->accountancy_code_sell); print length_accountg($obj->accountancy_code_sell);
if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_sell && empty($obj->aaid)) {
print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
}
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
print length_accountg($obj->accountancy_code_sell_intra); print length_accountg($obj->accountancy_code_sell_intra);
if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) {
print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
}
} else { } else {
print length_accountg($obj->accountancy_code_sell_export); print length_accountg($obj->accountancy_code_sell_export);
if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_sell_export && empty($obj->aaid)) {
print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
}
} }
print '</td>'; print '</td>';
@ -607,58 +656,82 @@ if ($result)
// Accounting account buy // Accounting account buy
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
if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; if (empty($defaultvalue)) {
$defaultvalue = $compta_prodbuy;
}
$codesell = length_accountg($obj->accountancy_code_buy); $codesell = length_accountg($obj->accountancy_code_buy);
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, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
// Accounting account buy intra (In EEC) // Accounting account buy intra (In EEC)
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
if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; if (empty($defaultvalue)) {
$defaultvalue = $compta_prodbuy;
}
$codesell = length_accountg($obj->accountancy_code_buy_intra); $codesell = length_accountg($obj->accountancy_code_buy_intra);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
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, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
// Accounting account buy export (Out of EEC) // Accounting account buy export (Out of EEC)
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
if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; if (empty($defaultvalue)) {
$defaultvalue = $compta_prodbuy;
}
$codesell = length_accountg($obj->accountancy_code_buy_export); $codesell = length_accountg($obj->accountancy_code_buy_export);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
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, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { } 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
if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; if (empty($defaultvalue)) {
$defaultvalue = $compta_prodsell;
}
$codesell = length_accountg($obj->accountancy_code_sell); $codesell = length_accountg($obj->accountancy_code_sell);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
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, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
// Accounting account sell intra (In EEC) // Accounting account sell intra (In EEC)
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
if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; if (empty($defaultvalue)) {
$defaultvalue = $compta_prodsell;
}
$codesell = length_accountg($obj->accountancy_code_sell_intra); $codesell = length_accountg($obj->accountancy_code_sell_intra);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
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, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} else { } else {
// Accounting account sell export (Out of EEC) // Accounting account sell export (Out of EEC)
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
if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; if (empty($defaultvalue)) {
$defaultvalue = $compta_prodsell;
}
$codesell = length_accountg($obj->accountancy_code_sell_export); $codesell = length_accountg($obj->accountancy_code_sell_export);
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, 0, 'maxwidth300 maxwidthonsmartphone productforselect'); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} }

View File

@ -43,20 +43,30 @@ $search_label = GETPOST('search_label', 'alpha');
$search_type = GETPOST('search_type', 'int'); $search_type = GETPOST('search_type', 'int');
// Security check // Security check
if ($user->socid > 0) accessforbidden(); if ($user->socid > 0) {
if (!$user->rights->accounting->chartofaccount) accessforbidden(); accessforbidden();
}
if (!$user->rights->accounting->chartofaccount) {
accessforbidden();
}
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) $sortfield = "label"; if (!$sortfield) {
if (!$sortorder) $sortorder = "ASC"; $sortfield = "label";
}
if (!$sortorder) {
$sortorder = "ASC";
}
$arrayfields = array( $arrayfields = array(
'subaccount'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'subaccount'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
@ -65,27 +75,35 @@ $arrayfields = array(
'reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1) 'reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1)
); );
if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['reconcilable']); if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
unset($arrayfields['reconcilable']);
}
/* /*
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha')) {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{ if (!empty($cancel)) {
if (!empty($cancel)) $action = ''; $action = '';
}
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All 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 test are required to be compatible with all browsers
{
$search_subaccount = ""; $search_subaccount = "";
$search_label = ""; $search_label = "";
$search_type = ""; $search_type = "";
@ -132,19 +150,24 @@ if (strlen(trim($search_subaccount))) {
$search_subaccount_tmp_clean = $search_subaccount_tmp; $search_subaccount_tmp_clean = $search_subaccount_tmp;
$search_subaccount_clean = $search_subaccount; $search_subaccount_clean = $search_subaccount;
$startchar = '%'; $startchar = '%';
if (strpos($search_subaccount_tmp, '^') === 0) if (strpos($search_subaccount_tmp, '^') === 0) {
{
$startchar = ''; $startchar = '';
$search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp); $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
$search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount); $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
} }
$sql .= " AND (sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'"; $sql .= " AND (sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
$sql .= " OR sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')"; $sql .= " OR sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
} else $sql .= natural_search("sa.code_compta", $search_subaccount_tmp); } else {
$sql .= natural_search("sa.code_compta", $search_subaccount_tmp);
}
} }
} }
if (strlen(trim($search_label))) $sql .= natural_search("sa.nom", $search_label); if (strlen(trim($search_label))) {
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'"; $sql .= natural_search("sa.nom", $search_label);
}
if (!empty($search_type) && $search_type >= 0) {
$sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
}
// Supplier // Supplier
$sql .= " UNION "; $sql .= " UNION ";
@ -174,19 +197,24 @@ if (strlen(trim($search_subaccount))) {
$search_subaccount_tmp_clean = $search_subaccount_tmp; $search_subaccount_tmp_clean = $search_subaccount_tmp;
$search_subaccount_clean = $search_subaccount; $search_subaccount_clean = $search_subaccount;
$startchar = '%'; $startchar = '%';
if (strpos($search_subaccount_tmp, '^') === 0) if (strpos($search_subaccount_tmp, '^') === 0) {
{
$startchar = ''; $startchar = '';
$search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp); $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
$search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount); $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
} }
$sql .= " AND (sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'"; $sql .= " AND (sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
$sql .= " OR sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')"; $sql .= " OR sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
} else $sql .= natural_search("sa.code_compta_fournisseur", $search_subaccount_tmp); } else {
$sql .= natural_search("sa.code_compta_fournisseur", $search_subaccount_tmp);
}
} }
} }
if (strlen(trim($search_label))) $sql .= natural_search("sa.nom", $search_label); if (strlen(trim($search_label))) {
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'"; $sql .= natural_search("sa.nom", $search_label);
}
if (!empty($search_type) && $search_type >= 0) {
$sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
}
// User // User
$sql .= " UNION "; $sql .= " UNION ";
@ -216,30 +244,33 @@ if (strlen(trim($search_subaccount))) {
$search_subaccount_tmp_clean = $search_subaccount_tmp; $search_subaccount_tmp_clean = $search_subaccount_tmp;
$search_subaccount_clean = $search_subaccount; $search_subaccount_clean = $search_subaccount;
$startchar = '%'; $startchar = '%';
if (strpos($search_subaccount_tmp, '^') === 0) if (strpos($search_subaccount_tmp, '^') === 0) {
{
$startchar = ''; $startchar = '';
$search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp); $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
$search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount); $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
} }
$sql .= " AND (u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'"; $sql .= " AND (u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
$sql .= " OR u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')"; $sql .= " OR u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
} else $sql .= natural_search("u.accountancy_code", $search_subaccount_tmp); } else {
$sql .= natural_search("u.accountancy_code", $search_subaccount_tmp);
}
} }
} }
if (strlen(trim($search_label))) $sql .= natural_search("u.lastname", $search_label); if (strlen(trim($search_label))) {
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'"; $sql .= natural_search("u.lastname", $search_label);
}
if (!empty($search_type) && $search_type >= 0) {
$sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -250,19 +281,30 @@ $sql .= $db->plimit($limit + 1, $offset);
dol_syslog('accountancy/admin/subaccount.php:: $sql='.$sql); dol_syslog('accountancy/admin/subaccount.php:: $sql='.$sql);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($search_subaccount) $param .= '&search_subaccount='.urlencode($search_subaccount); }
if ($search_label) $param .= '&search_label='.urlencode($search_label); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); $param .= '&limit='.urlencode($limit);
}
if ($search_subaccount) {
$param .= '&search_subaccount='.urlencode($search_subaccount);
}
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
@ -285,10 +327,20 @@ if ($resql)
// Line for search fields // Line for search fields
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['subaccount']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="'.$search_subaccount.'"></td>'; if (!empty($arrayfields['subaccount']['checked'])) {
if (!empty($arrayfields['label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>'; print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="'.$search_subaccount.'"></td>';
if (!empty($arrayfields['type']['checked'])) print '<td class="liste_titre center">'.$form->selectarray('search_type', array('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).'</td>'; }
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; } if (!empty($arrayfields['label']['checked'])) {
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>';
}
if (!empty($arrayfields['type']['checked'])) {
print '<td class="liste_titre center">'.$form->selectarray('search_type', array('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).'</td>';
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
if (!empty($arrayfields['reconcilable']['checked'])) {
print '<td class="liste_titre">&nbsp;</td>';
}
}
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
print $searchpicto; print $searchpicto;
@ -296,62 +348,69 @@ if ($resql)
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($arrayfields['subaccount']['checked'])) print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['subaccount']['checked'])) {
if (!empty($arrayfields['label']['checked'])) print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], "label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center '); }
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print_liste_field_titre($arrayfields['reconcilable']['label'], $_SERVER["PHP_SELF"], 'reconcilable', '', $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['label']['checked'])) {
print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], "label", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['type']['checked'])) {
print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center ');
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
if (!empty($arrayfields['reconcilable']['checked'])) {
print_liste_field_titre($arrayfields['reconcilable']['label'], $_SERVER["PHP_SELF"], 'reconcilable', '', $param, '', $sortfield, $sortorder, 'center ');
}
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
$totalarray = array(); $totalarray = array();
$i = 0; $i = 0;
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Account number // Account number
if (!empty($arrayfields['subaccount']['checked'])) if (!empty($arrayfields['subaccount']['checked'])) {
{
print "<td>"; print "<td>";
print length_accounta($obj->subaccount); print length_accounta($obj->subaccount);
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Subaccount label // Subaccount label
if (!empty($arrayfields['label']['checked'])) if (!empty($arrayfields['label']['checked'])) {
{
print "<td>"; print "<td>";
print $obj->label; print $obj->label;
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Type // Type
if (!empty($arrayfields['type']['checked'])) if (!empty($arrayfields['type']['checked'])) {
{
print '<td class="center">'; print '<td class="center">';
$s = ''; $s = '';
// Customer // Customer
if ($obj->type == 1) if ($obj->type == 1) {
{
$s .= '<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->rowid.'">'.$langs->trans("Customer").'</a>'; $s .= '<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->rowid.'">'.$langs->trans("Customer").'</a>';
} } elseif ($obj->type == 2) {
// Supplier // Supplier
elseif ($obj->type == 2)
{
$s .= '<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->rowid.'">'.$langs->trans("Supplier").'</a>'; $s .= '<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->rowid.'">'.$langs->trans("Supplier").'</a>';
} } elseif ($obj->type == 3) {
// User // User
elseif ($obj->type == 3)
{
$s .= '<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->id.'">'.$langs->trans("Employee").'</a>'; $s .= '<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->id.'">'.$langs->trans("Employee").'</a>';
} }
print $s; print $s;
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
@ -376,25 +435,22 @@ if ($resql)
// Action // Action
print '<td class="center">'; print '<td class="center">';
$e = ''; $e = '';
// Customer // Customer
if ($obj->type == 1) if ($obj->type == 1) {
{
$e .= '<a class="editfielda" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>'; $e .= '<a class="editfielda" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
} } elseif ($obj->type == 2) {
// Supplier // Supplier
elseif ($obj->type == 2)
{
$e .= '<a class="editfielda" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>'; $e .= '<a class="editfielda" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
} } elseif ($obj->type == 3) {
// User // User
elseif ($obj->type == 3)
{
$e .= '<a class="editfielda" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?action=edit&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>'; $e .= '<a class="editfielda" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?action=edit&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
} }
print $e; print $e;
print '</td>'."\n"; print '</td>'."\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n"; print '</tr>'."\n";
$i++; $i++;

View File

@ -48,7 +48,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -74,8 +76,7 @@ $formaccounting = new FormAccounting($db);
$formother = new FormOther($db); $formother = new FormOther($db);
$form = new Form($db); $form = new Form($db);
if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) {
{
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'";
$sql .= $db->plimit(1); $sql .= $db->plimit(1);
@ -87,11 +88,12 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction'))
} else { } else {
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1; $year_end = $year_start + 1;
$month_end = $month_start - 1; $month_end = $month_start - 1;
if ($month_end < 1) if ($month_end < 1) {
{
$month_end = 12; $month_end = 12;
$year_end--; $year_end--;
} }
@ -99,13 +101,21 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction'))
$search_date_end = dol_get_last_day($year_end, $month_end); $search_date_end = dol_get_last_day($year_end, $month_end);
} }
} }
if ($sortorder == "") $sortorder = "ASC"; if ($sortorder == "") {
if ($sortfield == "") $sortfield = "t.numero_compte"; $sortorder = "ASC";
}
if ($sortfield == "") {
$sortfield = "t.numero_compte";
}
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
$filter = array(); $filter = array();
if (!empty($search_date_start)) { if (!empty($search_date_start)) {
@ -129,8 +139,7 @@ if (!empty($search_accountancy_code_end)) {
* Action * Action
*/ */
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')) { // All tests are required to be compatible with all browsers
{
$show_subgroup = ''; $show_subgroup = '';
$search_date_start = ''; $search_date_start = '';
$search_date_end = ''; $search_date_end = '';
@ -144,8 +153,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
* View * View
*/ */
if ($action == 'export_csv') if ($action == 'export_csv') {
{
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$filename = 'balance'; $filename = 'balance';
@ -157,8 +165,7 @@ if ($action == 'export_csv')
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
foreach ($object->lines as $line) foreach ($object->lines as $line) {
{
print length_accountg($line->numero_compte).$sep; print length_accountg($line->numero_compte).$sep;
print $object->get_compte_desc($line->numero_compte).$sep; print $object->get_compte_desc($line->numero_compte).$sep;
print price($line->debit).$sep; print price($line->debit).$sep;
@ -176,12 +183,10 @@ $title_page = $langs->trans("AccountBalance");
llxHeader('', $title_page); llxHeader('', $title_page);
if ($action != 'export_csv') if ($action != 'export_csv') {
{
// List // List
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
if ($nbtotalofrecords < 0) { if ($nbtotalofrecords < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -194,7 +199,9 @@ if ($action != 'export_csv')
} }
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" id="action" value="list">'; print '<input type="hidden" name="action" id="action" value="list">';
@ -263,7 +270,9 @@ if ($action != 'export_csv')
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
}
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
@ -298,8 +307,7 @@ if ($action != 'export_csv')
} }
} }
foreach ($object->lines as $line) foreach ($object->lines as $line) {
{
// reset before the fetch (in case of the fetch fails) // reset before the fetch (in case of the fetch fails)
$accountingaccountstatic->id = 0; $accountingaccountstatic->id = 0;
$accountingaccountstatic->account_number = ''; $accountingaccountstatic->account_number = '';
@ -336,15 +344,16 @@ if ($action != 'export_csv')
//$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>'; //$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
} }
if (!empty($show_subgroup)) if (!empty($show_subgroup)) {
{
// Show accounting account // Show accounting account
if (empty($displayed_account) || $root_account_number != $displayed_account) { if (empty($displayed_account) || $root_account_number != $displayed_account) {
// Show subtotal per accounting account // Show subtotal per accounting account
if ($displayed_account != "") { if ($displayed_account != "") {
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td class="right">'.$langs->trans("SubTotal").':</td>'; print '<td class="right">'.$langs->trans("SubTotal").':</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowrap right">'.price($sous_total_opening_balance).'</td>'; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowrap right">'.price($sous_total_opening_balance).'</td>';
}
print '<td class="nowrap right">'.price($sous_total_debit).'</td>'; print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>'; print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
@ -370,7 +379,9 @@ if ($action != 'export_csv')
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$accounting_account.'</td>'; print '<td>'.$accounting_account.'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowraponall right">'.price($opening_balance).'</td>'; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowraponall right">'.price($opening_balance).'</td>';
}
$urlzoom = ''; $urlzoom = '';
if ($line->numero_compte) { if ($line->numero_compte) {
@ -402,10 +413,11 @@ if ($action != 'export_csv')
$sous_total_opening_balance += $opening_balance; $sous_total_opening_balance += $opening_balance;
} }
if (!empty($show_subgroup)) if (!empty($show_subgroup)) {
{
print '<tr class="liste_total"><td class="right">'.$langs->trans("SubTotal").':</td>'; print '<tr class="liste_total"><td class="right">'.$langs->trans("SubTotal").':</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowrap right">'.price($sous_total_opening_balance).'</td>'; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowrap right">'.price($sous_total_opening_balance).'</td>';
}
print '<td class="nowrap right">'.price($sous_total_debit).'</td>'; print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>'; print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
@ -418,7 +430,9 @@ if ($action != 'export_csv')
} }
print '<tr class="liste_total"><td class="right">'.$langs->trans("AccountBalance").':</td>'; print '<tr class="liste_total"><td class="right">'.$langs->trans("AccountBalance").':</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '<td class="nowrap right">'.price($total_opening_balance).'</td>'; if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
print '<td class="nowrap right">'.price($total_opening_balance).'</td>';
}
print '<td class="nowrap right">'.price($total_debit).'</td>'; print '<td class="nowrap right">'.price($total_debit).'</td>';
print '<td class="nowrap right">'.price($total_credit).'</td>'; print '<td class="nowrap right">'.price($total_credit).'</td>';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {

View File

@ -1,136 +0,0 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountancy/bookkeeping/balancebymonth.php
* \ingroup Accountancy (Double entries)
* \brief Balance by month
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills", "compta", "accountancy", "other"));
// Filter
$year = GETPOST("year", 'int');
if ($year == 0) {
$year_current = strftime("%Y", time());
$year_start = $year_current;
} else {
$year_current = $year;
$year_start = $year;
}
/*
* View
*/
llxHeader('', $langs->trans("Bookkeeping"));
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("AccountBalanceByMonth").' '.$textprevyear.' '.$langs->trans("Year").' '.$year_start.' '.$textnextyear);
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " , ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE fd.fk_code_ventilation = 0";
$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;";
dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql);
$result = $db->query($sql);
if ($result) {
$row = $db->fetch_row($result);
$nbfac = $row[0];
$db->free($result);
}
$y = $year_current;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width=150>'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++)
{
print '<td class="right">'.$langs->trans("MonthShort".sprintf("%02s", $i)).'</td>';
}
print '<td class="center"><strong>'.$langs->trans("Total").'</strong></td>';
print '</tr>';
$sql = "SELECT bk.numero_compte AS 'compte',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=1,bk.montant,0)),2) AS 'Janvier',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=2,bk.montant,0)),2) AS 'Fevrier',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=3,bk.montant,0)),2) AS 'Mars',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=4,bk.montant,0)),2) AS 'Avril',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=5,bk.montant,0)),2) AS 'Mai',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=6,bk.montant,0)),2) AS 'Juin',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=7,bk.montant,0)),2) AS 'Juillet',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=8,bk.montant,0)),2) AS 'Aout',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=9,bk.montant,0)),2) AS 'Septembre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',";
$sql .= " ROUND(SUM(bk.montant),2) as 'Total'";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
$sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
$sql .= " GROUP BY bk.numero_compte";
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ($i < $num) {
$row = $db->fetch_row($resql);
print '<tr class="oddeven"><td width="14%">'.length_accountg($row[0]).'</td>';
print '<td class="right" width="6.5%">'.price($row[1]).'</td>';
print '<td class="right" width="6.5%">'.price($row[2]).'</td>';
print '<td class="right" width="6.5%">'.price($row[3]).'</td>';
print '<td class="right" width="6.5%">'.price($row[4]).'</td>';
print '<td class="right" width="6.5%">'.price($row[5]).'</td>';
print '<td class="right" width="6.5%">'.price($row[6]).'</td>';
print '<td class="right" width="6.5%">'.price($row[7]).'</td>';
print '<td class="right" width="6.5%">'.price($row[8]).'</td>';
print '<td class="right" width="6.5%">'.price($row[9]).'</td>';
print '<td class="right" width="6.5%">'.price($row[10]).'</td>';
print '<td class="right" width="6.5%">'.price($row[11]).'</td>';
print '<td class="right" width="6.5%">'.price($row[12]).'</td>';
print '<td class="right" width="8%"><strong>'.price($row[13]).'</strong></td>';
print '</tr>';
$i++;
}
$db->free($resql);
} else {
print $db->lasterror();
}
print "</table>\n";
// End of page
llxFooter();
$db->close();

View File

@ -73,9 +73,13 @@ $debit = price2num(GETPOST('debit', 'alpha'));
$credit = price2num(GETPOST('credit', 'alpha')); $credit = price2num(GETPOST('credit', 'alpha'));
$save = GETPOST('save', 'alpha'); $save = GETPOST('save', 'alpha');
if (!empty($save)) $action = 'add'; if (!empty($save)) {
$action = 'add';
}
$update = GETPOST('update', 'alpha'); $update = GETPOST('update', 'alpha');
if (!empty($update)) $action = 'confirm_update'; if (!empty($update)) {
$action = 'confirm_update';
}
$object = new BookKeeping($db); $object = new BookKeeping($db);
@ -92,15 +96,13 @@ if ($action == "confirm_update") {
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$action = 'update'; $action = 'update';
} }
if (empty($accountingaccount_number) || $accountingaccount_number == '-1') if (empty($accountingaccount_number) || $accountingaccount_number == '-1') {
{
$error++; $error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
$action = 'update'; $action = 'update';
} }
if (!$error) if (!$error) {
{
$object = new BookKeeping($db); $object = new BookKeeping($db);
$result = $object->fetch($id, null, $mode); $result = $object->fetch($id, null, $mode);
@ -145,14 +147,12 @@ if ($action == "confirm_update") {
} elseif ($action == "add") { } elseif ($action == "add") {
$error = 0; $error = 0;
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
{
$error++; $error++;
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$action = ''; $action = '';
} }
if (empty($accountingaccount_number) || $accountingaccount_number == '-1') if (empty($accountingaccount_number) || $accountingaccount_number == '-1') {
{
$error++; $error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
$action = ''; $action = '';
@ -228,15 +228,13 @@ if ($action == "confirm_update") {
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (!GETPOST('doc_ref', 'alpha')) if (!GETPOST('doc_ref', 'alpha')) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors');
$action = 'create'; $action = 'create';
$error++; $error++;
} }
if (!$error) if (!$error) {
{
$object->label_compte = ''; $object->label_compte = '';
$object->debit = 0; $object->debit = 0;
$object->credit = 0; $object->credit = 0;
@ -255,8 +253,7 @@ if ($action == "confirm_update") {
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
if ($mode != '_tmp') if ($mode != '_tmp') {
{
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
$action = 'update'; $action = 'update';
@ -272,8 +269,7 @@ if ($action == 'setdate') {
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
if ($mode != '_tmp') if ($mode != '_tmp') {
{
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
$action = ''; $action = '';
@ -286,8 +282,7 @@ if ($action == 'setjournal') {
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
if ($mode != '_tmp') if ($mode != '_tmp') {
{
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
$action = ''; $action = '';
@ -300,8 +295,7 @@ if ($action == 'setdocref') {
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
if ($mode != '_tmp') if ($mode != '_tmp') {
{
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
$action = ''; $action = '';
@ -335,20 +329,20 @@ if ($action == 'delete') {
print $formconfirm; print $formconfirm;
} }
if ($action == 'create') if ($action == 'create') {
{
print load_fiche_titre($langs->trans("CreateMvts")); print load_fiche_titre($langs->trans("CreateMvts"));
$object = new BookKeeping($db); $object = new BookKeeping($db);
$next_num_mvt = $object->getNextNumMvt('_tmp'); $next_num_mvt = $object->getNextNumMvt('_tmp');
if (empty($next_num_mvt)) if (empty($next_num_mvt)) {
{
dol_print_error('', 'Failed to get next piece number'); dol_print_error('', 'Failed to get next piece number');
} }
print '<form action="'.$_SERVER["PHP_SELF"].'" name="create_mvt" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" name="create_mvt" method="POST">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="confirm_create">'."\n"; print '<input type="hidden" name="action" value="confirm_create">'."\n";
print '<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.'">'."\n"; print '<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.'">'."\n";
@ -405,8 +399,7 @@ if ($action == 'create')
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
if (!empty($object->piece_num)) if (!empty($object->piece_num)) {
{
$backlink = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans('BackToList').'</a>'; $backlink = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans('BackToList').'</a>';
print load_fiche_titre($langs->trans("UpdateMvts"), $backlink); print load_fiche_titre($langs->trans("UpdateMvts"), $backlink);
@ -439,13 +432,16 @@ if ($action == 'create')
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Docdate'); print $langs->trans('Docdate');
print '</td>'; print '</td>';
if ($action != 'editdate') if ($action != 'editdate') {
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;piece_num='.$object->piece_num.'&amp;mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'</a></td>'; print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;piece_num='.$object->piece_num.'&amp;mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'</a></td>';
}
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($action == 'editdate') { if ($action == 'editdate') {
print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">'; print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdate">'; print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
@ -463,13 +459,16 @@ if ($action == 'create')
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Codejournal'); print $langs->trans('Codejournal');
print '</td>'; print '</td>';
if ($action != 'editjournal') if ($action != 'editjournal') {
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editjournal&amp;piece_num='.$object->piece_num.'&amp;mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>'; print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editjournal&amp;piece_num='.$object->piece_num.'&amp;mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
}
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editjournal') { if ($action == 'editjournal') {
print '<form name="setjournal" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">'; print '<form name="setjournal" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setjournal">'; print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
@ -487,13 +486,16 @@ if ($action == 'create')
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Piece'); print $langs->trans('Piece');
print '</td>'; print '</td>';
if ($action != 'editdocref') if ($action != 'editdocref') {
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdocref&amp;piece_num='.$object->piece_num.'&amp;mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>'; print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdocref&amp;piece_num='.$object->piece_num.'&amp;mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
}
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editdocref') { if ($action == 'editdocref') {
print '<form name="setdocref" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">'; print '<form name="setdocref" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setdocref">'; print '<input type="hidden" name="action" value="setdocref">';
print '<input type="hidden" name="mode" value="'.$mode.'">'; print '<input type="hidden" name="mode" value="'.$mode.'">';
@ -516,8 +518,7 @@ if ($action == 'create')
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
// Doc type // Doc type
if (!empty($object->doc_type)) if (!empty($object->doc_type)) {
{
print '<tr>'; print '<tr>';
print '<td class="titlefield">'.$langs->trans("Doctype").'</td>'; print '<td class="titlefield">'.$langs->trans("Doctype").'</td>';
print '<td>'.$object->doc_type.'</td>'; print '<td>'.$object->doc_type.'</td>';
@ -589,7 +590,9 @@ if ($action == 'create')
print load_fiche_titre($langs->trans("ListeMvts"), '', ''); print load_fiche_titre($langs->trans("ListeMvts"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="doc_date" value="'.$object->doc_date.'">'."\n"; print '<input type="hidden" name="doc_date" value="'.$object->doc_date.'">'."\n";
print '<input type="hidden" name="doc_type" value="'.$object->doc_type.'">'."\n"; print '<input type="hidden" name="doc_type" value="'.$object->doc_type.'">'."\n";
@ -664,7 +667,9 @@ if ($action == 'create')
print '</a> &nbsp;'; print '</a> &nbsp;';
$actiontodelete = 'delete'; $actiontodelete = 'delete';
if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete = 'confirm_delete'; if ($mode == '_tmp' || $action != 'delmouv') {
$actiontodelete = 'confirm_delete';
}
print '<a href="'.$_SERVER["PHP_SELF"].'?action='.$actiontodelete.'&id='.$line->id.'&piece_num='.urlencode($line->piece_num).'&mode='.urlencode($mode).'&token='.urlencode(newToken()).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action='.$actiontodelete.'&id='.$line->id.'&piece_num='.urlencode($line->piece_num).'&mode='.urlencode($mode).'&token='.urlencode(newToken()).'">';
print img_delete(); print img_delete();
@ -678,8 +683,7 @@ if ($action == 'create')
$total_debit = price2num($total_debit, 'MT'); $total_debit = price2num($total_debit, 'MT');
$total_credit = price2num($total_credit, 'MT'); $total_credit = price2num($total_credit, 'MT');
if ($total_debit != $total_credit) if ($total_debit != $total_credit) {
{
setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings');
} }
@ -710,12 +714,10 @@ if ($action == 'create')
print '</table>'; print '</table>';
if ($mode == '_tmp' && $action == '') if ($mode == '_tmp' && $action == '') {
{
print '<br>'; print '<br>';
print '<div class="center">'; print '<div class="center">';
if ($total_debit == $total_credit) if ($total_debit == $total_credit) {
{
print '<a class="button" href="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'&action=valid">'.$langs->trans("ValidTransaction").'</a>'; print '<a class="button" href="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'&action=valid">'.$langs->trans("ValidTransaction").'</a>';
} else { } else {
print '<input type="submit" class="button" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $debit, $credit)).'" value="'.dol_escape_htmltag($langs->trans("ValidTransaction")).'">'; print '<input type="submit" class="button" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $debit, $credit)).'" value="'.dol_escape_htmltag($langs->trans("ValidTransaction")).'">';

View File

@ -94,12 +94,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; } if (empty($page) || $page < 0) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC"; if ($sortorder == "") {
if ($sortfield == "") $sortfield = "t.piece_num,t.rowid"; $sortorder = "ASC";
}
if ($sortfield == "") {
$sortfield = "t.piece_num,t.rowid";
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new BookKeeping($db); $object = new BookKeeping($db);
@ -108,10 +114,8 @@ $hookmanager->initHooks(array('bookkeepinglist'));
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$form = new Form($db); $form = new Form($db);
if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) {
{ if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) {
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values'))
{
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
$res = $db->query($query); $res = $db->query($query);
@ -123,11 +127,12 @@ if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GE
} else { } else {
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1; $year_end = $year_start + 1;
$month_end = $month_start - 1; $month_end = $month_start - 1;
if ($month_end < 1) if ($month_end < 1) {
{
$month_end = 12; $month_end = 12;
$year_end--; $year_end--;
} }
@ -154,11 +159,15 @@ $arrayfields = array(
't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
); );
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
unset($arrayfields['t.lettering_code']);
}
$listofformat = AccountancyExport::getType(); $listofformat = AccountancyExport::getType();
$formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV; $formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV;
if (empty($listofformat[$formatexportset])) $formatexportset = 1; if (empty($listofformat[$formatexportset])) {
$formatexportset = 1;
}
$error = 0; $error = 0;
@ -167,19 +176,23 @@ $error = 0;
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array('socid'=>$socid); $parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
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')) { // All tests are required to be compatible with all browsers
{
$search_mvt_num = ''; $search_mvt_num = '';
$search_doc_type = ''; $search_doc_type = '';
$search_doc_ref = ''; $search_doc_ref = '';
@ -348,8 +361,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
$deljournal = 0; $deljournal = 0;
} }
if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
{
$result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -381,7 +393,9 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri
} }
if ($action == 'setreexport') { if ($action == 'setreexport') {
$setreexport = GETPOST('value', 'int'); $setreexport = GETPOST('value', 'int');
if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) {
$error++;
}
if (!$error) { if (!$error) {
if ($conf->global->ACCOUNTING_REEXPORT == 1) { if ($conf->global->ACCOUNTING_REEXPORT == 1) {
@ -475,26 +489,22 @@ if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->ex
// TODO Replace the fetchAll + ->export later that consume too much memory on large export with the query($sql) and loop on each line to export them. // TODO Replace the fetchAll + ->export later that consume too much memory on large export with the query($sql) and loop on each line to export them.
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT); $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT);
if ($result < 0) if ($result < 0) {
{
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
// Export files // Export files
$accountancyexport = new AccountancyExport($db); $accountancyexport = new AccountancyExport($db);
$accountancyexport->export($object->lines, $formatexportset); $accountancyexport->export($object->lines, $formatexportset);
if (!empty($accountancyexport->errors)) if (!empty($accountancyexport->errors)) {
{
setEventMessages('', $accountancyexport->errors, 'errors'); setEventMessages('', $accountancyexport->errors, 'errors');
} else { } else {
// Specify as export : update field date_export // Specify as export : update field date_export
$error = 0; $error = 0;
$db->begin(); $db->begin();
if (is_array($object->lines)) if (is_array($object->lines)) {
{ foreach ($object->lines as $movement) {
foreach ($object->lines as $movement)
{
$now = dol_now(); $now = dol_now();
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
@ -504,16 +514,14 @@ if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->ex
dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
$error++; $error++;
break; break;
} }
} }
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
// setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
} else { } else {
@ -538,26 +546,22 @@ $title_page = $langs->trans("Operations").' - '.$langs->trans("Journals");
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
{
$num = $nbtotalofrecords; $num = $nbtotalofrecords;
} else { } else {
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
@ -636,19 +640,28 @@ if ($action == 'delbookkeepingyear') {
} }
//$param=''; param started before //$param=''; param started before
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">';
}
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.urlencode($sortfield).'">'; print '<input type="hidden" name="sortfield" value="'.urlencode($sortfield).'">';
print '<input type="hidden" name="sortorder" value="'.urlencode($sortorder).'">'; print '<input type="hidden" name="sortorder" value="'.urlencode($sortorder).'">';
if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList"); if (count($filter)) {
else $buttonLabel = $langs->trans("ExportList"); $buttonLabel = $langs->trans("ExportFilteredList");
} else {
$buttonLabel = $langs->trans("ExportList");
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
@ -661,14 +674,18 @@ if (empty($reshook)) {
} }
$newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>'; $newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
if (!empty($user->rights->accounting->mouvements->export)) $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); if (!empty($user->rights->accounting->mouvements->export)) {
$newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export);
}
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
$url = './card.php?action=create'; $url = './card.php?action=create';
if (!empty($socid)) $url .= '&socid='.$socid; if (!empty($socid)) {
$url .= '&socid='.$socid;
}
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer); $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer);
} }
@ -676,12 +693,17 @@ print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield,
$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
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); if ($massactionbutton) {
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; if (empty($reshook)) {
else $moreforfilter = $hookmanager->resPrint; $moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste centpercent">'; print '<table class="tagtable liste centpercent">';
@ -690,18 +712,15 @@ print '<table class="tagtable liste centpercent">';
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
// Movement number // Movement number
if (!empty($arrayfields['t.piece_num']['checked'])) if (!empty($arrayfields['t.piece_num']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>'; print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
} }
// Code journal // Code journal
if (!empty($arrayfields['t.code_journal']['checked'])) if (!empty($arrayfields['t.code_journal']['checked'])) {
{
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.(is_array($search_ledger_code) ? join('|', $search_ledger_code) : $search_ledger_code).'"></td>'; print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.(is_array($search_ledger_code) ? join('|', $search_ledger_code) : $search_ledger_code).'"></td>';
} }
// Date document // Date document
if (!empty($arrayfields['t.doc_date']['checked'])) if (!empty($arrayfields['t.doc_date']['checked'])) {
{
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
@ -712,13 +731,11 @@ if (!empty($arrayfields['t.doc_date']['checked']))
print '</td>'; print '</td>';
} }
// Ref document // Ref document
if (!empty($arrayfields['t.doc_ref']['checked'])) if (!empty($arrayfields['t.doc_ref']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).'"></td>'; print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
} }
// Accountancy account // Accountancy account
if (!empty($arrayfields['t.numero_compte']['checked'])) if (!empty($arrayfields['t.numero_compte']['checked'])) {
{
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $langs->trans('From').' '; print $langs->trans('From').' ';
@ -731,14 +748,12 @@ if (!empty($arrayfields['t.numero_compte']['checked']))
print '</td>'; print '</td>';
} }
// Subledger account // Subledger account
if (!empty($arrayfields['t.subledger_account']['checked'])) if (!empty($arrayfields['t.subledger_account']['checked'])) {
{
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<div class="nowrap">'; print '<div class="nowrap">';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database. // use setup of keypress to select thirdparty and this hang browser on large database.
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
{
print $langs->trans('From').' '; print $langs->trans('From').' ';
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1); print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
} else { } else {
@ -748,8 +763,7 @@ if (!empty($arrayfields['t.subledger_account']['checked']))
print '<div class="nowrap">'; print '<div class="nowrap">';
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
// use setup of keypress to select thirdparty and this hang browser on large database. // use setup of keypress to select thirdparty and this hang browser on large database.
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
{
print $langs->trans('to').' '; print $langs->trans('to').' ';
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1); print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
} else { } else {
@ -759,29 +773,25 @@ if (!empty($arrayfields['t.subledger_account']['checked']))
print '</td>'; print '</td>';
} }
// Label operation // Label operation
if (!empty($arrayfields['t.label_operation']['checked'])) if (!empty($arrayfields['t.label_operation']['checked'])) {
{
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.$search_mvt_label.'"/>'; print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.$search_mvt_label.'"/>';
print '</td>'; print '</td>';
} }
// Debit // Debit
if (!empty($arrayfields['t.debit']['checked'])) if (!empty($arrayfields['t.debit']['checked'])) {
{
print '<td class="liste_titre right">'; print '<td class="liste_titre right">';
print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">'; print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
print '</td>'; print '</td>';
} }
// Credit // Credit
if (!empty($arrayfields['t.credit']['checked'])) if (!empty($arrayfields['t.credit']['checked'])) {
{
print '<td class="liste_titre right">'; print '<td class="liste_titre right">';
print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">'; print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
print '</td>'; print '</td>';
} }
// Lettering code // Lettering code
if (!empty($arrayfields['t.lettering_code']['checked'])) if (!empty($arrayfields['t.lettering_code']['checked'])) {
{
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>'; print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>'; print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
@ -794,8 +804,7 @@ $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // N
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Date creation // Date creation
if (!empty($arrayfields['t.date_creation']['checked'])) if (!empty($arrayfields['t.date_creation']['checked'])) {
{
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
@ -806,8 +815,7 @@ if (!empty($arrayfields['t.date_creation']['checked']))
print '</td>'; print '</td>';
} }
// Date modification // Date modification
if (!empty($arrayfields['t.tms']['checked'])) if (!empty($arrayfields['t.tms']['checked'])) {
{
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
@ -818,8 +826,7 @@ if (!empty($arrayfields['t.tms']['checked']))
print '</td>'; print '</td>';
} }
// Date export // Date export
if (!empty($arrayfields['t.date_export']['checked'])) if (!empty($arrayfields['t.date_export']['checked'])) {
{
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
@ -837,23 +844,49 @@ print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['t.piece_num']['checked'])) {
if (!empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); }
if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['t.code_journal']['checked'])) {
if (!empty($arrayfields['t.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); }
if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['t.doc_date']['checked'])) {
if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); }
if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['t.doc_ref']['checked'])) {
print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['t.numero_compte']['checked'])) {
print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['t.subledger_account']['checked'])) {
print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['t.label_operation']['checked'])) {
print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['t.debit']['checked'])) {
print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['t.credit']['checked'])) {
print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['t.lettering_code']['checked'])) {
print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
}
// Hook fields // Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (!empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['t.date_creation']['checked'])) {
if (!empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); }
if (!empty($arrayfields['t.tms']['checked'])) {
print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.date_export']['checked'])) {
print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";
@ -864,10 +897,11 @@ $line = new BookKeepingLine();
// -------------------------------------------------------------------- // --------------------------------------------------------------------
$i = 0; $i = 0;
$totalarray = array(); $totalarray = array();
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen if (empty($obj)) {
break; // Should not happen
}
$line->id = $obj->rowid; $line->id = $obj->rowid;
$line->doc_date = $db->jdate($obj->doc_date); $line->doc_date = $db->jdate($obj->doc_date);
@ -902,38 +936,39 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Piece number // Piece number
if (!empty($arrayfields['t.piece_num']['checked'])) if (!empty($arrayfields['t.piece_num']['checked'])) {
{
print '<td>'; print '<td>';
$object->id = $line->id; $object->id = $line->id;
$object->piece_num = $line->piece_num; $object->piece_num = $line->piece_num;
print $object->getNomUrl(1, '', 0, '', 1); print $object->getNomUrl(1, '', 0, '', 1);
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Journal code // Journal code
if (!empty($arrayfields['t.code_journal']['checked'])) if (!empty($arrayfields['t.code_journal']['checked'])) {
{
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('', $line->code_journal); $result = $accountingjournal->fetch('', $line->code_journal);
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
print '<td class="center">'.$journaltoshow.'</td>'; print '<td class="center">'.$journaltoshow.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Document date // Document date
if (!empty($arrayfields['t.doc_date']['checked'])) if (!empty($arrayfields['t.doc_date']['checked'])) {
{
print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>'; print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Document ref // Document ref
if (!empty($arrayfields['t.doc_ref']['checked'])) if (!empty($arrayfields['t.doc_ref']['checked'])) {
{ if ($line->doc_type == 'customer_invoice') {
if ($line->doc_type == 'customer_invoice')
{
$langs->loadLangs(array('bills')); $langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -945,8 +980,7 @@ while ($i < min($num, $limit))
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'supplier_invoice') } elseif ($line->doc_type == 'supplier_invoice') {
{
$langs->loadLangs(array('bills')); $langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
@ -958,8 +992,7 @@ while ($i < min($num, $limit))
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
} elseif ($line->doc_type == 'expense_report') } elseif ($line->doc_type == 'expense_report') {
{
$langs->loadLangs(array('trips')); $langs->loadLangs(array('trips'));
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
@ -971,8 +1004,7 @@ while ($i < min($num, $limit))
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'bank') } elseif ($line->doc_type == 'bank') {
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$objectstatic = new AccountLine($db); $objectstatic = new AccountLine($db);
$objectstatic->fetch($line->fk_doc); $objectstatic->fetch($line->fk_doc);
@ -986,8 +1018,7 @@ while ($i < min($num, $limit))
// Picto + Ref // Picto + Ref
print '<td class="nobordernopadding nowrap">'; print '<td class="nobordernopadding nowrap">';
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
{
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
print $documentlink; print $documentlink;
} elseif ($line->doc_type == 'bank') { } elseif ($line->doc_type == 'bank') {
@ -1000,53 +1031,65 @@ while ($i < min($num, $limit))
print '</td></tr></table>'; print '</td></tr></table>';
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Account number // Account number
if (!empty($arrayfields['t.numero_compte']['checked'])) if (!empty($arrayfields['t.numero_compte']['checked'])) {
{
print '<td>'.length_accountg($line->numero_compte).'</td>'; print '<td>'.length_accountg($line->numero_compte).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Subledger account // Subledger account
if (!empty($arrayfields['t.subledger_account']['checked'])) if (!empty($arrayfields['t.subledger_account']['checked'])) {
{
print '<td>'.length_accounta($line->subledger_account).'</td>'; print '<td>'.length_accounta($line->subledger_account).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Label operation // Label operation
if (!empty($arrayfields['t.label_operation']['checked'])) if (!empty($arrayfields['t.label_operation']['checked'])) {
{
print '<td>'.$line->label_operation.'</td>'; print '<td>'.$line->label_operation.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Amount debit // Amount debit
if (!empty($arrayfields['t.debit']['checked'])) if (!empty($arrayfields['t.debit']['checked'])) {
{
print '<td class="nowrap right">'.($line->debit != 0 ? price($line->debit) : '').'</td>'; print '<td class="nowrap right">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; $totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
}
$totalarray['val']['totaldebit'] += $line->debit; $totalarray['val']['totaldebit'] += $line->debit;
} }
// Amount credit // Amount credit
if (!empty($arrayfields['t.credit']['checked'])) if (!empty($arrayfields['t.credit']['checked'])) {
{
print '<td class="nowrap right">'.($line->credit != 0 ? price($line->credit) : '').'</td>'; print '<td class="nowrap right">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; $totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
}
$totalarray['val']['totalcredit'] += $line->credit; $totalarray['val']['totalcredit'] += $line->credit;
} }
// Lettering code // Lettering code
if (!empty($arrayfields['t.lettering_code']['checked'])) if (!empty($arrayfields['t.lettering_code']['checked'])) {
{
print '<td class="center">'.$line->lettering_code.'</td>'; print '<td class="center">'.$line->lettering_code.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Fields from hook // Fields from hook
@ -1055,24 +1098,27 @@ while ($i < min($num, $limit))
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Creation operation date // Creation operation date
if (!empty($arrayfields['t.date_creation']['checked'])) if (!empty($arrayfields['t.date_creation']['checked'])) {
{
print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour').'</td>'; print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Modification operation date // Modification operation date
if (!empty($arrayfields['t.tms']['checked'])) if (!empty($arrayfields['t.tms']['checked'])) {
{
print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour').'</td>'; print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Exported operation date // Exported operation date
if (!empty($arrayfields['t.date_export']['checked'])) if (!empty($arrayfields['t.date_export']['checked'])) {
{
print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>'; print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Action column // Action column
@ -1087,7 +1133,9 @@ while ($i < min($num, $limit))
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
print "</tr>\n"; print "</tr>\n";

View File

@ -85,12 +85,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; } if (empty($page) || $page < 0) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC"; if ($sortorder == "") {
if ($sortfield == "") $sortfield = "t.doc_date,t.rowid"; $sortorder = "ASC";
}
if ($sortfield == "") {
$sortfield = "t.doc_date,t.rowid";
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new BookKeeping($db); $object = new BookKeeping($db);
@ -113,11 +119,12 @@ if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('searc
} else { } else {
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1; $year_end = $year_start + 1;
$month_end = $month_start - 1; $month_end = $month_start - 1;
if ($month_end < 1) if ($month_end < 1) {
{
$month_end = 12; $month_end = 12;
$year_end--; $year_end--;
} }
@ -139,7 +146,9 @@ $arrayfields = array(
't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
); );
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
unset($arrayfields['t.lettering_code']);
}
if ($search_date_start && empty($search_date_startyear)) { if ($search_date_start && empty($search_date_startyear)) {
$tmparray = dol_getdate($search_date_start); $tmparray = dol_getdate($search_date_start);
@ -159,19 +168,23 @@ if ($search_date_end && empty($search_date_endyear)) {
* Action * Action
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array('socid'=>$socid); $parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
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')) { // All tests are required to be compatible with all browsers
{
$search_doc_date = ''; $search_doc_date = '';
$search_accountancy_code = ''; $search_accountancy_code = '';
$search_accountancy_code_start = ''; $search_accountancy_code_start = '';
@ -305,8 +318,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
$deljournal = 0; $deljournal = 0;
} }
if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
{
$result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0)); $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -418,7 +430,9 @@ if ($action == 'delbookkeepingyear') {
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
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="formfilteraction" id="formfilteraction" 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.'">';
@ -432,18 +446,27 @@ if (empty($reshook)) {
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
} }
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
$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
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); if ($massactionbutton) {
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
}
// Reverse sort order // Reverse sort order
if (preg_match('/^asc/i', $sortorder)) $sortorder = "asc"; if (preg_match('/^asc/i', $sortorder)) {
else $sortorder = "desc"; $sortorder = "asc";
} else {
$sortorder = "desc";
}
$moreforfilter = ''; $moreforfilter = '';
@ -460,8 +483,11 @@ $moreforfilter .= '</div>';
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; if (empty($reshook)) {
else $moreforfilter = $hookmanager->resPrint; $moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter; print $moreforfilter;
@ -474,8 +500,7 @@ print '<table class="tagtable liste centpercent">';
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
// Movement number // Movement number
if (!empty($arrayfields['t.piece_num']['checked'])) if (!empty($arrayfields['t.piece_num']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>'; print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
} }
// Code journal // Code journal
@ -512,8 +537,7 @@ if (!empty($arrayfields['t.credit']['checked'])) {
print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'"></td>'; print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'"></td>';
} }
// Lettering code // Lettering code
if (!empty($arrayfields['t.lettering_code']['checked'])) if (!empty($arrayfields['t.lettering_code']['checked'])) {
{
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>'; print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>'; print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
@ -544,15 +568,33 @@ print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($arrayfields['t.piece_num']['checked'])) print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['t.piece_num']['checked'])) {
if (!empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center '); }
if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['t.code_journal']['checked'])) {
if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); }
if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['t.doc_date']['checked'])) {
if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); }
if (!empty($arrayfields['t.doc_ref']['checked'])) {
print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['t.label_operation']['checked'])) {
print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['t.debit']['checked'])) {
print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['t.credit']['checked'])) {
print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['t.lettering_code']['checked'])) {
print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['t.date_export']['checked'])) {
print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
}
// Hook fields // Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
@ -571,8 +613,7 @@ $displayed_account_number = null; // Start with undefined to be able to distingu
// -------------------------------------------------------------------- // --------------------------------------------------------------------
$i = 0; $i = 0;
$totalarray = array(); $totalarray = array();
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$line = $object->lines[$i]; $line = $object->lines[$i];
$total_debit += $line->debit; $total_debit += $line->debit;
@ -586,11 +627,15 @@ while ($i < min($num, $limit))
$colnumber = 5; $colnumber = 5;
$colnumberend = 7; $colnumberend = 7;
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) $colnumber--; if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
if (empty($arrayfields['t.date_export']['checked'])) $colnumber--; $colnumber--;
}
if (empty($arrayfields['t.date_export']['checked'])) {
$colnumber--;
}
$colspan = $totalarray['nbfield'] - $colnumber; $colspan = $totalarray['nbfield'] - $colnumber;
$colspanend = $totalarray['nbfield'] - $colnumberend; $colspanend = $totalarray['nbfield'] - $colnumberend;
// Show a subtotal by accounting account // Show a subtotal by accounting account
if (isset($displayed_account_number)) { if (isset($displayed_account_number)) {
print '<tr class="liste_total">'; print '<tr class="liste_total">';
@ -603,8 +648,7 @@ while ($i < min($num, $limit))
$balance = $sous_total_debit - $sous_total_credit; $balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>'; print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0) if ($balance > 0) {
{
print '<td class="nowraponall right">'; print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit); print price($sous_total_debit - $sous_total_credit);
print '</td>'; print '</td>';
@ -622,8 +666,11 @@ while ($i < min($num, $limit))
// Show the break account // Show the break account
print "<tr>"; print "<tr>";
print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : 10).'" style="font-weight:bold; border-bottom: 1pt solid black;">'; print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : 10).'" style="font-weight:bold; border-bottom: 1pt solid black;">';
if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte); if ($line->numero_compte != "" && $line->numero_compte != '-1') {
else print '<span class="error">'.$langs->trans("Unknown").'</span>'; print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte);
} else {
print '<span class="error">'.$langs->trans("Unknown").'</span>';
}
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -638,38 +685,39 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Piece number // Piece number
if (!empty($arrayfields['t.piece_num']['checked'])) if (!empty($arrayfields['t.piece_num']['checked'])) {
{
print '<td>'; print '<td>';
$object->id = $line->id; $object->id = $line->id;
$object->piece_num = $line->piece_num; $object->piece_num = $line->piece_num;
print $object->getNomUrl(1, '', 0, '', 1); print $object->getNomUrl(1, '', 0, '', 1);
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Journal code // Journal code
if (!empty($arrayfields['t.code_journal']['checked'])) if (!empty($arrayfields['t.code_journal']['checked'])) {
{
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('', $line->code_journal); $result = $accountingjournal->fetch('', $line->code_journal);
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal); $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
print '<td class="center">'.$journaltoshow.'</td>'; print '<td class="center">'.$journaltoshow.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Document date // Document date
if (!empty($arrayfields['t.doc_date']['checked'])) if (!empty($arrayfields['t.doc_date']['checked'])) {
{
print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>'; print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Document ref // Document ref
if (!empty($arrayfields['t.doc_ref']['checked'])) if (!empty($arrayfields['t.doc_ref']['checked'])) {
{ if ($line->doc_type == 'customer_invoice') {
if ($line->doc_type == 'customer_invoice')
{
$langs->loadLangs(array('bills')); $langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
@ -681,8 +729,7 @@ while ($i < min($num, $limit))
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'supplier_invoice') } elseif ($line->doc_type == 'supplier_invoice') {
{
$langs->loadLangs(array('bills')); $langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
@ -694,8 +741,7 @@ while ($i < min($num, $limit))
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
} elseif ($line->doc_type == 'expense_report') } elseif ($line->doc_type == 'expense_report') {
{
$langs->loadLangs(array('trips')); $langs->loadLangs(array('trips'));
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
@ -707,8 +753,7 @@ while ($i < min($num, $limit))
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'bank') } elseif ($line->doc_type == 'bank') {
{
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$objectstatic = new AccountLine($db); $objectstatic = new AccountLine($db);
$objectstatic->fetch($line->fk_doc); $objectstatic->fetch($line->fk_doc);
@ -722,8 +767,7 @@ while ($i < min($num, $limit))
// Picto + Ref // Picto + Ref
print '<td class="nobordernopadding">'; print '<td class="nobordernopadding">';
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
{
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
print $documentlink; print $documentlink;
} elseif ($line->doc_type == 'bank') { } elseif ($line->doc_type == 'bank') {
@ -736,7 +780,9 @@ while ($i < min($num, $limit))
print '</td></tr></table>'; print '</td></tr></table>';
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Label operation // Label operation
@ -744,38 +790,49 @@ while ($i < min($num, $limit))
// Affiche un lien vers la facture client/fournisseur // Affiche un lien vers la facture client/fournisseur
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>'.$line->label_operation.'</td>' : '<td>'.$line->label_operation.'<br><span style="font-size:0.8em">('.length_accounta($line->subledger_account).')</span></td>'; print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>'.$line->label_operation.'</td>' : '<td>'.$line->label_operation.'<br><span style="font-size:0.8em">('.length_accounta($line->subledger_account).')</span></td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Amount debit // Amount debit
if (!empty($arrayfields['t.debit']['checked'])) if (!empty($arrayfields['t.debit']['checked'])) {
{
print '<td class="nowrap right">'.($line->debit ? price($line->debit) : '').'</td>'; print '<td class="nowrap right">'.($line->debit ? price($line->debit) : '').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit'; $totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
}
$totalarray['val']['totaldebit'] += $line->debit; $totalarray['val']['totaldebit'] += $line->debit;
} }
// Amount credit // Amount credit
if (!empty($arrayfields['t.credit']['checked'])) { if (!empty($arrayfields['t.credit']['checked'])) {
print '<td class="nowrap right">'.($line->credit ? price($line->credit) : '').'</td>'; print '<td class="nowrap right">'.($line->credit ? price($line->credit) : '').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; $totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
}
$totalarray['val']['totalcredit'] += $line->credit; $totalarray['val']['totalcredit'] += $line->credit;
} }
// Lettering code // Lettering code
if (!empty($arrayfields['t.lettering_code']['checked'])) if (!empty($arrayfields['t.lettering_code']['checked'])) {
{
print '<td class="center">'.$line->lettering_code.'</td>'; print '<td class="center">'.$line->lettering_code.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Exported operation date // Exported operation date
if (!empty($arrayfields['t.date_export']['checked'])) if (!empty($arrayfields['t.date_export']['checked'])) {
{
print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>'; print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Fields from hook // Fields from hook
@ -794,7 +851,9 @@ while ($i < min($num, $limit))
} }
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
// Comptabilise le sous-total // Comptabilise le sous-total
$sous_total_debit += $line->debit; $sous_total_debit += $line->debit;
@ -818,8 +877,7 @@ if ($num > 0) {
$balance = $sous_total_debit - $sous_total_credit; $balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>'; print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0) if ($balance > 0) {
{
print '<td class="nowraponall right">'; print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit); print price($sous_total_debit - $sous_total_credit);
print '</td>'; print '</td>';

View File

@ -503,8 +503,7 @@ print '<table class="tagtable liste centpercent">';
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
// Movement number // Movement number
if (!empty($arrayfields['t.piece_num']['checked'])) if (!empty($arrayfields['t.piece_num']['checked'])) {
{
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>'; print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
} }
// Code journal // Code journal
@ -631,11 +630,15 @@ while ($i < min($num, $limit)) {
$colnumber = 5; $colnumber = 5;
$colnumberend = 7; $colnumberend = 7;
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) $colnumber--; if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
if (empty($arrayfields['t.date_export']['checked'])) $colnumber--; $colnumber--;
}
if (empty($arrayfields['t.date_export']['checked'])) {
$colnumber--;
}
$colspan = $totalarray['nbfield'] - $colnumber; $colspan = $totalarray['nbfield'] - $colnumber;
$colspanend = $totalarray['nbfield'] - $colnumberend; $colspanend = $totalarray['nbfield'] - $colnumberend;
// Show a subtotal by accounting account // Show a subtotal by accounting account
if (isset($displayed_account_number)) { if (isset($displayed_account_number)) {
@ -838,10 +841,11 @@ while ($i < min($num, $limit)) {
} }
// Exported operation date // Exported operation date
if (!empty($arrayfields['t.date_export']['checked'])) if (!empty($arrayfields['t.date_export']['checked'])) {
{
print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>'; print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
} }
// Fields from hook // Fields from hook

View File

@ -145,7 +145,7 @@ print dol_get_fiche_end();
$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 = '".$db->escape($object->code_compta)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)."' )"; $sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)."' )";
@ -225,7 +225,6 @@ if ($resql) {
// Piece // Piece
print '<td><input type="text" name="search_doc_ref" value="' . $search_doc_ref . '"></td>'; print '<td><input type="text" name="search_doc_ref" value="' . $search_doc_ref . '"></td>';
print '<td colspan="6">&nbsp;</td>'; print '<td colspan="6">&nbsp;</td>';
print '<td class="right">'; print '<td class="right">';
$searchpicto = $form->showFilterButtons(); $searchpicto = $form->showFilterButtons();

View File

@ -144,7 +144,7 @@ print dol_get_fiche_end();
$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, bk.date_validated "; $sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code, bk.date_validated ";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta_fournisseur)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)."' )"; $sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta_fournisseur)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)."' )";
if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) { if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {
@ -222,7 +222,6 @@ if ($resql) {
// Piece // Piece
print '<td><input type="text" name="search_doc_ref" value="' . $search_doc_ref . '"></td>'; print '<td><input type="text" name="search_doc_ref" value="' . $search_doc_ref . '"></td>';
print '<td colspan="6">&nbsp;</td>'; print '<td colspan="6">&nbsp;</td>';
print '<td class="right">'; print '<td class="right">';
$searchpicto = $form->showFilterButtons(); $searchpicto = $form->showFilterButtons();

View File

@ -153,22 +153,42 @@ class AccountancyCategory // extends CommonObject
$error = 0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->code)) $this->code = trim($this->code); if (isset($this->code)) {
if (isset($this->label)) $this->label = trim($this->label); $this->code = trim($this->code);
if (isset($this->range_account)) $this->range_account = trim($this->range_account); }
if (isset($this->sens)) $this->sens = (int) $this->sens; if (isset($this->label)) {
if (isset($this->category_type)) $this->category_type = (int) $this->category_type; $this->label = trim($this->label);
if (isset($this->formula)) $this->formula = trim($this->formula); }
if (isset($this->position)) $this->position = (int) $this->position; if (isset($this->range_account)) {
if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country; $this->range_account = trim($this->range_account);
if (isset($this->active)) $this->active = (int) $this->active; }
if (isset($this->sens)) {
$this->sens = (int) $this->sens;
}
if (isset($this->category_type)) {
$this->category_type = (int) $this->category_type;
}
if (isset($this->formula)) {
$this->formula = trim($this->formula);
}
if (isset($this->position)) {
$this->position = (int) $this->position;
}
if (isset($this->fk_country)) {
$this->fk_country = (int) $this->fk_country;
}
if (isset($this->active)) {
$this->active = (int) $this->active;
}
// 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."c_accounting_category("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_accounting_category(";
if ($this->rowid > 0) $sql .= "rowid, "; if ($this->rowid > 0) {
$sql .= "rowid, ";
}
$sql .= "code, "; $sql .= "code, ";
$sql .= "label, "; $sql .= "label, ";
$sql .= "range_account, "; $sql .= "range_account, ";
@ -180,7 +200,9 @@ class AccountancyCategory // extends CommonObject
$sql .= "active, "; $sql .= "active, ";
$sql .= "entity"; $sql .= "entity";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
if ($this->rowid > 0) $sql .= " ".$this->rowid.","; if ($this->rowid > 0) {
$sql .= " ".$this->rowid.",";
}
$sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").",";
$sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").","; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").",";
$sql .= " ".(!isset($this->range_account) ? 'NULL' : "'".$this->db->escape($this->range_account)."'").","; $sql .= " ".(!isset($this->range_account) ? 'NULL' : "'".$this->db->escape($this->range_account)."'").",";
@ -197,13 +219,13 @@ class AccountancyCategory // extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback // Commit or rollback
if ($error) if ($error) {
{ foreach ($this->errors as $errmsg) {
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
@ -238,19 +260,21 @@ class AccountancyCategory // extends CommonObject
$sql .= " t.fk_country,"; $sql .= " t.fk_country,";
$sql .= " t.active"; $sql .= " t.active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t"; $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t";
if ($id) $sql .= " WHERE t.rowid = ".$id; if ($id) {
else { $sql .= " WHERE t.rowid = ".$id;
} else {
$sql .= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid $sql .= " WHERE t.entity IN (".getEntity('c_accounting_category').")"; // Dont't use entity if you use rowid
if ($code) $sql .= " AND t.code = '".$this->db->escape($code)."'"; if ($code) {
elseif ($label) $sql .= " AND t.label = '".$this->db->escape($label)."'"; $sql .= " AND t.code = '".$this->db->escape($code)."'";
} elseif ($label) {
$sql .= " AND t.label = '".$this->db->escape($label)."'";
}
} }
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ if ($this->db->num_rows($resql)) {
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
@ -287,15 +311,33 @@ class AccountancyCategory // extends CommonObject
$error = 0; $error = 0;
// Clean parameters // Clean parameters
if (isset($this->code)) $this->code = trim($this->code); if (isset($this->code)) {
if (isset($this->label)) $this->label = trim($this->label); $this->code = trim($this->code);
if (isset($this->range_account)) $this->range_account = trim($this->range_account); }
if (isset($this->sens)) $this->sens = (int) $this->sens; if (isset($this->label)) {
if (isset($this->category_type)) $this->category_type = (int) $this->category_type; $this->label = trim($this->label);
if (isset($this->formula)) $this->formula = trim($this->formula); }
if (isset($this->position)) $this->position = (int) $this->position; if (isset($this->range_account)) {
if (isset($this->fk_country)) $this->fk_country = (int) $this->fk_country; $this->range_account = trim($this->range_account);
if (isset($this->active)) $this->active = (int) $this->active; }
if (isset($this->sens)) {
$this->sens = (int) $this->sens;
}
if (isset($this->category_type)) {
$this->category_type = (int) $this->category_type;
}
if (isset($this->formula)) {
$this->formula = trim($this->formula);
}
if (isset($this->position)) {
$this->position = (int) $this->position;
}
if (isset($this->fk_country)) {
$this->fk_country = (int) $this->fk_country;
}
if (isset($this->active)) {
$this->active = (int) $this->active;
}
// Check parameters // Check parameters
@ -318,13 +360,13 @@ class AccountancyCategory // extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG); dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback // Commit or rollback
if ($error) if ($error) {
{ foreach ($this->errors as $errmsg) {
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
@ -356,13 +398,13 @@ class AccountancyCategory // extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback // Commit or rollback
if ($error) if ($error) {
{ foreach ($this->errors as $errmsg) {
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
} }
@ -537,13 +579,13 @@ class AccountancyCategory // extends CommonObject
} }
$accountincptsadded = array(); $accountincptsadded = array();
while ($obj = $this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql)) {
{
$account_number_formated = length_accountg($obj->account_number); $account_number_formated = length_accountg($obj->account_number);
if (!empty($accountincptsadded[$account_number_formated])) continue; if (!empty($accountincptsadded[$account_number_formated])) {
continue;
}
if (array_key_exists($account_number_formated, $cpts)) if (array_key_exists($account_number_formated, $cpts)) {
{
$accountincptsadded[$account_number_formated] = 1; $accountincptsadded[$account_number_formated] = 1;
// We found an account number that is in list $cpts of account to add // We found an account number that is in list $cpts of account to add
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account"; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account";
@ -687,48 +729,49 @@ class AccountancyCategory // extends CommonObject
$this->sdcpermonth = array(); $this->sdcpermonth = array();
$sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit"; $sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit";
if (is_array($cpt)) $sql .= ", t.numero_compte as accountancy_account"; if (is_array($cpt)) {
$sql .= ", t.numero_compte as accountancy_account";
}
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
//if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date'; //if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date';
$sql .= " WHERE t.entity = ".$conf->entity; $sql .= " WHERE t.entity = ".$conf->entity;
if (is_array($cpt)) if (is_array($cpt)) {
{
$listofaccount = ''; $listofaccount = '';
foreach ($cpt as $cptcursor) foreach ($cpt as $cptcursor) {
{ if ($listofaccount) {
if ($listofaccount) $listofaccount .= ","; $listofaccount .= ",";
}
$listofaccount .= "'".$cptcursor."'"; $listofaccount .= "'".$cptcursor."'";
} }
$sql .= " AND t.numero_compte IN (".$listofaccount.")"; $sql .= " AND t.numero_compte IN (".$listofaccount.")";
} else { } else {
$sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'"; $sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'";
} }
if (!empty($date_start) && !empty($date_end) && (empty($month) || empty($year))) // If month/year provided, it is stronger than filter date_start/date_end if (!empty($date_start) && !empty($date_end) && (empty($month) || empty($year))) { // If month/year provided, it is stronger than filter date_start/date_end
$sql .= " AND (t.doc_date BETWEEN '".$this->db->idate($date_start)."' AND '".$this->db->idate($date_end)."')"; $sql .= " AND (t.doc_date BETWEEN '".$this->db->idate($date_start)."' AND '".$this->db->idate($date_end)."')";
}
if (!empty($month) && !empty($year)) { if (!empty($month) && !empty($year)) {
$sql .= " AND (t.doc_date BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."')"; $sql .= " AND (t.doc_date BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."')";
} }
if ($thirdparty_code != 'nofilter') if ($thirdparty_code != 'nofilter') {
{
$sql .= " AND t.thirdparty_code = '".$this->db->escape($thirdparty_code)."'"; $sql .= " AND t.thirdparty_code = '".$this->db->escape($thirdparty_code)."'";
} }
if (is_array($cpt)) $sql .= " GROUP BY t.numero_compte"; if (is_array($cpt)) {
$sql .= " GROUP BY t.numero_compte";
}
//print $sql; //print $sql;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) if ($num) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($sens == 1) { if ($sens == 1) {
$this->sdc = $obj->debit - $obj->credit; $this->sdc = $obj->debit - $obj->credit;
} else { } else {
$this->sdc = $obj->credit - $obj->debit; $this->sdc = $obj->credit - $obj->debit;
} }
if (is_array($cpt)) if (is_array($cpt)) {
{
$this->sdcperaccount[$obj->accountancy_account] = $this->sdc; $this->sdcperaccount[$obj->accountancy_account] = $this->sdc;
} }
} }
@ -760,7 +803,9 @@ class AccountancyCategory // extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
$sql .= " WHERE c.active = 1"; $sql .= " WHERE c.active = 1";
$sql .= " AND c.entity = ".$conf->entity; $sql .= " AND c.entity = ".$conf->entity;
if ($categorytype >= 0) $sql .= " AND c.category_type = 1"; if ($categorytype >= 0) {
$sql .= " AND c.category_type = 1";
}
$sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)";
$sql .= " ORDER BY c.position ASC"; $sql .= " ORDER BY c.position ASC";
@ -815,8 +860,7 @@ class AccountancyCategory // extends CommonObject
exit(); exit();
} }
if (!empty($cat_id)) if (!empty($cat_id)) {
{
$sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql = "SELECT t.rowid, t.account_number, t.label as account_label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
$sql .= " WHERE t.fk_accounting_category = ".$cat_id; $sql .= " WHERE t.fk_accounting_category = ".$cat_id;
@ -838,8 +882,7 @@ class AccountancyCategory // extends CommonObject
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$data = array(); $data = array();
if ($num) { if ($num) {
while ($obj = $this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql)) {
{
$data[] = array( $data[] = array(
'id' => $obj->rowid, 'id' => $obj->rowid,
'account_number' => $obj->account_number, 'account_number' => $obj->account_number,

View File

@ -277,61 +277,61 @@ class AccountancyExport
switch ($formatexportset) { switch ($formatexportset) {
case self::$EXPORT_TYPE_CONFIGURABLE : case self::$EXPORT_TYPE_CONFIGURABLE:
$this->exportConfigurable($TData); $this->exportConfigurable($TData);
break; break;
case self::$EXPORT_TYPE_CEGID : case self::$EXPORT_TYPE_CEGID:
$this->exportCegid($TData); $this->exportCegid($TData);
break; break;
case self::$EXPORT_TYPE_COALA : case self::$EXPORT_TYPE_COALA:
$this->exportCoala($TData); $this->exportCoala($TData);
break; break;
case self::$EXPORT_TYPE_BOB50 : case self::$EXPORT_TYPE_BOB50:
$this->exportBob50($TData); $this->exportBob50($TData);
break; break;
case self::$EXPORT_TYPE_CIEL : case self::$EXPORT_TYPE_CIEL:
$this->exportCiel($TData); $this->exportCiel($TData);
break; break;
case self::$EXPORT_TYPE_QUADRATUS : case self::$EXPORT_TYPE_QUADRATUS:
$this->exportQuadratus($TData); $this->exportQuadratus($TData);
break; break;
case self::$EXPORT_TYPE_WINFIC : case self::$EXPORT_TYPE_WINFIC:
$this->exportWinfic($TData); $this->exportWinfic($TData);
break; break;
case self::$EXPORT_TYPE_EBP : case self::$EXPORT_TYPE_EBP:
$this->exportEbp($TData); $this->exportEbp($TData);
break; break;
case self::$EXPORT_TYPE_COGILOG : case self::$EXPORT_TYPE_COGILOG:
$this->exportCogilog($TData); $this->exportCogilog($TData);
break; break;
case self::$EXPORT_TYPE_AGIRIS : case self::$EXPORT_TYPE_AGIRIS:
$this->exportAgiris($TData); $this->exportAgiris($TData);
break; break;
case self::$EXPORT_TYPE_OPENCONCERTO : case self::$EXPORT_TYPE_OPENCONCERTO:
$this->exportOpenConcerto($TData); $this->exportOpenConcerto($TData);
break; break;
case self::$EXPORT_TYPE_SAGE50_SWISS : case self::$EXPORT_TYPE_SAGE50_SWISS:
$this->exportSAGE50SWISS($TData); $this->exportSAGE50SWISS($TData);
break; break;
case self::$EXPORT_TYPE_CHARLEMAGNE : case self::$EXPORT_TYPE_CHARLEMAGNE:
$this->exportCharlemagne($TData); $this->exportCharlemagne($TData);
break; break;
case self::$EXPORT_TYPE_LDCOMPTA : case self::$EXPORT_TYPE_LDCOMPTA:
$this->exportLDCompta($TData); $this->exportLDCompta($TData);
break; break;
case self::$EXPORT_TYPE_LDCOMPTA10 : case self::$EXPORT_TYPE_LDCOMPTA10:
$this->exportLDCompta10($TData); $this->exportLDCompta10($TData);
break; break;
case self::$EXPORT_TYPE_GESTIMUMV3 : case self::$EXPORT_TYPE_GESTIMUMV3:
$this->exportGestimumV3($TData); $this->exportGestimumV3($TData);
break; break;
case self::$EXPORT_TYPE_GESTIMUMV5 : case self::$EXPORT_TYPE_GESTIMUMV5:
$this->exportGestimumV5($TData); $this->exportGestimumV5($TData);
break; break;
case self::$EXPORT_TYPE_FEC : case self::$EXPORT_TYPE_FEC:
$this->exportFEC($TData); $this->exportFEC($TData);
break; break;
case self::$EXPORT_TYPE_FEC2 : case self::$EXPORT_TYPE_FEC2:
$this->exportFEC2($TData); $this->exportFEC2($TData);
break; break;
default: default:
@ -359,9 +359,9 @@ class AccountancyExport
print length_accountg($line->numero_compte).$separator; print length_accountg($line->numero_compte).$separator;
print length_accounta($line->subledger_account).$separator; print length_accounta($line->subledger_account).$separator;
print $line->sens.$separator; print $line->sens.$separator;
print price($line->montant).$separator; print price2fec(abs($line->debit - $line->credit)).$separator;
print $line->label_operation.$separator; print dol_string_unaccent($line->label_operation).$separator;
print $line->doc_ref; print dol_string_unaccent($line->doc_ref);
print $end_line; print $end_line;
} }
} }
@ -387,11 +387,11 @@ class AccountancyExport
print $line->label_operation.$separator; print $line->label_operation.$separator;
print $date.$separator; print $date.$separator;
if ($line->sens == 'D') { if ($line->sens == 'D') {
print price($line->montant).$separator; print price($line->debit).$separator;
print ''.$separator; print ''.$separator;
} elseif ($line->sens == 'C') { } elseif ($line->sens == 'C') {
print ''.$separator; print ''.$separator;
print price($line->montant).$separator; print price($line->credit).$separator;
} }
print $line->doc_ref.$separator; print $line->doc_ref.$separator;
print $line->label_operation.$separator; print $line->label_operation.$separator;
@ -481,8 +481,9 @@ class AccountancyExport
$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd
foreach ($TData as $data) { foreach ($TData as $data) {
$code_compta = $data->numero_compte; $code_compta = $data->numero_compte;
if (!empty($data->subledger_account)) if (!empty($data->subledger_account)) {
$code_compta = $data->subledger_account; $code_compta = $data->subledger_account;
}
$Tab = array(); $Tab = array();
$Tab['num_ecriture'] = str_pad($i, 5); $Tab['num_ecriture'] = str_pad($i, 5);
@ -492,7 +493,7 @@ class AccountancyExport
$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12);
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25); $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25);
$Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); $Tab['montant'] = str_pad(abs($data->debit - $data->credit), 13, ' ', STR_PAD_LEFT);
$Tab['type_montant'] = str_pad($data->sens, 1); $Tab['type_montant'] = str_pad($data->sens, 1);
$Tab['vide'] = str_repeat(' ', 18); $Tab['vide'] = str_repeat(' ', 18);
$Tab['intitule_compte'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 34), 34); $Tab['intitule_compte'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 34), 34);
@ -522,8 +523,9 @@ class AccountancyExport
// $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy // $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
foreach ($TData as $data) { foreach ($TData as $data) {
$code_compta = $data->numero_compte; $code_compta = $data->numero_compte;
if (!empty($data->subledger_account)) if (!empty($data->subledger_account)) {
$code_compta = $data->subledger_account; $code_compta = $data->subledger_account;
}
$Tab = array(); $Tab = array();
$Tab['type_ligne'] = 'M'; $Tab['type_ligne'] = 'M';
@ -539,6 +541,7 @@ class AccountancyExport
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20); $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20);
// Credit invoice - invert sens // Credit invoice - invert sens
/*
if ($data->montant < 0) { if ($data->montant < 0) {
if ($data->sens == 'C') { if ($data->sens == 'C') {
$Tab['sens'] = 'D'; $Tab['sens'] = 'D';
@ -549,10 +552,12 @@ class AccountancyExport
} else { } else {
$Tab['sens'] = $data->sens; // C or D $Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+'; $Tab['signe_montant'] = '+';
} }*/
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
// The amount must be in centimes without decimal points. // The amount must be in centimes without decimal points.
$Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); $Tab['montant'] = str_pad(abs(($data->debit - $abs->credit) * 100), 12, '0', STR_PAD_LEFT);
$Tab['contrepartie'] = str_repeat(' ', 8); $Tab['contrepartie'] = str_repeat(' ', 8);
// Force date format : %d%m%y // Force date format : %d%m%y
@ -616,8 +621,9 @@ class AccountancyExport
//$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy //$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy
foreach ($TData as $data) { foreach ($TData as $data) {
$code_compta = $data->numero_compte; $code_compta = $data->numero_compte;
if (!empty($data->subledger_account)) if (!empty($data->subledger_account)) {
$code_compta = $data->subledger_account; $code_compta = $data->subledger_account;
}
$Tab = array(); $Tab = array();
//$Tab['type_ligne'] = 'M'; //$Tab['type_ligne'] = 'M';
@ -637,13 +643,13 @@ class AccountancyExport
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0'); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0');
if ($data->sens == 'D') { if ($data->sens == 'D') {
$Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_debit'] = str_pad(number_format($data->debit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
$Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
} else { } else {
$Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
$Tab['montant_crebit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format($data->credit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
} }
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 30), 30); $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 30), 30);
@ -704,7 +710,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(abs($line->montant)).$separator; print price2num(abs($line->debit - $line->credit)).$separator;
print $line->sens.$separator; print $line->sens.$separator;
print $date.$separator; print $date.$separator;
//print 'EUR'; //print 'EUR';
@ -744,7 +750,7 @@ class AccountancyExport
print self::toAnsi($line->doc_ref).$separator; print self::toAnsi($line->doc_ref).$separator;
print price($line->debit).$separator; print price($line->debit).$separator;
print price($line->credit).$separator; print price($line->credit).$separator;
print price($line->montant).$separator; print price(abs($line->debit - $line->credit)).$separator;
print $line->sens.$separator; print $line->sens.$separator;
print $line->lettering_code.$separator; print $line->lettering_code.$separator;
print $line->code_journal; print $line->code_journal;
@ -807,7 +813,7 @@ class AccountancyExport
$tab[] = length_accounta($line->subledger_account); $tab[] = length_accounta($line->subledger_account);
$tab[] = price2num($line->debit); $tab[] = price2num($line->debit);
$tab[] = price2num($line->credit); $tab[] = price2num($line->credit);
$tab[] = price2num($line->montant); $tab[] = price2num($line->debit - $line->credit);
$tab[] = $line->code_journal; $tab[] = $line->code_journal;
print implode($separator, $tab).$this->end_line; print implode($separator, $tab).$this->end_line;
@ -849,14 +855,14 @@ class AccountancyExport
print $end_line; print $end_line;
foreach ($objectLines as $line) { foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) { if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]); //unset($array[$line]);
} else { } else {
$date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d'); $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
$date_validation = dol_print_date($line->date_validated, '%Y%m%d'); $date_validation = dol_print_date($line->date_validated, '%Y%m%d');
$date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d'); $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
// FEC:JournalCode // FEC:JournalCode
print $line->code_journal . $separator; print $line->code_journal . $separator;
@ -956,7 +962,7 @@ class AccountancyExport
foreach ($objectLines as $line) { foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) { if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]); //unset($array[$line]);
} else { } else {
$date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d');
@ -1048,21 +1054,17 @@ class AccountancyExport
$thisPieceNum = ""; $thisPieceNum = "";
$thisPieceAccountNr = ""; $thisPieceAccountNr = "";
$aSize = count($objectLines); $aSize = count($objectLines);
foreach ($objectLines as $aIndex=>$line) foreach ($objectLines as $aIndex => $line) {
{
$sammelBuchung = false; $sammelBuchung = false;
if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) {
{
$sammelBuchung = true; $sammelBuchung = true;
} elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) {
{
$sammelBuchung = true; $sammelBuchung = true;
} elseif ($aIndex + 1 < $aSize } elseif ($aIndex + 1 < $aSize
&& $objectLines[$aIndex + 1]->piece_num == $line->piece_num && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
&& $aIndex - 1 < $aSize && $aIndex - 1 < $aSize
&& $objectLines[$aIndex - 1]->piece_num == $line->piece_num && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
) ) {
{
$sammelBuchung = true; $sammelBuchung = true;
} }
@ -1076,8 +1078,7 @@ class AccountancyExport
// Kto // Kto
print length_accountg($line->numero_compte).$this->separator; print length_accountg($line->numero_compte).$this->separator;
// S/H // S/H
if ($line->sens == 'D') if ($line->sens == 'D') {
{
print 'S'.$this->separator; print 'S'.$this->separator;
} else { } else {
print 'H'.$this->separator; print 'H'.$this->separator;
@ -1085,10 +1086,8 @@ class AccountancyExport
//Grp //Grp
print self::trunc($line->code_journal, 1).$this->separator; print self::trunc($line->code_journal, 1).$this->separator;
// GKto // GKto
if (empty($line->code_tiers)) if (empty($line->code_tiers)) {
{ if ($line->piece_num == $thisPieceNum) {
if ($line->piece_num == $thisPieceNum)
{
print length_accounta($thisPieceAccountNr).$this->separator; print length_accounta($thisPieceAccountNr).$this->separator;
} else { } else {
print "div".$this->separator; print "div".$this->separator;
@ -1106,8 +1105,7 @@ class AccountancyExport
print "0".$this->separator; print "0".$this->separator;
//MTyp 1=Fibu Einzelbuchung 2=Sammebuchung //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
if ($sammelBuchung) if ($sammelBuchung) {
{
print "2".$this->separator; print "2".$this->separator;
} else { } else {
print "1".$this->separator; print "1".$this->separator;
@ -1115,30 +1113,22 @@ class AccountancyExport
// Code // Code
print '""'.$this->separator; print '""'.$this->separator;
// Netto // Netto
if ($line->montant >= 0) print abs($line->debit - $line->credit).$this->separator;
{
print $line->montant.$this->separator;
} else {
print ($line->montant * -1).$this->separator;
}
// Steuer // Steuer
print "0.00".$this->separator; print "0.00".$this->separator;
// FW-Betrag // FW-Betrag
print "0.00".$this->separator; print "0.00".$this->separator;
// Tx1 // Tx1
$line1 = self::toAnsi($line->label_compte, 29); $line1 = self::toAnsi($line->label_compte, 29);
if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) {
{
$line1 = ""; $line1 = "";
} }
$line2 = self::toAnsi($line->doc_ref, 29); $line2 = self::toAnsi($line->doc_ref, 29);
if (strlen($line1) == 0) if (strlen($line1) == 0) {
{
$line1 = $line2; $line1 = $line2;
$line2 = ""; $line2 = "";
} }
if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) {
{
$line1 = $line1.' / '.$line2; $line1 = $line1.' / '.$line2;
$line2 = ""; $line2 = "";
} }
@ -1156,8 +1146,7 @@ class AccountancyExport
print $this->end_line; print $this->end_line;
if ($line->piece_num !== $thisPieceNum) if ($line->piece_num !== $thisPieceNum) {
{
$thisPieceNum = $line->piece_num; $thisPieceNum = $line->piece_num;
$thisPieceAccountNr = $line->numero_compte; $thisPieceAccountNr = $line->numero_compte;
} }
@ -1200,13 +1189,13 @@ class AccountancyExport
print $date_lim_reglement.$separator; print $date_lim_reglement.$separator;
// CNPI // CNPI
if ($line->doc_type == 'supplier_invoice') { if ($line->doc_type == 'supplier_invoice') {
if ($line->montant < 0) { if (($line->debit - $line->credit) > 0) {
$nature_piece = 'AF'; $nature_piece = 'AF';
} else { } else {
$nature_piece = 'FF'; $nature_piece = 'FF';
} }
} elseif ($line->doc_type == 'customer_invoice') { } elseif ($line->doc_type == 'customer_invoice') {
if ($line->montant < 0) { if (($line->debit - $line->credit) < 0) {
$nature_piece = 'AC'; $nature_piece = 'AC';
} else { } else {
$nature_piece = 'FC'; $nature_piece = 'FC';
@ -1230,7 +1219,7 @@ class AccountancyExport
print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
// MONT // MONT
print price(abs($line->montant), 0, '', 1, 2, 2).$separator; print price(abs($line->debit - $line->credit), 0, '', 1, 2, 2).$separator;
// CODC // CODC
print $line->sens.$separator; print $line->sens.$separator;
// CPTG // CPTG
@ -1320,15 +1309,14 @@ class AccountancyExport
$sql .= " WHERE code_client = '".$this->db->escape($line->thirdparty_code)."'"; $sql .= " WHERE code_client = '".$this->db->escape($line->thirdparty_code)."'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql && $this->db->num_rows($resql) > 0) if ($resql && $this->db->num_rows($resql) > 0) {
{
$soc = $this->db->fetch_object($resql); $soc = $this->db->fetch_object($resql);
$address = array('', '', ''); $address = array('', '', '');
if (strpos($soc->address, "\n") !== false) { if (strpos($soc->address, "\n") !== false) {
$address = explode("\n", $soc->address); $address = explode("\n", $soc->address);
if (is_array($address) && count($address) > 0) { if (is_array($address) && count($address) > 0) {
foreach ($address as $key=>$data) { foreach ($address as $key => $data) {
$address[$key] = str_replace(array("\t", "\n", "\r"), "", $data); $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data);
$address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
} }
@ -1462,13 +1450,13 @@ class AccountancyExport
print $date_lim_reglement.$separator; print $date_lim_reglement.$separator;
// CNPI // CNPI
if ($line->doc_type == 'supplier_invoice') { if ($line->doc_type == 'supplier_invoice') {
if ($line->montant < 0) { if (($line->debit - $line->credit) > 0) {
$nature_piece = 'AF'; $nature_piece = 'AF';
} else { } else {
$nature_piece = 'FF'; $nature_piece = 'FF';
} }
} elseif ($line->doc_type == 'customer_invoice') { } elseif ($line->doc_type == 'customer_invoice') {
if ($line->montant < 0) { if (($line->debit - $line->credit) < 0) {
$nature_piece = 'AC'; $nature_piece = 'AC';
} else { } else {
$nature_piece = 'FC'; $nature_piece = 'FC';
@ -1492,7 +1480,7 @@ class AccountancyExport
print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
// MONT // MONT
print price(abs($line->montant), 0, '', 1, 2).$separator; print price(abs($line->debit - $line->credit), 0, '', 1, 2).$separator;
// CODC // CODC
print $line->sens.$separator; print $line->sens.$separator;
// CPTG // CPTG
@ -1603,8 +1591,9 @@ class AccountancyExport
print self::trunc($line->code_journal, 6).$separator; //Journal code print self::trunc($line->code_journal, 6).$separator; //Journal code
if (!empty($line->subledger_account)) $account = $line->subledger_account; if (!empty($line->subledger_account)) {
else { $account = $line->subledger_account;
} else {
$account = $line->numero_compte; $account = $line->numero_compte;
} }
print self::trunc($account, 15).$separator; //Account number print self::trunc($account, 15).$separator; //Account number
@ -1612,7 +1601,7 @@ class AccountancyExport
print self::trunc($line->label_compte, 60).$separator; //Account label print self::trunc($line->label_compte, 60).$separator; //Account label
print self::trunc($line->doc_ref, 20).$separator; //Piece print self::trunc($line->doc_ref, 20).$separator; //Piece
print self::trunc($line->label_operation, 60).$separator; //Operation label print self::trunc($line->label_operation, 60).$separator; //Operation label
print price(abs($line->montant)).$separator; //Amount print price(abs($line->debit - $line->credit)).$separator; //Amount
print $line->sens.$separator; //Direction print $line->sens.$separator; //Direction
print $separator; //Analytic print $separator; //Analytic
print $separator; //Analytic print $separator; //Analytic
@ -1641,7 +1630,7 @@ class AccountancyExport
$supplier_invoices_infos = array(); $supplier_invoices_infos = array();
foreach ($objectLines as $line) { foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) { if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]); //unset($array[$line]);
} else { } else {
$date = dol_print_date($line->doc_date, '%d/%m/%Y'); $date = dol_print_date($line->doc_date, '%d/%m/%Y');
@ -1709,8 +1698,8 @@ class AccountancyExport
print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator; print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator;
//Devise //Devise
print 'EUR' . $this->separator; print 'EUR' . $this->separator;
//Montant //Amount
print price2num(abs($line->montant)) . $this->separator; print price2num(abs($line->debit - $line->credit)) . $this->separator;
//Sens //Sens
print $line->sens . $this->separator; print $line->sens . $this->separator;
//Code lettrage //Code lettrage
@ -1736,14 +1725,14 @@ class AccountancyExport
foreach ($objectLines as $line) { foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) { if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]); //unset($array[$line]);
} else { } else {
$date = dol_print_date($line->doc_date, '%d%m%Y'); $date = dol_print_date($line->doc_date, '%d%m%Y');
print $line->id . $this->separator; print $line->id . $this->separator;
print $date . $this->separator; print $date . $this->separator;
print substr($line->code_journal, 0, 4) . $this->separator; print substr($line->code_journal, 0, 4) . $this->separator;
if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { // TODO No hard code value
print length_accountg($line->subledger_account) . $this->separator; print length_accountg($line->subledger_account) . $this->separator;
} else { } else {
print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
@ -1752,7 +1741,7 @@ class AccountancyExport
//print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
print '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"' . $this->separator; print '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"' . $this->separator;
print '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"' . $this->separator; print '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"' . $this->separator;
print price2num($line->montant) . $this->separator; print price2num(abs($line->debit - $line->credit)) . $this->separator;
print $line->sens . $this->separator; print $line->sens . $this->separator;
print $date . $this->separator; print $date . $this->separator;
print $this->separator; print $this->separator;
@ -1785,8 +1774,7 @@ class AccountancyExport
public static function toAnsi($str, $size = -1) public static function toAnsi($str, $size = -1)
{ {
$retVal = dol_string_nohtmltag($str, 1, 'Windows-1251'); $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251');
if ($retVal >= 0 && $size >= 0) if ($retVal >= 0 && $size >= 0) {
{
$retVal = mb_substr($retVal, 0, $size, 'Windows-1251'); $retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
} }
return $retVal; return $retVal;

View File

@ -95,8 +95,7 @@ class AccountancySystem
{ {
global $conf; global $conf;
if ($rowid > 0 || $ref) if ($rowid > 0 || $ref) {
{
$sql = "SELECT a.rowid, a.pcg_version, a.label, a.active"; $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
$sql .= " WHERE"; $sql .= " WHERE";

View File

@ -236,19 +236,23 @@ class AccountingAccount extends CommonObject
$now = dol_now(); $now = dol_now();
// Clean parameters // Clean parameters
if (isset($this->fk_pcg_version)) if (isset($this->fk_pcg_version)) {
$this->fk_pcg_version = trim($this->fk_pcg_version); $this->fk_pcg_version = trim($this->fk_pcg_version);
if (isset($this->pcg_type)) }
if (isset($this->pcg_type)) {
$this->pcg_type = trim($this->pcg_type); $this->pcg_type = trim($this->pcg_type);
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->label)) }
if (isset($this->label)) {
$this->label = trim($this->label); $this->label = trim($this->label);
if (isset($this->labelshort)) }
if (isset($this->labelshort)) {
$this->labelshort = trim($this->labelshort); $this->labelshort = trim($this->labelshort);
}
if (empty($this->pcg_type) || $this->pcg_type == '-1') if (empty($this->pcg_type) || $this->pcg_type == '-1') {
{
$this->pcg_type = 'XXXXXX'; $this->pcg_type = 'XXXXXX';
} }
// Check parameters // Check parameters
@ -329,8 +333,7 @@ class AccountingAccount extends CommonObject
public function update($user) public function update($user)
{ {
// Check parameters // Check parameters
if (empty($this->pcg_type) || $this->pcg_type == '-1') if (empty($this->pcg_type) || $this->pcg_type == '-1') {
{
$this->pcg_type = 'XXXXXX'; $this->pcg_type = 'XXXXXX';
} }
@ -456,7 +459,9 @@ class AccountingAccount extends CommonObject
global $langs, $conf; global $langs, $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = ''; $result = '';
@ -474,31 +479,36 @@ class AccountingAccount extends CommonObject
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $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 ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
$picto = 'billr'; $picto = 'billr';
$label = ''; $label = '';
if (empty($this->labelshort) || $withcompletelabel == 1) if (empty($this->labelshort) || $withcompletelabel == 1) {
{
$labeltoshow = $this->label; $labeltoshow = $this->label;
} else { } else {
$labeltoshow = $this->labelshort; $labeltoshow = $this->labelshort;
} }
$label = '<u>'.$labelurl.'</u>'; $label = '<u>'.$labelurl.'</u>';
if (!empty($this->account_number)) if (!empty($this->account_number)) {
$label .= '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number); $label .= '<br><b>'.$langs->trans('AccountAccounting').':</b> '.length_accountg($this->account_number);
if (!empty($labeltoshow)) }
if (!empty($labeltoshow)) {
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow; $label .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow;
if ($moretitle) $label .= ' - '.$moretitle; }
if ($moretitle) {
$label .= ' - '.$moretitle;
}
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $labelurl; $label = $labelurl;
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
@ -510,19 +520,26 @@ class AccountingAccount extends CommonObject
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
if ($nourl) if ($nourl) {
{
$linkstart = ''; $linkstart = '';
$linkclose = ''; $linkclose = '';
$linkend = ''; $linkend = '';
} }
$label_link = length_accountg($this->account_number); $label_link = length_accountg($this->account_number);
if ($withlabel) $label_link .= ' - '.($nourl ? '<span class="opacitymedium">' : '').$labeltoshow.($nourl ? '</span>' : ''); if ($withlabel) {
$label_link .= ' - '.($nourl ? '<span class="opacitymedium">' : '').$labeltoshow.($nourl ? '</span>' : '');
}
if ($withpicto) $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend); if ($withpicto) {
if ($withpicto && $withpicto != 2) $result .= ' '; $result .= ($linkstart.img_object(($notooltip ? '' : $label), $picto, ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).$linkend);
if ($withpicto != 2) $result .= $linkstart.$label_link.$linkend; }
if ($withpicto && $withpicto != 2) {
$result .= ' ';
}
if ($withpicto != 2) {
$result .= $linkstart.$label_link.$linkend;
}
return $result; return $result;
} }
@ -576,8 +593,7 @@ class AccountingAccount extends CommonObject
$result = $this->checkUsage(); $result = $this->checkUsage();
$fieldtouse = 'active'; $fieldtouse = 'active';
if ($mode == 1) if ($mode == 1) {
{
$fieldtouse = 'reconcilable'; $fieldtouse = 'reconcilable';
} }
@ -664,30 +680,42 @@ class AccountingAccount extends CommonObject
global $langs; global $langs;
$langs->loadLangs(array("users")); $langs->loadLangs(array("users"));
if ($mode == 0) if ($mode == 0) {
{ if ($status == 1) {
if ($status == 1) return $langs->trans('Enabled'); return $langs->trans('Enabled');
elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($status == 0) {
} elseif ($mode == 1) return $langs->trans('Disabled');
{ }
if ($status == 1) return $langs->trans('Enabled'); } elseif ($mode == 1) {
elseif ($status == 0) return $langs->trans('Disabled'); if ($status == 1) {
} elseif ($mode == 2) return $langs->trans('Enabled');
{ } elseif ($status == 0) {
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); return $langs->trans('Disabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); }
} elseif ($mode == 3) } elseif ($mode == 2) {
{ if ($status == 1) {
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($status == 0) {
} elseif ($mode == 4) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
{ }
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); } elseif ($mode == 3) {
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); if ($status == 1) {
} elseif ($mode == 5) return img_picto($langs->trans('Enabled'), 'statut4');
{ } elseif ($status == 0) {
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); return img_picto($langs->trans('Disabled'), 'statut5');
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); }
} elseif ($mode == 4) {
if ($status == 1) {
return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
} elseif ($status == 0) {
return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
}
} elseif ($mode == 5) {
if ($status == 1) {
return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
} elseif ($status == 0) {
return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
}
} }
} }
} }

View File

@ -102,23 +102,20 @@ class AccountingJournal extends CommonObject
{ {
global $conf; global $conf;
if ($rowid || $journal_code) if ($rowid || $journal_code) {
{
$sql = "SELECT rowid, code, label, nature, active"; $sql = "SELECT rowid, code, label, nature, active";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql .= " WHERE"; $sql .= " WHERE";
if ($rowid) { if ($rowid) {
$sql .= " rowid = ".((int) $rowid); $sql .= " rowid = ".((int) $rowid);
} elseif ($journal_code) } elseif ($journal_code) {
{
$sql .= " code = '".$this->db->escape($journal_code)."'"; $sql .= " code = '".$this->db->escape($journal_code)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
} }
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj) { if ($obj) {
@ -226,24 +223,28 @@ class AccountingJournal extends CommonObject
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = ''; $result = '';
$url = DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35'; $url = DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35';
$label = '<u>'.$langs->trans("ShowAccountingJournal").'</u>'; $label = '<u>'.$langs->trans("ShowAccountingJournal").'</u>';
if (!empty($this->code)) if (!empty($this->code)) {
$label .= '<br><b>'.$langs->trans('Code').':</b> '.$this->code; $label .= '<br><b>'.$langs->trans('Code').':</b> '.$this->code;
if (!empty($this->label)) }
if (!empty($this->label)) {
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$langs->transnoentities($this->label); $label .= '<br><b>'.$langs->trans('Label').':</b> '.$langs->transnoentities($this->label);
if ($moretitle) $label .= ' - '.$moretitle; }
if ($moretitle) {
$label .= ' - '.$moretitle;
}
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowAccountingJournal"); $label = $langs->trans("ShowAccountingJournal");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
@ -255,19 +256,24 @@ class AccountingJournal extends CommonObject
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
if ($nourl) if ($nourl) {
{
$linkstart = ''; $linkstart = '';
$linkclose = ''; $linkclose = '';
$linkend = ''; $linkend = '';
} }
$label_link = $this->code; $label_link = $this->code;
if ($withlabel) $label_link .= ' - '.($nourl ? '<span class="opacitymedium">' : '').$langs->transnoentities($this->label).($nourl ? '</span>' : ''); if ($withlabel) {
$label_link .= ' - '.($nourl ? '<span class="opacitymedium">' : '').$langs->transnoentities($this->label).($nourl ? '</span>' : '');
}
$result .= $linkstart; $result .= $linkstart;
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); if ($withpicto) {
if ($withpicto != 2) $result .= $label_link; $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);
}
if ($withpicto != 2) {
$result .= $label_link;
}
$result .= $linkend; $result .= $linkend;
return $result; return $result;
@ -299,23 +305,35 @@ class AccountingJournal extends CommonObject
$langs->loadLangs(array("accountancy")); $langs->loadLangs(array("accountancy"));
if ($mode == 0) if ($mode == 0) {
{
$prefix = ''; $prefix = '';
if ($nature == 9) return $langs->trans('AccountingJournalType9'); if ($nature == 9) {
elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); return $langs->trans('AccountingJournalType9');
elseif ($nature == 4) return $langs->trans('AccountingJournalType4'); } elseif ($nature == 5) {
elseif ($nature == 3) return $langs->trans('AccountingJournalType3'); return $langs->trans('AccountingJournalType5');
elseif ($nature == 2) return $langs->trans('AccountingJournalType2'); } elseif ($nature == 4) {
elseif ($nature == 1) return $langs->trans('AccountingJournalType1'); return $langs->trans('AccountingJournalType4');
} elseif ($mode == 1) } elseif ($nature == 3) {
{ return $langs->trans('AccountingJournalType3');
if ($nature == 9) return $langs->trans('AccountingJournalType9'); } elseif ($nature == 2) {
elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); return $langs->trans('AccountingJournalType2');
elseif ($nature == 4) return $langs->trans('AccountingJournalType4'); } elseif ($nature == 1) {
elseif ($nature == 3) return $langs->trans('AccountingJournalType3'); return $langs->trans('AccountingJournalType1');
elseif ($nature == 2) return $langs->trans('AccountingJournalType2'); }
elseif ($nature == 1) return $langs->trans('AccountingJournalType1'); } elseif ($mode == 1) {
if ($nature == 9) {
return $langs->trans('AccountingJournalType9');
} elseif ($nature == 5) {
return $langs->trans('AccountingJournalType5');
} elseif ($nature == 4) {
return $langs->trans('AccountingJournalType4');
} elseif ($nature == 3) {
return $langs->trans('AccountingJournalType3');
} elseif ($nature == 2) {
return $langs->trans('AccountingJournalType2');
} elseif ($nature == 1) {
return $langs->trans('AccountingJournalType1');
}
} }
} }
} }

View File

@ -135,6 +135,7 @@ class BookKeeping extends CommonObject
/** /**
* @var float FEC:Amount (Not necessary) * @var float FEC:Amount (Not necessary)
* @deprecated No more used
*/ */
public $amount; public $amount;
@ -239,6 +240,9 @@ class BookKeeping extends CommonObject
if (isset($this->montant)) { if (isset($this->montant)) {
$this->montant = (float) $this->montant; $this->montant = (float) $this->montant;
} }
if (isset($this->amount)) {
$this->amount = (float) $this->amount;
}
if (isset($this->sens)) { if (isset($this->sens)) {
$this->sens = trim($this->sens); $this->sens = trim($this->sens);
} }
@ -254,21 +258,22 @@ class BookKeeping extends CommonObject
if (isset($this->piece_num)) { if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num); $this->piece_num = trim($this->piece_num);
} }
if (empty($this->debit)) $this->debit = 0.0; if (empty($this->debit)) {
if (empty($this->credit)) $this->credit = 0.0; $this->debit = 0.0;
}
if (empty($this->credit)) {
$this->credit = 0.0;
}
// Check parameters // Check parameters
if (($this->numero_compte == "") || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined') if (($this->numero_compte == "") || $this->numero_compte == '-1' || $this->numero_compte == 'NotDefined') {
{
$langs->loadLangs(array("errors")); $langs->loadLangs(array("errors"));
if (in_array($this->doc_type, array('bank', 'expense_report'))) if (in_array($this->doc_type, array('bank', 'expense_report'))) {
{
$this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type); $this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForBankLine', $this->fk_docdet, $this->doc_type);
} else { } else {
//$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte); //$this->errors[]=$langs->trans('ErrorFieldAccountNotDefinedForInvoiceLine', $this->doc_ref, $this->label_compte);
$mesg = $this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte; $mesg = $this->doc_ref.', '.$langs->trans("AccountAccounting").': '.$this->numero_compte;
if ($this->subledger_account && $this->subledger_account != $this->numero_compte) if ($this->subledger_account && $this->subledger_account != $this->numero_compte) {
{
$mesg .= ', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account; $mesg .= ', '.$langs->trans("SubledgerAccount").': '.$this->subledger_account;
} }
$this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForLine', $mesg); $this->errors[] = $langs->trans('ErrorFieldAccountNotDefinedForLine', $mesg);
@ -299,8 +304,7 @@ class BookKeeping extends CommonObject
if ($resql) { if ($resql) {
$row = $this->db->fetch_object($resql); $row = $this->db->fetch_object($resql);
if ($row->nb == 0) if ($row->nb == 0) {
{
// Determine piece_num // Determine piece_num
$sqlnum = "SELECT piece_num"; $sqlnum = "SELECT piece_num";
$sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
@ -452,7 +456,9 @@ class BookKeeping extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = ''; $result = '';
$companylink = ''; $companylink = '';
@ -463,33 +469,40 @@ class BookKeeping extends CommonObject
$url = DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$this->piece_num; $url = DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$this->piece_num;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $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 ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowTransaction"); $label = $langs->trans("ShowTransaction");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } 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) $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); if ($withpicto) {
if ($withpicto != 2) $result .= $this->piece_num; $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);
}
if ($withpicto != 2) {
$result .= $this->piece_num;
}
$result .= $linkend; $result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -554,6 +567,9 @@ class BookKeeping extends CommonObject
if (isset($this->montant)) { if (isset($this->montant)) {
$this->montant = trim($this->montant); $this->montant = trim($this->montant);
} }
if (isset($this->amount)) {
$this->amount = trim($this->amount);
}
if (isset($this->sens)) { if (isset($this->sens)) {
$this->sens = trim($this->sens); $this->sens = trim($this->sens);
} }
@ -569,8 +585,12 @@ class BookKeeping extends CommonObject
if (isset($this->piece_num)) { if (isset($this->piece_num)) {
$this->piece_num = trim($this->piece_num); $this->piece_num = trim($this->piece_num);
} }
if (empty($this->debit)) $this->debit = 0; if (empty($this->debit)) {
if (empty($this->credit)) $this->credit = 0; $this->debit = 0;
}
if (empty($this->credit)) {
$this->credit = 0;
}
$this->debit = price2num($this->debit, 'MT'); $this->debit = price2num($this->debit, 'MT');
$this->credit = price2num($this->credit, 'MT'); $this->credit = price2num($this->credit, 'MT');
@ -695,7 +715,7 @@ class BookKeeping extends CommonObject
$sql .= " t.label_operation,"; $sql .= " t.label_operation,";
$sql .= " t.debit,"; $sql .= " t.debit,";
$sql .= " t.credit,"; $sql .= " t.credit,";
$sql .= " t.montant,"; $sql .= " t.montant as amount,";
$sql .= " t.sens,"; $sql .= " t.sens,";
$sql .= " t.fk_user_author,"; $sql .= " t.fk_user_author,";
$sql .= " t.import_key,"; $sql .= " t.import_key,";
@ -734,7 +754,8 @@ class BookKeeping extends CommonObject
$this->label_operation = $obj->label_operation; $this->label_operation = $obj->label_operation;
$this->debit = $obj->debit; $this->debit = $obj->debit;
$this->credit = $obj->credit; $this->credit = $obj->credit;
$this->montant = $obj->montant; $this->montant = $obj->amount;
$this->amount = $obj->amount;
$this->sens = $obj->sens; $this->sens = $obj->sens;
$this->fk_user_author = $obj->fk_user_author; $this->fk_user_author = $obj->fk_user_author;
$this->import_key = $obj->import_key; $this->import_key = $obj->import_key;
@ -828,14 +849,14 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; $sqlwhere[] = $key.'\''.$this->db->idate($value).'\'';
} elseif ($key == 't.credit' || $key == 't.debit') { } elseif ($key == 't.credit' || $key == 't.debit') {
$sqlwhere[] = natural_search($key, $value, 1, 1); $sqlwhere[] = natural_search($key, $value, 1, 1);
} elseif ($key == 't.reconciled_option') { } elseif ($key == 't.reconciled_option') {
$sqlwhere[] = 't.lettering_code IS NULL'; $sqlwhere[] = 't.lettering_code IS NULL';
} elseif ($key == 't.code_journal' && !empty($value)) { } elseif ($key == 't.code_journal' && !empty($value)) {
if (is_array($value)) { if (is_array($value)) {
$sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
} else { } else {
$sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1);
} }
} else { } else {
$sqlwhere[] = natural_search($key, $value, 0, 1); $sqlwhere[] = natural_search($key, $value, 0, 1);
} }
@ -1009,8 +1030,7 @@ class BookKeeping extends CommonObject
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) {
{
$line = new BookKeepingLine(); $line = new BookKeepingLine();
$line->id = $obj->rowid; $line->id = $obj->rowid;
@ -1118,13 +1138,11 @@ class BookKeeping extends CommonObject
} }
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) {
{
$line = new BookKeepingLine(); $line = new BookKeepingLine();
$line->numero_compte = $obj->numero_compte; $line->numero_compte = $obj->numero_compte;
@ -1197,8 +1215,8 @@ class BookKeeping extends CommonObject
if (isset($this->credit)) { if (isset($this->credit)) {
$this->credit = trim($this->credit); $this->credit = trim($this->credit);
} }
if (isset($this->montant)) { if (isset($this->amount)) {
$this->montant = trim($this->montant); $this->amount = trim($this->amount);
} }
if (isset($this->sens)) { if (isset($this->sens)) {
$this->sens = trim($this->sens); $this->sens = trim($this->sens);
@ -1404,13 +1422,11 @@ class BookKeeping extends CommonObject
{ {
global $langs; global $langs;
if (empty($delyear) && empty($journal)) if (empty($delyear) && empty($journal)) {
{
$this->error = 'ErrorOneFieldRequired'; $this->error = 'ErrorOneFieldRequired';
return -1; return -1;
} }
if (!empty($delmonth) && empty($delyear)) if (!empty($delmonth) && empty($delyear)) {
{
$this->error = 'YearRequiredIfMonthDefined'; $this->error = 'YearRequiredIfMonthDefined';
return -2; return -2;
} }
@ -1422,7 +1438,9 @@ class BookKeeping extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " WHERE 1 = 1"; $sql .= " WHERE 1 = 1";
$sql .= dolSqlDateFilter('doc_date', 0, $delmonth, $delyear); $sql .= dolSqlDateFilter('doc_date', 0, $delmonth, $delyear);
if (!empty($journal)) $sql .= " AND code_journal = '".$this->db->escape($journal)."'"; if (!empty($journal)) {
$sql .= " AND code_journal = '".$this->db->escape($journal)."'";
}
$sql .= " AND entity IN (".getEntity('accountancy').")"; $sql .= " AND entity IN (".getEntity('accountancy').")";
// TODO: In a future we must forbid deletion if record is inside a closed fiscal period. // TODO: In a future we must forbid deletion if record is inside a closed fiscal period.
@ -1617,8 +1635,12 @@ class BookKeeping extends CommonObject
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj) $result = $obj->max; if ($obj) {
if (empty($result)) $result = 1; $result = $obj->max;
}
if (empty($result)) {
$result = 1;
}
return $result; return $result;
} else { } else {
$this->error = "Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
@ -1641,7 +1663,7 @@ class BookKeeping extends CommonObject
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,";
$sql .= " numero_compte, label_compte, label_operation, debit, credit,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation"; $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " WHERE piece_num = ".$piecenum; $sql .= " WHERE piece_num = ".$piecenum;
$sql .= " AND entity IN (".getEntity('accountancy').")"; $sql .= " AND entity IN (".getEntity('accountancy').")";
@ -1667,7 +1689,8 @@ class BookKeeping extends CommonObject
$line->label_operation = $obj->label_operation; $line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->amount;
$line->amount = $obj->amount;
$line->sens = $obj->sens; $line->sens = $obj->sens;
$line->code_journal = $obj->code_journal; $line->code_journal = $obj->code_journal;
$line->journal_label = $obj->journal_label; $line->journal_label = $obj->journal_label;
@ -1700,7 +1723,7 @@ class BookKeeping extends CommonObject
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,";
$sql .= " numero_compte, label_compte, label_operation, debit, credit,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " WHERE entity IN (".getEntity('accountancy').")"; $sql .= " WHERE entity IN (".getEntity('accountancy').")";
@ -1730,7 +1753,8 @@ class BookKeeping extends CommonObject
$line->label_operation = $obj->label_operation; $line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->amount;
$line->amount = $obj->amount;
$line->sens = $obj->sens; $line->sens = $obj->sens;
$line->code_journal = $obj->code_journal; $line->code_journal = $obj->code_journal;
$line->piece_num = $obj->piece_num; $line->piece_num = $obj->piece_num;
@ -1760,8 +1784,7 @@ class BookKeeping extends CommonObject
$this->db->begin(); $this->db->begin();
if ($direction == 0) if ($direction == 0) {
{
$next_piecenum = $this->getNextNumMvt(); $next_piecenum = $this->getNextNumMvt();
$now = dol_now(); $now = dol_now();

View File

@ -67,12 +67,15 @@ class Lettering extends BookKeeping
$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 ($object->code_compta != "") if ($object->code_compta != "") {
$sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' ";
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") }
if ($object->code_compta != "" && $object->code_compta_fournisseur != "") {
$sql .= " OR "; $sql .= " OR ";
if ($object->code_compta_fournisseur != "") }
if ($object->code_compta_fournisseur != "") {
$sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_fournisseur)."' "; $sql .= " bk.subledger_account = '".$this->db->escape($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) ";
@ -89,8 +92,7 @@ class Lettering extends BookKeeping
$ids = array(); $ids = array();
$ids_fact = array(); $ids_fact = array();
if ($obj->type == 'payment_supplier') if ($obj->type == 'payment_supplier') {
{
$sql = 'SELECT DISTINCT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank, facf.rowid as fact_id'; $sql = 'SELECT DISTINCT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank, facf.rowid as fact_id';
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf "; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn facf ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
@ -244,8 +246,9 @@ class Lettering extends BookKeeping
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$lettre = (empty($obj->lettering_code) ? 'AAA' : $obj->lettering_code); $lettre = (empty($obj->lettering_code) ? 'AAA' : $obj->lettering_code);
if (!empty($obj->lettering_code)) if (!empty($obj->lettering_code)) {
$lettre++; $lettre++;
}
} else { } else {
$this->errors[] = 'Error'.$this->db->lasterror(); $this->errors[] = 'Error'.$this->db->lasterror();
$error++; $error++;
@ -269,8 +272,7 @@ class Lettering extends BookKeeping
$now = dol_now(); $now = dol_now();
if (!$error) if (!$error) {
{
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
$sql .= " lettering_code='".$this->db->escape($lettre)."'"; $sql .= " lettering_code='".$this->db->escape($lettre)."'";
$sql .= " , date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false $sql .= " , date_lettering = '".$this->db->idate($now)."'"; // todo correct date it's false

View File

@ -39,23 +39,27 @@ $action = GETPOST('action', 'aZ09');
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
accessforbidden(); accessforbidden();
} }
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->fiscalyear->write) }
if (!$user->rights->accounting->fiscalyear->write) {
accessforbidden(); accessforbidden();
}
$object = new BookKeeping($db); $object = new BookKeeping($db);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); if (GETPOST("year", 'int')) {
else { $year_start = GETPOST("year", 'int');
} else {
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
} }
$year_end = $year_start + 1; $year_end = $year_start + 1;
$month_end = $month_start - 1; $month_end = $month_start - 1;
if ($month_end < 1) if ($month_end < 1) {
{
$month_end = 12; $month_end = 12;
$year_end--; $year_end--;
} }
@ -69,8 +73,7 @@ $year_current = $year_start;
if ($action == 'validate_movements_confirm' && $user->rights->accounting->fiscalyear->write) { if ($action == 'validate_movements_confirm' && $user->rights->accounting->fiscalyear->write) {
$result = $object->fetchAll(); $result = $object->fetchAll();
if ($result < 0) if ($result < 0) {
{
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
// Specify as export : update field date_validated on selected month/year // Specify as export : update field date_validated on selected month/year
@ -80,30 +83,26 @@ if ($action == 'validate_movements_confirm' && $user->rights->accounting->fiscal
$date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); $date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
if (is_array($object->lines)) if (is_array($object->lines)) {
{ foreach ($object->lines as $movement) {
foreach ($object->lines as $movement)
{
$now = dol_now(); $now = dol_now();
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " SET date_validated = '".$db->idate($now)."'"; $sql .= " SET date_validated = '".$db->idate($now)."'";
$sql .= " WHERE rowid = ".$movement->id; $sql .= " WHERE rowid = ".$movement->id;
$sql .= " AND doc_date >= '" . dol_print_date($date_start, 'dayrfc') . "'"; $sql .= " AND doc_date >= '" . dol_print_date($date_start, 'dayrfc') . "'";
$sql .= " AND doc_date <= '" . dol_print_date($date_end, 'dayrfc') . "'"; $sql .= " AND doc_date <= '" . dol_print_date($date_end, 'dayrfc') . "'";
dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated sql=".$sql, LOG_DEBUG); dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated sql=".$sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result) {
{
$error++; $error++;
break; break;
} }
} }
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("AllMovementsWereRecordedAsValidated"), null, 'mesgs'); setEventMessages($langs->trans("AllMovementsWereRecordedAsValidated"), null, 'mesgs');
} else { } else {
@ -171,7 +170,9 @@ print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -179,7 +180,9 @@ print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'
$sql = "SELECT COUNT(b.rowid) as detail,"; $sql = "SELECT COUNT(b.rowid) as detail,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " COUNT(b.rowid) as total"; $sql .= " COUNT(b.rowid) as total";

View File

@ -38,19 +38,20 @@ $codeventil = GETPOST('codeventil', 'int');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
}
/* /*
* Actions * Actions
*/ */
if ($action == 'ventil' && $user->rights->accounting->bind->write) if ($action == 'ventil' && $user->rights->accounting->bind->write) {
{ if (!$cancel) {
if (!$cancel) if ($codeventil < 0) {
{ $codeventil = 0;
if ($codeventil < 0) $codeventil = 0; }
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
$sql .= " SET fk_code_ventilation = ".$codeventil; $sql .= " SET fk_code_ventilation = ".$codeventil;
@ -61,8 +62,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} else { } else {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage) if ($backtopage) {
{
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit(); exit();
} }

View File

@ -39,22 +39,26 @@ $langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
accessforbidden(); accessforbidden();
} }
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->bind->write) }
if (!$user->rights->accounting->bind->write) {
accessforbidden(); accessforbidden();
}
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); if (GETPOST("year", 'int')) {
else { $year_start = GETPOST("year", 'int');
} else {
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
} }
$year_end = $year_start + 1; $year_end = $year_start + 1;
$month_end = $month_start - 1; $month_end = $month_start - 1;
if ($month_end < 1) if ($month_end < 1) {
{
$month_end = 12; $month_end = 12;
$year_end--; $year_end--;
} }
@ -72,8 +76,7 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
* Actions * Actions
*/ */
if ($action == 'clean' || $action == 'validatehistory') if ($action == 'clean' || $action == 'validatehistory') {
{
// Clean database // Clean database
$db->begin(); $db->begin();
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd";
@ -187,15 +190,13 @@ if ($action == 'validatehistory') {
$suggestedaccountingaccountfor = ''; $suggestedaccountingaccountfor = '';
} }
if ($objp->aarowid_suggest > 0) if ($objp->aarowid_suggest > 0) {
{
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet";
$sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
$sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
$resqlupdate = $db->query($sqlupdate); $resqlupdate = $db->query($sqlupdate);
if (!$resqlupdate) if (!$resqlupdate) {
{
$error++; $error++;
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
break; break;
@ -206,8 +207,7 @@ if ($action == 'validatehistory') {
} }
} }
if ($error) if ($error) {
{
$db->rollback(); $db->rollback();
} else { } else {
$db->commit(); $db->commit();
@ -246,7 +246,9 @@ print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>
print '<td width="200" class="left">'.$langs->trans("Label").'</td>'; print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -255,7 +257,9 @@ $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(fd.total_ht) as total"; $sql .= " SUM(fd.total_ht) as total";
@ -286,16 +290,18 @@ if ($resql) {
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} else print length_accountg($row[0]); } else {
print length_accountg($row[0]);
}
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} else print $row[1]; } else {
print $row[1];
}
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
@ -324,7 +330,9 @@ print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>
print '<td width="200" class="left">'.$langs->trans("Label").'</td>'; print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -333,7 +341,9 @@ $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(fd.total_ht) as total"; $sql .= " SUM(fd.total_ht) as total";
@ -364,17 +374,19 @@ if ($resql) {
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} else print length_accountg($row[0]); } else {
print length_accountg($row[0]);
}
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} else print $row[1]; } else {
print $row[1];
}
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
@ -392,8 +404,7 @@ print "</table>\n";
print '</div>'; print '</div>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report that should rely on result of this step ?
{
print '<br>'; print '<br>';
print '<br>'; print '<br>';
@ -405,7 +416,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("TotalVente").'</td>'; print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("TotalVente").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -413,7 +426,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$sql = "SELECT '".$db->escape($langs->trans("TotalVente"))."' AS total,"; $sql = "SELECT '".$db->escape($langs->trans("TotalVente"))."' AS total,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, 'fd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(fd.total_ht) as total"; $sql .= " SUM(fd.total_ht) as total";
@ -462,7 +477,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print '<tr class="liste_titre"><td width="400">'.$langs->trans("TotalMarge").'</td>'; print '<tr class="liste_titre"><td width="400">'.$langs->trans("TotalMarge").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -470,7 +487,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,"; $sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total";

View File

@ -64,12 +64,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) $page = 0; if (empty($page) || $page < 0) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) if (!$sortfield) {
$sortfield = "f.datef, f.ref, fd.rowid"; $sortfield = "f.datef, f.ref, fd.rowid";
}
if (!$sortorder) { if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = "DESC"; $sortorder = "DESC";
@ -77,10 +80,12 @@ if (!$sortorder) {
} }
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->bind->write) }
if (!$user->rights->accounting->bind->write) {
accessforbidden(); accessforbidden();
}
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
@ -90,8 +95,7 @@ $formaccounting = new FormAccounting($db);
*/ */
// Purge search criteria // Purge search criteria
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')) { // All tests are required to be compatible with all browsers
{
$search_societe = ''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
@ -111,14 +115,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
if (is_array($changeaccount) && count($changeaccount) > 0) { if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0; $error = 0;
if (!(GETPOST('account_parent', 'int') >= 0)) if (!(GETPOST('account_parent', 'int') >= 0)) {
{
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
} }
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l"; $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as l";
@ -231,16 +233,23 @@ $sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) { if (strlen(trim($search_country))) {
$arrayofcode = getCountriesInEEC(); $arrayofcode = getCountriesInEEC();
$country_code_in_EEC = $country_code_in_EEC_without_me = ''; $country_code_in_EEC = $country_code_in_EEC_without_me = '';
foreach ($arrayofcode as $key => $value) foreach ($arrayofcode as $key => $value) {
{
$country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'"; $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; if ($value != $mysoc->country_code) {
$country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
}
}
if ($search_country == 'special_allnotme') {
$sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
} elseif ($search_country == 'special_eec') {
$sql .= " AND co.code IN (".$country_code_in_EEC.")";
} elseif ($search_country == 'special_eecnotme') {
$sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
} elseif ($search_country == 'special_noteec') {
$sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
} else {
$sql .= natural_search("co.code", $search_country);
} }
if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
else $sql .= natural_search("co.code", $search_country);
} }
if (strlen(trim($search_tvaintra))) { if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra); $sql .= natural_search("s.tva_intra", $search_tvaintra);
@ -250,12 +259,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -270,24 +277,54 @@ if ($result) {
$i = 0; $i = 0;
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($search_societe) $param .= "&search_societe=".urlencode($search_societe); }
if ($search_invoice) $param .= "&search_invoice=".urlencode($search_invoice); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); $param .= '&limit='.urlencode($limit);
if ($search_label) $param .= "&search_label=".urlencode($search_label); }
if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); if ($search_societe) {
if ($search_account) $param .= "&search_account=".urlencode($search_account); $param .= "&search_societe=".urlencode($search_societe);
if ($search_vat) $param .= "&search_vat=".urlencode($search_vat); }
if ($search_day) $param .= '&search_day='.urlencode($search_day); if ($search_invoice) {
if ($search_month) $param .= '&search_month='.urlencode($search_month); $param .= "&search_invoice=".urlencode($search_invoice);
if ($search_year) $param .= '&search_year='.urlencode($search_year); }
if ($search_country) $param .= "&search_country=".urlencode($search_country); if ($search_ref) {
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); $param .= "&search_ref=".urlencode($search_ref);
}
if ($search_label) {
$param .= "&search_label=".urlencode($search_label);
}
if ($search_desc) {
$param .= "&search_desc=".urlencode($search_desc);
}
if ($search_account) {
$param .= "&search_account=".urlencode($search_account);
}
if ($search_vat) {
$param .= "&search_vat=".urlencode($search_vat);
}
if ($search_day) {
$param .= '&search_day='.urlencode($search_day);
}
if ($search_month) {
$param .= '&search_month='.urlencode($search_month);
}
if ($search_year) {
$param .= '&search_year='.urlencode($search_year);
}
if ($search_country) {
$param .= "&search_country=".urlencode($search_country);
}
if ($search_tvaintra) {
$param .= "&search_tvaintra=".urlencode($search_tvaintra);
}
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n"; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" 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.'">';
@ -313,8 +350,8 @@ if ($result) {
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
} }
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5); $formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
@ -402,9 +439,15 @@ if ($result) {
// Ref Product // Ref Product
print '<td class="tdoverflowmax100">'; print '<td class="tdoverflowmax100">';
if ($productstatic->id > 0) print $productstatic->getNomUrl(1); if ($productstatic->id > 0) {
if ($productstatic->id > 0 && $objp->product_label) print '<br>'; print $productstatic->getNomUrl(1);
if ($objp->product_label) print '<span class="opacitymedium">'.$objp->product_label.'</span>'; }
if ($productstatic->id > 0 && $objp->product_label) {
print '<br>';
}
if ($objp->product_label) {
print '<span class="opacitymedium">'.$objp->product_label.'</span>';
}
print '</td>'; print '</td>';
print '<td class="tdoverflowonsmartphone">'; print '<td class="tdoverflowonsmartphone">';
@ -422,8 +465,7 @@ if ($result) {
// Country // Country
print '<td>'; print '<td>';
if ($objp->country_code) if ($objp->country_code) {
{
print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')'; print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
} }
print '</td>'; print '</td>';

View File

@ -72,12 +72,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; } if (empty($page) || $page < 0) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) if (!$sortfield) {
$sortfield = "f.datef, f.ref, l.rowid"; $sortfield = "f.datef, f.ref, l.rowid";
}
if (!$sortorder) { if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
$sortorder = "DESC"; $sortorder = "DESC";
@ -85,10 +88,12 @@ if (!$sortorder) {
} }
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->bind->write) }
if (!$user->rights->accounting->bind->write) {
accessforbidden(); accessforbidden();
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('accountancycustomerlist')); $hookmanager->initHooks(array('accountancycustomerlist'));
@ -102,18 +107,22 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All 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 test are required to be compatible with all browsers
{
$search_societe = ''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
@ -155,8 +164,7 @@ if ($massaction == 'ventil') {
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId); $monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0) if ($monCompte <= 0) {
{
$msg .= '<div><span style="color:red">'.$langs->trans("Lineofinvoice", $monId).' - '.$langs->trans("NoAccountSelected").'</span></div>'; $msg .= '<div><span style="color:red">'.$langs->trans("Lineofinvoice", $monId).' - '.$langs->trans("NoAccountSelected").'</span></div>';
$ko++; $ko++;
} else { } else {
@ -195,8 +203,7 @@ $formother = new FormOther($db);
llxHeader('', $langs->trans("Ventilation")); llxHeader('', $langs->trans("Ventilation"));
if (empty($chartaccountcode)) if (empty($chartaccountcode)) {
{
print $langs->trans("ErrorChartOfAccountSystemNotSelected"); print $langs->trans("ErrorChartOfAccountSystemNotSelected");
// End of page // End of page
llxFooter(); llxFooter();
@ -264,16 +271,23 @@ $sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) { if (strlen(trim($search_country))) {
$arrayofcode = getCountriesInEEC(); $arrayofcode = getCountriesInEEC();
$country_code_in_EEC = $country_code_in_EEC_without_me = ''; $country_code_in_EEC = $country_code_in_EEC_without_me = '';
foreach ($arrayofcode as $key => $value) foreach ($arrayofcode as $key => $value) {
{
$country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'"; $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; if ($value != $mysoc->country_code) {
$country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
}
}
if ($search_country == 'special_allnotme') {
$sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
} elseif ($search_country == 'special_eec') {
$sql .= " AND co.code IN (".$country_code_in_EEC.")";
} elseif ($search_country == 'special_eecnotme') {
$sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
} elseif ($search_country == 'special_noteec') {
$sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
} else {
$sql .= natural_search("co.code", $search_country);
} }
if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
else $sql .= natural_search("co.code", $search_country);
} }
if (strlen(trim($search_tvaintra))) { if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra); $sql .= natural_search("s.tva_intra", $search_tvaintra);
@ -294,12 +308,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -321,20 +333,48 @@ if ($result) {
$arrayofselected = is_array($toselect) ? $toselect : array(); $arrayofselected = is_array($toselect) ? $toselect : array();
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); }
if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($search_day) $param .= '&search_day='.urlencode($search_day); $param .= '&limit='.urlencode($limit);
if ($search_month) $param .= '&search_month='.urlencode($search_month); }
if ($search_year) $param .= '&search_year='.urlencode($search_year); if ($search_societe) {
if ($search_invoice) $param .= '&search_invoice='.urlencode($search_invoice); $param .= '&search_societe='.urlencode($search_societe);
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); }
if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); if ($search_lineid) {
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); $param .= '&search_lineid='.urlencode($search_lineid);
if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); }
if ($search_country) $param .= "&search_country=".urlencode($search_country); if ($search_day) {
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); $param .= '&search_day='.urlencode($search_day);
}
if ($search_month) {
$param .= '&search_month='.urlencode($search_month);
}
if ($search_year) {
$param .= '&search_year='.urlencode($search_year);
}
if ($search_invoice) {
$param .= '&search_invoice='.urlencode($search_invoice);
}
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_desc) {
$param .= '&search_desc='.urlencode($search_desc);
}
if ($search_amount) {
$param .= '&search_amount='.urlencode($search_amount);
}
if ($search_vat) {
$param .= '&search_vat='.urlencode($search_vat);
}
if ($search_country) {
$param .= "&search_country=".urlencode($search_country);
}
if ($search_tvaintra) {
$param .= "&search_tvaintra=".urlencode($search_tvaintra);
}
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate") 'ventil'=>$langs->trans("Ventilate")
@ -347,7 +387,9 @@ if ($result) {
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n"; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" 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.'">';
@ -358,7 +400,9 @@ if ($result) {
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>'; print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>';
if ($msg) print $msg.'<br>'; if ($msg) {
print $msg.'<br>';
}
$moreforfilter = ''; $moreforfilter = '';
@ -370,11 +414,11 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre center nowraponall minwidth100imp">'; print '<td class="liste_titre center nowraponall minwidth100imp">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
} }
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5); $formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>'; //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
@ -410,7 +454,9 @@ if ($result) {
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall '); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
$checkpicto = ''; $checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); if ($massactionbutton) {
$checkpicto = $form->showCheckAddButtons('checkforselect', 1);
}
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
@ -503,7 +549,9 @@ if ($result) {
} }
} }
} }
if ($objp->code_sell_l == -1) $objp->code_sell_l = ''; if ($objp->code_sell_l == -1) {
$objp->code_sell_l = '';
}
// Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding) // Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding)
$suggestedaccountingaccountfor = ''; $suggestedaccountingaccountfor = '';
@ -553,8 +601,12 @@ if ($result) {
} else { } else {
$code_sell_p_notset = 'color:orange'; $code_sell_p_notset = 'color:orange';
} }
if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) $code_sell_p_notset = 'color:red'; if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) {
if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber' && empty($code_sell_p_notset)) $code_sell_p_notset = 'color:orange'; $code_sell_p_notset = 'color:red';
}
if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber' && empty($code_sell_p_notset)) {
$code_sell_p_notset = 'color:orange';
}
// $objp->code_sell_l is now default code of product/service // $objp->code_sell_l is now default code of product/service
// $objp->code_sell_p is now code of product/service // $objp->code_sell_p is now code of product/service
@ -575,7 +627,9 @@ if ($result) {
if ($product_static->id > 0) { if ($product_static->id > 0) {
print $product_static->getNomUrl(1); print $product_static->getNomUrl(1);
} }
if ($objp->product_label) print '<br><span class="opacitymedium small">'.$objp->product_label.'</span>'; if ($objp->product_label) {
print '<br><span class="opacitymedium small">'.$objp->product_label.'</span>';
}
print '</td>'; print '</td>';
print '<td class="tdoverflowonsmartphone small">'; print '<td class="tdoverflowonsmartphone small">';
@ -589,8 +643,9 @@ if ($result) {
print '</td>'; print '</td>';
// Vat rate // Vat rate
if ($objp->vat_tx_l != $objp->vat_tx_p) if ($objp->vat_tx_l != $objp->vat_tx_p) {
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
}
print '<td style="'.$code_vat_differ.'" class="right">'; print '<td style="'.$code_vat_differ.'" class="right">';
print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')); print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : ''));
print '</td>'; print '</td>';
@ -610,22 +665,27 @@ if ($result) {
print '<td>'; print '<td>';
$s = '<span class="small">1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>'; $s = '<span class="small">1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>';
$shelp = ''; $shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); if ($suggestedaccountingaccountbydefaultfor == 'eec') {
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); $shelp .= $langs->trans("SaleEEC");
} elseif ($suggestedaccountingaccountbydefaultfor == 'export') {
$shelp .= $langs->trans("SaleExport");
}
$s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>'); $s .= ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
if ($objp->product_id > 0) if ($objp->product_id > 0) {
{
print '<br>'; print '<br>';
$s = '<span class="small">2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>'; $s = '<span class="small">2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
$shelp = ''; $ttype = 'help'; $shelp = ''; $ttype = 'help';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); if ($suggestedaccountingaccountfor == 'eec') {
elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT"); $shelp = $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') { } elseif ($suggestedaccountingaccountfor == 'eecwithvat') {
$shelp = $langs->trans("SaleEECWithVAT");
} elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') {
$shelp = $langs->trans("SaleEECWithoutVATNumber"); $shelp = $langs->trans("SaleEECWithoutVATNumber");
$ttype = 'warning'; $ttype = 'warning';
} elseif ($suggestedaccountingaccountfor == 'export') {
$shelp = $langs->trans("SaleExport");
} }
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
$s .= (empty($objp->code_sell_p) ? '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_sell_p)); $s .= (empty($objp->code_sell_p) ? '<span style="'.$code_sell_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_sell_p));
print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1); print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1);
} else { } else {
@ -649,10 +709,8 @@ if ($result) {
// Suggested accounting account // Suggested accounting account
print '<td>'; print '<td>';
$suggestedid = $objp->aarowid_suggest; $suggestedid = $objp->aarowid_suggest;
if (empty($suggestedid) && empty($objp->code_sell_p) && !empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) if (empty($suggestedid) && empty($objp->code_sell_p) && !empty($objp->code_sell_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) {
{ if (empty($accountingaccount_codetotid_cache[$objp->code_sell_l])) {
if (empty($accountingaccount_codetotid_cache[$objp->code_sell_l]))
{
$tmpaccount = new AccountingAccount($db); $tmpaccount = new AccountingAccount($db);
$tmpaccount->fetch(0, $objp->code_sell_l, 1); $tmpaccount->fetch(0, $objp->code_sell_l, 1);
if ($tmpaccount->id > 0) { if ($tmpaccount->id > 0) {
@ -669,7 +727,9 @@ if ($result) {
// Column with checkbox // Column with checkbox
print '<td class="center">'; print '<td class="center">';
$ischecked = $objp->aarowid_suggest; $ischecked = $objp->aarowid_suggest;
if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $ischecked = 0; if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') {
$ischecked = 0;
}
print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($ischecked ? "checked" : "").'/>'; print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="'.$objp->rowid."_".$i.'"'.($ischecked ? "checked" : "").'/>';
print '</td>'; print '</td>';

View File

@ -42,19 +42,20 @@ $codeventil = GETPOST('codeventil', 'int');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
}
/* /*
* Actions * Actions
*/ */
if ($action == 'ventil' && $user->rights->accounting->bind->write) if ($action == 'ventil' && $user->rights->accounting->bind->write) {
{ if (!$cancel) {
if (!$cancel) if ($codeventil < 0) {
{ $codeventil = 0;
if ($codeventil < 0) $codeventil = 0; }
$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
$sql .= " SET fk_code_ventilation = ".$codeventil; $sql .= " SET fk_code_ventilation = ".$codeventil;
@ -65,8 +66,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} else { } else {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage) if ($backtopage) {
{
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit(); exit();
} }

View File

@ -36,21 +36,25 @@ $langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
accessforbidden(); accessforbidden();
} }
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->bind->write) }
if (!$user->rights->accounting->bind->write) {
accessforbidden(); accessforbidden();
}
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); if (GETPOST("year", 'int')) {
else { $year_start = GETPOST("year", 'int');
} else {
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
} }
$year_end = $year_start + 1; $year_end = $year_start + 1;
$month_end = $month_start - 1; $month_end = $month_start - 1;
if ($month_end < 1) if ($month_end < 1) {
{
$month_end = 12; $month_end = 12;
$year_end--; $year_end--;
} }
@ -67,8 +71,7 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
if ($action == 'clean' || $action == 'validatehistory') if ($action == 'clean' || $action == 'validatehistory') {
{
// Clean database // Clean database
$db->begin(); $db->begin();
$sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd"; $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd";
@ -156,7 +159,9 @@ print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>
print '<td width="200" class="left">'.$langs->trans("Label").'</td>'; print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -165,7 +170,9 @@ $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(erd.total_ht) as total"; $sql .= " SUM(erd.total_ht) as total";
@ -190,16 +197,18 @@ if ($resql) {
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} else print length_accountg($row[0]); } else {
print length_accountg($row[0]);
}
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} else print $row[1]; } else {
print $row[1];
}
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
@ -229,7 +238,9 @@ print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>
print '<td width="200" class="left">'.$langs->trans("Label").'</td>'; print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -238,7 +249,9 @@ $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(er.date_debut)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " ROUND(SUM(erd.total_ht),2) as total"; $sql .= " ROUND(SUM(erd.total_ht),2) as total";
@ -263,17 +276,19 @@ if ($resql) {
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} else print length_accountg($row[0]); } else {
print length_accountg($row[0]);
}
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} else print $row[1]; } else {
print $row[1];
}
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
@ -291,8 +306,7 @@ print '</div>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ? if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ?
{
print '<br>'; print '<br>';
print '<br>'; print '<br>';
@ -304,7 +318,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>'; print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -312,7 +328,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$sql = "SELECT '".$db->escape($langs->trans("TotalExpenseReport"))."' AS label,"; $sql = "SELECT '".$db->escape($langs->trans("TotalExpenseReport"))."' AS label,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(erd.total_ht) as total"; $sql .= " SUM(erd.total_ht) as total";

View File

@ -58,12 +58,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) $page = 0; if (empty($page) || $page < 0) {
$page = 0;
}
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
$offset = $limit * $page; $offset = $limit * $page;
if (!$sortfield) if (!$sortfield) {
$sortfield = "erd.date, erd.rowid"; $sortfield = "erd.date, erd.rowid";
}
if (!$sortorder) { if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = "DESC"; $sortorder = "DESC";
@ -71,10 +74,12 @@ if (!$sortorder) {
} }
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->bind->write) }
if (!$user->rights->accounting->bind->write) {
accessforbidden(); accessforbidden();
}
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
@ -84,8 +89,7 @@ $formaccounting = new FormAccounting($db);
*/ */
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || 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')) { // Both test are required to be compatible with all browsers
{
$search_login = ''; $search_login = '';
$search_expensereport = ''; $search_expensereport = '';
$search_label = ''; $search_label = '';
@ -101,14 +105,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
if (is_array($changeaccount) && count($changeaccount) > 0) { if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0; $error = 0;
if (!(GETPOST('account_parent', 'int') >= 0)) if (!(GETPOST('account_parent', 'int') >= 0)) {
{
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
} }
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
$sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd"; $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd";
@ -205,12 +207,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -226,21 +226,45 @@ if ($result) {
$i = 0; $i = 0;
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($search_login) $param .= '&search_login='.urlencode($search_login); }
if ($search_expensereport) $param .= "&search_expensereport=".urlencode($search_expensereport); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($search_label) $param .= "&search_label=".urlencode($search_label); $param .= '&limit='.urlencode($limit);
if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); }
if ($search_account) $param .= "&search_account=".urlencode($search_account); if ($search_login) {
if ($search_vat) $param .= "&search_vat=".urlencode($search_vat); $param .= '&search_login='.urlencode($search_login);
if ($search_day) $param .= '&search_day='.urlencode($search_day); }
if ($search_month) $param .= '&search_month='.urlencode($search_month); if ($search_expensereport) {
if ($search_year) $param .= '&search_year='.urlencode($search_year); $param .= "&search_expensereport=".urlencode($search_expensereport);
}
if ($search_label) {
$param .= "&search_label=".urlencode($search_label);
}
if ($search_desc) {
$param .= "&search_desc=".urlencode($search_desc);
}
if ($search_account) {
$param .= "&search_account=".urlencode($search_account);
}
if ($search_vat) {
$param .= "&search_vat=".urlencode($search_vat);
}
if ($search_day) {
$param .= '&search_day='.urlencode($search_day);
}
if ($search_month) {
$param .= '&search_month='.urlencode($search_month);
}
if ($search_year) {
$param .= '&search_year='.urlencode($search_year);
}
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n"; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" 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.'">';
@ -268,9 +292,11 @@ if ($result) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5); }
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';

View File

@ -68,12 +68,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; } if (empty($page) || $page < 0) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) if (!$sortfield) {
$sortfield = "erd.date, erd.rowid"; $sortfield = "erd.date, erd.rowid";
}
if (!$sortorder) { if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
$sortorder = "DESC"; $sortorder = "DESC";
@ -81,10 +84,12 @@ if (!$sortorder) {
} }
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->bind->write) }
if (!$user->rights->accounting->bind->write) {
accessforbidden(); accessforbidden();
}
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$accounting = new AccountingAccount($db); $accounting = new AccountingAccount($db);
@ -96,12 +101,15 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
* Action * Action
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All 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 test are required to be compatible with all browsers
{
$search_login = ''; $search_login = '';
$search_expensereport = ''; $search_expensereport = '';
$search_label = ''; $search_label = '';
@ -137,8 +145,7 @@ if ($massaction == 'ventil') {
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId); $monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0) if ($monCompte <= 0) {
{
$msg .= '<div><span style="color:red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</span></div>'; $msg .= '<div><span style="color:red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</span></div>';
$ko++; $ko++;
} else { } else {
@ -177,8 +184,7 @@ $formother = new FormOther($db);
llxHeader('', $langs->trans("ExpenseReportsVentilation")); llxHeader('', $langs->trans("ExpenseReportsVentilation"));
if (empty($chartaccountcode)) if (empty($chartaccountcode)) {
{
print $langs->trans("ErrorChartOfAccountSystemNotSelected"); print $langs->trans("ErrorChartOfAccountSystemNotSelected");
// End of page // End of page
llxFooter(); llxFooter();
@ -231,12 +237,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -253,18 +257,42 @@ if ($result) {
$arrayofselected = is_array($toselect) ? $toselect : array(); $arrayofselected = is_array($toselect) ? $toselect : array();
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($search_login) $param .= '&search_login='.urlencode($search_login); }
if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($search_day) $param .= '&search_day='.urlencode($search_day); $param .= '&limit='.urlencode($limit);
if ($search_month) $param .= '&search_month='.urlencode($search_month); }
if ($search_year) $param .= '&search_year='.urlencode($search_year); if ($search_login) {
if ($search_expensereport) $param .= '&search_expensereport='.urlencode($search_expensereport); $param .= '&search_login='.urlencode($search_login);
if ($search_label) $param .= '&search_label='.urlencode($search_label); }
if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); if ($search_lineid) {
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); $param .= '&search_lineid='.urlencode($search_lineid);
if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); }
if ($search_day) {
$param .= '&search_day='.urlencode($search_day);
}
if ($search_month) {
$param .= '&search_month='.urlencode($search_month);
}
if ($search_year) {
$param .= '&search_year='.urlencode($search_year);
}
if ($search_expensereport) {
$param .= '&search_expensereport='.urlencode($search_expensereport);
}
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_desc) {
$param .= '&search_desc='.urlencode($search_desc);
}
if ($search_amount) {
$param .= '&search_amount='.urlencode($search_amount);
}
if ($search_vat) {
$param .= '&search_vat='.urlencode($search_vat);
}
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil' => $langs->trans("Ventilate") 'ventil' => $langs->trans("Ventilate")
@ -274,7 +302,9 @@ if ($result) {
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n"; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" 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.'">';
@ -285,7 +315,9 @@ if ($result) {
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoExpenseReport").'</span></br><br>'; print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoExpenseReport").'</span></br><br>';
if ($msg) print $msg.'<br>'; if ($msg) {
print $msg.'<br>';
}
$moreforfilter = ''; $moreforfilter = '';
@ -301,9 +333,11 @@ if ($result) {
print '<td class="liste_titre"></td>'; print '<td class="liste_titre"></td>';
} }
print '<td class="liste_titre center nowraponall minwidth100imp">'; print '<td class="liste_titre center nowraponall minwidth100imp">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5); }
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
@ -332,7 +366,9 @@ if ($result) {
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall '); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', ''); print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', '');
$checkpicto = ''; $checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); if ($massactionbutton) {
$checkpicto = $form->showCheckAddButtons('checkforselect', 1);
}
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";

View File

@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$langs->loadLangs(array("compta", "bills", "other", "accountancy", "loans", "banks", "admin", "dict")); $langs->loadLangs(array("compta", "bills", "other", "accountancy", "loans", "banks", "admin", "dict"));
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
}
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$hookmanager->initHooks(array('accountancyindex')); $hookmanager->initHooks(array('accountancyindex'));
@ -43,8 +44,8 @@ $hookmanager->initHooks(array('accountancyindex'));
* Actions * Actions
*/ */
if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) if (GETPOST('addbox')) {
{ // Add box (when submit is done from a form when ajax disabled)
require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
$zone = GETPOST('areacode', 'aZ09'); $zone = GETPOST('areacode', 'aZ09');
$userid = GETPOST('userid', 'int'); $userid = GETPOST('userid', 'int');
@ -52,7 +53,9 @@ if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax dis
$boxorder .= GETPOST('boxcombo', 'aZ09'); $boxorder .= GETPOST('boxcombo', 'aZ09');
$result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); if ($result > 0) {
setEventMessages($langs->trans("BoxAdded"), null);
}
} }
@ -60,10 +63,11 @@ if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax dis
* View * View
*/ */
llxHeader('', $langs->trans("AccountancyArea")); $help_url = '';
if ($conf->accounting->enabled) llxHeader('', $langs->trans("AccountancyArea"), $help_url);
{
if ($conf->accounting->enabled) {
$step = 0; $step = 0;
$resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
@ -71,8 +75,7 @@ if ($conf->accounting->enabled)
$helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default. $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default.
$showtutorial = ''; $showtutorial = '';
if (!$helpisexpanded) if (!$helpisexpanded) {
{
$showtutorial = '<div align="right"><a href="#" id="show_hide">'; $showtutorial = '<div align="right"><a href="#" id="show_hide">';
$showtutorial .= img_picto('', 'chevron-down'); $showtutorial .= img_picto('', 'chevron-down');
$showtutorial .= ' '.$langs->trans("ShowTutorial"); $showtutorial .= ' '.$langs->trans("ShowTutorial");
@ -90,7 +93,7 @@ if ($conf->accounting->enabled)
} }
print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy', 0, '', '', $showtutorial); print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial);
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
print "<br>\n"; print "<br>\n";
@ -141,8 +144,7 @@ if ($conf->accounting->enabled)
$s = str_replace('{s}', $textlink, $s); $s = str_replace('{s}', $textlink, $s);
print $s; print $s;
print "<br>\n"; print "<br>\n";
if (!empty($conf->tax->enabled)) if (!empty($conf->tax->enabled)) {
{
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>'; $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
$step++; $step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}'); $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
@ -150,8 +152,7 @@ if ($conf->accounting->enabled)
print $s; print $s;
print "<br>\n"; print "<br>\n";
} }
if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. if (!empty($conf->expensereport->enabled)) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
{
$step++; $step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}'); $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>', $s); $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>', $s);
@ -190,8 +191,7 @@ if ($conf->accounting->enabled)
print $s; print $s;
print "<br>\n"; print "<br>\n";
if (!empty($conf->expensereport->enabled) || !empty($conf->deplacement->enabled)) if (!empty($conf->expensereport->enabled) || !empty($conf->deplacement->enabled)) {
{
$step++; $step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '{s}')."\n"; $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '{s}')."\n";
$s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong></a>', $s); $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong></a>', $s);
@ -218,8 +218,8 @@ if ($conf->accounting->enabled)
print '<div class="fichecenter fichecenterbis">'; print '<div class="fichecenter fichecenterbis">';
/* /*
* Show boxes * Show boxes
*/ */
$boxlist .= '<div class="twocolumns">'; $boxlist .= '<div class="twocolumns">';
$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">'; $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';

View File

@ -51,13 +51,16 @@ $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday'); $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear'); $date_endyear = GETPOST('date_endyear');
$in_bookkeeping = GETPOST('in_bookkeeping'); $in_bookkeeping = GETPOST('in_bookkeeping');
if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; if ($in_bookkeeping == '') {
$in_bookkeeping = 'notyet';
}
$now = dol_now(); $now = dol_now();
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
}
/* /*
* Actions * Actions
@ -73,8 +76,7 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_startmonth) || empty($date_endmonth)) if (empty($date_startmonth) || empty($date_endmonth)) {
{
// Period by default on transfer // Period by default on transfer
$dates = getDefaultDatesForTransfer(); $dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start']; $date_start = $dates['date_start'];
@ -83,8 +85,7 @@ if (empty($date_startmonth) || empty($date_endmonth))
$pastmonth = $dates['pastmonth']; $pastmonth = $dates['pastmonth'];
} }
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) { // We define date_start and date_end, only if we did not submit the form
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
@ -101,19 +102,18 @@ $sql .= " JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = er.fk_user_author";
$sql .= " WHERE er.fk_statut > 0"; $sql .= " WHERE er.fk_statut > 0";
$sql .= " AND erd.fk_code_ventilation > 0"; $sql .= " AND erd.fk_code_ventilation > 0";
$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
if ($date_start && $date_end) if ($date_start && $date_end) {
$sql .= " AND er.date_debut >= '".$db->idate($date_start)."' AND er.date_debut <= '".$db->idate($date_end)."'"; $sql .= " AND er.date_debut >= '".$db->idate($date_start)."' AND er.date_debut <= '".$db->idate($date_end)."'";
}
// Define begin binding date // Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; $sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
} }
// Already in bookkeeping or not // Already in bookkeeping or not
if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'already') {
{
$sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; $sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
} }
if ($in_bookkeeping == 'notyet') if ($in_bookkeeping == 'notyet') {
{
$sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
} }
$sql .= " ORDER BY er.date_debut"; $sql .= " ORDER BY er.date_debut";
@ -150,8 +150,7 @@ if ($result) {
$compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva); $compta_localtax2 = (!empty($vatdata['accountancy_code_buy']) ? $vatdata['accountancy_code_buy'] : $cpttva);
// Define array to display all VAT rates that use this accounting account $compta_tva // Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
{
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')); $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
} }
@ -161,11 +160,21 @@ if ($result) {
$taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid; $taber[$obj->rowid]["fk_expensereportdet"] = $obj->erdid;
// Avoid warnings // Avoid warnings
if (!isset($tabttc[$obj->rowid][$compta_user])) $tabttc[$obj->rowid][$compta_user] = 0; if (!isset($tabttc[$obj->rowid][$compta_user])) {
if (!isset($tabht[$obj->rowid][$compta_fees])) $tabht[$obj->rowid][$compta_fees] = 0; $tabttc[$obj->rowid][$compta_user] = 0;
if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; }
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; if (!isset($tabht[$obj->rowid][$compta_fees])) {
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; $tabht[$obj->rowid][$compta_fees] = 0;
}
if (!isset($tabtva[$obj->rowid][$compta_tva])) {
$tabtva[$obj->rowid][$compta_tva] = 0;
}
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
$tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
}
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
$tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
}
$tabttc[$obj->rowid][$compta_user] += $obj->total_ttc; $tabttc[$obj->rowid][$compta_user] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_fees] += $obj->total_ht; $tabht[$obj->rowid][$compta_fees] += $obj->total_ht;
@ -189,8 +198,7 @@ if ($action == 'writebookkeeping') {
$now = dol_now(); $now = dol_now();
$error = 0; $error = 0;
foreach ($taber as $key => $val) // Loop on each expense report foreach ($taber as $key => $val) { // Loop on each expense report
{
$errorforline = 0; $errorforline = 0;
$totalcredit = 0; $totalcredit = 0;
@ -199,8 +207,7 @@ if ($action == 'writebookkeeping') {
$db->begin(); $db->begin();
// Thirdparty // Thirdparty
if (!$errorforline) if (!$errorforline) {
{
foreach ($tabttc[$key] as $k => $mt) { foreach ($tabttc[$key] as $k => $mt) {
if ($mt) { if ($mt) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
@ -232,8 +239,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
{
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
@ -248,8 +254,7 @@ if ($action == 'writebookkeeping') {
} }
// Fees // Fees
if (!$errorforline) if (!$errorforline) {
{
foreach ($tabht[$key] as $k => $mt) { foreach ($tabht[$key] as $k => $mt) {
if ($mt) { if ($mt) {
// get compte id and label // get compte id and label
@ -280,8 +285,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
{
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
@ -297,14 +301,16 @@ if ($action == 'writebookkeeping') {
} }
// VAT // VAT
if (!$errorforline) if (!$errorforline) {
{
$listoftax = array(0, 1, 2); $listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) foreach ($listoftax as $numtax) {
{
$arrayofvat = $tabtva; $arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1; if ($numtax == 1) {
if ($numtax == 2) $arrayofvat = $tablocaltax2; $arrayofvat = $tablocaltax1;
}
if ($numtax == 2) {
$arrayofvat = $tablocaltax2;
}
foreach ($arrayofvat[$key] as $k => $mt) { foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
@ -338,8 +344,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
{
$error++; $error++;
$errorforline++; $errorforline++;
//setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
@ -355,21 +360,18 @@ if ($action == 'writebookkeeping') {
} }
// Protection against a bug on line before // Protection against a bug on line before
if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) {
{
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages('Try to insert a non balanced transaction in book for '.$val["ref"].'. Canceled. Surely a bug.', null, 'errors'); setEventMessages('Try to insert a non balanced transaction in book for '.$val["ref"].'. Canceled. Surely a bug.', null, 'errors');
} }
if (!$errorforline) if (!$errorforline) {
{
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
if ($error >= 10) if ($error >= 10) {
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach break; // Break in the foreach
} }
@ -380,8 +382,7 @@ if ($action == 'writebookkeeping') {
if (empty($error) && count($tabpay) > 0) { if (empty($error) && count($tabpay) > 0) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} elseif (count($tabpay) == $error) } elseif (count($tabpay) == $error) {
{
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
} else { } else {
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
@ -390,8 +391,7 @@ if ($action == 'writebookkeeping') {
$action = ''; $action = '';
// Must reload data, so we make a redirect // Must reload data, so we make a redirect
if (count($tabpay) != $error) if (count($tabpay) != $error) {
{
$param = 'id_journal='.$id_journal; $param = 'id_journal='.$id_journal;
$param .= '&date_startday='.$date_startday; $param .= '&date_startday='.$date_startday;
$param .= '&date_startmonth='.$date_startmonth; $param .= '&date_startmonth='.$date_startmonth;
@ -503,12 +503,17 @@ if (empty($action) || $action == 'view') {
} }
print '<div class="tabsAction tabsActionNoBottom">'; print '<div class="tabsAction tabsActionNoBottom">';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
}
if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') { if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} else { } else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; if ($in_bookkeeping == 'notyet') {
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
} else {
print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
}
} }
print '</div>'; print '</div>';
@ -573,10 +578,11 @@ if (empty($action) || $action == 'view') {
// Account // Account
print "<td>"; print "<td>";
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("FeeAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("FeeAccountNotDefined").'</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print '</td>'; print '</td>';
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -602,18 +608,20 @@ if (empty($action) || $action == 'view') {
// Account // Account
print "<td>"; print "<td>";
$accountoshow = length_accounta($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT); $accountoshow = length_accounta($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("MainAccountForUsersNotDefined").'</span>'; print '<span class="error">'.$langs->trans("MainAccountForUsersNotDefined").'</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";
$accountoshow = length_accounta($k); $accountoshow = length_accounta($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("UserAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("UserAccountNotDefined").'</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print '</td>'; print '</td>';
print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>"; print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>";
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>"; print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
@ -625,8 +633,12 @@ if (empty($action) || $action == 'view') {
$listoftax = array(0, 1, 2); $listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) { foreach ($listoftax as $numtax) {
$arrayofvat = $tabtva; $arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1; if ($numtax == 1) {
if ($numtax == 2) $arrayofvat = $tablocaltax2; $arrayofvat = $tablocaltax1;
}
if ($numtax == 2) {
$arrayofvat = $tablocaltax2;
}
foreach ($arrayofvat[$key] as $k => $mt) { foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
@ -637,10 +649,11 @@ if (empty($action) || $action == 'view') {
// Account // Account
print "<td>"; print "<td>";
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";

View File

@ -51,13 +51,16 @@ $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday'); $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear'); $date_endyear = GETPOST('date_endyear');
$in_bookkeeping = GETPOST('in_bookkeeping'); $in_bookkeeping = GETPOST('in_bookkeeping');
if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; if ($in_bookkeeping == '') {
$in_bookkeeping = 'notyet';
}
$now = dol_now(); $now = dol_now();
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
}
$hookmanager->initHooks(array('purchasesjournal')); $hookmanager->initHooks(array('purchasesjournal'));
$parameters = array(); $parameters = array();
@ -78,8 +81,7 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_startmonth) || empty($date_endmonth)) if (empty($date_startmonth) || empty($date_endmonth)) {
{
// Period by default on transfer // Period by default on transfer
$dates = getDefaultDatesForTransfer(); $dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start']; $date_start = $dates['date_start'];
@ -88,8 +90,7 @@ if (empty($date_startmonth) || empty($date_endmonth))
$pastmonth = $dates['pastmonth']; $pastmonth = $dates['pastmonth'];
} }
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) { // We define date_start and date_end, only if we did not submit the form
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
@ -111,19 +112,18 @@ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
} else { } else {
$sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")"; $sql .= " AND f.type IN (".FactureFournisseur::TYPE_STANDARD.",".FactureFournisseur::TYPE_REPLACEMENT.",".FactureFournisseur::TYPE_CREDIT_NOTE.",".FactureFournisseur::TYPE_DEPOSIT.",".FactureFournisseur::TYPE_SITUATION.")";
} }
if ($date_start && $date_end) if ($date_start && $date_end) {
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
// Define begin binding date // Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
} }
// Already in bookkeeping or not // Already in bookkeeping or not
if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'already') {
{
$sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; $sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
} }
if ($in_bookkeeping == 'notyet') if ($in_bookkeeping == 'notyet') {
{
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')"; $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
} }
$sql .= " ORDER BY f.datef"; $sql .= " ORDER BY f.datef";
@ -156,9 +156,9 @@ if ($result) {
$compta_prod = $obj->compte; $compta_prod = $obj->compte;
if (empty($compta_prod)) { if (empty($compta_prod)) {
if ($obj->product_type == 0) if ($obj->product_type == 0) {
$compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined'; $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : 'NotDefined';
else { } else {
$compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined'; $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : 'NotDefined';
} }
} }
@ -170,8 +170,7 @@ if ($result) {
$compta_counterpart_tva_npr = (!empty($conf->global->ACCOUNTING_COUNTERPART_VAT_NPR)) ? $conf->global->ACCOUNTING_COUNTERPART_VAT_NPR : 'NotDefined'; $compta_counterpart_tva_npr = (!empty($conf->global->ACCOUNTING_COUNTERPART_VAT_NPR)) ? $conf->global->ACCOUNTING_COUNTERPART_VAT_NPR : 'NotDefined';
// Define array to display all VAT rates that use this accounting account $compta_tva // Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
{
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')); $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
} }
@ -189,17 +188,26 @@ if ($result) {
//$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; //$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid;
// Avoid warnings // Avoid warnings
if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; if (!isset($tabttc[$obj->rowid][$compta_soc])) {
if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; $tabttc[$obj->rowid][$compta_soc] = 0;
if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; }
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; if (!isset($tabht[$obj->rowid][$compta_prod])) {
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; $tabht[$obj->rowid][$compta_prod] = 0;
}
if (!isset($tabtva[$obj->rowid][$compta_tva])) {
$tabtva[$obj->rowid][$compta_tva] = 0;
}
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
$tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
}
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
$tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
}
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
if (!empty($line->tva_npr)) // Add an entry for counterpart if (!empty($line->tva_npr)) { // Add an entry for counterpart
{
$tabother[$obj->rowid][$compta_counterpart_tva_npr] += $obj->total_tva; $tabother[$obj->rowid][$compta_counterpart_tva_npr] += $obj->total_tva;
} }
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1; $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
@ -226,14 +234,14 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice
$sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0"; $sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
$sql .= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key; $sql .= " AND fd.total_ttc <> 0 AND fk_facture_fourn = ".$key;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj->nb > 0) if ($obj->nb > 0) {
{
$errorforinvoice[$key] = 'somelinesarenotbound'; $errorforinvoice[$key] = 'somelinesarenotbound';
} }
} else dol_print_error($db); } else {
dol_print_error($db);
}
} }
//var_dump($errorforinvoice);exit; //var_dump($errorforinvoice);exit;
@ -274,31 +282,29 @@ if ($action == 'writebookkeeping') {
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0; $replacedinvoice = 0;
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
{
$replacedinvoice = 1; $replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2; if ($alreadydispatched) {
$replacedinvoice = 2;
}
} }
// If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted) // If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
if ($replacedinvoice == 1) if ($replacedinvoice == 1) {
{
$db->rollback(); $db->rollback();
continue; continue;
} }
// Error if some lines are not binded/ready to be journalized // Error if some lines are not binded/ready to be journalized
if ($errorforinvoice[$key] == 'somelinesarenotbound') if ($errorforinvoice[$key] == 'somelinesarenotbound') {
{
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors'); setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
} }
// Thirdparty // Thirdparty
if (!$errorforline) if (!$errorforline) {
{
foreach ($tabttc[$key] as $k => $mt) { foreach ($tabttc[$key] as $k => $mt) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
@ -331,8 +337,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
@ -348,8 +353,7 @@ if ($action == 'writebookkeeping') {
} }
// Product / Service // Product / Service
if (!$errorforline) if (!$errorforline) {
{
foreach ($tabht[$key] as $k => $mt) { foreach ($tabht[$key] as $k => $mt) {
// get compte id and label // get compte id and label
if ($accountingaccount->fetch(null, $k, true)) { if ($accountingaccount->fetch(null, $k, true)) {
@ -381,8 +385,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
@ -400,14 +403,16 @@ if ($action == 'writebookkeeping') {
// VAT // VAT
// var_dump($tabtva); // var_dump($tabtva);
if (!$errorforline) if (!$errorforline) {
{
$listoftax = array(0, 1, 2); $listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) foreach ($listoftax as $numtax) {
{
$arrayofvat = $tabtva; $arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1; if ($numtax == 1) {
if ($numtax == 2) $arrayofvat = $tablocaltax2; $arrayofvat = $tablocaltax1;
}
if ($numtax == 2) {
$arrayofvat = $tablocaltax2;
}
foreach ($arrayofvat[$key] as $k => $mt) { foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
@ -442,8 +447,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
@ -462,8 +466,7 @@ if ($action == 'writebookkeeping') {
// Counterpart of VAT for VAT NPR // Counterpart of VAT for VAT NPR
// var_dump($tabother); // var_dump($tabother);
if (!$errorforline && is_array($tabother[$key])) if (!$errorforline && is_array($tabother[$key])) {
{
foreach ($tabother[$key] as $k => $mt) { foreach ($tabother[$key] as $k => $mt) {
if ($mt) { if ($mt) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
@ -493,8 +496,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
@ -511,22 +513,19 @@ if ($action == 'writebookkeeping') {
} }
// Protection against a bug on lines before // Protection against a bug on lines before
if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))) if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))) {
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'amountsnotbalanced'; $errorforinvoice[$key] = 'amountsnotbalanced';
setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors'); setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
} }
if (!$errorforline) if (!$errorforline) {
{
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
if ($error >= 10) if ($error >= 10) {
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach break; // Break in the foreach
} }
@ -537,8 +536,7 @@ if ($action == 'writebookkeeping') {
if (empty($error) && count($tabpay) > 0) { if (empty($error) && count($tabpay) > 0) {
setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
} elseif (count($tabpay) == $error) } elseif (count($tabpay) == $error) {
{
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
} else { } else {
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
@ -547,8 +545,7 @@ if ($action == 'writebookkeeping') {
$action = ''; $action = '';
// Must reload data, so we make a redirect // Must reload data, so we make a redirect
if (count($tabpay) != $error) if (count($tabpay) != $error) {
{
$param = 'id_journal='.$id_journal; $param = 'id_journal='.$id_journal;
$param .= '&date_startday='.$date_startday; $param .= '&date_startday='.$date_startday;
$param .= '&date_startmonth='.$date_startmonth; $param .= '&date_startmonth='.$date_startmonth;
@ -579,8 +576,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
$companystatic = new Fournisseur($db); $companystatic = new Fournisseur($db);
$invoicestatic = new FactureFournisseur($db); $invoicestatic = new FactureFournisseur($db);
foreach ($tabfac as $key => $val) foreach ($tabfac as $key => $val) {
{
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta']; $companystatic->code_compta = $tabcompany[$key]['code_compta'];
@ -600,16 +596,16 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0; $replacedinvoice = 0;
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
{
$replacedinvoice = 1; $replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2; if ($alreadydispatched) {
$replacedinvoice = 2;
}
} }
// If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted) // If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
if ($replacedinvoice == 1) if ($replacedinvoice == 1) {
{
continue; continue;
} }
@ -657,8 +653,12 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
$listoftax = array(0, 1, 2); $listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) { foreach ($listoftax as $numtax) {
$arrayofvat = $tabtva; $arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1; if ($numtax == 1) {
if ($numtax == 2) $arrayofvat = $tablocaltax2; $arrayofvat = $tablocaltax1;
}
if ($numtax == 2) {
$arrayofvat = $tablocaltax2;
}
foreach ($arrayofvat[$key] as $k => $mt) { foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
@ -679,8 +679,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
} }
// VAT counterpart for NPR // VAT counterpart for NPR
if (is_array($tabother[$key])) if (is_array($tabother[$key])) {
{
foreach ($tabother[$key] as $k => $mt) { foreach ($tabother[$key] as $k => $mt) {
if ($mt) { if ($mt) {
print '"'.$key.'"'.$sep; print '"'.$key.'"'.$sep;
@ -733,12 +732,17 @@ if (empty($action) || $action == 'view') {
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>'); print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
} }
print '<div class="tabsAction tabsActionNoBottom">'; print '<div class="tabsAction tabsActionNoBottom">';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
}
if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { if (($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} else { } else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; if ($in_bookkeeping == 'notyet') {
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
} else {
print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
}
} }
print '</div>'; print '</div>';
@ -781,8 +785,7 @@ if (empty($action) || $action == 'view') {
$invoicestatic = new FactureFournisseur($db); $invoicestatic = new FactureFournisseur($db);
$companystatic = new Fournisseur($db); $companystatic = new Fournisseur($db);
foreach ($tabfac as $key => $val) foreach ($tabfac as $key => $val) {
{
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta']; $companystatic->code_compta = $tabcompany[$key]['code_compta'];
@ -802,16 +805,16 @@ if (empty($action) || $action == 'view') {
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0; $replacedinvoice = 0;
if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
{
$replacedinvoice = 1; $replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2; if ($alreadydispatched) {
$replacedinvoice = 2;
}
} }
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???. // If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
if ($replacedinvoice == 1) if ($replacedinvoice == 1) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<!-- Replaced invoice -->"; print "<!-- Replaced invoice -->";
print "<td>".$date."</td>"; print "<td>".$date."</td>";
@ -831,8 +834,7 @@ if (empty($action) || $action == 'view') {
continue; continue;
} }
if ($errorforinvoice[$key] == 'somelinesarenotbound') if ($errorforinvoice[$key] == 'somelinesarenotbound') {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<!-- Some lines are not bound -->"; print "<!-- Some lines are not bound -->";
print "<td>".$date."</td>"; print "<td>".$date."</td>";
@ -860,18 +862,20 @@ if (empty($action) || $action == 'view') {
// Account // Account
print "<td>"; print "<td>";
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER); $accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("MainAccountForSuppliersNotDefined").'</span>'; print '<span class="error">'.$langs->trans("MainAccountForSuppliersNotDefined").'</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print '</td>'; print '</td>';
// Subledger account // Subledger account
print "<td>"; print "<td>";
$accountoshow = length_accounta($k); $accountoshow = length_accounta($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print '</td>'; print '</td>';
print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount")."</td>"; print "<td>".$companystatic->getNomUrl(0, 'supplier', 16).' - '.$invoicestatic->ref_supplier.' - '.$langs->trans("SubledgerAccount")."</td>";
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>"; print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
@ -891,10 +895,11 @@ if (empty($action) || $action == 'view') {
// Account // Account
print "<td>"; print "<td>";
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -911,8 +916,12 @@ if (empty($action) || $action == 'view') {
$listoftax = array(0, 1, 2); $listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) { foreach ($listoftax as $numtax) {
$arrayofvat = $tabtva; $arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1; if ($numtax == 1) {
if ($numtax == 2) $arrayofvat = $tablocaltax2; $arrayofvat = $tablocaltax1;
}
if ($numtax == 2) {
$arrayofvat = $tablocaltax2;
}
foreach ($arrayofvat[$key] as $k => $mt) { foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
@ -923,10 +932,11 @@ if (empty($action) || $action == 'view') {
// Account // Account
print "<td>"; print "<td>";
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Purchase").')</span>'; print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Purchase").')</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -942,8 +952,7 @@ if (empty($action) || $action == 'view') {
} }
// VAT counterpart for NPR // VAT counterpart for NPR
if (is_array($tabother[$key])) if (is_array($tabother[$key])) {
{
foreach ($tabother[$key] as $k => $mt) { foreach ($tabother[$key] as $k => $mt) {
if ($mt) { if ($mt) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -953,10 +962,11 @@ if (empty($action) || $action == 'view') {
// Account // Account
print '<td>'; print '<td>';
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if ($accountoshow == '' || $accountoshow == 'NotDefined') if ($accountoshow == '' || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("NPR counterpart").'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>'; print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("NPR counterpart").'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print '</td>'; print '</td>';
// Subledger account // Subledger account
print "<td>"; print "<td>";

View File

@ -53,13 +53,16 @@ $date_endmonth = GETPOST('date_endmonth');
$date_endday = GETPOST('date_endday'); $date_endday = GETPOST('date_endday');
$date_endyear = GETPOST('date_endyear'); $date_endyear = GETPOST('date_endyear');
$in_bookkeeping = GETPOST('in_bookkeeping'); $in_bookkeeping = GETPOST('in_bookkeeping');
if ($in_bookkeeping == '') $in_bookkeeping = 'notyet'; if ($in_bookkeeping == '') {
$in_bookkeeping = 'notyet';
}
$now = dol_now(); $now = dol_now();
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
}
$hookmanager->initHooks(array('sellsjournal')); $hookmanager->initHooks(array('sellsjournal'));
$parameters = array(); $parameters = array();
@ -81,8 +84,7 @@ $journal_label = $accountingjournalstatic->label;
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_startmonth) || empty($date_endmonth)) if (empty($date_startmonth) || empty($date_endmonth)) {
{
// Period by default on transfer // Period by default on transfer
$dates = getDefaultDatesForTransfer(); $dates = getDefaultDatesForTransfer();
$date_start = $dates['date_start']; $date_start = $dates['date_start'];
@ -91,8 +93,7 @@ if (empty($date_startmonth) || empty($date_endmonth))
$pastmonth = $dates['pastmonth']; $pastmonth = $dates['pastmonth'];
} }
if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) // We define date_start and date_end, only if we did not submit the form if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) { // We define date_start and date_end, only if we did not submit the form
{
$date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
} }
@ -115,20 +116,19 @@ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Non common s
$sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")"; $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
} }
$sql .= " AND fd.product_type IN (0,1)"; $sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end) if ($date_start && $date_end) {
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
// Define begin binding date // Define begin binding date
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
$sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
} }
// Already in bookkeeping or not // Already in bookkeeping or not
if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'already') {
{
$sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; $sql .= " AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
// $sql .= " AND fd.rowid IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account // $sql .= " AND fd.rowid IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account
} }
if ($in_bookkeeping == 'notyet') if ($in_bookkeeping == 'notyet') {
{
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
// $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account
} }
@ -162,9 +162,9 @@ if ($result) {
$compta_prod = $obj->compte; $compta_prod = $obj->compte;
if (empty($compta_prod)) { if (empty($compta_prod)) {
if ($obj->product_type == 0) if ($obj->product_type == 0) {
$compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined'; $compta_prod = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : 'NotDefined';
else { } else {
$compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined'; $compta_prod = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : 'NotDefined';
} }
} }
@ -175,8 +175,7 @@ if ($result) {
$compta_localtax2 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva); $compta_localtax2 = (!empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
// Define array to display all VAT rates that use this accounting account $compta_tva // Define array to display all VAT rates that use this accounting account $compta_tva
if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) if (price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
{
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')); $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : '')] = (vatrate($obj->tva_tx).($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''));
} }
@ -207,15 +206,27 @@ if ($result) {
//$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid; //$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid;
// Avoid warnings // Avoid warnings
if (!isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; if (!isset($tabttc[$obj->rowid][$compta_soc])) {
if (!isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; $tabttc[$obj->rowid][$compta_soc] = 0;
if (!isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; }
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) $tablocaltax1[$obj->rowid][$compta_localtax1] = 0; if (!isset($tabht[$obj->rowid][$compta_prod])) {
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; $tabht[$obj->rowid][$compta_prod] = 0;
}
if (!isset($tabtva[$obj->rowid][$compta_tva])) {
$tabtva[$obj->rowid][$compta_tva] = 0;
}
if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
$tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
}
if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
$tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
}
$tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio;
$tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
if (empty($line->tva_npr)) $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR if (empty($line->tva_npr)) {
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR
}
$tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio; $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
$tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio; $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
$tabcompany[$obj->rowid] = array( $tabcompany[$obj->rowid] = array(
@ -240,14 +251,14 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice
$sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0"; $sql .= " WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
$sql .= " AND fd.total_ttc <> 0 AND fk_facture = ".$key; $sql .= " AND fd.total_ttc <> 0 AND fk_facture = ".$key;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj->nb > 0) if ($obj->nb > 0) {
{
$errorforinvoice[$key] = 'somelinesarenotbound'; $errorforinvoice[$key] = 'somelinesarenotbound';
} }
} else dol_print_error($db); } else {
dol_print_error($db);
}
} }
//var_dump($errorforinvoice);exit; //var_dump($errorforinvoice);exit;
@ -285,31 +296,29 @@ if ($action == 'writebookkeeping') {
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0; $replacedinvoice = 0;
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
{
$replacedinvoice = 1; $replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2; if ($alreadydispatched) {
$replacedinvoice = 2;
}
} }
// If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted) // If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
if ($replacedinvoice == 1) if ($replacedinvoice == 1) {
{
$db->rollback(); $db->rollback();
continue; continue;
} }
// Error if some lines are not binded/ready to be journalized // Error if some lines are not binded/ready to be journalized
if ($errorforinvoice[$key] == 'somelinesarenotbound') if ($errorforinvoice[$key] == 'somelinesarenotbound') {
{
$error++; $error++;
$errorforline++; $errorforline++;
setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors'); setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors');
} }
// Thirdparty // Thirdparty
if (!$errorforline) if (!$errorforline) {
{
foreach ($tabttc[$key] as $k => $mt) { foreach ($tabttc[$key] as $k => $mt) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
@ -342,8 +351,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
@ -359,8 +367,7 @@ if ($action == 'writebookkeeping') {
} }
// Product / Service // Product / Service
if (!$errorforline) if (!$errorforline) {
{
foreach ($tabht[$key] as $k => $mt) { foreach ($tabht[$key] as $k => $mt) {
// get compte id and label // get compte id and label
if ($accountingaccount->fetch(null, $k, true)) { if ($accountingaccount->fetch(null, $k, true)) {
@ -392,8 +399,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
@ -410,14 +416,16 @@ if ($action == 'writebookkeeping') {
} }
// VAT // VAT
if (!$errorforline) if (!$errorforline) {
{
$listoftax = array(0, 1, 2); $listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) foreach ($listoftax as $numtax) {
{
$arrayofvat = $tabtva; $arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1; if ($numtax == 1) {
if ($numtax == 2) $arrayofvat = $tablocaltax2; $arrayofvat = $tablocaltax1;
}
if ($numtax == 2) {
$arrayofvat = $tablocaltax2;
}
foreach ($arrayofvat[$key] as $k => $mt) { foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
@ -452,8 +460,7 @@ if ($action == 'writebookkeeping') {
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
if ($result < 0) { if ($result < 0) {
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'alreadyjournalized'; $errorforinvoice[$key] = 'alreadyjournalized';
@ -471,22 +478,19 @@ if ($action == 'writebookkeeping') {
} }
// Protection against a bug on lines before // Protection against a bug on lines before
if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))) if (!$errorforline && (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT'))) {
{
$error++; $error++;
$errorforline++; $errorforline++;
$errorforinvoice[$key] = 'amountsnotbalanced'; $errorforinvoice[$key] = 'amountsnotbalanced';
setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors'); setEventMessages('Try to insert a non balanced transaction in book for '.$invoicestatic->ref.'. Canceled. Surely a bug.', null, 'errors');
} }
if (!$errorforline) if (!$errorforline) {
{
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
if ($error >= 10) if ($error >= 10) {
{
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach break; // Break in the foreach
} }
@ -506,8 +510,7 @@ if ($action == 'writebookkeeping') {
$action = ''; $action = '';
// Must reload data, so we make a redirect // Must reload data, so we make a redirect
if (count($tabpay) != $error) if (count($tabpay) != $error) {
{
$param = 'id_journal='.$id_journal; $param = 'id_journal='.$id_journal;
$param .= '&date_startday='.$date_startday; $param .= '&date_startday='.$date_startday;
$param .= '&date_startmonth='.$date_startmonth; $param .= '&date_startmonth='.$date_startmonth;
@ -540,8 +543,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
$companystatic = new Client($db); $companystatic = new Client($db);
$invoicestatic = new Facture($db); $invoicestatic = new Facture($db);
foreach ($tabfac as $key => $val) foreach ($tabfac as $key => $val) {
{
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta']; $companystatic->code_compta = $tabcompany[$key]['code_compta'];
@ -559,16 +561,16 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0; $replacedinvoice = 0;
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
{
$replacedinvoice = 1; $replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2; if ($alreadydispatched) {
$replacedinvoice = 2;
}
} }
// If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted) // If not already into bookkeeping, we won't add it. If yes, do nothing (should not happen because creating replacement not possible if invoice is accounted)
if ($replacedinvoice == 1) if ($replacedinvoice == 1) {
{
continue; continue;
} }
@ -616,8 +618,12 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
$listoftax = array(0, 1, 2); $listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) { foreach ($listoftax as $numtax) {
$arrayofvat = $tabtva; $arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1; if ($numtax == 1) {
if ($numtax == 2) $arrayofvat = $tablocaltax2; $arrayofvat = $tablocaltax1;
}
if ($numtax == 2) {
$arrayofvat = $tablocaltax2;
}
foreach ($arrayofvat[$key] as $k => $mt) { foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
@ -651,9 +657,9 @@ if (empty($action) || $action == 'view') {
$exportlink = ''; $exportlink = '';
$builddate = dol_now(); $builddate = dol_now();
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("DepositsAreNotIncluded"); $description .= $langs->trans("DepositsAreNotIncluded");
else { } else {
$description .= $langs->trans("DepositsAreIncluded"); $description .= $langs->trans("DepositsAreIncluded");
} }
@ -672,12 +678,17 @@ if (empty($action) || $action == 'view') {
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>'); print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
} }
print '<div class="tabsAction tabsActionNoBottom">'; print '<div class="tabsAction tabsActionNoBottom">';
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') {
print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
}
if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') { if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} else { } else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; if ($in_bookkeeping == 'notyet') {
else print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
} else {
print '<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
}
} }
print '</div>'; print '</div>';
@ -720,8 +731,7 @@ if (empty($action) || $action == 'view') {
$companystatic = new Client($db); $companystatic = new Client($db);
$invoicestatic = new Facture($db); $invoicestatic = new Facture($db);
foreach ($tabfac as $key => $val) foreach ($tabfac as $key => $val) {
{
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta']; $companystatic->code_compta = $tabcompany[$key]['code_compta'];
@ -739,16 +749,16 @@ if (empty($action) || $action == 'view') {
// Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched // Is it a replaced invoice ? 0=not a replaced invoice, 1=replaced invoice not yet dispatched, 2=replaced invoice dispatched
$replacedinvoice = 0; $replacedinvoice = 0;
if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
{
$replacedinvoice = 1; $replacedinvoice = 1;
$alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping. $alreadydispatched = $invoicestatic->getVentilExportCompta(); // Test if replaced invoice already into bookkeeping.
if ($alreadydispatched) $replacedinvoice = 2; if ($alreadydispatched) {
$replacedinvoice = 2;
}
} }
// If not already into bookkeeping, we won't add it, if yes, add the counterpart ???. // If not already into bookkeeping, we won't add it, if yes, add the counterpart ???.
if ($replacedinvoice == 1) if ($replacedinvoice == 1) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<!-- Replaced invoice -->"; print "<!-- Replaced invoice -->";
print "<td>".$date."</td>"; print "<td>".$date."</td>";
@ -768,8 +778,7 @@ if (empty($action) || $action == 'view') {
continue; continue;
} }
if ($errorforinvoice[$key] == 'somelinesarenotbound') if ($errorforinvoice[$key] == 'somelinesarenotbound') {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<!-- Some lines are not bound -->"; print "<!-- Some lines are not bound -->";
print "<td>".$date."</td>"; print "<td>".$date."</td>";
@ -789,8 +798,7 @@ if (empty($action) || $action == 'view') {
} }
// Third party // Third party
foreach ($tabttc[$key] as $k => $mt) foreach ($tabttc[$key] as $k => $mt) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<!-- Thirdparty -->"; print "<!-- Thirdparty -->";
print "<td>".$date."</td>"; print "<td>".$date."</td>";
@ -798,18 +806,20 @@ if (empty($action) || $action == 'view') {
// Account // Account
print "<td>"; print "<td>";
$accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER); $accountoshow = length_accounta($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>'; print '<span class="error">'.$langs->trans("MainAccountForCustomersNotDefined").'</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print '</td>'; print '</td>';
// Subledger account // Subledger account
print "<td>"; print "<td>";
$accountoshow = length_accounta($k); $accountoshow = length_accounta($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print '</td>'; print '</td>';
print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount")."</td>"; print "<td>".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("SubledgerAccount")."</td>";
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>"; print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
@ -818,8 +828,7 @@ if (empty($action) || $action == 'view') {
} }
// Product / Service // Product / Service
foreach ($tabht[$key] as $k => $mt) foreach ($tabht[$key] as $k => $mt) {
{
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true); $accountingaccount->fetch(null, $k, true);
@ -830,10 +839,11 @@ if (empty($action) || $action == 'view') {
// Account // Account
print "<td>"; print "<td>";
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>'; print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";
@ -848,11 +858,14 @@ if (empty($action) || $action == 'view') {
// VAT // VAT
$listoftax = array(0, 1, 2); $listoftax = array(0, 1, 2);
foreach ($listoftax as $numtax) foreach ($listoftax as $numtax) {
{
$arrayofvat = $tabtva; $arrayofvat = $tabtva;
if ($numtax == 1) $arrayofvat = $tablocaltax1; if ($numtax == 1) {
if ($numtax == 2) $arrayofvat = $tablocaltax2; $arrayofvat = $tablocaltax1;
}
if ($numtax == 2) {
$arrayofvat = $tablocaltax2;
}
foreach ($arrayofvat[$key] as $k => $mt) { foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
@ -863,10 +876,11 @@ if (empty($action) || $action == 'view') {
// Account // Account
print "<td>"; print "<td>";
$accountoshow = length_accountg($k); $accountoshow = length_accountg($k);
if (($accountoshow == "") || $accountoshow == 'NotDefined') if (($accountoshow == "") || $accountoshow == 'NotDefined') {
{
print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Sale").')</span>'; print '<span class="error">'.$langs->trans("VATAccountNotDefined").' ('.$langs->trans("Sale").')</span>';
} else print $accountoshow; } else {
print $accountoshow;
}
print "</td>"; print "</td>";
// Subledger account // Subledger account
print "<td>"; print "<td>";

View File

@ -42,19 +42,20 @@ $codeventil = GETPOST('codeventil', 'int');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
}
/* /*
* Actions * Actions
*/ */
if ($action == 'ventil' && $user->rights->accounting->bind->write) if ($action == 'ventil' && $user->rights->accounting->bind->write) {
{ if (!$cancel) {
if (!$cancel) if ($codeventil < 0) {
{ $codeventil = 0;
if ($codeventil < 0) $codeventil = 0; }
$sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
$sql .= " SET fk_code_ventilation = ".$codeventil; $sql .= " SET fk_code_ventilation = ".$codeventil;
@ -65,8 +66,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} else { } else {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage) if ($backtopage) {
{
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit(); exit();
} }

View File

@ -37,22 +37,26 @@ $langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
if (empty($conf->accounting->enabled)) { if (empty($conf->accounting->enabled)) {
accessforbidden(); accessforbidden();
} }
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->bind->write) }
if (!$user->rights->accounting->bind->write) {
accessforbidden(); accessforbidden();
}
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); if (GETPOST("year", 'int')) {
else { $year_start = GETPOST("year", 'int');
} else {
$year_start = dol_print_date(dol_now(), '%Y'); $year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year if (dol_print_date(dol_now(), '%m') < $month_start) {
$year_start--; // If current month is lower that starting fiscal month, we start last year
}
} }
$year_end = $year_start + 1; $year_end = $year_start + 1;
$month_end = $month_start - 1; $month_end = $month_start - 1;
if ($month_end < 1) if ($month_end < 1) {
{
$month_end = 12; $month_end = 12;
$year_end--; $year_end--;
} }
@ -70,8 +74,7 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
* Actions * Actions
*/ */
if ($action == 'clean' || $action == 'validatehistory') if ($action == 'clean' || $action == 'validatehistory') {
{
// Clean database // Clean database
$db->begin(); $db->begin();
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as fd"; $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as fd";
@ -177,15 +180,13 @@ if ($action == 'validatehistory') {
$suggestedaccountingaccountfor = ''; $suggestedaccountingaccountfor = '';
} }
if ($objp->aarowid_suggest > 0) if ($objp->aarowid_suggest > 0) {
{
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
$sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest; $sqlupdate .= " SET fk_code_ventilation = ".$objp->aarowid_suggest;
$sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid; $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".$objp->rowid;
$resqlupdate = $db->query($sqlupdate); $resqlupdate = $db->query($sqlupdate);
if (!$resqlupdate) if (!$resqlupdate) {
{
$error++; $error++;
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
break; break;
@ -196,8 +197,7 @@ if ($action == 'validatehistory') {
} }
} }
if ($error) if ($error) {
{
$db->rollback(); $db->rollback();
} else { } else {
$db->commit(); $db->commit();
@ -235,7 +235,9 @@ print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>
print '<td width="200" class="left">'.$langs->trans("Label").'</td>'; print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -244,7 +246,9 @@ $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(ffd.total_ht) as total"; $sql .= " SUM(ffd.total_ht) as total";
@ -270,16 +274,18 @@ if ($resql) {
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} else print length_accountg($row[0]); } else {
print length_accountg($row[0]);
}
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} else print $row[1]; } else {
print $row[1];
}
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
@ -308,7 +314,9 @@ print '<tr class="liste_titre"><td width="200">'.$langs->trans("Account").'</td>
print '<td width="200" class="left">'.$langs->trans("Label").'</td>'; print '<td width="200" class="left">'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -317,7 +325,9 @@ $sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account
$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,"; $sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(ffd.total_ht) as total"; $sql .= " SUM(ffd.total_ht) as total";
@ -343,16 +353,18 @@ if ($resql) {
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("Unknown"); print $langs->trans("Unknown");
} else print length_accountg($row[0]); } else {
print length_accountg($row[0]);
}
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
if ($row[0] == 'tobind') if ($row[0] == 'tobind') {
{
print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind")); print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
} else print $row[1]; } else {
print $row[1];
}
print '</td>'; print '</td>';
for ($i = 2; $i <= 12; $i++) { for ($i = 2; $i <= 12; $i++) {
print '<td class="nowrap right">'.price($row[$i]).'</td>'; print '<td class="nowrap right">'.price($row[$i]).'</td>';
@ -370,8 +382,7 @@ print '</div>';
if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ? if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report that should rely on result of this step ?
{
print '<br>'; print '<br>';
print '<br>'; print '<br>';
@ -383,7 +394,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>'; print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>'; print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
} }
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>'; print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
@ -391,7 +404,9 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
$sql = "SELECT '".$db->escape($langs->trans("CAHTF"))."' AS label,"; $sql = "SELECT '".$db->escape($langs->trans("CAHTF"))."' AS label,";
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12; if ($j > 12) {
$j -= 12;
}
$sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; $sql .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM(ffd.total_ht) as total"; $sql .= " SUM(ffd.total_ht) as total";

View File

@ -65,12 +65,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) $page = 0; if (empty($page) || $page < 0) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) if (!$sortfield) {
$sortfield = "f.datef, f.ref, l.rowid"; $sortfield = "f.datef, f.ref, l.rowid";
}
if (!$sortorder) { if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
$sortorder = "DESC"; $sortorder = "DESC";
@ -78,10 +81,12 @@ if (!$sortorder) {
} }
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->bind->write) }
if (!$user->rights->accounting->bind->write) {
accessforbidden(); accessforbidden();
}
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
@ -91,8 +96,7 @@ $formaccounting = new FormAccounting($db);
*/ */
// Purge search criteria // Purge search criteria
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')) { // All tests are required to be compatible with all browsers
{
$search_societe = ''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
@ -112,15 +116,13 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
if (is_array($changeaccount) && count($changeaccount) > 0) { if (is_array($changeaccount) && count($changeaccount) > 0) {
$error = 0; $error = 0;
if (!(GETPOST('account_parent', 'int') >= 0)) if (!(GETPOST('account_parent', 'int') >= 0)) {
{
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
} }
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as l"; $sql1 = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det as l";
@ -224,16 +226,23 @@ $sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) { if (strlen(trim($search_country))) {
$arrayofcode = getCountriesInEEC(); $arrayofcode = getCountriesInEEC();
$country_code_in_EEC = $country_code_in_EEC_without_me = ''; $country_code_in_EEC = $country_code_in_EEC_without_me = '';
foreach ($arrayofcode as $key => $value) foreach ($arrayofcode as $key => $value) {
{
$country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'"; $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; if ($value != $mysoc->country_code) {
$country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
}
}
if ($search_country == 'special_allnotme') {
$sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
} elseif ($search_country == 'special_eec') {
$sql .= " AND co.code IN (".$country_code_in_EEC.")";
} elseif ($search_country == 'special_eecnotme') {
$sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
} elseif ($search_country == 'special_noteec') {
$sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
} else {
$sql .= natural_search("co.code", $search_country);
} }
if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
else $sql .= natural_search("co.code", $search_country);
} }
if (strlen(trim($search_tvaintra))) { if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra); $sql .= natural_search("s.tva_intra", $search_tvaintra);
@ -249,12 +258,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -269,24 +276,54 @@ if ($result) {
$i = 0; $i = 0;
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($search_societe) $param .= "&search_societe=".urlencode($search_societe); }
if ($search_invoice) $param .= "&search_invoice=".urlencode($search_invoice); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref); $param .= '&limit='.urlencode($limit);
if ($search_label) $param .= "&search_label=".urlencode($search_label); }
if ($search_desc) $param .= "&search_desc=".urlencode($search_desc); if ($search_societe) {
if ($search_account) $param .= "&search_account=".urlencode($search_account); $param .= "&search_societe=".urlencode($search_societe);
if ($search_vat) $param .= "&search_vat=".urlencode($search_vat); }
if ($search_day) $param .= '&search_day='.urlencode($search_day); if ($search_invoice) {
if ($search_month) $param .= '&search_month='.urlencode($search_month); $param .= "&search_invoice=".urlencode($search_invoice);
if ($search_year) $param .= '&search_year='.urlencode($search_year); }
if ($search_country) $param .= "&search_country=".urlencode($search_country); if ($search_ref) {
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); $param .= "&search_ref=".urlencode($search_ref);
}
if ($search_label) {
$param .= "&search_label=".urlencode($search_label);
}
if ($search_desc) {
$param .= "&search_desc=".urlencode($search_desc);
}
if ($search_account) {
$param .= "&search_account=".urlencode($search_account);
}
if ($search_vat) {
$param .= "&search_vat=".urlencode($search_vat);
}
if ($search_day) {
$param .= '&search_day='.urlencode($search_day);
}
if ($search_month) {
$param .= '&search_month='.urlencode($search_month);
}
if ($search_year) {
$param .= '&search_year='.urlencode($search_year);
}
if ($search_country) {
$param .= "&search_country=".urlencode($search_country);
}
if ($search_tvaintra) {
$param .= "&search_tvaintra=".urlencode($search_tvaintra);
}
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n"; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" 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.'">';
@ -311,9 +348,11 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre center nowraponall">'; print '<td class="liste_titre center nowraponall">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5); }
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
@ -355,8 +394,7 @@ if ($result) {
$accountingaccountstatic = new AccountingAccount($db); $accountingaccountstatic = new AccountingAccount($db);
$i = 0; $i = 0;
while ($i < min($num_lines, $limit)) while ($i < min($num_lines, $limit)) {
{
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$facturefournisseur_static->ref = $objp->ref; $facturefournisseur_static->ref = $objp->ref;
@ -405,9 +443,15 @@ if ($result) {
// Ref Product // Ref Product
print '<td class="tdoverflowmax100">'; print '<td class="tdoverflowmax100">';
if ($productstatic->id > 0) print $productstatic->getNomUrl(1); if ($productstatic->id > 0) {
if ($productstatic->id > 0 && $objp->product_label) print '<br>'; print $productstatic->getNomUrl(1);
if ($objp->product_label) print '<span class="opacitymedium">'.$objp->product_label.'</span>'; }
if ($productstatic->id > 0 && $objp->product_label) {
print '<br>';
}
if ($objp->product_label) {
print '<span class="opacitymedium">'.$objp->product_label.'</span>';
}
print '</td>'; print '</td>';
print '<td class="tdoverflowonsmartphone">'; print '<td class="tdoverflowonsmartphone">';
@ -425,8 +469,7 @@ if ($result) {
// Country // Country
print '<td>'; print '<td>';
if ($objp->country_code) if ($objp->country_code) {
{
print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')'; print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
} }
print '</td>'; print '</td>';

View File

@ -73,12 +73,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; } if (empty($page) || $page < 0) {
$page = 0;
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) if (!$sortfield) {
$sortfield = "f.datef, f.ref, l.rowid"; $sortfield = "f.datef, f.ref, l.rowid";
}
if (!$sortorder) { if (!$sortorder) {
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
$sortorder = "DESC"; $sortorder = "DESC";
@ -86,10 +89,12 @@ if (!$sortorder) {
} }
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
accessforbidden(); accessforbidden();
if (!$user->rights->accounting->bind->write) }
if (!$user->rights->accounting->bind->write) {
accessforbidden(); accessforbidden();
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('accountancysupplierlist')); $hookmanager->initHooks(array('accountancysupplierlist'));
@ -107,18 +112,22 @@ $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'acco
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All 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 test are required to be compatible with all browsers
{
$search_societe = ''; $search_societe = '';
$search_lineid = ''; $search_lineid = '';
$search_ref = ''; $search_ref = '';
@ -160,8 +169,7 @@ if ($massaction == 'ventil') {
$monId = $maLigneCourante[0]; $monId = $maLigneCourante[0];
$monCompte = GETPOST('codeventil'.$monId); $monCompte = GETPOST('codeventil'.$monId);
if ($monCompte <= 0) if ($monCompte <= 0) {
{
$msg .= '<div><span style="color:red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</span></div>'; $msg .= '<div><span style="color:red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</span></div>';
$ko++; $ko++;
} else { } else {
@ -200,8 +208,7 @@ $formother = new FormOther($db);
llxHeader('', $langs->trans("SuppliersVentilation")); llxHeader('', $langs->trans("SuppliersVentilation"));
if (empty($chartaccountcode)) if (empty($chartaccountcode)) {
{
print $langs->trans("ErrorChartOfAccountSystemNotSelected"); print $langs->trans("ErrorChartOfAccountSystemNotSelected");
// End of page // End of page
llxFooter(); llxFooter();
@ -269,16 +276,23 @@ $sql .= dolSqlDateFilter('f.datef', $search_day, $search_month, $search_year);
if (strlen(trim($search_country))) { if (strlen(trim($search_country))) {
$arrayofcode = getCountriesInEEC(); $arrayofcode = getCountriesInEEC();
$country_code_in_EEC = $country_code_in_EEC_without_me = ''; $country_code_in_EEC = $country_code_in_EEC_without_me = '';
foreach ($arrayofcode as $key => $value) foreach ($arrayofcode as $key => $value) {
{
$country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'"; $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'"; if ($value != $mysoc->country_code) {
$country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
}
}
if ($search_country == 'special_allnotme') {
$sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
} elseif ($search_country == 'special_eec') {
$sql .= " AND co.code IN (".$country_code_in_EEC.")";
} elseif ($search_country == 'special_eecnotme') {
$sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
} elseif ($search_country == 'special_noteec') {
$sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
} else {
$sql .= natural_search("co.code", $search_country);
} }
if ($search_country == 'special_allnotme') $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
elseif ($search_country == 'special_eec') $sql .= " AND co.code IN (".$country_code_in_EEC.")";
elseif ($search_country == 'special_eecnotme') $sql .= " AND co.code IN (".$country_code_in_EEC_without_me.")";
elseif ($search_country == 'special_noteec') $sql .= " AND co.code NOT IN (".$country_code_in_EEC.")";
else $sql .= natural_search("co.code", $search_country);
} }
if (strlen(trim($search_tvaintra))) { if (strlen(trim($search_tvaintra))) {
$sql .= natural_search("s.tva_intra", $search_tvaintra); $sql .= natural_search("s.tva_intra", $search_tvaintra);
@ -299,12 +313,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
@ -322,21 +334,51 @@ if ($result) {
$arrayofselected = is_array($toselect) ? $toselect : array(); $arrayofselected = is_array($toselect) ? $toselect : array();
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($search_societe) $param .= '&search_societe='.urlencode($search_societe); }
if ($search_lineid) $param .= '&search_lineid='.urlencode($search_lineid); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($search_day) $param .= '&search_day='.urlencode($search_day); $param .= '&limit='.urlencode($limit);
if ($search_month) $param .= '&search_month='.urlencode($search_month); }
if ($search_year) $param .= '&search_year='.urlencode($search_year); if ($search_societe) {
if ($search_invoice) $param .= '&search_invoice='.urlencode($search_invoice); $param .= '&search_societe='.urlencode($search_societe);
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); }
if ($search_label) $param .= '&search_label='.urlencode($search_label); if ($search_lineid) {
if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); $param .= '&search_lineid='.urlencode($search_lineid);
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); }
if ($search_vat) $param .= '&search_vat='.urlencode($search_vat); if ($search_day) {
if ($search_country) $param .= "&search_country=".urlencode($search_country); $param .= '&search_day='.urlencode($search_day);
if ($search_tvaintra) $param .= "&search_tvaintra=".urlencode($search_tvaintra); }
if ($search_month) {
$param .= '&search_month='.urlencode($search_month);
}
if ($search_year) {
$param .= '&search_year='.urlencode($search_year);
}
if ($search_invoice) {
$param .= '&search_invoice='.urlencode($search_invoice);
}
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_desc) {
$param .= '&search_desc='.urlencode($search_desc);
}
if ($search_amount) {
$param .= '&search_amount='.urlencode($search_amount);
}
if ($search_vat) {
$param .= '&search_vat='.urlencode($search_vat);
}
if ($search_country) {
$param .= "&search_country=".urlencode($search_country);
}
if ($search_tvaintra) {
$param .= "&search_tvaintra=".urlencode($search_tvaintra);
}
$arrayofmassactions = array( $arrayofmassactions = array(
'ventil'=>$langs->trans("Ventilate") 'ventil'=>$langs->trans("Ventilate")
@ -349,7 +391,9 @@ if ($result) {
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n"; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="action" value="ventil">'; print '<input type="hidden" name="action" value="ventil">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" 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.'">';
@ -360,7 +404,9 @@ if ($result) {
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>'; print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>';
if ($msg) print $msg.'<br>'; if ($msg) {
print $msg.'<br>';
}
$moreforfilter = ''; $moreforfilter = '';
@ -373,9 +419,11 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
//print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>'; //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
print '<td class="liste_titre center nowraponall minwidth100imp">'; print '<td class="liste_titre center nowraponall minwidth100imp">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">'; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">'; print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5); }
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.'">';
$formother->select_year($search_year, 'search_year', 1, 20, 5);
print '</td>'; print '</td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>'; print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
@ -411,7 +459,9 @@ if ($result) {
print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall '); print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
$checkpicto = ''; $checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1); if ($massactionbutton) {
$checkpicto = $form->showCheckAddButtons('checkforselect', 1);
}
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center '); print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
print "</tr>\n"; print "</tr>\n";
@ -496,7 +546,9 @@ if ($result) {
} }
} }
} }
if ($objp->code_sell_l == -1) $objp->code_sell_l = ''; if ($objp->code_sell_l == -1) {
$objp->code_sell_l = '';
}
// Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding) // Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding)
$suggestedaccountingaccountfor = ''; $suggestedaccountingaccountfor = '';
@ -528,7 +580,9 @@ if ($result) {
} else { } else {
$code_buy_p_notset = 'color:orange'; $code_buy_p_notset = 'color:orange';
} }
if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) $code_buy_p_notset = 'color:red'; if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) {
$code_buy_p_notset = 'color:red';
}
// $objp->code_buy_l is now default code of product/service // $objp->code_buy_l is now default code of product/service
// $objp->code_buy_p is now code of product/service // $objp->code_buy_p is now code of product/service
@ -551,9 +605,12 @@ if ($result) {
// Ref Product // Ref Product
print '<td class="tdoverflowmax150">'; print '<td class="tdoverflowmax150">';
if ($product_static->id > 0) if ($product_static->id > 0) {
print $product_static->getNomUrl(1); print $product_static->getNomUrl(1);
if ($objp->product_label) print '<br><span class="opacitymedium small">'.$objp->product_label.'</span>'; }
if ($objp->product_label) {
print '<br><span class="opacitymedium small">'.$objp->product_label.'</span>';
}
print '</td>'; print '</td>';
// Description // Description
@ -568,8 +625,9 @@ if ($result) {
print '</td>'; print '</td>';
// Vat rate // Vat rate
if ($objp->vat_tx_l != $objp->vat_tx_p) if ($objp->vat_tx_l != $objp->vat_tx_p) {
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
}
print '<td style="'.$code_vat_differ.'" class="right">'; print '<td style="'.$code_vat_differ.'" class="right">';
print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')); print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : ''));
print '</td>'; print '</td>';
@ -590,17 +648,22 @@ if ($result) {
print '<td>'; print '<td>';
$s = '<span class="small">1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>'; $s = '<span class="small">1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': </span>';
$shelp = ''; $shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC"); if ($suggestedaccountingaccountbydefaultfor == 'eec') {
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport"); $shelp .= $langs->trans("SaleEEC");
} elseif ($suggestedaccountingaccountbydefaultfor == 'export') {
$shelp .= $langs->trans("SaleExport");
}
$s .= ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : '<span style="'.$code_buy_p_notset.'">'.$langs->trans("NotDefined").'</span>'); $s .= ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : '<span style="'.$code_buy_p_notset.'">'.$langs->trans("NotDefined").'</span>');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
if ($objp->product_id > 0) if ($objp->product_id > 0) {
{
print '<br>'; print '<br>';
$s = '<span class="small">2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>'; $s = '<span class="small">2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': </span>';
$shelp = ''; $shelp = '';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); if ($suggestedaccountingaccountfor == 'eec') {
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); $shelp = $langs->trans("SaleEEC");
} elseif ($suggestedaccountingaccountfor == 'export') {
$shelp = $langs->trans("SaleExport");
}
$s .= (empty($objp->code_buy_p) ? '<span style="'.$code_buy_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_buy_p)); $s .= (empty($objp->code_buy_p) ? '<span style="'.$code_buy_p_notset.'">'.$langs->trans("NotDefined").'</span>' : length_accountg($objp->code_buy_p));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
} else { } else {
@ -620,10 +683,8 @@ if ($result) {
// Suggested accounting account // Suggested accounting account
print '<td>'; print '<td>';
$suggestedid = $objp->aarowid_suggest; $suggestedid = $objp->aarowid_suggest;
if (empty($suggestedid) && empty($objp->code_buy_p) && !empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) if (empty($suggestedid) && empty($objp->code_buy_p) && !empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) {
{ if (empty($accountingaccount_codetotid_cache[$objp->code_buy_l])) {
if (empty($accountingaccount_codetotid_cache[$objp->code_buy_l]))
{
$tmpaccount = new AccountingAccount($db); $tmpaccount = new AccountingAccount($db);
$tmpaccount->fetch(0, $objp->code_buy_l, 1); $tmpaccount->fetch(0, $objp->code_buy_l, 1);
if ($tmpaccount->id > 0) { if ($tmpaccount->id > 0) {

View File

@ -17,8 +17,7 @@
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) if (empty($conf) || !is_object($conf)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -37,11 +36,9 @@ header('Content-Type: text/csv');
include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
$accountancyexport = new AccountancyExport($db); $accountancyexport = new AccountancyExport($db);
if ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$EXPORT_TYPE_FEC && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger if ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$EXPORT_TYPE_FEC && $type_export == "general_ledger") { // Specific filename for FEC model export into the general ledger
{
// FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle // FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle
if (empty($search_date_end)) if (empty($search_date_end)) {
{
// TODO Get the max date into bookeeping table // TODO Get the max date into bookeeping table
$search_date_end = dol_now(); $search_date_end = dol_now();
} }
@ -49,8 +46,9 @@ if ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$
$tmparray = dol_getdate($datetouseforfilename); $tmparray = dol_getdate($datetouseforfilename);
$fiscalmonth = empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START; $fiscalmonth = empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START;
// Define end of month to use // Define end of month to use
if ($tmparray['mon'] <= $fiscalmonth) $tmparray['mon'] = $fiscalmonth; if ($tmparray['mon'] <= $fiscalmonth) {
else { $tmparray['mon'] = $fiscalmonth;
} else {
$tmparray['mon'] = $fiscalmonth; $tmparray['mon'] = $fiscalmonth;
$tmparray['year']++; $tmparray['year']++;
} }

View File

@ -133,6 +133,7 @@ if ($conf->use_javascript_ajax) {
print '<span class="opacitymedium">'.$langs->trans("BlankSubscriptionFormDesc").'</span><br><br>'; print '<span class="opacitymedium">'.$langs->trans("BlankSubscriptionFormDesc").'</span><br><br>';
$param = '';
$enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' '; $enabledisablehtml = $langs->trans("EnablePublicSubscriptionForm").' ';
if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) { if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) {

View File

@ -81,6 +81,9 @@ if (!empty($canvas)) {
$objcanvas->getCanvas('adherent', 'membercard', $canvas); $objcanvas->getCanvas('adherent', 'membercard', $canvas);
} }
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('membercard', 'globalcard'));
// Security check // Security check
$result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', 0); $result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', 0);
@ -107,9 +110,6 @@ if ($id) {
$caneditfieldmember = $user->rights->adherent->creer; $caneditfieldmember = $user->rights->adherent->creer;
} }
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('membercard', 'globalcard'));
/* /*
@ -796,7 +796,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$adht = new AdherentType($db); $adht = new AdherentType($db);
print load_fiche_titre($langs->trans("NewMember"), '', 'members'); print load_fiche_titre($langs->trans("NewMember"), '', $object->picto);
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';

View File

@ -236,7 +236,7 @@ $form = new Form($db);
llxHeader('', $langs->trans("MembersCards")); llxHeader('', $langs->trans("MembersCards"));
print load_fiche_titre($langs->trans("LinkToGeneratedPages"), '', 'members'); print load_fiche_titre($langs->trans("LinkToGeneratedPages"), '', $adherentstatic->picto);
print '<span class="opacitymedium">'.$langs->trans("LinkToGeneratedPagesDesc").'</span><br>'; print '<span class="opacitymedium">'.$langs->trans("LinkToGeneratedPagesDesc").'</span><br>';
print '<br>'; print '<br>';

View File

@ -46,7 +46,7 @@ class AdherentType extends CommonObject
/** /**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/ */
public $picto = 'group'; public $picto = 'members';
/** /**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe

View File

@ -73,7 +73,7 @@ $upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'me
* Actions * Actions
*/ */
include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/* /*

View File

@ -52,7 +52,7 @@ $staticmember = new Adherent($db);
$statictype = new AdherentType($db); $statictype = new AdherentType($db);
$subscriptionstatic = new Subscription($db); $subscriptionstatic = new Subscription($db);
print load_fiche_titre($langs->trans("MembersArea"), '', 'members'); print load_fiche_titre($langs->trans("MembersArea"), '', 'member');
$Adherents = array(); $Adherents = array();
$AdherentsAValider = array(); $AdherentsAValider = array();

View File

@ -425,7 +425,7 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
$topicmail = "Information"; $topicmail = "Information";
$modelmail = "member"; $modelmail = "member";
@ -443,8 +443,7 @@ $moreforfilter = '';
if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('Categories').': '; $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedlength"').$formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1);
$moreforfilter .= $formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1);
$moreforfilter .= '</div>'; $moreforfilter .= '</div>';
} }
$parameters = array(); $parameters = array();

View File

@ -57,7 +57,7 @@ llxHeader('', $langs->trans("MembersStatisticsByProperties"), '', '', 0, 0, arra
$title = $langs->trans("MembersStatisticsByProperties"); $title = $langs->trans("MembersStatisticsByProperties");
print load_fiche_titre($title, '', 'object_group'); print load_fiche_titre($title, '', $memberstatic->picto);
dol_mkdir($dir); dol_mkdir($dir);
@ -128,7 +128,7 @@ if ($resql) {
$head = member_stats_prepare_head($adh); $head = member_stats_prepare_head($adh);
print dol_get_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'user'); print dol_get_fiche_head($head, 'statsbyproperties', '', -1, '');
// Print title // Print title

View File

@ -25,6 +25,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$graphwidth = DolGraph::getDefaultGraphSizeForStats('width', 700); $graphwidth = DolGraph::getDefaultGraphSizeForStats('width', 700);
$mapratio = 0.5; $mapratio = 0.5;
@ -52,6 +53,8 @@ $langs->loadLangs(array("companies", "members", "banks"));
* View * View
*/ */
$memberstatic = new Adherent($db);
$arrayjs = array('https://www.google.com/jsapi'); $arrayjs = array('https://www.google.com/jsapi');
if (!empty($conf->dol_use_jmobile)) $arrayjs = array(); if (!empty($conf->dol_use_jmobile)) $arrayjs = array();
@ -63,7 +66,7 @@ if ($mode == 'memberbyregion') $title = $langs->trans("MembersStatisticsByRegion
llxHeader('', $title, '', '', 0, 0, $arrayjs); llxHeader('', $title, '', '', 0, 0, $arrayjs);
print load_fiche_titre($title, '', 'object_group'); print load_fiche_titre($title, '', $memberstatic->picto);
dol_mkdir($dir); dol_mkdir($dir);
@ -196,7 +199,7 @@ if ($mode) {
$head = member_stats_prepare_head($adh); $head = member_stats_prepare_head($adh);
print dol_get_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user'); print dol_get_fiche_head($head, $tab, '', -1, '');
// Print title // Print title
@ -268,7 +271,6 @@ if (count($arrayjs) && $mode == 'memberbycountry') {
// print the div tag that will contain the map // print the div tag that will contain the map
print '<div class="center" id="'.$mode.'"></div>'."\n"; print '<div class="center" id="'.$mode.'"></div>'."\n";
print '<br>';
} }
if ($mode) { if ($mode) {

View File

@ -24,6 +24,7 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
@ -53,12 +54,13 @@ $langs->loadLangs(array("companies", "members"));
* View * View
*/ */
$memberstatic = new Adherent($db);
$form = new Form($db); $form = new Form($db);
$title = $langs->trans("SubscriptionsStatistics"); $title = $langs->trans("SubscriptionsStatistics");
llxHeader('', $title); llxHeader('', $title);
print load_fiche_titre($title, '', 'members'); print load_fiche_titre($title, '', $memberstatic->picto);
$dir = $conf->adherent->dir_temp; $dir = $conf->adherent->dir_temp;
@ -133,7 +135,7 @@ if (!$mesg) {
$head = member_stats_prepare_head($adh); $head = member_stats_prepare_head($adh);
print dol_get_fiche_head($head, 'statssubscription', $langs->trans("Statistics"), -1, 'user'); print dol_get_fiche_head($head, 'statssubscription', '', -1, '');
print '<div class="fichecenter"><div class="fichethirdleft">'; print '<div class="fichecenter"><div class="fichethirdleft">';

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* 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-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net> * 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
@ -106,13 +106,22 @@ $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') :
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
$datefrom = 0;
$dateto = 0;
$paymentdate = -1;
/* /*
* Actions * Actions
*/ */
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
// Create third party from a member // Create third party from a member
if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) {
if ($result > 0) { if ($result > 0) {
// Creation of thirdparty // Creation of thirdparty
$company = new Societe($db); $company = new Societe($db);
@ -129,7 +138,7 @@ if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights
} }
} }
if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) {
$error = 0; $error = 0;
if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only
if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) { if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id) {
@ -148,7 +157,7 @@ if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights
} }
} }
if ($action == 'setsocid') { if (empty($reshook) && $action == 'setsocid') {
$error = 0; $error = 0;
if (!$error) { if (!$error) {
if (GETPOST('socid', 'int') != $object->fk_soc) { // If link differs from currently in database if (GETPOST('socid', 'int') != $object->fk_soc) { // If link differs from currently in database
@ -208,7 +217,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$emetteur_nom = $_POST["chqemetteur"]; $emetteur_nom = $_POST["chqemetteur"];
$emetteur_banque = $_POST["chqbank"]; $emetteur_banque = $_POST["chqbank"];
$option = $_POST["paymentsave"]; $option = $_POST["paymentsave"];
if (empty($option)) $option = 'none'; if (empty($option)) {
$option = 'none';
}
$sendalsoemail = GETPOST("sendmail", 'alpha'); $sendalsoemail = GETPOST("sendmail", 'alpha');
// Check parameters // Check parameters
@ -247,11 +258,19 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
} else { } else {
if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') { if (!empty($conf->banque->enabled) && $_POST["paymentsave"] != 'none') {
if ($_POST["subscription"]) { if ($_POST["subscription"]) {
if (!$_POST["label"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); if (!$_POST["label"]) {
if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) $errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount")); }
if ($_POST["paymentsave"] != 'invoiceonly' && !$_POST["operation"]) {
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
}
if ($_POST["paymentsave"] != 'invoiceonly' && !($_POST["accountid"] > 0)) {
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("FinancialAccount"));
}
} else { } else {
if ($_POST["accountid"]) $errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount"); if ($_POST["accountid"]) {
$errmsg = $langs->trans("ErrorDoNotProvideAccountsIfNullAmount");
}
} }
if ($errmsg) { if ($errmsg) {
$error++; $error++;
@ -333,7 +352,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$arraydefaultmessage = null; $arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); if (!empty($labeltouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
}
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic; $subject = $arraydefaultmessage->topic;
@ -579,8 +600,8 @@ if ($rowid > 0) {
/* /*
* Action buttons * Action buttons
*/ */
// Button to create a new subscription if member no draft neither resiliated // Button to create a new subscription if member no draft neither resiliated
if ($user->rights->adherent->cotisation->creer) { if ($user->rights->adherent->cotisation->creer) {
@ -595,8 +616,8 @@ if ($rowid > 0) {
} }
/* /*
* List of subscriptions * List of subscriptions
*/ */
if ($action != 'addsubscription' && $action != 'create_thirdparty') { if ($action != 'addsubscription' && $action != 'create_thirdparty') {
$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
$sql .= " c.rowid as crowid, c.subscription,"; $sql .= " c.rowid as crowid, c.subscription,";
@ -716,8 +737,8 @@ if ($rowid > 0) {
} }
/* /*
* Add new subscription form * Add new subscription form
*/ */
if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) {
print '<br>'; print '<br>';
@ -743,31 +764,31 @@ if ($rowid > 0) {
//var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE)); //var_dump($bankdirect.'-'.$bankviainvoice.'-'.$invoiceonly.'-'.empty($conf->global->ADHERENT_BANK_USE));
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () { print '$(document).ready(function () {
$(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ? 'show()' : 'hide()').'; $(".bankswitchclass, .bankswitchclass2").'.(($bankdirect || $bankviainvoice) ? 'show()' : 'hide()').';
$("#none, #invoiceonly").click(function() { $("#none, #invoiceonly").click(function() {
$(".bankswitchclass").hide(); $(".bankswitchclass").hide();
$(".bankswitchclass2").hide(); $(".bankswitchclass2").hide();
}); });
$("#bankdirect, #bankviainvoice").click(function() { $("#bankdirect, #bankviainvoice").click(function() {
$(".bankswitchclass").show(); $(".bankswitchclass").show();
$(".bankswitchclass2").show(); $(".bankswitchclass2").show();
}); });
$("#selectoperation").change(function() { $("#selectoperation").change(function() {
var code = $(this).val(); var code = $(this).val();
if (code == "CHQ") if (code == "CHQ")
{ {
$(".fieldrequireddyn").addClass("fieldrequired"); $(".fieldrequireddyn").addClass("fieldrequired");
if ($("#fieldchqemetteur").val() == "") if ($("#fieldchqemetteur").val() == "")
{ {
$("#fieldchqemetteur").val($("#memberlabel").val()); $("#fieldchqemetteur").val($("#memberlabel").val());
} }
} }
else else
{ {
$(".fieldrequireddyn").removeClass("fieldrequired"); $(".fieldrequireddyn").removeClass("fieldrequired");
} }
}); });
'; ';
if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);'; if (GETPOST('paymentsave')) print '$("#'.GETPOST('paymentsave').'").prop("checked",true);';
print '});'; print '});';
print '</script>'."\n"; print '</script>'."\n";
@ -826,9 +847,6 @@ if ($rowid > 0) {
print '<tbody>'; print '<tbody>';
$today = dol_now(); $today = dol_now();
$datefrom = 0;
$dateto = 0;
$paymentdate = -1;
// Date payment // Date payment
if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) { if (GETPOST('paymentyear') && GETPOST('paymentmonth') && GETPOST('paymentday')) {
@ -921,8 +939,9 @@ if ($rowid > 0) {
print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ? ' checked' : ''); print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.(!empty($bankviainvoice) ? ' checked' : '');
//if (empty($object->fk_soc)) print ' disabled'; //if (empty($object->fk_soc)) print ' disabled';
print '> '.$langs->trans("MoreActionBankViaInvoice"); print '> '.$langs->trans("MoreActionBankViaInvoice");
if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; if ($object->fk_soc) {
else { print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
} else {
print ' ('; print ' (';
if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember")); if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
print $langs->trans("NoThirdPartyAssociatedToMember"); print $langs->trans("NoThirdPartyAssociatedToMember");
@ -1001,7 +1020,9 @@ if ($rowid > 0) {
$arraydefaultmessage = null; $arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); if (!empty($labeltouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
}
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic; $subject = $arraydefaultmessage->topic;

View File

@ -55,6 +55,11 @@ $permissionnote = $user->rights->adherent->cotisation->creer; // Used by the inc
$permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php $permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php $permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php
$hookmanager->initHooks(array('subscriptioncard', 'globalcard'));
// Security check
$result = restrictedArea($user, 'subscription', 0); // TODO Check on object id
/* /*
* Actions * Actions
@ -148,8 +153,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent-
$form = new Form($db); $form = new Form($db);
$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
llxHeader('', $langs->trans("SubscriptionCard"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros'); llxHeader('', $langs->trans("SubscriptionCard"), $help_url);
dol_htmloutput_errors($errmsg); dol_htmloutput_errors($errmsg);

View File

@ -209,7 +209,8 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
exit; exit;
} }
llxHeader('', $langs->trans("ListOfSubscriptions"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros'); $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
llxHeader('', $langs->trans("ListOfSubscriptions"), $help_url);
$i = 0; $i = 0;
@ -253,7 +254,7 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $subscription->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
$topicmail = "Information"; $topicmail = "Information";
$modelmail = "subscription"; $modelmail = "subscription";

View File

@ -203,7 +203,8 @@ if ($action == 'confirm_delete' && $user->rights->adherent->configurer) {
$form = new Form($db); $form = new Form($db);
$formproduct = new FormProduct($db); $formproduct = new FormProduct($db);
llxHeader('', $langs->trans("MembersTypeSetup"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros'); $help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
llxHeader('', $langs->trans("MembersTypeSetup"), $help_url);
// List of members type // List of members type
if (!$rowid && $action != 'create' && $action != 'edit') { if (!$rowid && $action != 'create' && $action != 'edit') {

View File

@ -34,7 +34,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adm
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'companies')); $langs->loadLangs(array('admin', 'companies'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$error = 0; $error = 0;
@ -45,11 +47,12 @@ $error = 0;
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (($action == 'update' && !GETPOST("cancel", 'alpha')) if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|| ($action == 'updateedit')) || ($action == 'updateedit')) {
{
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'nohtml'), 'chaine', 0, '', $conf->entity);
@ -64,8 +67,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity);
if ($action != 'updateedit' && !$error) if ($action != 'updateedit' && !$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
@ -131,7 +133,9 @@ print '<input name="town" class="minwidth100" id="town" value="'.(GETPOSTISSET('
print '<tr class="oddeven"><td><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">'; print '<tr class="oddeven"><td><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
print img_picto('', 'globe-americas', 'class="paddingrightonly"'); print img_picto('', 'globe-americas', 'class="paddingrightonly"');
print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY) ? $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY : '')), 'country_id'); print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY) ? $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY : '')), 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>'."\n"; print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">'; print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';

View File

@ -28,8 +28,9 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'agenda')); $langs->loadLangs(array('admin', 'other', 'agenda'));
@ -45,12 +46,10 @@ $sql = "SELECT a.rowid, a.code, a.label, a.elementtype, a.rang as position";
$sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql .= " ORDER BY a.rang ASC"; $sql .= " ORDER BY a.rang ASC";
$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;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$triggers[$i]['rowid'] = $obj->rowid; $triggers[$i]['rowid'] = $obj->rowid;
$triggers[$i]['code'] = $obj->code; $triggers[$i]['code'] = $obj->code;
@ -73,36 +72,32 @@ if ($resql)
*/ */
// Purge search criteria // Purge search criteria
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')) { // All tests are required to be compatible with all browsers
{
$search_event = ''; $search_event = '';
$action = ''; $action = '';
} }
if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) // To avoid the save when we click on search if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { // To avoid the save when we click on search
{
$action = ''; $action = '';
} }
if ($action == "save" && empty($cancel)) if ($action == "save" && empty($cancel)) {
{
$i = 0; $i = 0;
$db->begin(); $db->begin();
foreach ($triggers as $trigger) foreach ($triggers as $trigger) {
{
$keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; $keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
//print "param=".$param." - ".$_POST[$param]; //print "param=".$param." - ".$_POST[$param];
if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam)) if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam)) {
{
$res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
} }
} }
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
$db->commit(); $db->commit();
} else { } else {
@ -155,17 +150,27 @@ print '<th class="liste_titre" colspan="2">'.$langs->trans("ActionsEvents").'</t
print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param ? $param : '').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param ? $param : '').'">'.$langs->trans("None").'</a></th>'; print '<th class="liste_titre"><a href="'.$_SERVER["PHP_SELF"].'?action=selectall'.($param ? $param : '').'">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone'.($param ? $param : '').'">'.$langs->trans("None").'</a></th>';
print '</tr>'."\n"; print '</tr>'."\n";
// Show each trigger (list is in c_action_trigger) // Show each trigger (list is in c_action_trigger)
if (!empty($triggers)) if (!empty($triggers)) {
{ foreach ($triggers as $trigger) {
foreach ($triggers as $trigger)
{
$module = $trigger['element']; $module = $trigger['element'];
if ($module == 'order_supplier' || $module == 'invoice_supplier') $module = 'fournisseur'; if ($module == 'order_supplier' || $module == 'invoice_supplier') {
if ($module == 'shipping') $module = 'expedition_bon'; $module = 'fournisseur';
if ($module == 'member') $module = 'adherent'; }
if ($module == 'project') $module = 'projet'; if ($module == 'shipping') {
if ($module == 'proposal_supplier') $module = 'supplier_proposal'; $module = 'expedition_bon';
if ($module == 'contact') $module = 'societe'; }
if ($module == 'member') {
$module = 'adherent';
}
if ($module == 'project') {
$module = 'projet';
}
if ($module == 'proposal_supplier') {
$module = 'supplier_proposal';
}
if ($module == 'contact') {
$module = 'societe';
}
// If 'element' value is myobject@mymodule instead of mymodule // If 'element' value is myobject@mymodule instead of mymodule
$tmparray = explode('@', $module); $tmparray = explode('@', $module);
@ -174,14 +179,16 @@ if (!empty($triggers))
} }
//print 'module='.$module.' code='.$trigger['code'].'<br>'; //print 'module='.$module.' code='.$trigger['code'].'<br>';
if (!empty($conf->$module->enabled)) if (!empty($conf->$module->enabled)) {
{
// Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED // Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED
if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; continue;
}
if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
continue;
}
if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $trigger['code'])) if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $trigger['code'])) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$trigger['code'].'</td>'; print '<td>'.$trigger['code'].'</td>';
print '<td>'.$trigger['label'].'</td>'; print '<td>'.$trigger['label'].'</td>';

View File

@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'agenda')); $langs->loadLangs(array('admin', 'other', 'agenda'));
@ -43,13 +44,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'actioncomm'; //Must be the $table_element of the class that manage extrafield $elementtype = 'actioncomm'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -82,8 +87,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -96,8 +100,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -109,8 +112,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -32,7 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('agenda', 'admin', 'other')); $langs->loadLangs(array('agenda', 'admin', 'other'));
@ -41,7 +43,9 @@ $def = array();
$actiontest = GETPOST('test', 'alpha'); $actiontest = GETPOST('test', 'alpha');
$actionsave = GETPOST('save', 'alpha'); $actionsave = GETPOST('save', 'alpha');
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; if (empty($conf->global->AGENDA_EXT_NB)) {
$conf->global->AGENDA_EXT_NB = 5;
}
$MAXAGENDA = $conf->global->AGENDA_EXT_NB; $MAXAGENDA = $conf->global->AGENDA_EXT_NB;
// List of available colors // List of available colors
@ -52,8 +56,7 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', '
* Actions * Actions
*/ */
if ($actionsave) if ($actionsave) {
{
$db->begin(); $db->begin();
$disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha');
@ -63,17 +66,17 @@ if ($actionsave)
$error = 0; $error = 0;
// Save agendas // Save agendas
while ($i <= $MAXAGENDA) while ($i <= $MAXAGENDA) {
{
$name = trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha')); $name = trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha'));
$src = trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha')); $src = trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha'));
$offsettz = trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha')); $offsettz = trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha'));
$color = trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha')); $color = trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha'));
if ($color == '-1') $color = ''; if ($color == '-1') {
$color = '';
}
$enabled = trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha')); $enabled = trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha'));
if (!empty($src) && !dol_is_url($src)) if (!empty($src) && !dol_is_url($src)) {
{
setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors'); setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors');
$error++; $error++;
$errorsaved++; $errorsaved++;
@ -82,34 +85,48 @@ if ($actionsave)
//print '-name='.$name.'-color='.$color; //print '-name='.$name.'-color='.$color;
$res = dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$i++; $i++;
} }
// Save nb of agenda // Save nb of agenda
if (!$error) if (!$error) {
{
$res = dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; $error++;
}
if (empty($conf->global->AGENDA_EXT_NB)) {
$conf->global->AGENDA_EXT_NB = 5;
}
$MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB; $MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB;
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
$db->rollback(); $db->rollback();
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); if (empty($errorsaved)) {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} }
} }
@ -143,7 +160,11 @@ print "<br>\n";
$selectedvalue = $conf->global->AGENDA_DISABLE_EXT; $selectedvalue = $conf->global->AGENDA_DISABLE_EXT;
if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1; if ($selectedvalue == 1) {
$selectedvalue = 0;
} else {
$selectedvalue = 1;
}
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
@ -157,12 +178,10 @@ print "</tr>";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("ExtSitesEnableThisTool")."</td>"; print "<td>".$langs->trans("ExtSitesEnableThisTool")."</td>";
print '<td class="center">'; print '<td class="center">';
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
print ajax_constantonoff('AGENDA_DISABLE_EXT', array('enabled'=>array(0=>'.hideifnotset')), null, 1); print ajax_constantonoff('AGENDA_DISABLE_EXT', array('enabled'=>array(0=>'.hideifnotset')), null, 1);
} else { } else {
if (empty($conf->global->AGENDA_DISABLE_EXT)) if (empty($conf->global->AGENDA_DISABLE_EXT)) {
{
print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -194,8 +213,7 @@ print '<td class="right">'.$langs->trans("Color").'</td>';
print "</tr>"; print "</tr>";
$i = 1; $i = 1;
while ($i <= $MAXAGENDA) while ($i <= $MAXAGENDA) {
{
$key = $i; $key = $i;
$name = 'AGENDA_EXT_NAME'.$key; $name = 'AGENDA_EXT_NAME'.$key;
$src = 'AGENDA_EXT_SRC'.$key; $src = 'AGENDA_EXT_SRC'.$key;

View File

@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'agenda', 'users')); $langs->loadLangs(array('admin', 'other', 'agenda', 'users'));
@ -52,12 +53,10 @@ $type = 'action';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
$reg = array(); $reg = array();
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
{
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -65,27 +64,23 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
} }
} }
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
{
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
if ($action == 'set') if ($action == 'set') {
{
$getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE'); $getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE');
$defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter; $defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter;
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
} elseif ($action == 'specimen') // For orders } elseif ($action == 'specimen') { // For orders
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
@ -95,25 +90,21 @@ if ($action == 'set')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db, $commande); $module = new $classname($db, $commande);
if ($module->write_file($commande, $langs) > 0) if ($module->write_file($commande, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -124,27 +115,20 @@ if ($action == 'set')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'setmodel') {
// Activate a model
// Activate a model
elseif ($action == 'setmodel')
{
//print "sssd".$value; //print "sssd".$value;
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") {
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
}
} }
} } elseif ($action == 'setdoc') {
// Set default model
// Set default model if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
elseif ($action == 'setdoc')
{
if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->ACTION_EVENT_ADDON_PDF = $value; $conf->global->ACTION_EVENT_ADDON_PDF = $value;
@ -152,8 +136,7 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} }
@ -193,12 +176,10 @@ $sql .= " WHERE type = 'action'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -207,8 +188,7 @@ if ($resql)
dol_print_error($db); dol_print_error($db);
} }
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
{
print load_fiche_titre($langs->trans("AgendaModelModule"), '', ''); print load_fiche_titre($langs->trans("AgendaModelModule"), '', '');
print '<table class="noborder centpercent">'."\n"; print '<table class="noborder centpercent">'."\n";
@ -223,19 +203,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/action/doc"); $dir = dol_buildpath($reldir."core/modules/action/doc");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
{
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -249,17 +224,17 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print "<td>\n"; print "<td>\n";
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db, $specimenthirdparty); $module = new $classname($db, $specimenthirdparty);
if (method_exists($module, 'info')) if (method_exists($module, 'info')) {
print $module->info($langs); print $module->info($langs);
else print $module->description; } else {
print $module->description;
}
print "</td>\n"; print "</td>\n";
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
@ -275,8 +250,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -324,8 +298,7 @@ print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE").'</td>'."\n";
print '<td class="center">&nbsp;</td>'."\n"; print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right">'."\n"; print '<td class="right">'."\n";
//print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list //print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list
if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
{
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_USE_EVENT_TYPE&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_USE_EVENT_TYPE&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';
@ -342,8 +315,7 @@ $tmplist = array(''=>'&nbsp;', 'show_list'=>$langs->trans("ViewList"), 'show_mon
print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW); print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
print '</td></tr>'."\n"; print '</td></tr>'."\n";
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
{
print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->'; print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n"; print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";

View File

@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php'; require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other", "agenda")); $langs->loadLangs(array("admin", "other", "agenda"));
@ -47,12 +48,10 @@ $type = 'action';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
$value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
{
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -60,25 +59,21 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
} }
} }
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
{
$code = $reg[1]; $code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
{
Header("Location: ".$_SERVER["PHP_SELF"]); Header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
if ($action == 'set') if ($action == 'set') {
{
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
} elseif ($action == 'specimen') // For orders } elseif ($action == 'specimen') { // For orders
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
@ -88,25 +83,21 @@ if ($action == 'set')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db, $commande); $module = new $classname($db, $commande);
if ($module->write_file($commande, $langs) > 0) if ($module->write_file($commande, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -117,27 +108,20 @@ if ($action == 'set')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'setmodel') {
// Activate a model
// Activate a model
elseif ($action == 'setmodel')
{
//print "sssd".$value; //print "sssd".$value;
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") {
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
}
} }
} } elseif ($action == 'setdoc') {
// Set default model
// Set default model if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
elseif ($action == 'setdoc')
{
if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// The constant that has been read in front of the new set // The constant that has been read in front of the new set
// is therefore passed through a variable to have a coherent display // is therefore passed through a variable to have a coherent display
$conf->global->ACTION_EVENT_ADDON_PDF = $value; $conf->global->ACTION_EVENT_ADDON_PDF = $value;
@ -145,8 +129,7 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} }
@ -184,7 +167,7 @@ print '</tr>'."\n";
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n"; print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n";
print '<td class="center">&nbsp;</td>'."\n"; print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right">'."\n"; print '<td class="right nowraponall">'."\n";
if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
if (!isHTTPS()) { if (!isHTTPS()) {
@ -232,7 +215,7 @@ if (!empty($conf->cron->enabled)) {
} }
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">&nbsp;</td>'."\n"; print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right">'."\n"; print '<td class="right nowraponall">'."\n";
if (empty($conf->cron->enabled)) { if (empty($conf->cron->enabled)) {
print '<span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module2300Name")).'</span>'; print '<span class="opacitymedium">'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module2300Name")).'</span>';

View File

@ -29,8 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other", "agenda")); $langs->loadLangs(array("admin", "other", "agenda"));
@ -39,8 +40,7 @@ $def = array();
$actionsave = GETPOST('save', 'alpha'); $actionsave = GETPOST('save', 'alpha');
// Sauvegardes parametres // Sauvegardes parametres
if ($actionsave) if ($actionsave) {
{
$i = 0; $i = 0;
$db->begin(); $db->begin();
@ -50,8 +50,7 @@ if ($actionsave)
$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity);
$i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity);
if ($i >= 4) if ($i >= 4) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -66,7 +65,9 @@ if ($actionsave)
* View * View
*/ */
if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100; if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) {
$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
}
$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; $wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); llxHeader('', $langs->trans("AgendaSetup"), $wikihelp);
@ -97,8 +98,9 @@ print "</tr>";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>"; print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') ?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') : $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">'; print '<td><input required="required" type="text" class="flat" id="MAIN_AGENDA_XCAL_EXPORTKEY" name="MAIN_AGENDA_XCAL_EXPORTKEY" value="'.(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') ?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha') : $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY).'" size="40">';
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); print '&nbsp;'.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
}
print '</td>'; print '</td>';
print "<td>&nbsp;</td>"; print "<td>&nbsp;</td>";
print "</tr>"; print "</tr>";
@ -183,8 +185,7 @@ $message .= $langs->trans("AgendaUrlOptionsIncludeHolidays", '1', '1').'<br>';
print info_admin($message); print info_admin($message);
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax)) {
{
print "\n".'<script type="text/javascript">'; print "\n".'<script type="text/javascript">';
print '$(document).ready(function () { print '$(document).ready(function () {
$("#generate_token").click(function() { $("#generate_token").click(function() {

View File

@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "companies", "bills", "other", "banks")); $langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$actionsave = GETPOST('save', 'alpha'); $actionsave = GETPOST('save', 'alpha');
@ -51,8 +52,7 @@ $type = 'bankaccount';
// Order display of bank account // Order display of bank account
if ($action == 'setbankorder') { if ($action == 'setbankorder') {
if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -62,16 +62,14 @@ if ($action == 'setbankorder') {
// Auto report last num releve on conciliate // Auto report last num releve on conciliate
if ($action == 'setreportlastnumreleve') { if ($action == 'setreportlastnumreleve') {
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} elseif ($action == 'unsetreportlastnumreleve') { } elseif ($action == 'unsetreportlastnumreleve') {
if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -81,16 +79,14 @@ if ($action == 'setreportlastnumreleve') {
// Colorize movements // Colorize movements
if ($action == 'setbankcolorizemovement') { if ($action == 'setbankcolorizemovement') {
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} elseif ($action == 'unsetbankcolorizemovement') { } elseif ($action == 'unsetbankcolorizemovement') {
if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} else { } else {
@ -98,31 +94,34 @@ if ($action == 'setbankcolorizemovement') {
} }
} }
if ($actionsave) if ($actionsave) {
{
$db->begin(); $db->begin();
$i = 1; $errorsaved = 0; $i = 1; $errorsaved = 0;
$error = 0; $error = 0;
// Save colors // Save colors
while ($i <= 2) while ($i <= 2) {
{
$color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha'); $color = GETPOST('BANK_COLORIZE_MOVEMENT_COLOR'.$i, 'alpha');
if ($color == '-1') $color = ''; if ($color == '-1') {
$color = '';
}
$res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'BANK_COLORIZE_MOVEMENT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
$i++; $i++;
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
$db->rollback(); $db->rollback();
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); if (empty($errorsaved)) {
setEventMessages($langs->trans("Error"), null, 'errors');
}
} }
} }
@ -175,12 +174,12 @@ if ($action == 'set') {
} elseif ($action == 'del') { } elseif ($action == 'del') {
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) { if ($ret > 0) {
if ($conf->global->BANKADDON_PDF == "$value") if ($conf->global->BANKADDON_PDF == "$value") {
dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity); dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity);
}
} }
} } elseif ($action == 'setdoc') {
// Set default model // Set default model
elseif ($action == 'setdoc') {
if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
// The constant that was read before the new set // The constant that was read before the new set
// We therefore requires a variable to have a coherent view // We therefore requires a variable to have a coherent view
@ -247,8 +246,9 @@ while ($i < $nbofbank) {
print '<td class="nowrap">'; print '<td class="nowrap">';
$tmparray = explode(' ', $bankorder[$i][2]); $tmparray = explode(' ', $bankorder[$i][2]);
foreach ($tmparray as $key => $val) { foreach ($tmparray as $key => $val) {
if ($key > 0) if ($key > 0) {
print ', '; print ', ';
}
print $langs->trans($val); print $langs->trans($val);
} }
print "</td>\n"; print "</td>\n";
@ -333,18 +333,22 @@ foreach ($dirmodels as $reldir) {
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
$modulequalified = 0; $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) }
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0; $modulequalified = 0;
}
if ($modulequalified) { if ($modulequalified) {
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print(empty($module->name) ? $name : $module->name); print(empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) if (method_exists($module, 'info')) {
print $module->info($langs); print $module->info($langs);
else print $module->description; } else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
@ -436,11 +440,9 @@ if ($conf->global->BANK_COLORIZE_MOVEMENT) {
print "</tr>\n"; print "</tr>\n";
if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) if (!empty($conf->global->BANK_COLORIZE_MOVEMENT)) {
{
$i = 1; $i = 1;
while ($i <= 2) while ($i <= 2) {
{
$key = $i; $key = $i;
$color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key; $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;

View File

@ -39,13 +39,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'bank_account'; //Must be the $element of the class that manage extrafield $elementtype = 'bank_account'; //Must be the $element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -79,8 +83,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -90,8 +93,7 @@ if ($action != 'create' && $action != 'edit')
/* /*
* Creation of an optional field * Creation of an optional field
*/ */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -101,8 +103,7 @@ if ($action == 'create')
/* /*
* Edition of an optional field * Edition of an optional field
*/ */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -42,21 +44,17 @@ $action = GETPOST('action', 'aZ09');
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setbarcodeproducton') if ($action == 'setbarcodeproducton') {
{
$barcodenumberingmodule = GETPOST('value', 'alpha'); $barcodenumberingmodule = GETPOST('value', 'alpha');
$res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity);
if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) {
{
$res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity);
} }
} elseif ($action == 'setbarcodeproductoff') } elseif ($action == 'setbarcodeproductoff') {
{
$res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity); $res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity);
} }
if ($action == 'setcoder') if ($action == 'setcoder') {
{
$coder = GETPOST('coder', 'alpha'); $coder = GETPOST('coder', 'alpha');
$code_id = GETPOST('code_id', 'int'); $code_id = GETPOST('code_id', 'int');
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
@ -65,9 +63,10 @@ if ($action == 'setcoder')
$sqlp .= " AND entity = ".$conf->entity; $sqlp .= " AND entity = ".$conf->entity;
$resql = $db->query($sqlp); $resql = $db->query($sqlp);
if (!$resql) dol_print_error($db); if (!$resql) {
} elseif ($action == 'update') dol_print_error($db);
{ }
} elseif ($action == 'update') {
$location = GETPOST('GENBARCODE_LOCATION', 'alpha'); $location = GETPOST('GENBARCODE_LOCATION', 'alpha');
$res = dolibarr_set_const($db, "GENBARCODE_LOCATION", $location, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "GENBARCODE_LOCATION", $location, 'chaine', 0, '', $conf->entity);
$coder_id = GETPOST('PRODUIT_DEFAULT_BARCODE_TYPE', 'alpha'); $coder_id = GETPOST('PRODUIT_DEFAULT_BARCODE_TYPE', 'alpha');
@ -75,31 +74,26 @@ if ($action == 'setcoder')
$coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY', 'alpha'); $coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY', 'alpha');
$res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity);
if ($res > 0) if ($res > 0) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'updateengine') } elseif ($action == 'updateengine') {
{
$sql = "SELECT rowid, coder"; $sql = "SELECT rowid, coder";
$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
$sql .= " WHERE entity = ".$conf->entity; $sql .= " WHERE entity = ".$conf->entity;
$sql .= " ORDER BY code"; $sql .= " ORDER BY code";
$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;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (GETPOST('coder'.$obj->rowid, 'alpha')) if (GETPOST('coder'.$obj->rowid, 'alpha')) {
{
$coder = GETPOST('coder'.$obj->rowid, 'alpha'); $coder = GETPOST('coder'.$obj->rowid, 'alpha');
$code_id = $obj->rowid; $code_id = $obj->rowid;
@ -109,7 +103,9 @@ if ($action == 'setcoder')
$sqlp .= " AND entity = ".$conf->entity; $sqlp .= " AND entity = ".$conf->entity;
$upsql = $db->query($sqlp); $upsql = $db->query($sqlp);
if (!$upsql) dol_print_error($db); if (!$upsql) {
dol_print_error($db);
}
} }
$i++; $i++;
@ -140,25 +136,21 @@ clearstatcache();
// Scan list of all barcode included provided by external modules // Scan list of all barcode included provided by external modules
$dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']); $dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
foreach ($dirbarcode as $reldir) foreach ($dirbarcode as $reldir) {
{
$dir = dol_buildpath($reldir); $dir = dol_buildpath($reldir);
$newdir = dol_osencode($dir); $newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (!is_dir($newdir)) continue; if (!is_dir($newdir)) {
continue;
}
$handle = @opendir($newdir); $handle = @opendir($newdir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') {
{ if (is_readable($newdir.$file)) {
if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') if (preg_match('/(.*)\.modules\.php$/i', $file, $reg)) {
{
if (is_readable($newdir.$file))
{
if (preg_match('/(.*)\.modules\.php$/i', $file, $reg))
{
$filebis = $reg[1]; $filebis = $reg[1];
// Loading encoding class // Loading encoding class
@ -167,11 +159,14 @@ foreach ($dirbarcode as $reldir)
$module = new $classname($db); $module = new $classname($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
$barcodelist[$filebis] = $module->info(); $barcodelist[$filebis] = $module->info();
} }
} }
@ -188,8 +183,7 @@ foreach ($dirbarcode as $reldir)
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', ''); print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', '');
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax)) {
{
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="updateengine">'; print '<input type="hidden" name="action" value="updateengine">';
@ -210,13 +204,11 @@ $sql .= " ORDER BY code";
dol_syslog("admin/barcode.php", LOG_DEBUG); dol_syslog("admin/barcode.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;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
@ -230,29 +222,28 @@ if ($resql)
// Show example // Show example
print '<td class="center">'; print '<td class="center">';
if ($obj->coder && $obj->coder != -1) if ($obj->coder && $obj->coder != -1) {
{
$result = 0; $result = 0;
foreach ($dirbarcode as $reldir) foreach ($dirbarcode as $reldir) {
{
$dir = dol_buildpath($reldir, 0); $dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir); $newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (!is_dir($newdir)) continue; if (!is_dir($newdir)) {
continue;
}
$result = @include_once $newdir.$obj->coder.'.modules.php'; $result = @include_once $newdir.$obj->coder.'.modules.php';
if ($result) break; if ($result) {
break;
}
} }
if ($result) if ($result) {
{
$classname = "mod".ucfirst($obj->coder); $classname = "mod".ucfirst($obj->coder);
if (class_exists($classname)) if (class_exists($classname)) {
{
$module = new $classname($db); $module = new $classname($db);
if ($module->encodingIsSupported($obj->encoding)) if ($module->encodingIsSupported($obj->encoding)) {
{
// Build barcode on disk (not used, this is done to make debug easier) // Build barcode on disk (not used, this is done to make debug easier)
$result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y');
// Generate on the fly and output barcode with generator // Generate on the fly and output barcode with generator
@ -280,8 +271,7 @@ if ($resql)
} }
print "</table>\n"; print "</table>\n";
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax)) {
{
print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'"></div>'; print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'"></div>';
print '</form>'; print '</form>';
} }
@ -306,14 +296,12 @@ print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
// Chemin du binaire genbarcode sous linux // Chemin du binaire genbarcode sous linux
if (!isset($_SERVER['WINDIR'])) if (!isset($_SERVER['WINDIR'])) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("GenbarcodeLocation").'</td>'; print '<td>'.$langs->trans("GenbarcodeLocation").'</td>';
print '<td width="60" class="center">'; print '<td width="60" class="center">';
print '<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.$conf->global->GENBARCODE_LOCATION.'">'; print '<input type="text" size="40" name="GENBARCODE_LOCATION" value="'.$conf->global->GENBARCODE_LOCATION.'">';
if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION)) if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION)) {
{
$langs->load("errors"); $langs->load("errors");
print '<br><font class="error">'.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).'</font>'; print '<br><font class="error">'.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).'</font>';
} }
@ -321,8 +309,7 @@ if (!isset($_SERVER['WINDIR']))
} }
// Module products // Module products
if (!empty($conf->product->enabled)) if (!empty($conf->product->enabled)) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>'; print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>';
print '<td width="60" class="right">'; print '<td width="60" class="right">';
@ -331,8 +318,7 @@ if (!empty($conf->product->enabled))
} }
// Module thirdparty // Module thirdparty
if (!empty($conf->societe->enabled)) if (!empty($conf->societe->enabled)) {
{
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>'; print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>';
print '<td width="60" class="right">'; print '<td width="60" class="right">';
@ -351,8 +337,7 @@ print '<br>';
// Select barcode numbering module // Select barcode numbering module
if ($conf->product->enabled) if ($conf->product->enabled) {
{
print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', ''); print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', '');
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
@ -366,23 +351,18 @@ if ($conf->product->enabled)
$dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
foreach ($dirbarcodenum as $dirroot) foreach ($dirbarcodenum as $dirroot) {
{
$dir = dol_buildpath($dirroot, 0); $dir = dol_buildpath($dirroot, 0);
$handle = @opendir($dir); $handle = @opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (preg_match('/^mod_barcode_product_.*php$/', $file)) {
{
if (preg_match('/^mod_barcode_product_.*php$/', $file))
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
try { try {
dol_include_once($dirroot.$file.'.php'); dol_include_once($dirroot.$file.'.php');
} catch (Exception $e) } catch (Exception $e) {
{
dol_syslog($e->getMessage(), LOG_ERR); dol_syslog($e->getMessage(), LOG_ERR);
} }
@ -394,8 +374,7 @@ if ($conf->product->enabled)
print '</td>'; print '</td>';
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n"; print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") {
{
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';

View File

@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'mrp', 'other')); $langs->loadLangs(array('admin', 'errors', 'mrp', 'other'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -45,23 +47,24 @@ $type = 'bom';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstbom = GETPOST('maskconstBom', 'alpha'); $maskconstbom = GETPOST('maskconstBom', 'alpha');
$maskbom = GETPOST('maskBom', 'alpha'); $maskbom = GETPOST('maskBom', 'alpha');
if ($maskconstbom) $res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity); if ($maskconstbom) {
$res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen') {
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$bom = new BOM($db); $bom = new BOM($db);
@ -70,25 +73,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($bom, $langs) > 0) if ($module->write_file($bom, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bom&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bom&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -99,26 +98,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->BOM_ADDON_PDF == "$value") {
if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity);
}
} }
} } elseif ($action == 'setdoc') {
// Set default model
// Set default model if (dolibarr_set_const($db, "BOM_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
elseif ($action == 'setdoc')
{
if (dolibarr_set_const($db, "BOM_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// The constant that was read before the new set // The constant that was read before the new set
// We therefore requires a variable to have a coherent view // We therefore requires a variable to have a coherent view
$conf->global->BOM_ADDON_PDF = $value; $conf->global->BOM_ADDON_PDF = $value;
@ -126,39 +118,37 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') } elseif ($action == 'setmod') {
{
// TODO Check if numbering module chosen can be activated // TODO Check if numbering module chosen can be activated
// by calling method canBeActivated // by calling method canBeActivated
dolibarr_set_const($db, "BOM_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "BOM_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'set_BOM_DRAFT_WATERMARK') } elseif ($action == 'set_BOM_DRAFT_WATERMARK') {
{
$draft = GETPOST("BOM_DRAFT_WATERMARK"); $draft = GETPOST("BOM_DRAFT_WATERMARK");
$res = dolibarr_set_const($db, "BOM_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BOM_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_BOM_FREE_TEXT') } elseif ($action == 'set_BOM_FREE_TEXT') {
{
$freetext = GETPOST("BOM_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST("BOM_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "BOM_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BOM_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -200,19 +190,14 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/bom/"); $dir = dol_buildpath($reldir."core/modules/bom/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -220,11 +205,14 @@ foreach ($dirmodels as $reldir)
$module = new $file($db); $module = new $file($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -235,13 +223,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->BOM_ADDON == $file) if ($conf->global->BOM_ADDON == $file) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -261,8 +251,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -297,12 +288,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -324,31 +313,23 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/bom".$valdir; $realpath = $reldir."core/modules/bom".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -356,21 +337,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -384,8 +370,7 @@ foreach ($dirmodels as $reldir)
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->BOM_ADDON_PDF == $name) if ($conf->global->BOM_ADDON_PDF == $name) {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -395,8 +380,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -412,8 +396,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -448,7 +431,9 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -457,8 +442,7 @@ print '<input type="hidden" name="action" value="set_BOM_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'BOM_FREE_TEXT'; $variablename = 'BOM_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -39,13 +39,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'bom_bom'; $elementtype = 'bom_bom';
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -78,8 +82,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -89,8 +92,7 @@ if ($action != 'create' && $action != 'edit')
/* /*
* Creation of an optional field * Creation of an optional field
*/ */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -100,8 +102,7 @@ if ($action == 'create')
/* /*
* Edition of an optional field * Edition of an optional field
*/ */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -319,7 +319,7 @@ print '<tr class="liste_titre">';
print '<td width="300">'.$langs->trans("Box").'</td>'; print '<td width="300">'.$langs->trans("Box").'</td>';
print '<td>'.$langs->trans("Note").'/'.$langs->trans("Parameters").'</td>'; print '<td>'.$langs->trans("Note").'/'.$langs->trans("Parameters").'</td>';
print '<td>'.$langs->trans("SourceFile").'</td>'; print '<td>'.$langs->trans("SourceFile").'</td>';
print '<td width="160" class="center">'.$langs->trans("ActivateOn").'</td>'; print '<td width="160" class="center">'.$langs->trans("ActivatableOn").'</td>';
print "</tr>\n"; print "</tr>\n";
foreach ($boxtoadd as $box) { foreach ($boxtoadd as $box) {
@ -377,7 +377,7 @@ print '<table class="tagtable liste">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="300">'.$langs->trans("Box").'</td>'; print '<td width="300">'.$langs->trans("Box").'</td>';
print '<td>'.$langs->trans("Note").'/'.$langs->trans("Parameters").'</td>'; print '<td>'.$langs->trans("Note").'/'.$langs->trans("Parameters").'</td>';
print '<td class="center" width="160">'.$langs->trans("ActiveOn").'</td>'; print '<td class="center" width="160">'.$langs->trans("ActivatableOn").'</td>';
print '<td class="center" width="60" colspan="2">'.$langs->trans("PositionByDefault").'</td>'; print '<td class="center" width="60" colspan="2">'.$langs->trans("PositionByDefault").'</td>';
print '<td class="center" width="80">'.$langs->trans("Disable").'</td>'; print '<td class="center" width="80">'.$langs->trans("Disable").'</td>';
print '</tr>'."\n"; print '</tr>'."\n";

View File

@ -34,14 +34,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "companies", "bills", "other", "banks")); $langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipts_mint.php'; if (empty($conf->global->CHEQUERECEIPTS_ADDON)) {
$conf->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipts_mint.php';
}
@ -49,37 +52,38 @@ if (empty($conf->global->CHEQUERECEIPTS_ADDON)) $conf->global->CHEQUERECEIPTS_AD
* Actions * Actions
*/ */
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha'); $maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha');
$maskchequereceipts = GETPOST('maskchequereceipts', 'alpha'); $maskchequereceipts = GETPOST('maskchequereceipts', 'alpha');
if ($maskconstchequereceipts) $res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity); if ($maskconstchequereceipts) {
$res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if ($action == 'setmod') if ($action == 'setmod') {
{
dolibarr_set_const($db, "CHEQUERECEIPTS_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "CHEQUERECEIPTS_ADDON", $value, 'chaine', 0, '', $conf->entity);
} }
if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') if ($action == 'set_BANK_CHEQUERECEIPT_FREE_TEXT') {
{
$freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST('BANK_CHEQUERECEIPT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BANK_CHEQUERECEIPT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -118,45 +122,43 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/cheque/"); $dir = dol_buildpath($reldir."core/modules/cheque/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) {
{
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
{
$filebis = $file; $filebis = $file;
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = preg_replace('/\.php$/', '', $file); $classname = preg_replace('/\.php$/', '', $file);
// For compatibility // For compatibility
if (!is_file($dir.$filebis)) if (!is_file($dir.$filebis)) {
{
$filebis = $file."/".$file.".modules.php"; $filebis = $file."/".$file.".modules.php";
$classname = "mod_chequereceipt_".$file; $classname = "mod_chequereceipt_".$file;
} }
// Check if there is a filter on country // Check if there is a filter on country
preg_match('/\-(.*)_(.*)$/', $classname, $reg); preg_match('/\-(.*)_(.*)$/', $classname, $reg);
if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
continue;
}
$classname = preg_replace('/\-.*$/', '', $classname); $classname = preg_replace('/\-.*$/', '', $classname);
if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
{
// Charging the numbering class // Charging the numbering class
require_once $dir.$filebis; require_once $dir.$filebis;
$module = new $classname($db); $module = new $classname($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
@ -171,13 +173,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->CHEQUERECEIPTS_ADDON == $file || $conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) if ($conf->global->CHEQUERECEIPTS_ADDON == $file || $conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
@ -194,8 +198,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValue").': '; $htmltooltip .= $langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -205,9 +210,10 @@ foreach ($dirmodels as $reldir)
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) // If module is the one used, we show existing errors if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) { // If module is the one used, we show existing errors
{ if (!empty($module->error)) {
if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); dol_htmloutput_mesg($module->error, '', 'error', 1);
}
} }
print '</td>'; print '</td>';
@ -246,14 +252,15 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnChequeReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'BANK_CHEQUERECEIPT_FREE_TEXT'; $variablename = 'BANK_CHEQUERECEIPT_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -42,13 +44,11 @@ if (!in_array('clicktodial', $conf->modules)) {
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin) {
{
$result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity);
$result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity);
if ($result1 >= 0 && $result2 >= 0) if ($result1 >= 0 && $result2 >= 0) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -117,12 +117,13 @@ print '<div class="center"><br><input type="submit" class="button" value="'.$lan
print '</form><br><br>'; print '</form><br><br>';
if (!empty($conf->global->CLICKTODIAL_URL)) if (!empty($conf->global->CLICKTODIAL_URL)) {
{
$user->fetch_clicktodial(); $user->fetch_clicktodial();
$phonefortest = $mysoc->phone; $phonefortest = $mysoc->phone;
if (GETPOST('phonefortest')) $phonefortest = GETPOST('phonefortest'); if (GETPOST('phonefortest')) {
$phonefortest = GETPOST('phonefortest');
}
print '<form action="'.$_SERVER["PHP_SELF"].'">'; print '<form action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
@ -132,12 +133,17 @@ if (!empty($conf->global->CLICKTODIAL_URL))
print '</form>'; print '</form>';
$setupcomplete = 1; $setupcomplete = 1;
if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) $setupcomplete = 0; if (preg_match('/__LOGIN__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_login)) {
if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) $setupcomplete = 0; $setupcomplete = 0;
if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) $setupcomplete = 0; }
if (preg_match('/__PASSWORD__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_password)) {
$setupcomplete = 0;
}
if (preg_match('/__PHONEFROM__/', $conf->global->CLICKTODIAL_URL) && empty($user->clicktodial_poste)) {
$setupcomplete = 0;
}
if ($setupcomplete) if ($setupcomplete) {
{
print $langs->trans("LinkToTest", $user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL'); print $langs->trans("LinkToTest", $user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL');
} else { } else {
$langs->load("errors"); $langs->load("errors");

View File

@ -39,7 +39,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'orders', 'other')); $langs->loadLangs(array('admin', 'errors', 'orders', 'other'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -54,23 +56,24 @@ $type = 'order';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstorder = GETPOST('maskconstorder', 'alpha'); $maskconstorder = GETPOST('maskconstorder', 'alpha');
$maskorder = GETPOST('maskorder', 'alpha'); $maskorder = GETPOST('maskorder', 'alpha');
if ($maskconstorder) $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); if ($maskconstorder) {
$res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') } elseif ($action == 'specimen') {
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$commande = new Commande($db); $commande = new Commande($db);
@ -79,25 +82,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($commande, $langs) > 0) if ($module->write_file($commande, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -108,23 +107,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set') {
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') { } elseif ($action == 'del') {
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->COMMANDE_ADDON_PDF == "$value") {
if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
}
} }
} } elseif ($action == 'setdoc') {
// Set default model
// Set default model if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
elseif ($action == 'setdoc') {
if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// The constant that was read before the new set // The constant that was read before the new set
// We therefore requires a variable to have a coherent view // We therefore requires a variable to have a coherent view
$conf->global->COMMANDE_ADDON_PDF = $value; $conf->global->COMMANDE_ADDON_PDF = $value;
@ -132,8 +127,7 @@ elseif ($action == 'setdoc') {
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') { } elseif ($action == 'setmod') {
@ -141,29 +135,29 @@ elseif ($action == 'setdoc') {
// by calling method canBeActivated // by calling method canBeActivated
dolibarr_set_const($db, "COMMANDE_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "COMMANDE_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK') } elseif ($action == 'set_COMMANDE_DRAFT_WATERMARK') {
{
$draft = GETPOST("COMMANDE_DRAFT_WATERMARK"); $draft = GETPOST("COMMANDE_DRAFT_WATERMARK");
$res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'set_ORDER_FREE_TEXT') } elseif ($action == 'set_ORDER_FREE_TEXT') {
{
$freetext = GETPOST("ORDER_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST("ORDER_FREE_TEXT", 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -172,54 +166,52 @@ elseif ($action == 'setdoc') {
// Activate Set Shippable Icon In List // Activate Set Shippable Icon In List
$setshippableiconinlist = GETPOST('value', 'int'); $setshippableiconinlist = GETPOST('value', 'int');
$res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity); $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'setribchq') } elseif ($action == 'setribchq') {
{
$rib = GETPOST('rib', 'alpha'); $rib = GETPOST('rib', 'alpha');
$chq = GETPOST('chq', 'alpha'); $chq = GETPOST('chq', 'alpha');
$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} } elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') {
// Activate ask for payment bank
// Activate ask for payment bank
elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
{
$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} } elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') {
// Activate ask for warehouse
// Activate ask for warehouse
elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
{
$res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -262,19 +254,14 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/commande/"); $dir = dol_buildpath($reldir."core/modules/commande/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -282,11 +269,14 @@ foreach ($dirmodels as $reldir)
$module = new $file($db); $module = new $file($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -297,13 +287,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->COMMANDE_ADDON == $file) if ($conf->global->COMMANDE_ADDON == $file) {
{
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;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -323,8 +315,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -359,12 +352,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -387,31 +378,23 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/commande".$valdir; $realpath = $reldir."core/modules/commande".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -419,21 +402,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -447,8 +435,7 @@ foreach ($dirmodels as $reldir)
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->COMMANDE_ADDON_PDF == $name) if ($conf->global->COMMANDE_ADDON_PDF == $name) {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -458,8 +445,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -480,8 +466,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -528,26 +513,21 @@ print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>"; print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
print "<td>"; print "<td>";
if (empty($conf->facture->enabled)) if (empty($conf->facture->enabled)) {
{ if (!empty($conf->banque->enabled)) {
if (!empty($conf->banque->enabled))
{
$sql = "SELECT rowid, label"; $sql = "SELECT rowid, label";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql .= " WHERE clos = 0"; $sql .= " WHERE clos = 0";
$sql .= " AND courant = 1"; $sql .= " AND courant = 1";
$sql .= " AND entity IN (".getEntity('bank_account').")"; $sql .= " AND entity IN (".getEntity('bank_account').")";
$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;
if ($num > 0) if ($num > 0) {
{
print '<select name="rib" class="flat" id="rib">'; print '<select name="rib" class="flat" id="rib">';
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
while ($i < $num) while ($i < $num) {
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
@ -572,8 +552,7 @@ print "</td></tr>";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>"; print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
print "<td>"; print "<td>";
if (empty($conf->facture->enabled)) if (empty($conf->facture->enabled)) {
{
print '<select class="flat" name="chq" id="chq">'; print '<select class="flat" name="chq" id="chq">';
print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>'; print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>'; print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
@ -585,12 +564,10 @@ if (empty($conf->facture->enabled))
$sql .= " AND entity IN (".getEntity('bank_account').")"; $sql .= " AND entity IN (".getEntity('bank_account').")";
$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;
while ($i < $num) while ($i < $num) {
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
print '<option value="'.$row[0].'"'; print '<option value="'.$row[0].'"';
@ -626,7 +603,9 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -635,8 +614,7 @@ print '<input type="hidden" name="action" value="set_ORDER_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'ORDER_FREE_TEXT'; $variablename = 'ORDER_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
@ -671,11 +649,11 @@ print '<td>'.$langs->trans("ShippableOrderIconInList").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td class="center">'; print '<td class="center">';
if (!empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { if (!empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setshippableiconinlist&amp;token='.newToken().'&amp;value=0">'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=setshippableiconinlist&amp;token='.newToken().'&amp;value=0">';
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=setshippableiconinlist&amp;token='.newToken().'&amp;value=1">'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=setshippableiconinlist&amp;token='.newToken().'&amp;value=1">';
print img_picto($langs->trans("Disabled"),'switch_off'); print img_picto($langs->trans("Disabled"),'switch_off');
} }
print '</a></td>'; print '</a></td>';
print '</tr>'; print '</tr>';
@ -686,60 +664,60 @@ print '</tr>';
if ($conf->banque->enabled) if ($conf->banque->enabled)
{ {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">';
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_ORDER'); print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_ORDER');
} }
else else
{ {
if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER)) if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER))
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ORDER&amp;token='.newToken().'&amp;value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ORDER&amp;token='.newToken().'&amp;value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
else else
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ORDER&amp;token='.newToken().'&amp;value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_ORDER&amp;token='.newToken().'&amp;value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
} }
} }
print '</td></tr>'; print '</td></tr>';
} }
else else
{ {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>'; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
} }
// Ask for warehouse during order // Ask for warehouse during order
if ($conf->stock->enabled) if ($conf->stock->enabled)
{ {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'; print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">';
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER'); print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER');
} }
else else
{ {
if (empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) if (empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER))
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&amp;token='.newToken().'&amp;value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&amp;token='.newToken().'&amp;value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
else else
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&amp;token='.newToken().'&amp;value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&amp;token='.newToken().'&amp;value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
} }
} }
print '</td></tr>'; print '</td></tr>';
} }
else else
{ {
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>'; print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td>&nbsp;</td><td class="center">'.$langs->trans('NotAvailable').'</td></tr>';
} }
*/ */

View File

@ -35,8 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$langs->load("admin"); $langs->load("admin");
$langs->load("other"); $langs->load("other");
@ -48,13 +49,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->trans($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->trans($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield $elementtype = 'commande_fournisseur_dispatch'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -87,8 +92,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -101,8 +105,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -114,8 +117,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -43,7 +43,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adm
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'companies', 'bills')); $langs->loadLangs(array('admin', 'companies', 'bills'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$error = 0; $error = 0;
@ -57,14 +59,14 @@ $hookmanager->initHooks(array('admincompany', 'globaladmin'));
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (($action == 'update' && !GETPOST("cancel", 'alpha')) if (($action == 'update' && !GETPOST("cancel", 'alpha'))
|| ($action == 'updateedit')) || ($action == 'updateedit')) {
{
$tmparray = getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0); $tmparray = getCountry(GETPOST('country_id', 'int'), 'all', $db, $langs, 0);
if (!empty($tmparray['id'])) if (!empty($tmparray['id'])) {
{
$mysoc->country_id = $tmparray['id']; $mysoc->country_id = $tmparray['id'];
$mysoc->country_code = $tmparray['code']; $mysoc->country_code = $tmparray['code'];
$mysoc->country_label = $tmparray['label']; $mysoc->country_label = $tmparray['label'];
@ -76,8 +78,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
} }
$tmparray = getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0); $tmparray = getState(GETPOST('state_id', 'int'), 'all', $db, $langs, 0);
if (!empty($tmparray['id'])) if (!empty($tmparray['id'])) {
{
$mysoc->state_id = $tmparray['id']; $mysoc->state_id = $tmparray['id'];
$mysoc->state_code = $tmparray['code']; $mysoc->state_code = $tmparray['code'];
$mysoc->state_label = $tmparray['label']; $mysoc->state_label = $tmparray['label'];
@ -107,59 +108,58 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
$arrayofimages = array('logo', 'logo_squarred'); $arrayofimages = array('logo', 'logo_squarred');
foreach ($arrayofimages as $varforimage) foreach ($arrayofimages as $varforimage) {
{
if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported. if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) { // Logo can be used on a lot of different places. Only jpg and png can be supported.
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors'); setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
break; break;
} }
if ($_FILES[$varforimage]["tmp_name"]) if ($_FILES[$varforimage]["tmp_name"]) {
{
$reg = array(); $reg = array();
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) {
{
$original_file = $reg[1]; $original_file = $reg[1];
$isimage = image_format_supported($original_file); $isimage = image_format_supported($original_file);
if ($isimage >= 0) if ($isimage >= 0) {
{
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file); dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
if (!is_dir($dirforimage)) if (!is_dir($dirforimage)) {
{
dol_mkdir($dirforimage); dol_mkdir($dirforimage);
} }
$result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
if ($result > 0) if ($result > 0) {
{
$constant = "MAIN_INFO_SOCIETE_LOGO"; $constant = "MAIN_INFO_SOCIETE_LOGO";
if ($varforimage == 'logo_squarred') $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED"; if ($varforimage == 'logo_squarred') {
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
}
dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity);
// Create thumbs of logo (Note that PDF use original file and not thumbs) // Create thumbs of logo (Note that PDF use original file and not thumbs)
if ($isimage > 0) if ($isimage > 0) {
{
// Create thumbs // Create thumbs
//$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get... //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
// Create small thumb, Used on logon for example // Create small thumb, Used on logon for example
$imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality); $imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
{
$imgThumbSmall = $reg[1]; // Save only basename $imgThumbSmall = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
} else dol_syslog($imgThumbSmall); } else {
dol_syslog($imgThumbSmall);
}
// Create mini thumb, Used on menu or for setup page for example // Create mini thumb, Used on menu or for setup page for example
$imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality); $imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
{
$imgThumbMini = $reg[1]; // Save only basename $imgThumbMini = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
} else dol_syslog($imgThumbMini); } else {
} else dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING); dol_syslog($imgThumbMini);
}
} else {
dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING);
}
} elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) { } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
@ -198,13 +198,11 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
$usevat = GETPOST("optiontva", 'aZ09'); $usevat = GETPOST("optiontva", 'aZ09');
$uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09'); $uselocaltax1 = GETPOST("optionlocaltax1", 'aZ09');
$uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09'); $uselocaltax2 = GETPOST("optionlocaltax2", 'aZ09');
if ($uselocaltax1 == 'localtax1on' && !$usevat) if ($uselocaltax1 == 'localtax1on' && !$usevat) {
{
setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors'); setEventMessages($langs->trans("IfYouUseASecondTaxYouMustSetYouUseTheMainTax"), null, 'errors');
$error++; $error++;
} }
if ($uselocaltax2 == 'localtax2on' && !$usevat) if ($uselocaltax2 == 'localtax2on' && !$usevat) {
{
setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors'); setEventMessages($langs->trans("IfYouUseAThirdTaxYouMustSetYouUseTheMainTax"), null, 'errors');
$error++; $error++;
} }
@ -213,8 +211,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", $uselocaltax1, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", $uselocaltax2, 'chaine', 0, '', $conf->entity);
if ($_POST["optionlocaltax1"] == "localtax1on") if ($_POST["optionlocaltax1"] == "localtax1on") {
{
if (!GETPOSTISSET('lt1')) { if (!GETPOSTISSET('lt1')) {
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", 0, 'chaine', 0, '', $conf->entity);
} else { } else {
@ -222,8 +219,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
} }
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1", 'aZ09'), 'chaine', 0, '', $conf->entity);
} }
if ($_POST["optionlocaltax2"] == "localtax2on") if ($_POST["optionlocaltax2"] == "localtax2on") {
{
if (!GETPOSTISSET('lt2')) { if (!GETPOSTISSET('lt2')) {
dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", 0, 'chaine', 0, '', $conf->entity);
} else { } else {
@ -232,8 +228,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2", 'aZ09'), 'chaine', 0, '', $conf->entity);
} }
if (!$error) if (!$error) {
{
if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form. if (GETPOST('save')) { // To avoid to show message when we juste switch the country that resubmit the form.
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} }
@ -242,24 +237,22 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
$db->rollback(); $db->rollback();
} }
if ($action != 'updateedit' && !$error) if ($action != 'updateedit' && !$error) {
{
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
} }
if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumbs if ($action == 'addthumb' || $action == 'addthumbsquarred') { // Regenerate thumbs
{ if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"])) {
if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"]))
{
$isimage = image_format_supported($_GET["file"]); $isimage = image_format_supported($_GET["file"]);
// Create thumbs of logo // Create thumbs of logo
if ($isimage > 0) if ($isimage > 0) {
{
$constant = "MAIN_INFO_SOCIETE_LOGO"; $constant = "MAIN_INFO_SOCIETE_LOGO";
if ($action == 'addthumbsquarred') $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED"; if ($action == 'addthumbsquarred') {
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
}
$reg = array(); $reg = array();
@ -268,19 +261,21 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
// Create small thumb. Used on logon for example // Create small thumb. Used on logon for example
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality); $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
{
$imgThumbSmall = $reg[1]; // Save only basename $imgThumbSmall = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
} else dol_syslog($imgThumbSmall); } else {
dol_syslog($imgThumbSmall);
}
// Create mini thumbs. Used on menu or for setup page for example // Create mini thumbs. Used on menu or for setup page for example
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality); $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
{
$imgThumbMini = $reg[1]; // Save only basename $imgThumbMini = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
} else dol_syslog($imgThumbMini); } else {
dol_syslog($imgThumbMini);
}
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
@ -299,54 +294,67 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
} }
if ($action == 'removelogo' || $action == 'removelogosquarred') if ($action == 'removelogo' || $action == 'removelogosquarred') {
{
$constant = "MAIN_INFO_SOCIETE_LOGO"; $constant = "MAIN_INFO_SOCIETE_LOGO";
if ($action == 'removelogosquarred') $constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED"; if ($action == 'removelogosquarred') {
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$logofilename = $mysoc->logo; $logofilename = $mysoc->logo;
$logofilenamebis = $mysoc->logo_squarred; $logofilenamebis = $mysoc->logo_squarred;
if ($action == 'removelogosquarred') if ($action == 'removelogosquarred') {
{
$logofilename = $mysoc->logo_squarred; $logofilename = $mysoc->logo_squarred;
$logofilenamebis = $mysoc->logo; $logofilenamebis = $mysoc->logo;
} }
$logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename; $logofile = $conf->mycompany->dir_output.'/logos/'.$logofilename;
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logofile); if ($logofilename != '' && $logofilename != $logofilenamebis) {
dol_delete_file($logofile);
}
dolibarr_del_const($db, $constant, $conf->entity); dolibarr_del_const($db, $constant, $conf->entity);
if ($action == 'removelogosquarred') $mysoc->logo_squarred = ''; if ($action == 'removelogosquarred') {
else $mysoc->logo = ''; $mysoc->logo_squarred = '';
} else {
$mysoc->logo = '';
}
$logofilename = $mysoc->logo_small; $logofilename = $mysoc->logo_small;
$logofilenamebis = $mysoc->logo_squarred_small; $logofilenamebis = $mysoc->logo_squarred_small;
if ($action == 'removelogosquarred') if ($action == 'removelogosquarred') {
{
$logofilename = $mysoc->logo_squarred_small; $logofilename = $mysoc->logo_squarred_small;
$logofilenamebis = $mysoc->logo_small; $logofilenamebis = $mysoc->logo_small;
} }
$logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename; $logosmallfile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logosmallfile); if ($logofilename != '' && $logofilename != $logofilenamebis) {
dol_delete_file($logosmallfile);
}
dolibarr_del_const($db, $constant."_SMALL", $conf->entity); dolibarr_del_const($db, $constant."_SMALL", $conf->entity);
if ($action == 'removelogosquarred') $mysoc->logo_squarred_small = ''; if ($action == 'removelogosquarred') {
else $mysoc->logo_small = ''; $mysoc->logo_squarred_small = '';
} else {
$mysoc->logo_small = '';
}
$logofilename = $mysoc->logo_mini; $logofilename = $mysoc->logo_mini;
$logofilenamebis = $mysoc->logo_squarred_mini; $logofilenamebis = $mysoc->logo_squarred_mini;
if ($action == 'removelogosquarred') if ($action == 'removelogosquarred') {
{
$logofilename = $mysoc->logo_squarred_mini; $logofilename = $mysoc->logo_squarred_mini;
$logofilenamebis = $mysoc->logo_mini; $logofilenamebis = $mysoc->logo_mini;
} }
$logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename; $logominifile = $conf->mycompany->dir_output.'/logos/thumbs/'.$logofilename;
if ($logofilename != '' && $logofilename != $logofilenamebis) dol_delete_file($logominifile); if ($logofilename != '' && $logofilename != $logofilenamebis) {
dol_delete_file($logominifile);
}
dolibarr_del_const($db, $constant."_MINI", $conf->entity); dolibarr_del_const($db, $constant."_MINI", $conf->entity);
if ($action == 'removelogosquarred') $mysoc->logo_squarred_mini = ''; if ($action == 'removelogosquarred') {
else $mysoc->logo_mini = ''; $mysoc->logo_squarred_mini = '';
} else {
$mysoc->logo_mini = '';
}
} }
@ -411,13 +419,14 @@ print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth200" id="MAIN_INFO_SO
print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">'; print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
print img_picto('', 'globe-americas', 'class="paddingrightonly"'); print img_picto('', 'globe-americas', 'class="paddingrightonly"');
print $form->select_country($mysoc->country_id, 'country_id'); print $form->select_country($mysoc->country_id, 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>'."\n"; print '</td></tr>'."\n";
print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">'; print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
$state_id = 0; $state_id = 0;
if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE)) if (!empty($conf->global->MAIN_INFO_SOCIETE_STATE)) {
{
$tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE); $tmp = explode(':', $conf->global->MAIN_INFO_SOCIETE_STATE);
$state_id = $tmp[0]; $state_id = $tmp[0];
} }
@ -473,13 +482,13 @@ if (!empty($mysoc->logo_small)) {
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">'; print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">';
print '</div>'; print '</div>';
} elseif (!empty($mysoc->logo)) { } elseif (!empty($mysoc->logo)) {
if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) { if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) {
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_mini', $quality); $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_mini', $quality);
} }
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_small', $quality); $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo, $maxwidthmini, $maxheightmini, '_small', $quality);
print '<div class="inline-block valignmiddle">'; print '<div class="inline-block valignmiddle">';
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">'; print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">';
print '</div>'; print '</div>';
} }
print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>'; print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
} elseif (!empty($mysoc->logo)) { } elseif (!empty($mysoc->logo)) {
@ -508,13 +517,13 @@ if (!empty($mysoc->logo_squarred_small)) {
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_small).'">'; print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_small).'">';
print '</div>'; print '</div>';
} elseif (!empty($mysoc->logo_squarred)) { } elseif (!empty($mysoc->logo_squarred)) {
if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) { if (!file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) {
$imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_mini', $quality); $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_mini', $quality);
} }
$imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_small', $quality); $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred, $maxwidthmini, $maxheightmini, '_small', $quality);
print '<div class="inline-block valignmiddle">'; print '<div class="inline-block valignmiddle">';
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">'; print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.basename($imgThumbSmall)).'">';
print '</div>'; print '</div>';
} }
print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>'; print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
} elseif (!empty($mysoc->logo_squarred)) { } elseif (!empty($mysoc->logo_squarred)) {
@ -523,8 +532,7 @@ if (!empty($mysoc->logo_squarred_small)) {
print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo_squarred).'">'; print '<img style="max-height: 80px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo_squarred).'">';
print '</div>'; print '</div>';
print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>'; print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
} } else {
else {
print '<div class="inline-block valignmiddle">'; print '<div class="inline-block valignmiddle">';
print '<img height="80" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">'; print '<img height="80" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
print '</div>'; print '</div>';
@ -572,11 +580,9 @@ if ($mysoc->country_code) {
print '</td></tr>'; print '</td></tr>';
// ProfId1 // ProfId1
if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid1">'.$langs->transcountry("ProfId1", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="siren" id="profid1" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '').'">'; print '<input name="siren" id="profid1" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIREN) ? $conf->global->MAIN_INFO_SIREN : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -585,11 +591,9 @@ if ($langs->transcountry("ProfId1", $mysoc->country_code) != '-')
} }
// ProfId2 // ProfId2
if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid2">'.$langs->transcountry("ProfId2", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="siret" id="profid2" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '').'">'; print '<input name="siret" id="profid2" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_SIRET) ? $conf->global->MAIN_INFO_SIRET : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -598,11 +602,9 @@ if ($langs->transcountry("ProfId2", $mysoc->country_code) != '-')
} }
// ProfId3 // ProfId3
if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid3">'.$langs->transcountry("ProfId3", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="ape" id="profid3" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '').'">'; print '<input name="ape" id="profid3" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_APE) ? $conf->global->MAIN_INFO_APE : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -611,11 +613,9 @@ if ($langs->transcountry("ProfId3", $mysoc->country_code) != '-')
} }
// ProfId4 // ProfId4
if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid4">'.$langs->transcountry("ProfId4", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="rcs" id="profid4" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '').'">'; print '<input name="rcs" id="profid4" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_RCS) ? $conf->global->MAIN_INFO_RCS : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -624,11 +624,9 @@ if ($langs->transcountry("ProfId4", $mysoc->country_code) != '-')
} }
// ProfId5 // ProfId5
if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid5">'.$langs->transcountry("ProfId5", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '').'">'; print '<input name="MAIN_INFO_PROFID5" id="profid5" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID5) ? $conf->global->MAIN_INFO_PROFID5 : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -637,11 +635,9 @@ if ($langs->transcountry("ProfId5", $mysoc->country_code) != '-')
} }
// ProfId6 // ProfId6
if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') if ($langs->transcountry("ProfId6", $mysoc->country_code) != '-') {
{
print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>'; print '<tr class="oddeven"><td><label for="profid6">'.$langs->transcountry("ProfId6", $mysoc->country_code).'</label></td><td>';
if (!empty($mysoc->country_code)) if (!empty($mysoc->country_code)) {
{
print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '').'">'; print '<input name="MAIN_INFO_PROFID6" id="profid6" class="minwidth200" value="'.dol_escape_htmltag(!empty($conf->global->MAIN_INFO_PROFID6) ? $conf->global->MAIN_INFO_PROFID6 : '').'">';
} else { } else {
print $countrynotdefined; print $countrynotdefined;
@ -689,7 +685,9 @@ print "</tr>\n";
print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="use_vat" value="1"'.(empty($conf->global->FACTURE_TVAOPTION) ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>"; print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="use_vat" value="1"'.(empty($conf->global->FACTURE_TVAOPTION) ? "" : " checked")."> ".$langs->trans("VATIsUsed")."</label></td>";
print '<td colspan="2">'; print '<td colspan="2">';
$tooltiphelp = ''; $tooltiphelp = '';
if ($mysoc->country_code == 'FR') $tooltiphelp = '<i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>"; if ($mysoc->country_code == 'FR') {
$tooltiphelp = '<i>'.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i>";
}
print "<label for=\"use_vat\">".$form->textwithpicto($langs->trans("VATIsUsedDesc"), $tooltiphelp)."</label>"; print "<label for=\"use_vat\">".$form->textwithpicto($langs->trans("VATIsUsedDesc"), $tooltiphelp)."</label>";
print "</td></tr>\n"; print "</td></tr>\n";
@ -697,7 +695,9 @@ print "</td></tr>\n";
print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="no_vat" value="0"'.(empty($conf->global->FACTURE_TVAOPTION) ? " checked" : "")."> ".$langs->trans("VATIsNotUsed")."</label></td>"; print '<tr class="oddeven"><td width="140"><label><input type="radio" name="optiontva" id="no_vat" value="0"'.(empty($conf->global->FACTURE_TVAOPTION) ? " checked" : "")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
print '<td colspan="2">'; print '<td colspan="2">';
$tooltiphelp = ''; $tooltiphelp = '';
if ($mysoc->country_code == 'FR') $tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n"; if ($mysoc->country_code == 'FR') {
$tooltiphelp = "<i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i>\n";
}
print "<label for=\"no_vat\">".$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>"; print "<label for=\"no_vat\">".$form->textwithpicto($langs->trans("VATIsNotUsedDesc"), $tooltiphelp)."</label>";
print "</td></tr>\n"; print "</td></tr>\n";
@ -711,8 +711,7 @@ print '<td width="25%">'.$form->textwithpicto($langs->transcountry("LocalTax1Man
print '<td class="right">&nbsp;</td>'; print '<td class="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
if ($mysoc->useLocalTax(1)) if ($mysoc->useLocalTax(1)) {
{
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax1" id="lt1" value="localtax1on"'.(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>"; print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax1" id="lt1" value="localtax1on"'.(($conf->global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on") ? " checked" : "")."> ".$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
@ -720,8 +719,7 @@ if ($mysoc->useLocalTax(1))
$tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code); $tooltiphelp = $langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code);
$tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : ""); $tooltiphelp = ($tooltiphelp != "LocalTax1IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample", $mysoc->country_code)."</i>\n" : "");
print '<label for="lt1">'.$form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>"; print '<label for="lt1">'.$form->textwithpicto($langs->transcountry("LocalTax1IsUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
if (!isOnlyOneLocalTax(1)) if (!isOnlyOneLocalTax(1)) {
{
print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: '; print '<br><label for="lt1">'.$langs->trans("LTRate").'</label>: ';
$formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1"); $formcompany->select_localtax(1, $conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
} }
@ -740,8 +738,7 @@ if ($mysoc->useLocalTax(1))
print "<label for=\"nolt1\">".$form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>"; print "<label for=\"nolt1\">".$form->textwithpicto($langs->transcountry("LocalTax1IsNotUsedDesc", $mysoc->country_code), $tooltiphelp)."</label>";
print "</td></tr>\n"; print "</td></tr>\n";
} else { } else {
if (empty($mysoc->country_code)) if (empty($mysoc->country_code)) {
{
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>'; print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
} else { } else {
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax1Management")).'</td></tr>'; print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax1Management")).'</td></tr>';
@ -758,8 +755,7 @@ print '<td width="25%">'.$form->textwithpicto($langs->transcountry("LocalTax2Man
print '<td class="right">&nbsp;</td>'; print '<td class="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
if ($mysoc->useLocalTax(2)) if ($mysoc->useLocalTax(2)) {
{
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax2" id="lt2" value="localtax2on"'.(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>"; print '<tr class="oddeven"><td><input type="radio" name="optionlocaltax2" id="lt2" value="localtax2on"'.(($conf->global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on") ? " checked" : "")."> ".$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code)."</td>";
print '<td colspan="2">'; print '<td colspan="2">';
@ -767,8 +763,7 @@ if ($mysoc->useLocalTax(2))
print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>"; print '<label for="lt2">'.$langs->transcountry("LocalTax2IsUsedDesc", $mysoc->country_code)."</label>";
$tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code); $tooltiphelp = $langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code);
$tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : ""); $tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "<i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."</i>\n" : "");
if (!isOnlyOneLocalTax(2)) if (!isOnlyOneLocalTax(2)) {
{
print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: '; print '<br><label for="lt2">'.$langs->trans("LTRate").'</label>: ';
$formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2"); $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
} }
@ -786,8 +781,7 @@ if ($mysoc->useLocalTax(2))
print "</div>"; print "</div>";
print "</td></tr>\n"; print "</td></tr>\n";
} else { } else {
if (empty($mysoc->country_code)) if (empty($mysoc->country_code)) {
{
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>'; print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
} else { } else {
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax2Management")).'</td></tr>'; print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryVAT"), $langs->transnoentitiesnoconv("LocalTax2Management")).'</td></tr>';
@ -804,8 +798,7 @@ print '<tr class="liste_titre">';
print '<td width="25%">'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td>'.$langs->trans("Description").'</td>'; print '<td width="25%">'.$form->textwithpicto($langs->trans("RevenueStamp"), $langs->trans("RevenueStampDesc")).'</td><td>'.$langs->trans("Description").'</td>';
print '<td class="right">&nbsp;</td>'; print '<td class="right">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
if ($mysoc->useRevenueStamp()) if ($mysoc->useRevenueStamp()) {
{
// Note: When option is not set, it must not appears as set on on, because there is no default value for this option // Note: When option is not set, it must not appears as set on on, because there is no default value for this option
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
print $langs->trans("UseRevenueStamp"); print $langs->trans("UseRevenueStamp");
@ -814,8 +807,7 @@ if ($mysoc->useRevenueStamp())
print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp")); print $langs->trans("UseRevenueStampExample", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"));
print "</td></tr>\n"; print "</td></tr>\n";
} else { } else {
if (empty($mysoc->country_code)) if (empty($mysoc->country_code)) {
{
print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>'; print '<tr class="oddeven nohover"><td class="">'.$countrynotdefined.'</td><td></td><td></td></tr>';
} else { } else {
print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"), $langs->transnoentitiesnoconv("RevenueStamp")).'</td></tr>'; print '<tr class="oddeven nohover"><td class="" colspan="3">'.$langs->trans("NoLocalTaxXForThisCountry", $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("Dictionaries"), $langs->transnoentitiesnoconv("DictionaryRevenueStamp"), $langs->transnoentitiesnoconv("RevenueStamp")).'</td></tr>';

View File

@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'compta', 'accountancy')); $langs->loadLangs(array('admin', 'compta', 'accountancy'));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -56,8 +57,7 @@ $list = array(
$accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE; $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
if ($action == 'update') if ($action == 'update') {
{
$error = 0; $error = 0;
$accounting_modes = array( $accounting_modes = array(
@ -85,21 +85,34 @@ if ($action == 'update')
} }
$report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha'); $report_include_varpay = GETPOST('ACCOUNTING_REPORTS_INCLUDE_VARPAY', 'alpha');
if (!empty($report_include_varpay)) if (!empty($report_include_varpay)) {
if ($report_include_varpay == 'yes') if ($report_include_varpay == 'yes') {
if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', 1, 'chaine', 0, '', $conf->entity)) {
if ($report_include_varpay == 'no') $error++;
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) $error++; }
}
}
if ($report_include_varpay == 'no') {
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_VARPAY', $conf->entity)) {
$error++;
}
}
$report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha'); $report_include_loan = GETPOST('ACCOUNTING_REPORTS_INCLUDE_LOAN', 'alpha');
if (!empty($report_include_loan)) if (!empty($report_include_loan)) {
if ($report_include_loan == 'yes') if ($report_include_loan == 'yes') {
if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) $error++; if (!dolibarr_set_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', 1, 'chaine', 0, '', $conf->entity)) {
if ($report_include_loan == 'no') $error++;
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) $error++; }
}
}
if ($report_include_loan == 'no') {
if (!dolibarr_del_const($db, 'ACCOUNTING_REPORTS_INCLUDE_LOAN', $conf->entity)) {
$error++;
}
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -157,8 +170,7 @@ print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
print "</tr>\n"; print "</tr>\n";
foreach ($list as $key) foreach ($list as $key) {
{
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param

View File

@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'sendings', 'deliveries')); $langs->loadLangs(array('admin', 'sendings', 'deliveries'));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -43,35 +44,32 @@ $action = GETPOST('action', 'aZ09');
*/ */
// Shipment note // Shipment note
if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) {
{
// This option should always be set to on when module is on. // This option should always be set to on when module is on.
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity);
} }
/* /*
if ($action == 'activate_sending') if ($action == 'activate_sending')
{ {
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity);
header("Location: confexped.php"); header("Location: confexped.php");
exit; exit;
} }
if ($action == 'disable_sending') if ($action == 'disable_sending')
{ {
dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity); dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity);
header("Location: confexped.php"); header("Location: confexped.php");
exit; exit;
} }
*/ */
// Delivery note // Delivery note
if ($action == 'activate_delivery') if ($action == 'activate_delivery') {
{
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity); // We must also enable this
dolibarr_set_const($db, "MAIN_SUBMODULE_DELIVERY", "1", 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SUBMODULE_DELIVERY", "1", 'chaine', 0, '', $conf->entity);
header("Location: confexped.php"); header("Location: confexped.php");
exit; exit;
} elseif ($action == 'disable_delivery') } elseif ($action == 'disable_delivery') {
{
dolibarr_del_const($db, "MAIN_SUBMODULE_DELIVERY", $conf->entity); dolibarr_del_const($db, "MAIN_SUBMODULE_DELIVERY", $conf->entity);
header("Location: confexped.php"); header("Location: confexped.php");
exit; exit;
@ -131,8 +129,7 @@ print '<td>';
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
if (empty($conf->global->MAIN_SUBMODULE_DELIVERY)) if (empty($conf->global->MAIN_SUBMODULE_DELIVERY)) {
{
print '<a href="confexped.php?action=activate_delivery">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a href="confexped.php?action=activate_delivery">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
} else { } else {
print '<a href="confexped.php?action=disable_delivery">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>'; print '<a href="confexped.php?action=disable_delivery">'.img_picto($langs->trans("Enabled"), 'switch_on').'</a>';

View File

@ -30,8 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$rowid = GETPOST('rowid', 'int'); $rowid = GETPOST('rowid', 'int');
$entity = GETPOST('entity', 'int'); $entity = GETPOST('entity', 'int');
@ -49,37 +50,38 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (empty($sortfield)) $sortfield = 'entity,name'; if (empty($sortfield)) {
if (empty($sortorder)) $sortorder = 'ASC'; $sortfield = 'entity,name';
}
if (empty($sortorder)) {
$sortorder = 'ASC';
}
/* /*
* Actions * Actions
*/ */
if ($action == 'add' || (GETPOST('add') && $action != 'update')) if ($action == 'add' || (GETPOST('add') && $action != 'update')) {
{
$error = 0; $error = 0;
if (empty($constname)) if (empty($constname)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors');
$error++; $error++;
} }
if ($constvalue == '') if ($constvalue == '') {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Value")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Value")), null, 'errors');
$error++; $error++;
} }
if (!$error) if (!$error) {
{ if (dolibarr_set_const($db, $constname, $constvalue, 'chaine', 1, $constnote, $entity) >= 0) {
if (dolibarr_set_const($db, $constname, $constvalue, 'chaine', 1, $constnote, $entity) >= 0)
{
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$action = ""; $action = "";
$constname = ""; $constname = "";
@ -92,50 +94,44 @@ if ($action == 'add' || (GETPOST('add') && $action != 'update'))
} }
// Mass update // Mass update
if (!empty($consts) && $action == 'update') if (!empty($consts) && $action == 'update') {
{
$nbmodified = 0; $nbmodified = 0;
foreach ($consts as $const) foreach ($consts as $const) {
{ if (!empty($const["check"])) {
if (!empty($const["check"])) if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0) {
{
if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0)
{
$nbmodified++; $nbmodified++;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
if ($nbmodified > 0) setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); if ($nbmodified > 0) {
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
}
$action = ''; $action = '';
} }
// Mass delete // Mass delete
if (!empty($consts) && $action == 'delete') if (!empty($consts) && $action == 'delete') {
{
$nbdeleted = 0; $nbdeleted = 0;
foreach ($consts as $const) foreach ($consts as $const) {
{ if (!empty($const["check"])) { // Is checkbox checked
if (!empty($const["check"])) // Is checkbox checked if (dolibarr_del_const($db, $const["rowid"], -1) >= 0) {
{
if (dolibarr_del_const($db, $const["rowid"], -1) >= 0)
{
$nbdeleted++; $nbdeleted++;
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
} }
if ($nbdeleted > 0) setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); if ($nbdeleted > 0) {
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
}
$action = ''; $action = '';
} }
// Delete line from delete picto // Delete line from delete picto
if ($action == 'delete') if ($action == 'delete') {
{ if (dolibarr_del_const($db, $rowid, $entity) >= 0) {
if (dolibarr_del_const($db, $rowid, $entity) >= 0)
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -153,8 +149,7 @@ $wikihelp = 'EN:Setup_Other|FR:Paramétrage_Divers|ES:Configuración_Varios';
llxHeader('', $langs->trans("Setup"), $wikihelp); llxHeader('', $langs->trans("Setup"), $wikihelp);
// Add logic to show/hide buttons // Add logic to show/hide buttons
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
?> ?>
<script type="text/javascript"> <script type="text/javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
@ -173,7 +168,7 @@ jQuery(document).ready(function() {
}); });
}); });
</script> </script>
<?php <?php
} }
print load_fiche_titre($langs->trans("OtherSetup"), '', 'title_setup'); print load_fiche_titre($langs->trans("OtherSetup"), '', 'title_setup');
@ -196,8 +191,7 @@ print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, '
print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
if (!empty($conf->multicompany->enabled) && !$user->entity) if (!empty($conf->multicompany->enabled) && !$user->entity) {
{
print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
} }
print getTitleFieldOfList("", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList("", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
@ -219,8 +213,7 @@ print '</td>';
print '<td>'; print '<td>';
print '</td>'; print '</td>';
// Limit to superadmin // Limit to superadmin
if (!empty($conf->multicompany->enabled) && !$user->entity) if (!empty($conf->multicompany->enabled) && !$user->entity) {
{
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">'; print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
print '</td>'; print '</td>';
@ -245,20 +238,23 @@ $sql .= ", tms";
$sql .= ", entity"; $sql .= ", entity";
$sql .= " FROM ".MAIN_DB_PREFIX."const"; $sql .= " FROM ".MAIN_DB_PREFIX."const";
$sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; $sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")";
if ((empty($user->entity) || $user->admin) && $debug) {} // to force for superadmin to debug if ((empty($user->entity) || $user->admin) && $debug) {
elseif (!GETPOST('visible') || GETPOST('visible') != 'all') $sql .= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits } elseif (!GETPOST('visible') || GETPOST('visible') != 'all') {
if (GETPOST('name')) $sql .= natural_search("name", GETPOST('name')); // to force for superadmin to debug
$sql .= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits
}
if (GETPOST('name')) {
$sql .= natural_search("name", GETPOST('name'));
}
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
dol_syslog("Const::listConstant", LOG_DEBUG); dol_syslog("Const::listConstant", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print "\n"; print "\n";
@ -284,8 +280,7 @@ if ($result)
print '</td>'; print '</td>';
// Entity limit to superadmin // Entity limit to superadmin
if (!empty($conf->multicompany->enabled) && !$user->entity) if (!empty($conf->multicompany->enabled) && !$user->entity) {
{
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="1" name="const['.$i.'][entity]" value="'.$obj->entity.'">'; print '<input type="text" class="flat" size="1" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
print '</td>'; print '</td>';
@ -295,8 +290,7 @@ if ($result)
print '<input type="hidden" name="const['.$i.'][entity]" value="'.$obj->entity.'">'; print '<input type="hidden" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
} }
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.'" name="const['.$i.'][check]" value="1">'; print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.'" name="const['.$i.'][check]" value="1">';
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
@ -313,8 +307,7 @@ if ($result)
print '</table>'; print '</table>';
print '</div>'; print '</div>';
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax) {
{
print '<br>'; print '<br>';
print '<div id="updateconst" class="right">'; print '<div id="updateconst" class="right">';
print '<input type="submit" name="update" class="button marginbottomonly" value="'.$langs->trans("Modify").'">'; print '<input type="submit" name="update" class="button marginbottomonly" value="'.$langs->trans("Modify").'">';

View File

@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "errors", "contracts")); $langs->loadLangs(array("admin", "errors", "contracts"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -39,8 +41,7 @@ $label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha');
$type = 'contract'; $type = 'contract';
if (empty($conf->global->CONTRACT_ADDON)) if (empty($conf->global->CONTRACT_ADDON)) {
{
$conf->global->CONTRACT_ADDON = 'mod_contract_serpis'; $conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
} }
@ -51,22 +52,23 @@ if (empty($conf->global->CONTRACT_ADDON))
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconst = GETPOST('maskconstcontract', 'alpha'); $maskconst = GETPOST('maskconstcontract', 'alpha');
$maskvalue = GETPOST('maskcontract', 'alpha'); $maskvalue = GETPOST('maskcontract', 'alpha');
if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if ($maskconst) {
$res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'specimen') // For contract } elseif ($action == 'specimen') { // For contract
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$contract = new Contrat($db); $contract = new Contrat($db);
@ -75,25 +77,21 @@ if ($action == 'updateMask')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($contract, $langs) > 0) if ($module->write_file($contract, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=contract&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=contract&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -104,26 +102,19 @@ if ($action == 'updateMask')
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} } elseif ($action == 'set') {
// Activate a model
// Activate a model
elseif ($action == 'set')
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} elseif ($action == 'del') } elseif ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->CONTRACT_ADDON_PDF == "$value") {
if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity);
}
} }
} } elseif ($action == 'setdoc') {
// Set default model
// Set default model if (dolibarr_set_const($db, "CONTRACT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
elseif ($action == 'setdoc')
{
if (dolibarr_set_const($db, "CONTRACT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->CONTRACT_ADDON_PDF = $value; $conf->global->CONTRACT_ADDON_PDF = $value;
@ -131,18 +122,15 @@ elseif ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} elseif ($action == 'setmod') } elseif ($action == 'setmod') {
{
// 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, "CONTRACT_ADDON", $value, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "CONTRACT_ADDON", $value, 'chaine', 0, '', $conf->entity);
} elseif ($action == 'set_other') } elseif ($action == 'set_other') {
{
$freetext = GETPOST('CONTRACT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $freetext = GETPOST('CONTRACT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
@ -152,10 +140,11 @@ elseif ($action == 'setdoc')
$value = GETPOST('activate_hideClosedServiceByDefault', 'alpha'); $value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
$res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity); $res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) $error++; if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
@ -197,19 +186,14 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/contract/"); $dir = dol_buildpath($reldir."core/modules/contract/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false) if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
{
if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
{
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
require_once $dir.$file.'.php'; require_once $dir.$file.'.php';
@ -217,11 +201,14 @@ foreach ($dirmodels as $reldir)
$module = new $file($db); $module = new $file($db);
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
if ($module->isEnabled()) if ($module->isEnabled()) {
{
print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
print $module->info(); print $module->info();
print '</td>'; print '</td>';
@ -232,14 +219,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') {
print $langs->trans($tmp);
} else {
print $tmp;
} }
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->CONTRACT_ADDON == "$file") if ($conf->global->CONTRACT_ADDON == "$file") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
@ -258,8 +246,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -294,12 +283,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -321,31 +308,23 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{ foreach (array('', '/doc') as $valdir) {
foreach (array('', '/doc') as $valdir)
{
$realpath = $reldir."core/modules/contract".$valdir; $realpath = $reldir."core/modules/contract".$valdir;
$dir = dol_buildpath($realpath); $dir = dol_buildpath($realpath);
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -353,21 +332,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -381,8 +365,7 @@ foreach ($dirmodels as $reldir)
// Defaut // Defaut
print '<td class="center">'; print '<td class="center">';
if ($conf->global->CONTRACT_ADDON_PDF == $name) if ($conf->global->CONTRACT_ADDON_PDF == $name) {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -392,8 +375,7 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
} }
$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
@ -412,8 +394,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -452,15 +433,16 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
print '<br>'; print '<br>';
$variablename = 'CONTRACT_FREE_TEXT'; $variablename = 'CONTRACT_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -28,8 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other", "agenda")); $langs->loadLangs(array("admin", "other", "agenda"));
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Parameters // Parameters
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -71,8 +72,7 @@ $head = dav_admin_prepare_head();
print dol_get_fiche_head($head, 'webdav', '', -1, 'action'); print dol_get_fiche_head($head, 'webdav', '', -1, 'action');
if ($action == 'edit') if ($action == 'edit') {
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
@ -80,9 +80,10 @@ if ($action == 'edit')
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val) foreach ($arrayofparameters as $key => $val) {
{ if (isset($val['enabled']) && empty($val['enabled'])) {
if (isset($val['enabled']) && empty($val['enabled'])) continue; continue;
}
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
@ -93,11 +94,9 @@ if ($action == 'edit')
} }
print $form->textwithpicto($label, $tooltiphelp); print $form->textwithpicto($label, $tooltiphelp);
print '</td><td>'; print '</td><td>';
if ($key == 'DAV_ALLOW_PRIVATE_DIR') if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
{
print $langs->trans("AlwaysActive"); print $langs->trans("AlwaysActive");
} elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
{
print $form->selectyesno($key, $conf->global->$key, 1); print $form->selectyesno($key, $conf->global->$key, 1);
} else { } else {
print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'">'; print '<input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'">';
@ -117,8 +116,7 @@ if ($action == 'edit')
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach ($arrayofparameters as $key => $val) foreach ($arrayofparameters as $key => $val) {
{
print '<tr class="oddeven"><td>'; print '<tr class="oddeven"><td>';
$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
$label = $langs->trans($key); $label = $langs->trans($key);
@ -128,11 +126,9 @@ if ($action == 'edit')
} }
print $form->textwithpicto($label, $tooltiphelp); print $form->textwithpicto($label, $tooltiphelp);
print '</td><td>'; print '</td><td>';
if ($key == 'DAV_ALLOW_PRIVATE_DIR') if ($key == 'DAV_ALLOW_PRIVATE_DIR') {
{
print $langs->trans("AlwaysActive"); print $langs->trans("AlwaysActive");
} elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') {
{
print yn($conf->global->$key); print yn($conf->global->$key);
} else { } else {
print $conf->global->$key; print $conf->global->$key;
@ -174,8 +170,7 @@ $message = '';
$url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>'; $url = '<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', '{url}')); $message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', '{url}'));
$message .= '<br>'; $message .= '<br>';
if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) {
{
$urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : ''); $urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : '');
$url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>'; $url = '<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
$message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', '{url}')); $message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', '{url}'));

View File

@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
global $conf; global $conf;
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other")); $langs->loadLangs(array("admin", "other"));
@ -43,19 +45,16 @@ $action = GETPOST('action', 'aZ09');
*/ */
// Set modes // Set modes
if ($action == 'set') if ($action == 'set') {
{
$db->begin(); $db->begin();
$result1 = dolibarr_set_const($db, "DEBUGBAR_LOGS_LINES_NUMBER", GETPOST('DEBUGBAR_LOGS_LINES_NUMBER', 'int'), 'chaine', 0, '', 0); $result1 = dolibarr_set_const($db, "DEBUGBAR_LOGS_LINES_NUMBER", GETPOST('DEBUGBAR_LOGS_LINES_NUMBER', 'int'), 'chaine', 0, '', 0);
$result2 = dolibarr_set_const($db, "DEBUGBAR_USE_LOG_FILE", GETPOST('DEBUGBAR_USE_LOG_FILE', 'int'), 'chaine', 0, '', 0); $result2 = dolibarr_set_const($db, "DEBUGBAR_USE_LOG_FILE", GETPOST('DEBUGBAR_USE_LOG_FILE', 'int'), 'chaine', 0, '', 0);
if ($result1 < 0 || $result2 < 0) if ($result1 < 0 || $result2 < 0) {
{
$error++; $error++;
} }
if (!$error) if (!$error) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
@ -76,8 +75,7 @@ $form = new Form($db);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$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("DebugBarSetup"), $linkback, 'title_setup'); print load_fiche_titre($langs->trans("DebugBarSetup"), $linkback, 'title_setup');
if (!function_exists('mb_check_encoding')) if (!function_exists('mb_check_encoding')) {
{
$langs->load("errors"); $langs->load("errors");
print info_admin($langs->trans("ErrorPHPNeedModule", 'mbstring'), 0, 0, 'error'); print info_admin($langs->trans("ErrorPHPNeedModule", 'mbstring'), 0, 0, 'error');
} }

View File

@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'errors')); $langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'errors'));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$id = GETPOST('rowid', 'int'); $id = GETPOST('rowid', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -46,12 +48,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) $sortfield = 'page,param'; if (!$sortfield) {
if (!$sortorder) $sortorder = 'ASC'; $sortfield = 'page,param';
}
if (!$sortorder) {
$sortorder = 'ASC';
}
$defaulturl = GETPOST('defaulturl', 'alphanohtml'); $defaulturl = GETPOST('defaulturl', 'alphanohtml');
$defaultkey = GETPOST('defaultkey', 'alphanohtml'); $defaultkey = GETPOST('defaultkey', 'alphanohtml');
@ -71,18 +79,23 @@ $hookmanager->initHooks(array('admindefaultvalues', 'globaladmin'));
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
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')) { // All tests are required to be compatible with all browsers
{
$defaulturl = ''; $defaulturl = '';
$defaultkey = ''; $defaultkey = '';
$defaultvalue = ''; $defaultvalue = '';
@ -90,60 +103,51 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_array_options = array(); $search_array_options = array();
} }
if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') {
{ if (GETPOST('value')) {
if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity);
else dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity); } else {
dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity);
}
} }
if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) {
{
$error = 0; $error = 0;
if (($action == 'add' || (GETPOST('add') && $action != 'update'))) if (($action == 'add' || (GETPOST('add') && $action != 'update'))) {
{ if (empty($defaulturl)) {
if (empty($defaulturl))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
$error++; $error++;
} }
if (empty($defaultkey)) if (empty($defaultkey)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
$error++; $error++;
} }
} }
if (GETPOST('actionmodify')) if (GETPOST('actionmodify')) {
{ if (empty($urlpage)) {
if (empty($urlpage))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors');
$error++; $error++;
} }
if (empty($key)) if (empty($key)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors');
$error++; $error++;
} }
} }
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
if ($action == 'add' || (GETPOST('add') && $action != 'update')) if ($action == 'add' || (GETPOST('add') && $action != 'update')) {
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")";
} }
if (GETPOST('actionmodify')) if (GETPOST('actionmodify')) {
{
$sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'";
$sql .= " WHERE rowid = ".$id; $sql .= " WHERE rowid = ".$id;
} }
$result = $db->query($sql); $result = $db->query($sql);
if ($result > 0) if ($result > 0) {
{
$db->commit(); $db->commit();
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$action = ""; $action = "";
@ -159,13 +163,11 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac
} }
// Delete line from delete picto // Delete line from delete picto
if ($action == 'delete') if ($action == 'delete') {
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."default_values WHERE rowid = ".$db->escape($id); $sql = "DELETE FROM ".MAIN_DB_PREFIX."default_values WHERE rowid = ".$db->escape($id);
// Delete const // Delete const
$result = $db->query($sql); $result = $db->query($sql);
if ($result >= 0) if ($result >= 0) {
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
} else { } else {
dol_print_error($db); dol_print_error($db);
@ -187,8 +189,7 @@ llxHeader('', $langs->trans("Setup"), $wikihelp);
$param = '&mode='.$mode; $param = '&mode='.$mode;
$enabledisablehtml = $langs->trans("EnableDefaultValues").' '; $enabledisablehtml = $langs->trans("EnableDefaultValues").' ';
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
{
// Button off, click to enable // Button off, click to enable
$enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;token='.newToken().'&amp;value=1'.$param.'">'; $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_DEFAULT_VALUES&amp;token='.newToken().'&amp;value=1'.$param.'">';
$enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
@ -205,16 +206,30 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl
print '<span class="opacitymedium">'.$langs->trans("DefaultValuesDesc")."</span><br>\n"; print '<span class="opacitymedium">'.$langs->trans("DefaultValuesDesc")."</span><br>\n";
print "<br>\n"; print "<br>\n";
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); }
if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl); if ($limit > 0 && $limit != $conf->liste_limit) {
if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey); $param .= '&limit='.urlencode($limit);
if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue); }
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($defaulturl) {
$param .= '&defaulturl='.urlencode($defaulturl);
}
if ($defaultkey) {
$param .= '&defaultkey='.urlencode($defaultkey);
}
if ($defaultvalue) {
$param .= '&defaultvalue='.urlencode($defaultvalue);
}
print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && !empty($debug)) ? '?debug=1' : '').'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && !empty($debug)) ? '?debug=1' : '').'" method="POST">';
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="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
@ -226,12 +241,10 @@ $head = defaultvalues_prepare_head();
print dol_get_fiche_head($head, $mode, '', -1, ''); print dol_get_fiche_head($head, $mode, '', -1, '');
if ($mode == 'sortorder') if ($mode == 'sortorder') {
{
print info_admin($langs->trans("WarningSettingSortOrder")).'<br>'; print info_admin($langs->trans("WarningSettingSortOrder")).'<br>';
} }
if ($mode == 'mandatory') if ($mode == 'mandatory') {
{
print info_admin($langs->trans("FeatureSupportedOnTextFieldsOnly")).'<br>'; print info_admin($langs->trans("FeatureSupportedOnTextFieldsOnly")).'<br>';
} }
@ -244,15 +257,17 @@ print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
// Page // Page
$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') {
else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2'); $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');
}
$texthelp .= '<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate"); $texthelp .= '<br><br>'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
$texturl = $form->textwithpicto($langs->trans("RelativeURL"), $texthelp); $texturl = $form->textwithpicto($langs->trans("RelativeURL"), $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
$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField"); $texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField");
if ($mode != 'sortorder') if ($mode != 'sortorder') {
{
$textkey = $form->textwithpicto($langs->trans("Field"), $texthelp); $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
} else { } else {
$texthelp = 'field or alias.field'; $texthelp = 'field or alias.field';
@ -260,15 +275,12 @@ if ($mode != 'sortorder')
} }
print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder);
// Value // Value
if ($mode != 'focus' && $mode != 'mandatory') if ($mode != 'focus' && $mode != 'mandatory') {
{ if ($mode != 'sortorder') {
if ($mode != 'sortorder')
{
$substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST $substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST
unset($substitutionarray['__USER_SIGNATURE__']); unset($substitutionarray['__USER_SIGNATURE__']);
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach ($substitutionarray as $key => $val) foreach ($substitutionarray as $key => $val) {
{
$texthelp .= $key.' -> '.$val.'<br>'; $texthelp .= $key.' -> '.$val.'<br>';
} }
$textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip'); $textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
@ -279,8 +291,11 @@ if ($mode != 'focus' && $mode != 'mandatory')
print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder);
} }
// Entity // Entity
if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder); if (!empty($conf->multicompany->enabled) && !$user->entity) {
else print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
} else {
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
}
// Actions // Actions
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";
@ -299,15 +314,13 @@ print '<td>';
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag(GETPOST('defaultkey', 'alphanohtml')).'">'; print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultkey" value="'.dol_escape_htmltag(GETPOST('defaultkey', 'alphanohtml')).'">';
print '</td>'; print '</td>';
// Value // Value
if ($mode != 'focus' && $mode != 'mandatory') if ($mode != 'focus' && $mode != 'mandatory') {
{
print '<td>'; print '<td>';
print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">'; print '<input type="text" class="flat maxwidth100onsmartphone" name="defaultvalue" value="">';
print '</td>'; print '</td>';
} }
// Limit to superadmin // Limit to superadmin
if (!empty($conf->multicompany->enabled) && !$user->entity) if (!empty($conf->multicompany->enabled) && !$user->entity) {
{
print '<td>'; print '<td>';
print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">'; // We see environment, but to change it we must switch on other entity print '<input type="text" class="flat" size="1" disabled name="entity" value="'.$conf->entity.'">'; // We see environment, but to change it we must switch on other entity
print '</td>'; print '</td>';
@ -318,7 +331,9 @@ if (!empty($conf->multicompany->enabled) && !$user->entity)
} }
print '<td class="center">'; print '<td class="center">';
$disabled = ''; $disabled = '';
if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled = ' disabled="disabled"'; if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
$disabled = ' disabled="disabled"';
}
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">'; print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">';
print "</td>\n"; print "</td>\n";
print '</tr>'; print '</tr>';
@ -333,13 +348,11 @@ $sql .= $db->order($sortfield, $sortorder);
dol_syslog("translation::select from table", LOG_DEBUG); dol_syslog("translation::select from table", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num) {
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
print "\n"; print "\n";
@ -348,27 +361,35 @@ if ($result)
// Page // Page
print '<td>'; print '<td>';
if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) print $obj->page; if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) {
else print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($obj->page).'">'; print $obj->page;
} else {
print '<input type="text" name="urlpage" value="'.dol_escape_htmltag($obj->page).'">';
}
print '</td>'."\n"; print '</td>'."\n";
// Field // Field
print '<td>'; print '<td>';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param; if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
else print '<input type="text" name="key" value="'.dol_escape_htmltag($obj->param).'">'; print $obj->param;
} else {
print '<input type="text" name="key" value="'.dol_escape_htmltag($obj->param).'">';
}
print '</td>'."\n"; print '</td>'."\n";
// Value // Value
if ($mode != 'focus' && $mode != 'mandatory') if ($mode != 'focus' && $mode != 'mandatory') {
{
print '<td>'; print '<td>';
/*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">'; /*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">'; print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">'; print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">'; print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
*/ */
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value); if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
else print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">'; print dol_escape_htmltag($obj->value);
} else {
print '<input type="text" name="value" value="'.dol_escape_htmltag($obj->value).'">';
}
print '</td>'; print '</td>';
} }
@ -376,8 +397,7 @@ if ($result)
// Actions // Actions
print '<td class="center">'; print '<td class="center">';
if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
{
print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>'; print '<a class="editfielda marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=edit&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>'; print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.$mode.'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
} else { } else {

View File

@ -30,134 +30,138 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("admin"); $langs->load("admin");
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
if (empty($action)) $action = 'edit'; if (empty($action)) {
$action = 'edit';
}
// Define list of managed delays // Define list of managed delays
$modules = array( $modules = array(
'agenda' => array( 'agenda' => array(
array( array(
'code' => 'MAIN_DELAY_ACTIONS_TODO', 'code' => 'MAIN_DELAY_ACTIONS_TODO',
'img' => 'action' 'img' => 'action'
) )
), ),
'projet' => array( 'projet' => array(
array( array(
'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE', 'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
'img' => 'project' 'img' => 'project'
), ),
array( array(
'code' => 'MAIN_DELAY_TASKS_TODO', 'code' => 'MAIN_DELAY_TASKS_TODO',
'img' => 'projecttask' 'img' => 'projecttask'
) )
), ),
'propal' => array( 'propal' => array(
array( array(
'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE', 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
'img' => 'propal' 'img' => 'propal'
), ),
array( array(
'code' => 'MAIN_DELAY_PROPALS_TO_BILL', 'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
'img' => 'propal' 'img' => 'propal'
) )
), ),
'commande' => array( 'commande' => array(
array( array(
'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS', 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
'img' => 'order' 'img' => 'order'
) )
), ),
'facture' => array( 'facture' => array(
array( array(
'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED', 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
'img' => 'bill' 'img' => 'bill'
) )
), ),
'fournisseur' => array( 'fournisseur' => array(
array( array(
'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS', 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
'img' => 'order' 'img' => 'order'
), ),
array( array(
'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY', 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
'img' => 'bill' 'img' => 'bill'
) )
), ),
'service' => array( 'service' => array(
array( array(
'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES', 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
'img' => 'service' 'img' => 'service'
), ),
array( array(
'code' => 'MAIN_DELAY_RUNNING_SERVICES', 'code' => 'MAIN_DELAY_RUNNING_SERVICES',
'img' => 'service' 'img' => 'service'
) )
), ),
'banque' => array( 'banque' => array(
array( array(
'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE', 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
'img' => 'account' 'img' => 'account'
), ),
array( array(
'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT', 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
'img' => 'account' 'img' => 'account'
) )
), ),
'adherent' => array( 'adherent' => array(
array( array(
'code' => 'MAIN_DELAY_MEMBERS', 'code' => 'MAIN_DELAY_MEMBERS',
'img' => 'user' 'img' => 'user'
) )
), ),
'expensereport' => array( 'expensereport' => array(
array( array(
'code' => 'MAIN_DELAY_EXPENSEREPORTS', 'code' => 'MAIN_DELAY_EXPENSEREPORTS',
'img' => 'trip' 'img' => 'trip'
), ),
/* TODO Enable this /* TODO Enable this
array( array(
'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY', 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
'img' => 'trip' 'img' => 'trip'
)*/ )*/
), ),
'holiday' => array( 'holiday' => array(
array( array(
'code' => 'MAIN_DELAY_HOLIDAYS', 'code' => 'MAIN_DELAY_HOLIDAYS',
'img' => 'holiday' 'img' => 'holiday'
), ),
), ),
); );
$labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly")); $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) { if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) {
$conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php
} }
if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) { if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) {
$conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php
} }
if (!isset($conf->global->MAIN_DELAY_MEMBERS)) { if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
$conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
} }
if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) { if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
$conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
} }
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
} }
if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) { if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
$conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7; $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
} }
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
} }
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
} }
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
$conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
} }
@ -166,32 +170,31 @@ if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
* Actions * Actions
*/ */
if ($action == 'update') if ($action == 'update') {
{ foreach ($modules as $module => $delays) {
foreach ($modules as $module => $delays) if (!empty($conf->$module->enabled)) {
{ foreach ($delays as $delay) {
if (!empty($conf->$module->enabled)) if (GETPOST($delay['code']) != '') {
{ dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
foreach ($delays as $delay) }
{ }
if (GETPOST($delay['code']) != '') }
{ }
dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
}
}
}
}
dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
// For update value with percentage // For update value with percentage
$plus = ''; $plus = '';
if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
// Update values $plus = '_PERCENTAGE';
for ($i = 0; $i < 4; $i++) { }
if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); // Update values
} for ($i = 0; $i < 4; $i++) {
if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) {
dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
}
}
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@ -213,158 +216,165 @@ print '<span class="opacitymedium">'.$langs->transnoentities("DelaysOfToleranceD
print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n"; print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."</span><br>\n";
print "<br>\n"; print "<br>\n";
if ($action == 'edit') if ($action == 'edit') {
{ print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">';
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="form_index">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
foreach ($modules as $module => $delays) foreach ($modules as $module => $delays) {
{ if (!empty($conf->$module->enabled)) {
if (!empty($conf->$module->enabled)) foreach ($delays as $delay) {
{ $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
foreach ($delays as $delay) print '<tr class="oddeven">';
{ print '<td width="20px">'.img_object('', $delay['img']).'</td>';
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td class="nowraponall">';
print '<tr class="oddeven">'; print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>';
print '<td width="20px">'.img_object('', $delay['img']).'</td>'; }
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td><td class="nowraponall">'; }
print '<input class="right maxwidth75" type="number" name="'.$delay['code'].'" value="'.$value.'"> '.$langs->trans("days").'</td></tr>'; }
}
}
}
print '</table>'; print '</table>';
print '<br>'; print '<br>';
// Show if meteo is enabled // Show if meteo is enabled
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">'; print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO)); print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO));
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
} else { } else {
/* /*
* Show parameters * Show parameters
*/ */
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
foreach ($modules as $module => $delays) foreach ($modules as $module => $delays) {
{ if (!empty($conf->$module->enabled)) {
if (!empty($conf->$module->enabled)) foreach ($delays as $delay) {
{ $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
foreach ($delays as $delay) print '<tr class="oddeven">';
{ print '<td width="20px">'.img_object('', $delay['img']).'</td>';
$value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>';
print '<tr class="oddeven">'; print '<td class="right">'.$value.' '.$langs->trans("days").'</td></tr>';
print '<td width="20px">'.img_object('', $delay['img']).'</td>'; }
print '<td>'.$langs->trans('Delays_'.$delay['code']).'</td>'; }
print '<td class="right">'.$value.' '.$langs->trans("days").'</td></tr>'; }
}
}
}
print '</table>'; print '</table>';
print '<br>'; print '<br>';
// Show if meteo is enabled // Show if meteo is enabled
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td class="center" width="120px">'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">'; print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">';
print $labelmeteo[$conf->global->MAIN_DISABLE_METEO]; print $labelmeteo[$conf->global->MAIN_DISABLE_METEO];
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
} }
print '<br>'; print '<br>';
if ($conf->global->MAIN_DISABLE_METEO != 1) { if ($conf->global->MAIN_DISABLE_METEO != 1) {
// Show logo for weather // Show logo for weather
print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> '; print '<span class="opacitymedium">'.$langs->trans("DescWeather").'</span> ';
if ($action == 'edit') { if ($action == 'edit') {
$str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod')); $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod'));
$str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod')); $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod'));
if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
else $str_mode_enabled = $str_mode_percentage; $str_mode_enabled = $str_mode_std;
print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>'; } else {
print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />'; $str_mode_enabled = $str_mode_percentage;
}
print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
print '<br><br>'; print '<br><br>';
} else { } else {
if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled'); if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
else print $langs->trans('MeteoPercentageModEnabled'); print $langs->trans('MeteoStdModEnabled');
print '<br><br>'; } else {
} print $langs->trans('MeteoPercentageModEnabled');
}
print '<br><br>';
}
$offset = 0; $offset = 0;
$cursor = 10; // By default $cursor = 10; // By default
//if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET; //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
//if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP; //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
$level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0; $level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) {
$level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1; $level0 = $conf->global->MAIN_METEO_LEVEL0;
$level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2; }
$level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3; $level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) {
$text = ''; $options = 'class="valignmiddle" height="60px"'; $level1 = $conf->global->MAIN_METEO_LEVEL1;
}
$level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) {
$level2 = $conf->global->MAIN_METEO_LEVEL2;
}
$level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) {
$level3 = $conf->global->MAIN_METEO_LEVEL3;
}
$text = ''; $options = 'class="valignmiddle" height="60px"';
if ($action == 'edit') { if ($action == 'edit') {
print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>'; print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
print '<div>'; print '<div>';
print '<div class="inline-block" style="padding-right: 20px">'; print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 0, $options); print img_weather($text, 0, $options);
print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>'; print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 1, $options); print img_weather($text, 1, $options);
print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>'; print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 2, $options); print img_weather($text, 2, $options);
print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>'; print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 3, $options); print img_weather($text, 3, $options);
print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>'; print ' &lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>'; print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
print '<div>'; print '<div>';
print '<div class="inline-block" style="padding-right: 20px">'; print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 0, $options); print img_weather($text, 0, $options);
print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/>&nbsp;%</td>'; print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 1, $options); print img_weather($text, 1, $options);
print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/>&nbsp;%</td>'; print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 2, $options); print img_weather($text, 2, $options);
print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/>&nbsp;%</td>'; print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">'; print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 3, $options); print img_weather($text, 3, $options);
print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/>&nbsp;%</td>'; print ' &lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/>&nbsp;%</td>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
print '</div>'; print '</div>';
?> ?>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/delivery/class/delivery.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "sendings", "deliveries", "other")); $langs->loadLangs(array("admin", "sendings", "deliveries", "other"));
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha'); $value = GETPOST('value', 'alpha');
@ -52,39 +54,40 @@ $type = 'delivery';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateMask') if ($action == 'updateMask') {
{
$maskconstdelivery = GETPOST('maskconstdelivery', 'alpha'); $maskconstdelivery = GETPOST('maskconstdelivery', 'alpha');
$maskdelivery = GETPOST('maskdelivery', 'alpha'); $maskdelivery = GETPOST('maskdelivery', 'alpha');
if ($maskconstdelivery) $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity); if ($maskconstdelivery) {
$res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity);
}
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if ($action == 'set_DELIVERY_FREE_TEXT') if ($action == 'set_DELIVERY_FREE_TEXT') {
{
$free = GETPOST('DELIVERY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $free = GETPOST('DELIVERY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
$res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "DELIVERY_FREE_TEXT", $free, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++; if (!($res > 0)) {
$error++;
}
if (!$error) if (!$error) {
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
if ($action == 'specimen') if ($action == 'specimen') {
{
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$sending = new Delivery($db); $sending = new Delivery($db);
@ -93,25 +96,21 @@ if ($action == 'specimen')
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$file = dol_buildpath($reldir."core/modules/delivery/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/delivery/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file)) {
{
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound) {
{
require_once $file; require_once $file;
$module = new $classname($db); $module = new $classname($db);
if ($module->write_file($sending, $langs) > 0) if ($module->write_file($sending, $langs) > 0) {
{
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=delivery&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=delivery&file=SPECIMEN.pdf");
return; return;
} else { } else {
@ -124,24 +123,21 @@ if ($action == 'specimen')
} }
} }
if ($action == 'set') if ($action == 'set') {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
if ($action == 'del') if ($action == 'del') {
{
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{ if ($conf->global->DELIVERY_ADDON_PDF == "$value") {
if ($conf->global->DELIVERY_ADDON_PDF == "$value") dolibarr_del_const($db, 'DELIVERY_ADDON_PDF', $conf->entity); dolibarr_del_const($db, 'DELIVERY_ADDON_PDF', $conf->entity);
}
} }
} }
if ($action == 'setdoc') if ($action == 'setdoc') {
{ if (dolibarr_set_const($db, "DELIVERY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
if (dolibarr_set_const($db, "DELIVERY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
{
// La constante qui a ete lue en avant du nouveau set // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // on passe donc par une variable pour avoir un affichage coherent
$conf->global->DELIVERY_ADDON_PDF = $value; $conf->global->DELIVERY_ADDON_PDF = $value;
@ -149,14 +145,12 @@ if ($action == 'setdoc')
// On active le modele // On active le modele
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0) {
{
$ret = addDocumentModel($value, $type, $label, $scandir); $ret = addDocumentModel($value, $type, $label, $scandir);
} }
} }
if ($action == 'setmod') if ($action == 'setmod') {
{
// 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
@ -197,17 +191,13 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/delivery/"); $dir = dol_buildpath($reldir."core/modules/delivery/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
if (preg_match('/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) { if (preg_match('/^mod_delivery_([a-z0-9_]*)\.php$/', $file)) {
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
@ -215,11 +205,14 @@ foreach ($dirmodels as $reldir)
$module = new $file; $module = new $file;
if ($module->isEnabled()) if ($module->isEnabled()) {
{
// Show modules according to features level // Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; continue;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
continue;
}
print '<tr class="oddeven"><td>'.$module->name."</td><td>\n"; print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
print $module->info(); print $module->info();
@ -231,13 +224,15 @@ foreach ($dirmodels as $reldir)
if (preg_match('/^Error/', $tmp)) { if (preg_match('/^Error/', $tmp)) {
$langs->load("errors"); $langs->load("errors");
print '<div class="error">'.$langs->trans($tmp).'</div>'; print '<div class="error">'.$langs->trans($tmp).'</div>';
} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); } elseif ($tmp == 'NotConfigured') {
else print $tmp; print $langs->trans($tmp);
} else {
print $tmp;
}
print '</td>'."\n"; print '</td>'."\n";
print '<td class="center">'; print '<td class="center">';
if ($conf->global->DELIVERY_ADDON_NUMBER == "$file") if ($conf->global->DELIVERY_ADDON_NUMBER == "$file") {
{
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
} else { } else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
@ -254,8 +249,9 @@ foreach ($dirmodels as $reldir)
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
}
$htmltooltip .= $nextval.'<br>'; $htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
@ -294,12 +290,10 @@ $sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity; $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql) {
{
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows) {
{
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
@ -320,28 +314,21 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir) {
{
$dir = dol_buildpath($reldir."core/modules/delivery/doc/"); $dir = dol_buildpath($reldir."core/modules/delivery/doc/");
if (is_dir($dir)) if (is_dir($dir)) {
{
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle)) {
{ while (($file = readdir($handle)) !== false) {
while (($file = readdir($handle)) !== false)
{
$filelist[] = $file; $filelist[] = $file;
} }
closedir($handle); closedir($handle);
arsort($filelist); arsort($filelist);
foreach ($filelist as $file) foreach ($filelist as $file) {
{ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (file_exists($dir.'/'.$file)) {
{
if (file_exists($dir.'/'.$file))
{
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
@ -349,21 +336,26 @@ foreach ($dirmodels as $reldir)
$module = new $classname($db); $module = new $classname($db);
$modulequalified = 1; $modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; $modulequalified = 0;
}
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) if ($modulequalified) {
{
print '<tr class="oddeven"><td width="100">'; print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td><td>\n"; print "</td><td>\n";
if (method_exists($module, 'info')) print $module->info($langs); if (method_exists($module, 'info')) {
else print $module->description; print $module->info($langs);
} else {
print $module->description;
}
print '</td>'; print '</td>';
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def)) {
{
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
@ -377,8 +369,7 @@ foreach ($dirmodels as $reldir)
// Default // Default
print "<td align=\"center\">"; print "<td align=\"center\">";
if ($conf->global->DELIVERY_ADDON_PDF == "$name") if ($conf->global->DELIVERY_ADDON_PDF == "$name") {
{
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
@ -396,8 +387,7 @@ foreach ($dirmodels as $reldir)
// Preview // Preview
print '<td class="center">'; print '<td class="center">';
if ($module->type == 'pdf') if ($module->type == 'pdf') {
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
} else { } else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic'); print img_object($langs->trans("PreviewNotAvailable"), 'generic');
@ -430,7 +420,9 @@ print "</tr>\n";
$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>'; $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
foreach ($substitutionarray as $key => $val) $htmltext .= $key.'<br>'; foreach ($substitutionarray as $key => $val) {
$htmltext .= $key.'<br>';
}
$htmltext .= '</i>'; $htmltext .= '</i>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
@ -439,8 +431,7 @@ print '<input type="hidden" name="action" value="set_DELIVERY_FREE_TEXT">';
print '<tr class="oddeven"><td colspan="2">'; print '<tr class="oddeven"><td colspan="2">';
print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>'; print $form->textwithpicto($langs->trans("FreeLegalTextOnDeliveryReceipts"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
$variablename = 'DELIVERY_FREE_TEXT'; $variablename = 'DELIVERY_FREE_TEXT';
if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
{
print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>'; print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
} else { } else {
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';

View File

@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'sendings', 'deliveries')); $langs->loadLangs(array('admin', 'other', 'sendings', 'deliveries'));
@ -45,13 +46,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'delivery'; //Must be the $table_element of the class that manage extrafield $elementtype = 'delivery'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -84,8 +89,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -98,8 +102,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -111,8 +114,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

View File

@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'sendings')); $langs->loadLangs(array('admin', 'other', 'sendings'));
@ -46,13 +47,17 @@ $form = new Form($db);
// List of supported format // List of supported format
$tmptype2label = ExtraFields::$type2label; $tmptype2label = ExtraFields::$type2label;
$type2label = array(''); $type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha'); $attrname = GETPOST('attrname', 'alpha');
$elementtype = 'deliverydet'; //Must be the $table_element of the class that manage extrafield $elementtype = 'deliverydet'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden(); if (!$user->admin) {
accessforbidden();
}
/* /*
@ -85,8 +90,7 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit') {
{
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
@ -99,8 +103,7 @@ if ($action != 'create' && $action != 'edit')
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'create') if ($action == 'create') {
{
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
@ -112,8 +115,7 @@ if ($action == 'create')
/* Edition of an optional field */ /* Edition of an optional field */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname)) {
{
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,9 @@
* or see https://www.gnu.org/ * or see https://www.gnu.org/
*/ */
if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1); if (!defined('REQUIRE_JQUERY_BLOCKUI')) {
define('REQUIRE_JQUERY_BLOCKUI', 1);
}
if (!defined('NOTOKENRENEWAL')) { if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1); define('NOTOKENRENEWAL', 1);
} }
@ -47,7 +49,8 @@ try {
$url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality; $url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality;
$api = new PrestaShopWebservice( $api = new PrestaShopWebservice(
$conf->global->MAIN_MODULE_DOLISTORE_API_SRV, $conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
$conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api $conf->global->MAIN_MODULE_DOLISTORE_API_KEY,
$dolistore->debug_api
); );
//echo $url; //echo $url;
$request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET')); $request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
@ -56,7 +59,11 @@ try {
} catch (PrestaShopWebserviceException $e) { } catch (PrestaShopWebserviceException $e) {
// Here we are dealing with errors // Here we are dealing with errors
$trace = $e->getTrace(); $trace = $e->getTrace();
if ($trace[0]['args'][0] == 404) die('Bad ID'); if ($trace[0]['args'][0] == 404) {
elseif ($trace[0]['args'][0] == 401) die('Bad auth key'); die('Bad ID');
else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); } elseif ($trace[0]['args'][0] == 401) {
die('Bad auth key');
} else {
die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
}
} }

View File

@ -71,8 +71,9 @@ class PrestaShopWebservice
*/ */
public function __construct($url, $key, $debug = true) public function __construct($url, $key, $debug = true)
{ {
if (!extension_loaded('curl')) if (!extension_loaded('curl')) {
throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library'); throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library');
}
$this->url = $url; $this->url = $url;
$this->key = $key; $this->key = $key;
$this->debug = $debug; $this->debug = $debug;
@ -88,8 +89,7 @@ class PrestaShopWebservice
protected function checkStatusCode($status_code) protected function checkStatusCode($status_code)
{ {
$error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.'; $error_label = 'This call to PrestaShop Web Services failed and returned an HTTP status of %d. That means: %s.';
switch ($status_code) switch ($status_code) {
{
case 200: case 200:
case 201: case 201:
break; break;
@ -132,25 +132,27 @@ class PrestaShopWebservice
$session = curl_init($url); $session = curl_init($url);
$curl_options = array(); $curl_options = array();
foreach ($defaultParams as $defkey => $defval) foreach ($defaultParams as $defkey => $defval) {
{ if (isset($curl_params[$defkey])) {
if (isset($curl_params[$defkey]))
$curl_options[$defkey] = $curl_params[$defkey]; $curl_options[$defkey] = $curl_params[$defkey];
else { } else {
$curl_options[$defkey] = $defaultParams[$defkey]; $curl_options[$defkey] = $defaultParams[$defkey];
} }
} }
foreach ($curl_params as $defkey => $defval) foreach ($curl_params as $defkey => $defval) {
if (!isset($curl_options[$defkey])) if (!isset($curl_options[$defkey])) {
$curl_options[$defkey] = $curl_params[$defkey]; $curl_options[$defkey] = $curl_params[$defkey];
}
}
dol_syslog("curl curl_options = ".var_export($curl_options, true)); dol_syslog("curl curl_options = ".var_export($curl_options, true));
curl_setopt_array($session, $curl_options); curl_setopt_array($session, $curl_options);
$response = curl_exec($session); $response = curl_exec($session);
$index = strpos($response, "\r\n\r\n"); $index = strpos($response, "\r\n\r\n");
if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') {
throw new PrestaShopWebserviceException('Bad HTTP response'); throw new PrestaShopWebserviceException('Bad HTTP response');
}
$header = substr($response, 0, $index); $header = substr($response, 0, $index);
$body = substr($response, $index + 4); $body = substr($response, $index + 4);
@ -158,39 +160,39 @@ class PrestaShopWebservice
$headerArrayTmp = explode("\n", $header); $headerArrayTmp = explode("\n", $header);
$headerArray = array(); $headerArray = array();
foreach ($headerArrayTmp as &$headerItem) foreach ($headerArrayTmp as &$headerItem) {
{
$tmp = explode(':', $headerItem); $tmp = explode(':', $headerItem);
$tmp = array_map('trim', $tmp); $tmp = array_map('trim', $tmp);
if (count($tmp) == 2) if (count($tmp) == 2) {
$headerArray[$tmp[0]] = $tmp[1]; $headerArray[$tmp[0]] = $tmp[1];
}
} }
if (array_key_exists('PSWS-Version', $headerArray)) if (array_key_exists('PSWS-Version', $headerArray)) {
{
$this->version = $headerArray['PSWS-Version']; $this->version = $headerArray['PSWS-Version'];
if ( if (version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMIN, $headerArray['PSWS-Version']) == 1 ||
version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMIN, $headerArray['PSWS-Version']) == 1 ||
version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMAX, $headerArray['PSWS-Version']) == -1 version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMAX, $headerArray['PSWS-Version']) == -1
) ) {
throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library'); throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library');
}
} }
if ($this->debug) if ($this->debug) {
{
$this->printDebug('HTTP REQUEST HEADER', curl_getinfo($session, CURLINFO_HEADER_OUT)); $this->printDebug('HTTP REQUEST HEADER', curl_getinfo($session, CURLINFO_HEADER_OUT));
$this->printDebug('HTTP RESPONSE HEADER', $header); $this->printDebug('HTTP RESPONSE HEADER', $header);
} }
$status_code = curl_getinfo($session, CURLINFO_HTTP_CODE); $status_code = curl_getinfo($session, CURLINFO_HTTP_CODE);
if ($status_code === 0) if ($status_code === 0) {
throw new PrestaShopWebserviceException('CURL Error: '.curl_error($session)); throw new PrestaShopWebserviceException('CURL Error: '.curl_error($session));
}
curl_close($session); curl_close($session);
if ($this->debug) if ($this->debug) {
{ if ($curl_params[CURLOPT_CUSTOMREQUEST] == 'PUT' || $curl_params[CURLOPT_CUSTOMREQUEST] == 'POST') {
if ($curl_params[CURLOPT_CUSTOMREQUEST] == 'PUT' || $curl_params[CURLOPT_CUSTOMREQUEST] == 'POST')
$this->printDebug('XML SENT', urldecode($curl_params[CURLOPT_POSTFIELDS])); $this->printDebug('XML SENT', urldecode($curl_params[CURLOPT_POSTFIELDS]));
if ($curl_params[CURLOPT_CUSTOMREQUEST] != 'DELETE' && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') }
if ($curl_params[CURLOPT_CUSTOMREQUEST] != 'DELETE' && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') {
$this->printDebug('RETURN HTTP BODY', $body); $this->printDebug('RETURN HTTP BODY', $body);
}
} }
return array('status_code' => $status_code, 'response' => $body, 'header' => $header); return array('status_code' => $status_code, 'response' => $body, 'header' => $header);
} }
@ -227,13 +229,11 @@ class PrestaShopWebservice
*/ */
protected function parseXML($response) protected function parseXML($response)
{ {
if ($response != '') if ($response != '') {
{
libxml_clear_errors(); libxml_clear_errors();
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA); $xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
if (libxml_get_errors()) if (libxml_get_errors()) {
{
$msg = var_export(libxml_get_errors(), true); $msg = var_export(libxml_get_errors(), true);
libxml_clear_errors(); libxml_clear_errors();
throw new PrestaShopWebserviceException('HTTP XML response is not parsable: '.$msg); throw new PrestaShopWebserviceException('HTTP XML response is not parsable: '.$msg);
@ -261,14 +261,15 @@ class PrestaShopWebservice
$xml = ''; $xml = '';
$url = ''; $url = '';
if (isset($options['resource'], $options['postXml']) || isset($options['url'], $options['postXml'])) if (isset($options['resource'], $options['postXml']) || isset($options['url'], $options['postXml'])) {
{
$url = (isset($options['resource']) ? $this->url.'/api/'.$options['resource'] : $options['url']); $url = (isset($options['resource']) ? $this->url.'/api/'.$options['resource'] : $options['url']);
$xml = $options['postXml']; $xml = $options['postXml'];
if (isset($options['id_shop'])) if (isset($options['id_shop'])) {
$url .= '&id_shop='.$options['id_shop']; $url .= '&id_shop='.$options['id_shop'];
if (isset($options['id_group_shop'])) }
if (isset($options['id_group_shop'])) {
$url .= '&id_group_shop='.$options['id_group_shop']; $url .= '&id_group_shop='.$options['id_group_shop'];
}
} else { } else {
throw new PrestaShopWebserviceException('Bad parameters given'); throw new PrestaShopWebserviceException('Bad parameters given');
} }
@ -310,24 +311,28 @@ class PrestaShopWebservice
*/ */
public function get($options) public function get($options)
{ {
if (isset($options['url'])) if (isset($options['url'])) {
$url = $options['url']; $url = $options['url'];
elseif (isset($options['resource'])) } elseif (isset($options['resource'])) {
{
$url = $this->url.'/api/'.$options['resource']; $url = $this->url.'/api/'.$options['resource'];
$url_params = array(); $url_params = array();
if (isset($options['id'])) if (isset($options['id'])) {
$url .= '/'.$options['id']; $url .= '/'.$options['id'];
}
// @CHANGE LDR // @CHANGE LDR
//$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop'); //$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop');
$params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'date'); $params = array('filter', 'display', 'sort', 'limit', 'id_shop', 'id_group_shop', 'date');
foreach ($params as $p) foreach ($params as $p) {
foreach ($options as $k => $o) foreach ($options as $k => $o) {
if (strpos($k, $p) !== false) if (strpos($k, $p) !== false) {
$url_params[$k] = $options[$k]; $url_params[$k] = $options[$k];
if (count($url_params) > 0) }
}
}
if (count($url_params) > 0) {
$url .= '?'.http_build_query($url_params); $url .= '?'.http_build_query($url_params);
}
} else { } else {
throw new PrestaShopWebserviceException('Bad parameters given '); throw new PrestaShopWebserviceException('Bad parameters given ');
} }
@ -347,22 +352,26 @@ class PrestaShopWebservice
*/ */
public function head($options) public function head($options)
{ {
if (isset($options['url'])) if (isset($options['url'])) {
$url = $options['url']; $url = $options['url'];
elseif (isset($options['resource'])) } elseif (isset($options['resource'])) {
{
$url = $this->url.'/api/'.$options['resource']; $url = $this->url.'/api/'.$options['resource'];
$url_params = array(); $url_params = array();
if (isset($options['id'])) if (isset($options['id'])) {
$url .= '/'.$options['id']; $url .= '/'.$options['id'];
}
$params = array('filter', 'display', 'sort', 'limit'); $params = array('filter', 'display', 'sort', 'limit');
foreach ($params as $p) foreach ($params as $p) {
foreach ($options as $k => $o) foreach ($options as $k => $o) {
if (strpos($k, $p) !== false) if (strpos($k, $p) !== false) {
$url_params[$k] = $options[$k]; $url_params[$k] = $options[$k];
if (count($url_params) > 0) }
}
}
if (count($url_params) > 0) {
$url .= '?'.http_build_query($url_params); $url .= '?'.http_build_query($url_params);
}
} else { } else {
throw new PrestaShopWebserviceException('Bad parameters given'); throw new PrestaShopWebserviceException('Bad parameters given');
} }
@ -386,16 +395,17 @@ class PrestaShopWebservice
public function edit($options) public function edit($options)
{ {
$xml = ''; $xml = '';
if (isset($options['url'])) if (isset($options['url'])) {
$url = $options['url']; $url = $options['url'];
elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) } elseif ((isset($options['resource'], $options['id']) || isset($options['url'])) && $options['putXml']) {
{
$url = (isset($options['url']) ? $options['url'] : $this->url.'/api/'.$options['resource'].'/'.$options['id']); $url = (isset($options['url']) ? $options['url'] : $this->url.'/api/'.$options['resource'].'/'.$options['id']);
$xml = $options['putXml']; $xml = $options['putXml'];
if (isset($options['id_shop'])) if (isset($options['id_shop'])) {
$url .= '&id_shop='.$options['id_shop']; $url .= '&id_shop='.$options['id_shop'];
if (isset($options['id_group_shop'])) }
if (isset($options['id_group_shop'])) {
$url .= '&id_group_shop='.$options['id_group_shop']; $url .= '&id_group_shop='.$options['id_group_shop'];
}
} else { } else {
throw new PrestaShopWebserviceException('Bad parameters given'); throw new PrestaShopWebserviceException('Bad parameters given');
} }

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